Example usage for org.eclipse.jface.databinding.swt SWTObservables observeText

List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeText

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.swt SWTObservables observeText.

Prototype

@Deprecated
public static ISWTObservableValue observeText(Control control, int event) 

Source Link

Document

Returns an observable observing the text attribute of the provided control.

Usage

From source file:gov.redhawk.ide.dcd.ui.wizard.ScaServiceProjectPropertiesWizardPage.java

License:Open Source License

/**
 * {@inheritDoc}/*  w  w  w . j  av a2 s.  com*/
 */
@Override
public void customCreateControl(final Composite parent) {
    // Device Group
    final Group serviceGroup = new Group(parent, SWT.NONE);
    serviceGroup.setText(getResourceType());
    serviceGroup.setLayout(new GridLayout(3, false));
    GridDataFactory.generate(serviceGroup, 3, 1);

    final Label idlLabel = new Label(serviceGroup, SWT.NONE);
    idlLabel.setText("Service Interface");

    this.serviceIdlText = new Text(serviceGroup, SWT.BORDER | SWT.READ_ONLY);
    this.serviceIdlText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
    this.serviceIdlText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            validate();
        }
    });
    context.bindValue(SWTObservables.observeText(this.serviceIdlText, SWT.Modify),
            PojoObservables.observeValue(this.model, "repID"));

    final Button idlBrowseButton = new Button(serviceGroup, SWT.NONE);
    idlBrowseButton.setText("Browse...");
    idlBrowseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IdlInterfaceDcl result = IdlInterfaceSelectionDialog.create(getShell());
            if (result != null) {
                serviceIdlText.setText(result.getRepId());
            }
        }

    });
}

From source file:gov.redhawk.ide.sdr.ui.export.DeployableScaExportWizardPage.java

License:Open Source License

private void bind(final DataBindingContext dbc, final CheckboxTableViewer availableProjectsViewer,
        final Button directoryRadio, final Text directoryText, final Button archiveRadio,
        final Text archiveText) {

    // Data-Bindings
    // Setup databinding
    dbc.bindSet(ViewersObservables.observeCheckedElements(availableProjectsViewer, IProject.class),
            this.model.projectsToExport, null, null);

    dbc.bindValue(SWTObservables.observeSelection(directoryRadio), this.model.directoryExport, null, null);

    dbc.bindValue(SWTObservables.observeSelection(archiveRadio), this.model.archiveExport, null, null);

    dbc.bindValue(SWTObservables.observeText(directoryText, SWT.Modify), this.model.directoryDestination,
            new UpdateValueStrategy().setAfterConvertValidator(new IValidator() {
                @Override//  w w w .ja  v a  2s .  c  om
                public IStatus validate(final Object value) {
                    final String s = (String) value;
                    if (!directoryRadio.getSelection()) {
                        return ValidationStatus.ok();
                    }

                    if ((s == null) || (s.length() == 0)) {
                        return ValidationStatus.error("Enter an archive destination name.");
                    }
                    return ValidationStatus.ok();
                }
            }), null);

    dbc.bindValue(SWTObservables.observeText(archiveText, SWT.Modify), this.model.archiveDestination,
            new UpdateValueStrategy().setAfterConvertValidator(new IValidator() {
                @Override
                public IStatus validate(final Object value) {
                    final String s = (String) value;
                    if (!archiveRadio.getSelection()) {
                        return ValidationStatus.ok();
                    }

                    if ((s == null) || (s.length() == 0)) {
                        return ValidationStatus.error("Enter an archive destination name.");
                    }
                    return ValidationStatus.ok();
                }
            }), null);
}

