Example usage for org.eclipse.jface.databinding.viewers ViewerProperties singleSelection

List of usage examples for org.eclipse.jface.databinding.viewers ViewerProperties singleSelection

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.viewers ViewerProperties singleSelection.

Prototype

public static IViewerValueProperty singleSelection() 

Source Link

Document

Returns a value property for observing the single selection of a ISelectionProvider .

Usage

From source file:com.netxforge.netxstudio.screens.nf4.NewEditUser.java

License:Open Source License

/**
 * Converted to new EMF API./*from  w  w w.  j av  a  2  s  . c o  m*/
 * 
 * @return
 */
public EMFDataBindingContext initDataBindings_() {

    EMFDataBindingContext bindingContext = new EMFDataBindingContext();
    validationService.registerBindingContext(bindingContext);

    // Validation Strategies
    EMFUpdateValueStrategy loginStrategy = ValidationService.getStrategyfactory()
            .strategyBeforeSetStringNotEmpty("Login is required");

    EMFUpdateValueStrategy firstNameStrategy = ValidationService.getStrategyfactory()
            .strategyBeforeSetStringNotEmpty("First name is required");

    EMFUpdateValueStrategy lastNameStrategy = ValidationService.getStrategyfactory()
            .strategyBeforeSetStringNotEmpty("Last name is required");

    EMFUpdateValueStrategy emailNameStrategy = ValidationService.getStrategyfactory()
            .strategyBeforeSetStringNotEmpty("Email is required");

    // The active strategy is merely a warning.
    EMFUpdateValueStrategy activeStrategy = ValidationService.getStrategyfactory()
            .strategyAfterGet(new IValidator() {

                public IStatus validate(Object value) {
                    if (value instanceof Boolean) {
                        if (!((Boolean) value).booleanValue()) {
                            // Not active, issue warning.
                            return new Status(IStatus.WARNING, ScreensActivator.PLUGIN_ID,
                                    "Person not active, are you sure");
                        } else {
                            return Status.OK_STATUS;
                        }
                    } else {
                        return new Status(IStatus.ERROR, ScreensActivator.PLUGIN_ID,
                                "Should and will not occure");
                    }
                }

            });

    EMFUpdateValueStrategy roleStrategy = ValidationService.getStrategyfactory()
            .strategyAfterGet(new IValidator() {
                public IStatus validate(Object value) {
                    if (value == null) {
                        return new Status(IStatus.WARNING, ScreensActivator.PLUGIN_ID,
                                "A role should be selected");
                    } else {
                        // Any other value should do.
                        return Status.OK_STATUS;
                    }

                }
            });

    // Bindings

    IObservableValue textObserveTextObserveWidget_1 = SWTObservables.observeDelayedValue(100,
            SWTObservables.observeText(txtLogin, SWT.Modify));

    IEMFValueProperty userLoginObserveValue_1 = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.PERSON__LOGIN);

    bindingContext.bindValue(textObserveTextObserveWidget_1, userLoginObserveValue_1.observe(user),
            loginStrategy, null);

    IObservableValue txtFirstNameObserveTextObserveWidget = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtFirstName, SWT.Modify));
    // IObservableValue userFirstNameObserveValue =
    // EMFObservables.observeValue(user, Literals.PERSON__FIRST_NAME);

    IEMFValueProperty userFirstNameObserveValue = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.PERSON__FIRST_NAME);

    bindingContext.bindValue(txtFirstNameObserveTextObserveWidget, userFirstNameObserveValue.observe(user),
            firstNameStrategy, null);
    IObservableValue txtLastNameObserveTextObserveWidget = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtLastName, SWT.Modify));
    // IObservableValue userLastNameObserveValue = EMFObservables
    // .observeValue(user, Literals.PERSON__LAST_NAME);

    IEMFValueProperty userLastNameObserveValue = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.PERSON__LAST_NAME);

    bindingContext.bindValue(txtLastNameObserveTextObserveWidget, userLastNameObserveValue.observe(user),
            lastNameStrategy, null);

    IObservableValue txtEmailObserveTextObserveWidget = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtEmail, SWT.Modify));

    // IObservableValue userEmailObserveValue = EMFObservables.observeValue(
    // user, Literals.PERSON__EMAIL);

    IEMFValueProperty userEmailObserveValue = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.PERSON__EMAIL);

    bindingContext.bindValue(txtEmailObserveTextObserveWidget, userEmailObserveValue.observe(user),
            emailNameStrategy, null);

    IObservableValue btnCheckObserveSelectionObserveWidget = SWTObservables.observeSelection(btnCheck);
    IEMFValueProperty userActiveObserveValue = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.PERSON__ACTIVE);
    bindingContext.bindValue(btnCheckObserveSelectionObserveWidget, userActiveObserveValue.observe(user),
            activeStrategy, null);

    IObservableValue passwordObservableValue = new WritableValue();

    IObservableValue txtPasswordObserveTextObserveWidget = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtPass, SWT.Modify));
    IObservableValue txtConfirmObserveTextObserveWidget = SWTObservables.observeDelayedValue(400,
            SWTObservables.observeText(txtConfirm, SWT.Modify));

    // NEW CODE, Use a custom MultiValidator, it produces

    NewPasswordConfirmed newPasswordConfirmed = new NewPasswordConfirmed(bindingContext,
            new IObservableValue[] { txtPasswordObserveTextObserveWidget, txtConfirmObserveTextObserveWidget });

    passwordObservableValue = newPasswordConfirmed
            .observeValidatedValue(newPasswordConfirmed.getMiddletons().get(0));

    // OLD CODE.
    // Special writable case for password and confirmation,
    // both share the value changed listener, which only sets the model.
    // when both passwords are the same. 2 x widgets -> model

    // PasswordConfirmed confirmedHandler = new PasswordConfirmed(
    // passwordObservableValue);

    // txtPasswordObserveTextObserveWidget
    // .addValueChangeListener(confirmedHandler);

    // txtConfirmObserveTextObserveWidget
    // .addValueChangeListener(confirmedHandler);

    // EMFUpdateValueStrategy passStrategy = ValidationService
    // .getStrategyfactory().strategyAfterGet(confirmedHandler);

    EMFUpdateValueStrategy passStrategy = new EMFUpdateValueStrategy();
    passStrategy.setConverter(new PasswordConverter());

    IEMFValueProperty passwordObserveValue = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.PERSON__PASSWORD);

    // Password, can not be presented (Ok it can but we don't want to), so only target to model.
    bindingContext.bindValue(passwordObservableValue, passwordObserveValue.observe(user), passStrategy, null);

    newPasswordConfirmed.revalidateExternal();

    // Hand coded binding for a combo.

    ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
    this.getComboViewerWidget().setContentProvider(listContentProvider);

    IObservableMap observeMap = EMFObservables.observeMap(listContentProvider.getKnownElements(),
            Literals.ROLE__NAME);
    this.getComboViewerWidget().setLabelProvider(new ObservableMapLabelProvider(observeMap));

    rolesResource = editingService.getData(GenericsPackage.Literals.ROLE);
    IEMFListProperty l = EMFEditProperties.resource(editingService.getEditingDomain());
    IObservableList rolesObservableList = l.observe(rolesResource);

    // obm.addObservable(rolesObservableList);

    this.getComboViewerWidget().setInput(rolesObservableList);

    IObservableValue comboObserveProxy = ViewerProperties.singleSelection().observe(comboViewer);

    IEMFValueProperty roleObserveValue = EMFEditProperties.value(editingService.getEditingDomain(),
            Literals.PERSON__ROLES);

    bindingContext.bindValue(comboObserveProxy, roleObserveValue.observe(user), roleStrategy, null);

    return bindingContext;
}