From source file:gov.redhawk.ide.sdr.ui.internal.handlers.LaunchDomainManagerWithOptionsDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite root) {
    final Composite composite = new Composite(root, SWT.NONE);
    final GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);//from   w  w w . j a  v  a2s  .  c  om
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    final GridLayout gridLayout = new GridLayout(3, false);
    final GridDataFactory textFactory = GridDataFactory.fillDefaults().grab(true, false).span(2, 1);
    final GridData data;

    final Group domainManagerGroup = new Group(composite, SWT.NULL);

    domainManagerGroup.setText("Domain Manager");
    domainManagerGroup.setLayout(gridLayout);
    domainManagerGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    Label label = new Label(domainManagerGroup, SWT.NULL);
    label.setText("Domain Name: ");
    Text text = new Text(domainManagerGroup, SWT.BORDER);
    data = textFactory.create();
    data.horizontalSpan = 2;
    text.setLayoutData(data);
    this.nameBinding = this.context.bindValue(SWTObservables.observeText(text, SWT.Modify),
            PojoObservables.observeValue(this.model, DomainManagerLaunchConfiguration.PROP_DOMAIN_NAME),
            new UpdateValueStrategy().setAfterConvertValidator(this.nameValidator), null);
    text.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            updateButtonsEnableState((IStatus) LaunchDomainManagerWithOptionsDialog.this.nameBinding
                    .getValidationStatus().getValue());
        }
    });

    ControlDecorationSupport.create(this.nameBinding, SWT.TOP | SWT.LEFT);

    label = new Label(domainManagerGroup, SWT.NULL);
    label.setText("Debug Level: ");
    ComboViewer debugViewer = new ComboViewer(domainManagerGroup,
            SWT.READ_ONLY | SWT.SINGLE | SWT.DROP_DOWN | SWT.BORDER);
    debugViewer.setLabelProvider(new LabelProvider());
    debugViewer.setContentProvider(new ArrayContentProvider());
    debugViewer.setInput(DebugLevel.values());
    debugViewer.getControl().setLayoutData(data);
    this.context.bindValue(ViewersObservables.observeSingleSelection(debugViewer),
            PojoObservables.observeValue(this.model, DomainManagerLaunchConfiguration.PROP_DEBUG_LEVEL));

    label = new Label(domainManagerGroup, SWT.NULL);
    label.setText("Arguments:");
    text = new Text(domainManagerGroup, SWT.BORDER);
    text.setLayoutData(data);
    this.context.bindValue(SWTObservables.observeText(text, SWT.Modify),
            PojoObservables.observeValue(this.model, DomainManagerLaunchConfiguration.PROP_ARGUMENTS));

    final Group deviceManagerGroup = new Group(composite, SWT.NULL);

    deviceManagerGroup.setText("Device Manager");
    deviceManagerGroup.setLayout(GridLayoutFactory.fillDefaults().create());
    deviceManagerGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    deviceManagerGroup.setVisible(!this.sdrRoot.getNodesContainer().getNodes().isEmpty());

    final CheckboxTreeViewer treeViewer = createTreeViewer(deviceManagerGroup);
    treeViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final Control buttonComposite = createSelectionButtons(deviceManagerGroup);
    buttonComposite.setLayoutData(GridDataFactory.fillDefaults().create());

    context.bindSet(ViewersObservables.observeCheckedElements(treeViewer, DeviceConfiguration.class), nodes);

    // Insert a progress monitor
    this.progressMonitorPart = createProgressMonitorPart(composite, new GridLayout());
    final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    this.progressMonitorPart.setLayoutData(gridData);
    this.progressMonitorPart.setVisible(false);

    // Build the separator line
    final Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Dialog.applyDialogFont(composite);

    getShell().getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
            try {
                LaunchDomainManagerWithOptionsDialog.this.run(true, true, scanForTakenDomainNames);
                updateButtonsEnableState(Status.OK_STATUS);
            } catch (final InvocationTargetException e) {
                SdrUiPlugin.getDefault().getLog().log(
                        new Status(IStatus.ERROR, SdrUiPlugin.PLUGIN_ID, "Error scanning for domain names", e));
            } catch (final InterruptedException e) {
                updateButtonsEnableState(Status.OK_STATUS);
            }
        }
    });

    return composite;
}

From source file:gov.redhawk.ide.sdr.ui.internal.handlers.LaunchDomainManagerWithOptionsDialog.java

License:Open Source License

@Override
protected Composite createSelectionButtons(final Composite parent) {
    final Composite root = new Composite(parent, SWT.NULL);
    root.setLayout(new GridLayout(2, true));
    final Control controls = super.createSelectionButtons(root);
    controls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Composite subContainer = new Composite(root, SWT.NONE);
    final GridLayout gridLayout = new GridLayout(2, false);

    subContainer.setLayout(gridLayout);//from w w w.  ja v a2  s  .com
    subContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    Label label = new Label(subContainer, SWT.NULL);
    label.setText("Debug Level: ");

    final ComboViewer debugViewer = new ComboViewer(subContainer,
            SWT.READ_ONLY | SWT.SINGLE | SWT.DROP_DOWN | SWT.BORDER);
    debugViewer.setContentProvider(new ArrayContentProvider());
    debugViewer.setInput(DebugLevel.values());
    debugViewer.setSelection(new StructuredSelection("Info"));
    context.bindValue(ViewersObservables.observeSingleSelection(debugViewer), nodeDebugLevel);

    label = new Label(subContainer, SWT.NULL);
    label.setText("Arguments:");
    Text text = new Text(subContainer, SWT.BORDER);
    text.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    this.context.bindValue(SWTObservables.observeText(text, SWT.Modify), nodeArguments, null, null);

    return root;
}

From source file:gov.redhawk.ide.spd.internal.ui.editor.GeneralInfoSection.java

License:Open Source License

/**
 * {@inheritDoc}//  w  w w . j a  va 2 s.  c o  m
 */
@Override
public void refresh(final Resource resource) {
    this.spdResource = resource;

    this.client.setEditable(SCAEditorUtil.isEditableResource(getPage(), this.spdResource));
    for (final Binding binding : this.bindings) {
        binding.dispose();
    }
    this.bindings.clear();

    final SoftPkg model = getSoftPkg();
    if (model == null) {
        return;
    }

    final DataBindingContext context = this.getPage().getEditor().getDataBindingContext();

    this.bindings.add(context.bindValue(
            WidgetProperties.text(SWT.Modify).observeDelayed(SCAFormEditor.getFieldBindingDelay(),
                    this.client.getIdEntry().getText()),
            EMFEditObservables.observeValue(getEditingDomain(), model, SpdPackage.Literals.SOFT_PKG__ID),
            new EMFEmptyStringToNullUpdateValueStrategy(), null));

    this.bindings.add(context.bindValue(
            WidgetProperties.text(SWT.Modify).observeDelayed(SCAFormEditor.getFieldBindingDelay(),
                    this.client.getVersionEntry().getText()),
            EMFEditObservables.observeValue(getEditingDomain(), model, SpdPackage.Literals.SOFT_PKG__VERSION),
            new EMFEmptyStringToNullUpdateValueStrategy(), null));

    this.bindings.add(context.bindValue(
            WidgetProperties.text(SWT.Modify).observeDelayed(SCAFormEditor.getFieldBindingDelay(),
                    this.client.getNameEntry().getText()),
            EMFEditObservables.observeValue(getEditingDomain(), model, SpdPackage.Literals.SOFT_PKG__NAME),
            new EMFEmptyStringToNullUpdateValueStrategy(), null));
    SWTObservables.observeText(this.client.getNameEntry().getText(), SWT.Modify);

    this.bindings.add(context.bindValue(
            WidgetProperties.text(SWT.Modify).observeDelayed(SCAFormEditor.getFieldBindingDelay(),
                    this.client.getTitleEntry().getText()),
            EMFEditObservables.observeValue(getEditingDomain(), model, SpdPackage.Literals.SOFT_PKG__TITLE),
            new EMFEmptyStringToNullUpdateValueStrategy(), null));

    this.bindings.add(context.bindValue(
            WidgetProperties.text(SWT.Modify).observeDelayed(SCAFormEditor.getFieldBindingDelay(),
                    this.client.getDescriptionEntry().getText()),
            EMFEditObservables.observeValue(getEditingDomain(), model,
                    SpdPackage.Literals.SOFT_PKG__DESCRIPTION),
            new EMFEmptyStringToNullUpdateValueStrategy(), null));

    this.bindings.add(context.bindValue(
            WidgetProperties.text(SWT.Modify).observeDelayed(SCAFormEditor.getFieldBindingDelay(),
                    this.client.getPrfEntry().getText()),
            EMFEditProperties.value(getEditingDomain(),
                    FeaturePath.fromList(SpdPackage.Literals.SOFT_PKG__PROPERTY_FILE,
                            SpdPackage.Literals.PROPERTY_FILE__LOCAL_FILE,
                            SpdPackage.Literals.LOCAL_FILE__NAME))
                    .observe(model),
            null, null));

    this.bindings.add(context.bindValue(
            WidgetProperties.text(SWT.Modify).observeDelayed(SCAFormEditor.getFieldBindingDelay(),
                    this.client.getScdEntry().getText()),
            EMFEditProperties
                    .value(getEditingDomain(), FeaturePath.fromList(SpdPackage.Literals.SOFT_PKG__DESCRIPTOR,
                            SpdPackage.Literals.DESCRIPTOR__LOCALFILE, SpdPackage.Literals.LOCAL_FILE__NAME))
                    .observe(model),
            null, null));

    this.client.getTypeEntry().setValue(String.valueOf(model.getType()));
}