From source file:com.xored.af.ui.forms.parts.ComboFormPart.java

License:Open Source License

@Override
protected IObservableValue observeControl() {
    if (modelObservable instanceof IObserving) {
        final IObserving observing = (IObserving) modelObservable;
        viewer.setInput(observing.getObserved());
        getEmfForm().getInput().addValueChangeListener(new IValueChangeListener() {

            public void handleValueChange(ValueChangeEvent event) {
                viewer.setInput(event.diff.getNewValue());
                viewer.setSelection(//from www  .  j av a2s. co  m
                        modelObservable.getValue() != null ? new StructuredSelection(modelObservable.getValue())
                                : new StructuredSelection());
            }
        });
    }
    return ViewerProperties.singleSelection().observe(viewer);
}

From source file:com.xse.optstack.persconftool.ui.configuration.ConfigurationPart.java

License:Open Source License

@Inject
public void setInput(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) final EResource resource,
        final MPart part) {
    if ((resource != null) && (this.activeResource != resource)) {
        this.activeResource = resource;

        final EConfiguration configuration = resource.getConfiguration();
        this.clearBindings();

        configuration.eAdapters().add(new AdapterImpl() {
            @Override// w  w  w .  jav  a 2 s .c  om
            public void notifyChanged(final Notification msg) {
                part.setDirty(true);
            }
        });

        final IViewerValueProperty singleSelection = ViewerProperties.singleSelection();
        this.bindingContext.bindValue(singleSelection.observe(this.policyWidget.getViewer()),
                EMFProperties.value(PersconfPackage.Literals.ECONFIGURATION__POLICY).observe(configuration));
        this.bindingContext.bindValue(singleSelection.observe(this.permissionWidget.getViewer()), EMFProperties
                .value(PersconfPackage.Literals.ECONFIGURATION__PERMISSION).observe(configuration));
        this.bindingContext.bindValue(singleSelection.observe(this.storageWidget.getViewer()),
                EMFProperties.value(PersconfPackage.Literals.ECONFIGURATION__STORAGE).observe(configuration));

        this.bindingContext.bindValue(
                WidgetProperties.text(SWT.Modify).observe(this.maxSizeText.getTextControl()),
                EMFProperties.value(PersconfPackage.Literals.ECONFIGURATION__MAX_SIZE).observe(configuration));
        this.bindingContext.bindValue(
                WidgetProperties.text(SWT.Modify).observe(this.responsibleText.getTextControl()), EMFProperties
                        .value(PersconfPackage.Literals.ECONFIGURATION__RESPONSIBLE).observe(configuration));
        this.bindingContext.bindValue(
                WidgetProperties.text(SWT.Modify).observe(this.customNameText.getTextControl()), EMFProperties
                        .value(PersconfPackage.Literals.ECONFIGURATION__CUSTOM_NAME).observe(configuration));
        this.bindingContext.bindValue(singleSelection.observe(this.typeWidget.getViewer()),
                EMFProperties.value(PersconfPackage.Literals.ECONFIGURATION__TYPE).observe(configuration));
        this.bindingContext.bindValue(
                WidgetProperties.text(SWT.Modify).observe(this.customIdText.getTextControl()),
                EMFProperties.value(PersconfPackage.Literals.ECONFIGURATION__CUSTOM_ID).observe(configuration));

        this.setEnabledState(true);

        this.customIdText.isValid();
        this.customNameText.isValid();
        this.maxSizeText.isValid();
        this.responsibleText.isValid();
    } else {
        this.clearBindings();
        this.setEnabledState(false);
        this.clearValues();
    }
}