From source file:gov.redhawk.ide.spd.internal.ui.editor.wizard.AuthorWizardPage.java

License:Open Source License

/**
 * {@inheritDoc}/* w  w  w.j  a  v  a2 s . c  om*/
 */
@Override
public void createControl(final Composite parent) {
    final Composite client = new Composite(parent, SWT.NULL);
    client.setLayout(new GridLayout(2, false));

    Label label;
    final GridDataFactory labelFactory = GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP);
    Text text;
    final GridDataFactory textFactory = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
            false);

    label = new Label(client, SWT.NULL);
    label.setLayoutData(labelFactory.create());
    label.setText("Company:");
    text = new Text(client, SWT.BORDER);
    text.setLayoutData(textFactory.create());
    this.context.bindValue(SWTObservables.observeText(text, SWT.Modify),
            EMFObservables.observeValue(this.author, SpdPackage.Literals.AUTHOR__COMPANY), null, null);

    label = new Label(client, SWT.NULL);
    label.setLayoutData(labelFactory.create());
    label.setText("Webpage:");
    text = new Text(client, SWT.BORDER);
    text.setLayoutData(textFactory.create());
    this.context.bindValue(SWTObservables.observeText(text, SWT.Modify),
            EMFObservables.observeValue(this.author, SpdPackage.Literals.AUTHOR__WEBPAGE), null, null);

    label = new Label(client, SWT.NULL);
    label.setLayoutData(labelFactory.create());
    label.setText("Names:");
    final Composite namesComp = new Composite(client, SWT.NULL);
    namesComp.setLayoutData(
            new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL));
    final GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    namesComp.setLayout(layout);

    this.tableViewer = new TableViewer(namesComp, SWT.BORDER);
    this.tableViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
            // TODO Auto-generated method stub

        }

        @Override
        public void dispose() {
            // TODO Auto-generated method stub

        }

        @Override
        public Object[] getElements(final Object inputElement) {
            return ((Author) inputElement).getName().toArray();
        }
    });
    this.tableViewer.setLabelProvider(new LabelProvider());
    this.tableViewer.setInput(this.author);
    this.tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));

    final Button addButton = new Button(namesComp, SWT.PUSH);
    addButton.setText("Add");
    addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    addButton.addSelectionListener(new SelectionAdapter() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            handleAddName();
        }
    });

    final Button removeButton = new Button(namesComp, SWT.PUSH);
    removeButton.setText("Remove");
    removeButton.setEnabled(false);
    removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    this.tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            removeButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    removeButton.addSelectionListener(new SelectionAdapter() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            AuthorWizardPage.this.author.getName()
                    .remove(((IStructuredSelection) AuthorWizardPage.this.tableViewer.getSelection())
                            .getFirstElement());
            AuthorWizardPage.this.tableViewer.refresh();
        }
    });

    this.pageSupport = WizardPageSupport.create(this, this.context);

    this.setControl(client);
}