From source file:era.foss.objecteditor.specobject.SpecObjectCompositeViewer.java

License:Open Source License

/**
 * Create button bar showing:/*  ww w  .  j  a  v a2s .  c  om*/
 * <ul>
 * <li>combo box for the view</li>
 * <li>button for adding new SpecObjects</li>
 * </ul>
 * 
 * 
 * @param viewerComposite the parent composite
 * @return
 */
private void createButtonBar() {
    buttonBarComposite = new Composite(topLevelComposite, SWT.NONE);
    buttonBarComposite.setLayout(new GridLayout(4, true));
    buttonBarComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 0, 0));

    /*
     * create combo box showing the availible views
     */
    ComboViewer viewComboViewer = new ComboViewer(buttonBarComposite, SWT.READ_ONLY) {
        @Override
        protected void doUpdateItem(Widget data, Object element, boolean fullMap) {
            // memorize the selection before updating the item, as the
            // update routine removes the selection...
            ISelection currentSelection = this.getSelection();
            super.doUpdateItem(data, element, fullMap);
            // set the selection to the previous value
            this.setSelection(currentSelection);
        }
    };
    ObservableListContentProvider contentProvider = new ObservableListContentProvider();
    viewComboViewer.setContentProvider(contentProvider);
    viewComboViewer.setLabelProvider(
            new ObservableMapLabelProvider(EMFProperties.value(ErfPackage.Literals.IDENTIFIABLE__LONG_NAME)
                    .observeDetail(contentProvider.getKnownElements())));
    IEMFListProperty dataTypeDefinitions = EMFProperties.list(ErfPackage.Literals.ERA_TOOL_EXTENSION__VIEWS);
    IObservableList observableList = dataTypeDefinitions.observe(toolExtension);
    viewComboViewer.setInput(observableList);
    // use first view available
    // TODO: use a dedicated default view if available
    if (toolExtension.getViews().size() > 0) {
        viewComboViewer.setSelection(new StructuredSelection(toolExtension.getViews().get(0)));
    }
    viewComboViewer.getControl().setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));

    viewMaster = ViewerProperties.singleSelection().observe(viewComboViewer);

    // refresh composite table in case view has been changed
    viewMaster.addChangeListener(new IChangeListener() {

        @Override
        public void handleChange(ChangeEvent event) {
            dbc.dispose();

            compositeTable.dispose();
            createCompositeTable();

            binding();

            topLevelComposite.layout();
        }
    });

    /*
     * Create Combo box for selecting the SpecType
     */
    final ComboViewer specTypecomboViewer = new ComboViewer(buttonBarComposite, SWT.READ_ONLY) {
        @Override
        protected void doUpdateItem(Widget data, Object element, boolean fullMap) {
            // memorize the selection before updating the item, as the
            // update routine removes the selection...
            ISelection currentSelection = this.getSelection();
            super.doUpdateItem(data, element, fullMap);
            // set the selection to the previous value
            this.setSelection(currentSelection);
        }
    };
    ObservableListContentProvider comboViewercontentProvider = new ObservableListContentProvider();
    specTypecomboViewer.getControl().setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    // set content provider
    specTypecomboViewer.setContentProvider(comboViewercontentProvider);
    // set label provider
    specTypecomboViewer.setLabelProvider(
            new ObservableMapLabelProvider(EMFProperties.value(ErfPackage.Literals.IDENTIFIABLE__LONG_NAME)
                    .observeDetail(comboViewercontentProvider.getKnownElements())));
    // set input
    IEMFListProperty specTypeProperty = EMFProperties.list(ErfPackage.Literals.CONTENT__SPEC_TYPES);
    specTypecomboViewer.setInput(specTypeProperty.observe(this.erfModel.getCoreContent()));

    // TODO: use a dedicated default type if available
    if (erfModel.getCoreContent().getSpecTypes().size() > 0) {
        specTypecomboViewer
                .setSelection(new StructuredSelection(erfModel.getCoreContent().getSpecTypes().get(0)));
    }
    specTypeMaster = ViewerProperties.singleSelection().observe(specTypecomboViewer);

    /*
     * create add button
     */
    final Button addButton = new Button(buttonBarComposite, SWT.NONE);
    addButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    addButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
    addButton.setEnabled(specTypeMaster.getValue() != null);
    addButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            SpecObjectHandler.createNewSpecObject(editingDomain, erfModel.getCoreContent(),
                    (SpecType) SpecObjectCompositeViewer.this.specTypeMaster.getValue(),
                    erfModel.getCoreContent().getSpecifications().get(0));
        }
    });

    specTypeMaster.addValueChangeListener(new IValueChangeListener() {
        @Override
        public void handleValueChange(ValueChangeEvent event) {
            addButton.setEnabled(event.getObservableValue().getValue() != null);
        }
    });

}