From source file:gov.redhawk.ide.spd.internal.ui.editor.wizard.DependencyWizardPage.java

License:Open Source License

private void initBindings() {
    if (this.context == null) {
        return;/* w w  w .j a va 2s. co  m*/
    }
    for (final Object obj : this.context.getBindings().toArray()) {
        if (obj instanceof Binding) {
            final Binding b = (Binding) obj;
            this.context.removeBinding(b);
            b.dispose();
        }
    }

    final IEMFValueProperty propRefIdPath = EMFProperties.value(FeaturePath
            .fromList(SpdPackage.Literals.DEPENDENCY__PROPERTY_REF, SpdPackage.Literals.PROPERTY_REF__REF_ID));
    final IEMFValueProperty propValuePath = EMFProperties.value(FeaturePath
            .fromList(SpdPackage.Literals.DEPENDENCY__PROPERTY_REF, SpdPackage.Literals.PROPERTY_REF__VALUE));

    this.context.bindValue(SWTObservables.observeText(this.refIdText, SWT.Modify),
            propRefIdPath.observe(this.dependency), new EMFEmptyStringToNullUpdateValueStrategy(), null);

    final EMFEmptyStringToNullUpdateValueStrategy strategy = new EMFEmptyStringToNullUpdateValueStrategy();
    strategy.setConverter(new Converter(PropertyRef.class, String.class) {
        private final ImplementationDetailsSectionPropertyRefItemProvider itemPropertyRefItemProvider = new ImplementationDetailsSectionPropertyRefItemProvider(
                DependencyWizardPage.this.adapterFactory);

        @Override
        public Object convert(final Object fromObject) {
            final AbstractProperty prop = this.itemPropertyRefItemProvider
                    .getProperty(DependencyWizardPage.this.dependency.getPropertyRef());
            if (prop == null) {
                return "";
            } else {
                return prop.getName();
            }
        }

    });
    this.context.bindValue(SWTObservables.observeText(this.propNameText, SWT.None),
            propRefIdPath.observe(this.dependency), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            strategy);
    this.context.bindValue(WidgetProperties.text(SWT.Modify).observe(this.valueText),
            propValuePath.observe(this.dependency), new EMFEmptyStringToNullUpdateValueStrategy(), null);

    final EMFUpdateValueStrategy targetToModel = new EMFUpdateValueStrategy();
    targetToModel.setConverter(new ViewerToSoftPkgRef());
    final EMFUpdateValueStrategy modelToTarget = new EMFUpdateValueStrategy();
    modelToTarget.setConverter(new SoftPkgRefToViewer());
    final IEMFValueProperty softPkgRef = EMFProperties
            .value(FeaturePath.fromList(SpdPackage.Literals.DEPENDENCY__SOFT_PKG_REF));
    this.context.bindValue(ViewersObservables.observeSingleSelection(this.softPkgRefViewer),
            softPkgRef.observe(this.dependency), targetToModel, modelToTarget);

    this.context.bindValue(SWTObservables.observeText(this.dependencyTypeComboViewer.getCombo()),
            EMFObservables.observeValue(this.dependency, SpdPackage.Literals.DEPENDENCY__TYPE),
            new EMFEmptyStringToNullUpdateValueStrategy(), null);

}

From source file:gov.redhawk.ide.spd.internal.ui.editor.wizard.PortWizardPage.java