From source file:era.foss.typeeditor.common.AddDeleteTableViewer.java

License:Open Source License

/**
 * Create Text widget for displaying the element description.
 *///from ww  w.j av a  2  s  .c  o  m
private void createDescriptionField() {

    // Label for description
    Label descriptionLabel = new Label(composite, SWT.NONE);
    descriptionLabel.setText(typeEditorActivator.getString("_UI_Description_label") + ":");
    descriptionLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false));

    // Text widget for the general Description attribute of any ERF-Identifiable
    descriptionText = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.WRAP);

    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    // always show a mimimum of 2 lines of Text
    gridData.minimumHeight = descriptionText.getLineHeight() * 2 + 10;
    descriptionText.setLayoutData(gridData);
    descriptionText.setEnabled(false);

    // bind values
    master = ViewerProperties.singleSelection().observe(this);

    /*
     * We only need the listener as the F****** data binding can't handle null pointer as value of the master object
     * at the time the various listeners are created. Maybe this has something to do with the fact that the data
     * binding stuff automatically creates common converters (e.g. int -> string,...) but on the other hand... EMF
     * knows everything and especially the type...
     * 
     * However a null pointer is OK once a data binding has been created where the value of the master object is not
     * null.
     * 
     * This is major crap...
     */
    master.addChangeListener(new IChangeListener() {
        @Override
        public void handleChange(ChangeEvent event) {
            /*
             * create data binding as soon the master observable points to an object
             */
            if (master.getValue() == null) {
                descriptionText.setEnabled(false);
            } else {
                descriptionText.setEnabled(true);
                if (dataBindContext == null) {

                    dataBindContext
                            .bindValue(WidgetProperties.text(SWT.Modify).observeDelayed(400, descriptionText),
                                    EMFEditProperties
                                            .value(editingDomain, ErfPackage.Literals.IDENTIFIABLE__DESC)
                                            .observeDetail(master));
                }
            }
        }
    });
}