License:Open Source License

private void bind() {
    final IObservableValue nameObservable = new WritableValue(null, new String());
    this.context.bindValue(SWTObservables.observeText(this.name, SWT.Modify), nameObservable,
            new UpdateValueStrategy().setAfterConvertValidator(this.nameValidator), null);

    final IObservableValue repIdObservable = new WritableValue(null, new String());
    this.context.bindValue(SWTObservables.observeText(this.repid, SWT.Modify), repIdObservable,
            new UpdateValueStrategy().setAfterConvertValidator(this.repIDValidator), null);

    final IObservableValue portDirectionObservable = new WritableValue(null, WizardPortType.USES);
    this.context.bindValue(ViewersObservables.observeSingleSelection(this.portViewer), portDirectionObservable,
            new UpdateValueStrategy(), null);

    final MultiValidator constraintValidation = new MultiValidator() {

        @Override/*w w w . j a v  a2  s.  c  o m*/
        protected IStatus validate() {
            final String portName = (String) nameObservable.getValue();
            final String repId = (String) repIdObservable.getValue();
            final WizardPortType portType = (WizardPortType) portDirectionObservable.getValue();

            if ((portName == null) || (portName.trim().length() == 0)) {
                return ValidationStatus.ok();
            }

            if (PortWizardPage.this.model.ports != null) {
                for (final FeatureMap.Entry entry : PortWizardPage.this.model.ports.getGroup()) {
                    final AbstractPort existingPort = (AbstractPort) entry.getValue();
                    if (existingPort != PortWizardPage.this.model.getPort()
                            && (existingPort.getSibling() == null
                                    || existingPort.getSibling() != PortWizardPage.this.model.getPort())
                            && portName.equals(existingPort.getName())) {
                        return ValidationStatus
                                .error("A port with the name \"" + portName + "\" is already defined.");
                    }
                }
            }

            if ((repId == null) || (repId.trim().length() == 0)) {
                return ValidationStatus.ok();
            }

            if ("IDL:ExtendedEvent/MessageEvent:1.0".equals(repId) && (portType != WizardPortType.BIDIR)) {
                return ValidationStatus.info("It is recommended that MessageEvent ports be bidirectional");
            } else if (!"IDL:ExtendedEvent/MessageEvent:1.0".equals(repId)
                    && (portType == WizardPortType.BIDIR)) {
                return ValidationStatus.warning("Bidirectional support for this port type is not recommended.");
            }

            return ValidationStatus.ok();
        }
    };
    this.context.addValidationStatusProvider(constraintValidation);
    this.context.bindValue(constraintValidation.observeValidatedValue(repIdObservable),
            BeansObservables.observeValue(this.model, PortWizardModel.PROP_REP_ID));
    this.context.bindValue(constraintValidation.observeValidatedValue(portDirectionObservable),
            BeansObservables.observeValue(this.model, PortWizardModel.PROP_TYPE));
    this.context.bindValue(constraintValidation.observeValidatedValue(nameObservable),
            BeansObservables.observeValue(this.model, PortWizardModel.PROP_NAME));

    if (this.model.portTypes.isEmpty()) {
        selectDefaultChecks();
    } else {
        for (final PortType pt : this.model.portTypes) {
            this.typeViewer.setChecked(pt, true);
        }
    }

    this.typeViewer.addCheckStateListener(new ICheckStateListener() {
        private boolean ignore = false;

        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            if (this.ignore) {
                return;
            }
            for (final PortType type : PortType.values()) {
                if (PortWizardPage.this.typeViewer.getChecked(type)
                        && !PortWizardPage.this.typeViewer.getGrayed(type)) {
                    PortWizardPage.this.model.portTypes.add(type);
                } else {
                    PortWizardPage.this.model.portTypes.remove(type);
                }
            }
            this.ignore = true;
            if (PortWizardPage.this.model.portTypes.contains(PortType.CONTROL)) {
                if (PortWizardPage.this.model.portTypes.size() == 1) {
                    PortWizardPage.this.model.portTypes.clear();
                }
            } else if (PortWizardPage.this.model.portTypes.size() == 1) {
                PortWizardPage.this.typeViewer.setGrayed(PortType.CONTROL, false);
                PortWizardPage.this.typeViewer.setChecked(PortType.CONTROL, false);
            }

            if (PortWizardPage.this.model.portTypes.isEmpty()) {
                selectDefaultChecks();
            }
            this.ignore = false;
        }
    });

    // deal with interfaces
    final IdlLibrary library = this.editor.getIdlLibrary();
    if (library != null && this.libraryLoadAdapter == null) {
        this.libraryLoadAdapter = new LibraryLoadAdapter();
        library.eAdapters().add(this.libraryLoadAdapter);
    }

    updateTreeSelection();

    this.idlTree.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            final Object element = selection.getFirstElement();

            if (element instanceof IdlInterfaceDcl) {
                final IdlInterfaceDcl si = (IdlInterfaceDcl) element;
                final String theRepid = si.getRepId();
                PortWizardPage.this.model.setRepId(theRepid);
            } else {
                PortWizardPage.this.model.setRepId("");
            }
        }
    });
}

From source file:gov.redhawk.ide.spd.internal.ui.editor.wizard.UsesDeviceWizardPage.java

License:Open Source License

/**
 * {@inheritDoc}// www.j av a2 s  . co  m
 */
@Override
public void createControl(final Composite parent) {
    final Composite client = new Composite(parent, SWT.NULL);
    client.setLayout(new GridLayout(2, false));

    Label label;
    Text text;

    final GridDataFactory labelFactory = GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL);
    final GridDataFactory textFactory = GridDataFactory.fillDefaults().grab(true, false);

    label = new Label(client, SWT.NULL);
    label.setLayoutData(labelFactory.create());
    text = new Text(client, SWT.BORDER);
    text.setLayoutData(textFactory.create());
    label.setText("ID:");
    this.context.bindValue(SWTObservables.observeText(text, SWT.Modify),
            EMFObservables.observeValue(this.device, SpdPackage.Literals.USES_DEVICE__ID), null, null);

    label = new Label(client, SWT.NULL);
    label.setLayoutData(labelFactory.create());
    text = new Text(client, SWT.BORDER);
    text.setLayoutData(textFactory.create());
    label.setText("Type:");
    this.context.bindValue(SWTObservables.observeText(text, SWT.Modify),
            EMFObservables.observeValue(this.device, SpdPackage.Literals.USES_DEVICE__TYPE), null, null);

    this.setControl(client);
}

From source file:gov.redhawk.ide.spd.ui.wizard.ImplementationWizardPage.java

License:Open Source License

private void bind(boolean importingCode) {
    this.context.bindValue(SWTObservables.observeText(this.idText, SWT.Modify),
            EMFObservables.observeValue(this.impl, SpdPackage.Literals.IMPLEMENTATION__ID),
            new EMFEmptyStringToNullUpdateValueStrategy().setAfterConvertValidator(
                    new ImplementationIdValidator(this.softPkg, importingCode)),
            null);/*from  ww w .j av a2  s .  co m*/

    this.context.bindValue(SWTObservables.observeText(this.getProgLangEntryViewer()),
            EMFObservables.observeValue(this.getProgLang(), SpdPackage.Literals.PROGRAMMING_LANGUAGE__NAME),
            new EMFEmptyStringToNullUpdateValueStrategy(), null);

    this.context.bindValue(SWTObservables.observeText(this.descriptionText, SWT.Modify),
            EMFObservables.observeValue(this.impl, SpdPackage.Literals.IMPLEMENTATION__DESCRIPTION),
            new EMFEmptyStringToNullUpdateValueStrategy(), null);

    this.pageSupport = WizardPageSupport.create(this, this.context);
}