From source file:era.foss.typeeditor.common.Ui.java

License:Open Source License

/**
 * Create a column with EMF databinding for a table viewer
 * /*  www .java2s .c o  m*/
 * <li>In case the top level structural feature is a reference display a combo box</li> <li>In case the top level
 * structural feature is a containment reference create element if it does not exist</li> <li>In case the structural
 * feature is a boolean show a checkbox</li> <li>Otherwise show a simple text field</li>.
 *
 * @param column the column
 * @param eStructuralFeatureList list to create a feature path from
 * @param refObservedObject the ref observed object
 * @param refEStructuralFeatureList the ref e structural feature list
 */
public void bindColumn(TableViewerColumn column, EStructuralFeature[] eStructuralFeatureList,
        EObject refObservedObject, EStructuralFeature[] refEStructuralFeatureList) {

    TableViewer tableViewer = (TableViewer) column.getViewer();
    ObservableListContentProvider cp = (ObservableListContentProvider) tableViewer.getContentProvider();
    assert (cp != null);

    // get the top level structural feature
    EStructuralFeature topStructuralFeature = eStructuralFeatureList[0];

    // set label provider
    IValueProperty elementProperty = EMFEditProperties.value(editingDomain,
            FeaturePath.fromList(eStructuralFeatureList));
    IObservableMap attributeMap = elementProperty.observeDetail(cp.getKnownElements());
    column.setLabelProvider(new ObservableMapCellLabelProvider(attributeMap));

    EditingSupport editingSupport = null;

    // Show combo box for references
    if (refObservedObject != null && refEStructuralFeatureList != null) {

        // Combo box: Create combo box to select choices for the reference
        ComboBoxViewerCellEditor combo = new ComboBoxViewerCellEditorSp((Composite) tableViewer.getControl(),
                SWT.READ_ONLY);
        // Combo box: Set Content Provider
        ObservableListContentProvider comboContentProvider = new ObservableListContentProvider();
        combo.setContentProvider(comboContentProvider);

        IObservableMap comboAttributeMap = EMFProperties
                .value(eStructuralFeatureList[eStructuralFeatureList.length - 1])
                .observeDetail(comboContentProvider.getKnownElements());
        combo.setLabelProvider(new ObservableMapLabelProvider(comboAttributeMap));
        // Combo box: set input
        IEMFListProperty dataTypeDefinitions = EMFProperties
                .list(FeaturePath.fromList(refEStructuralFeatureList));
        combo.setInput(dataTypeDefinitions.observe(refObservedObject));

        // Set editing support of table cell
        IValueProperty editorElementProperty = EMFEditProperties.value(editingDomain, topStructuralFeature);
        IValueProperty cellEditorProperty = ViewerProperties.singleSelection();

        editingSupport = ObservableValueEditingSupport.create(tableViewer, dataBindContext, combo,
                cellEditorProperty, editorElementProperty);

    }
    // Simple text
    else {
        IValueProperty cellEditorProperty = CellEditorProperties.control()
                .value(WidgetProperties.text(SWT.Modify));

        editingSupport = ObservableValueEditingSupport.create(tableViewer, dataBindContext,
                new TextCellEditor(tableViewer.getTable()), cellEditorProperty, elementProperty);
    }

    column.setEditingSupport(editingSupport);

}

From source file:era.foss.typeeditor.datatype.DatatypeDefinitionsForm.java

License:Open Source License

/**
 * Instantiates a new datatype definitions form.
 * //from  w  w w.  j  a va2  s  .  c o m
 * @param parent the parent
 * @param editor the editor
 */
public DatatypeDefinitionsForm(Composite parent, IEditorPart editor) {
    super(parent, editor, SWT.NONE);

    // set-up layout
    GridLayout gridLayout = new GridLayout(2, true);
    this.setLayout(gridLayout);

    createTableViewer();

    // setup Data type properties viewer
    DataTypeDefinitionDetailViewer dataTypeDefinitionDetail = new DataTypeDefinitionDetailViewer(this, SWT.NONE,
            editingDomain, ViewerProperties.singleSelection().observe(tableViewer));
    dataTypeDefinitionDetail.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

}

From source file:era.foss.typeeditor.spectype.SpecTypeForm.java

License:Open Source License

/**
 * Create table viewer showing the SpecTypes
 *///  w w  w.jav a  2  s .  co m
private void createSpecTypeTableViewer() {
    AddDeleteTableViewer specTypeTableViewer = new AddDeleteTableViewer(this,
            SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    specTypeTableViewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    specTypeTableViewer.setEditingDomain(editingDomain);
    specTypeTableViewer.setElementInformation(erfModel.getCoreContent(),
            ErfPackage.Literals.CONTENT__SPEC_TYPES, ErfPackage.Literals.SPEC_TYPE);

    ObservableListContentProvider cp = new ObservableListContentProvider();
    specTypeTableViewer.setContentProvider(cp);

    TableColumnLayout columnLayout = (TableColumnLayout) specTypeTableViewer.getTable().getParent().getLayout();

    // create column with name of the SpecType
    TableViewerColumn nameColumn = new TableViewerColumn(specTypeTableViewer, SWT.NONE);
    columnLayout.setColumnData(nameColumn.getColumn(), new ColumnWeightData(100, 70));
    nameColumn.getColumn().setResizable(false);
    nameColumn.getColumn().setMoveable(false);
    nameColumn.getColumn().setText(Ui.getUiName(ErfPackage.Literals.IDENTIFIABLE__LONG_NAME));
    EStructuralFeature[] structuralFeature = { ErfPackage.Literals.IDENTIFIABLE__LONG_NAME };
    ui.bindColumn(nameColumn, structuralFeature);

    // provide input for the table
    IEMFListProperty specTypeProperty = EMFProperties.list(ErfPackage.Literals.CONTENT__SPEC_TYPES);
    specTypeTableViewer.setInput(specTypeProperty.observe(erfModel.getCoreContent()));
    specTypeTableViewer.getTable().select(0);

    this.specTypeMaster = ViewerProperties.singleSelection().observe(specTypeTableViewer);
}

From source file:era.foss.typeeditor.spectype.SpecTypeForm.java

License:Open Source License

/**
 * create detailed viewer for selected element.
 *//*from   w w w. j  a  v  a 2 s . co  m*/
private void createSpecAttributeDetailViewer() {
    // setup Data type properties viewer
    AttributeDefinitionDetailViewer detailViewer = new AttributeDefinitionDetailViewer(this, SWT.NONE,
            editingDomain, ViewerProperties.singleSelection().observe(specAttributeTableViewer));
    detailViewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

}

From source file:era.foss.typeeditor.view.ViewForm.java

License:Open Source License

/**
 * Creates the table viewer for {@link View}s
 *//*from ww  w. jav a2s .c o m*/
private void createViewTableViewer(Composite parent) {

    AddDeleteTableViewer viewTableViewer = new AddDeleteTableViewer(parent,
            SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);

    viewTableViewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    viewTableViewer.setEditingDomain(editingDomain);
    viewTableViewer.setElementInformation(toolExtension, ErfPackage.Literals.ERA_TOOL_EXTENSION__VIEWS,
            ErfPackage.Literals.VIEW);

    ObservableListContentProvider cp = new ObservableListContentProvider();
    viewTableViewer.setContentProvider(cp);

    TableColumnLayout columnLayout = (TableColumnLayout) viewTableViewer.getTable().getParent().getLayout();

    // create column with name of the view
    TableViewerColumn nameColumn = new TableViewerColumn(viewTableViewer, SWT.NONE);
    columnLayout.setColumnData(nameColumn.getColumn(), new ColumnWeightData(100, 70));
    nameColumn.getColumn().setResizable(false);
    nameColumn.getColumn().setMoveable(false);
    nameColumn.getColumn().setText(Ui.getUiName(ErfPackage.Literals.IDENTIFIABLE__LONG_NAME));
    ui.bindColumn(nameColumn, new EStructuralFeature[] { ErfPackage.Literals.IDENTIFIABLE__LONG_NAME });

    // provide input for the table
    IEMFListProperty viewsProperty = EMFProperties.list(ErfPackage.Literals.ERA_TOOL_EXTENSION__VIEWS);
    viewTableViewer.setInput(viewsProperty.observe(toolExtension));
    viewTableViewer.getTable().select(0);

    this.viewMaster = ViewerProperties.singleSelection().observe(viewTableViewer);

}