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

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

Introduction

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

Prototype

@Deprecated
public static ISWTObservableValue observeSelection(Control control) 

Source Link

Document

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

Usage

From source file:org.nabucco.framework.importing.ui.rcp.wizard.ImportWizardPage.java

License:Open Source License

/**
 * Layout the import all checkbox./*from ww w  . j av  a2  s.c  o m*/
 * 
 * @param parent
 *            the parent composite
 */
private Button layoutImportAll(Composite parent) {
    Button importAll = new Button(parent, SWT.CHECK);
    importAll.setText(I18N.i18n(CHECKBOX_EXPORT_ALL));

    DataBindingContext bindingContext = new DataBindingContext();
    IObservableValue uiElement = SWTObservables.observeSelection(importAll);
    IObservableValue modelElement = BeansObservables.observeValue(this.model,
            ImportWizardModel.PROPERTY_EXPORTALL);
    bindingContext.bindValue(uiElement, modelElement);

    return importAll;
}

From source file:org.nabucco.framework.importing.ui.rcp.wizard.ImportWizardPage.java

License:Open Source License

/**
 * Create the import destination specification widgets
 * /*  w  w  w.  j a v a2  s  .c o  m*/
 * @param parent
 *            the parent composite
 */
private void layoutDestinationGroup(Composite parent) {

    Composite group = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    group.setLayout(layout);

    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    group.setLayoutData(data);

    Label dest = new Label(group, SWT.NONE);
    dest.setText(I18N.i18n(LABEL_DESTINATION));

    // Destination Field
    Combo combo = new Combo(group, SWT.SINGLE | SWT.BORDER);
    combo.setFocus();

    for (String history : this.model.getDestinationNames()) {
        combo.add(history);
    }

    DataBindingContext bindingContext = new DataBindingContext();
    IObservableValue uiElement = SWTObservables.observeSelection(combo);
    IObservableValue modelElement = BeansObservables.observeValue(this.model,
            ImportWizardModel.PROPERTY_DESTINATION);
    bindingContext.bindValue(uiElement, modelElement);

    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    combo.setLayoutData(data);

    // Browse Button
    Button button = new Button(group, SWT.PUSH);
    button.setText(I18N.i18n(BUTTON_BROWSE));
    setButtonLayoutData(button);

    button.addSelectionListener(new ImportBrowseButtonListener(super.getContainer().getShell(), this.model));

    // Vertical Spacer
    new Label(parent, SWT.NONE);
}

From source file:org.nabucco.testautomation.config.ui.rcp.multipage.config.maintenance.masterdetails.widgetcreators.attributevalue.AttributeValueWidgetCreator.java

License:Open Source License

protected Control createWidget(Composite parent, Code code, CodePath codePath, Method method, Object object,
        boolean readOnly, ViewModel externalViewModel, NabuccoMessageManager messageManager,
        String propertyName) {/*from  w  w  w.  java  2 s .  c o m*/

    final CodeContentProvider codeContentProvider = new CodeContentProvider(codePath);

    final ElementPickerComboParameter params = new ElementPickerComboParameter(codeContentProvider,
            new CodeLabelProvider());

    // ElementPickerCombo elementCombo = new ElementPickerCombo(parent, params);
    ElementPickerCombo elementCombo = super.getFormToolkit().createElementPickerCombo(parent, params, readOnly,
            true);

    // combo.setLayoutData(gridData);

    final DataBindingContext bindingContext = new DataBindingContext();
    final IObservableValue uiElement = SWTObservables.observeSelection(elementCombo.getCombo());

    if (object instanceof Datatype) {

        final CodeMiniModel model = new CodeMiniModel(codeContentProvider, method, (Datatype) object,
                externalViewModel, code);
        final IObservableValue modelElement = BeansObservables.observeValue(model,
                CodeMiniModel.PROPERTY_VALUE);
        bindingContext.bindValue(uiElement, modelElement, null, null);
        elementCombo.addSelectionListener(new CodeComboBoxHandler(model));
    }

    return elementCombo;
}

From source file:org.nabucco.testautomation.script.ui.rcp.multipage.maintenance.masterdetails.widgetcreators.action.MetadataPickerActionComboWidgetCreator.java

License:Open Source License

private Control layoutActionCombo(MetadataPickerActionComboMiniModel model) {

    // Create ActionCombo ContentProvider
    List<SubEngineActionCode> availableActionCodes;
    Metadata metadata = action.getMetadata();
    boolean readOnly = false;
    if (this.readOnly) {
        readOnly = true;//from  ww w.j  a  va  2s . c o  m
    }
    if (metadata == null) {
        readOnly = true;
        availableActionCodes = new ArrayList<SubEngineActionCode>();
    } else {
        SubEngineOperationCode subEngineOperationCode = metadata.getOperation();
        availableActionCodes = subEngineOperationCode.getActionList();
    }
    ObjectListContentProvider contentProvider = new ObjectListContentProvider(availableActionCodes);
    ElementPickerComboParameter parameter = new ElementPickerComboParameter(contentProvider,
            new SubEngineActionCodeLabelProvider());

    // Layout ActionCombo
    ElementPickerCombo combo = super.getFormToolkit().createElementPickerCombo(parent, parameter, readOnly,
            false);

    // Set Combo and ContentProvier to MiniModel
    model.setActionCombo(combo);
    model.setActionComboContentProvider(contentProvider);

    // Bind ActionCombo
    DataBindingContext bindingContext = new DataBindingContext();
    IObservableValue uiElement = SWTObservables.observeSelection(combo.getCombo());
    IObservableValue modelElement = BeansObservables.observeValue(model,
            MetadataPickerActionComboMiniModel.PROPERTY_ACTION);
    bindingContext.bindValue(uiElement, modelElement, null, null);

    combo.addSelectionListener(new SubEngineActionCodeComboBoxHandler(model));
    return combo;
}

From source file:org.nabucco.testautomation.script.ui.rcp.multipage.metadata.masterdetail.widgetcreators.metadata.subengine.WidgetCreatorForSubEngineComboPair.java

License:Open Source License

/**
 * //from   w w w .j  a  va2s. c om
 * @param externalViewModel
 * @param data
 * @param masterBlockId
 * @param widgetFactory2
 */
public Control[] createWidget() throws ClientException {

    Control[] result = new Control[3];

    // Create Content Providers
    ObjectListContentProvider subEngineCodeContentProvider = new ObjectListContentProvider(subEngineCodeList);
    ElementPickerComboParameter subEngineCodeParameter = new ElementPickerComboParameter(
            subEngineCodeContentProvider, new SubEngineCodeLabelProvider());

    List<SubEngineOperationCode> subEngineOperationCodeList;
    if (metadata.getSubEngine() != null) {
        subEngineOperationCodeList = metadata.getSubEngine().getOperationList();
    } else {
        subEngineOperationCodeList = new ArrayList<SubEngineOperationCode>();
    }
    ObjectListContentProvider subEngineOperationCodeContentProvider = new ObjectListContentProvider(
            subEngineOperationCodeList);
    ElementPickerComboParameter subEngineOperationCodeParameter = new ElementPickerComboParameter(
            subEngineOperationCodeContentProvider, new SubEngineOperationCodeLabelProvider());

    // Create Labels and Widgets

    ElementPickerCombo subEngineCodeCombo = layoutSubEngineCodeCombo(subEngineCodeParameter);
    result[0] = subEngineCodeCombo;

    ElementPickerCombo subEngineOperationCodeCombo = layoutSubEngineOperationCodeCombo(
            subEngineOperationCodeParameter);
    result[1] = subEngineOperationCodeCombo;

    TableViewer propertiesList = layoutPropertiesControl();
    result[2] = propertiesList.getControl();

    // Create MiniModel
    SubEngineComboPairMiniModel model = new SubEngineComboPairMiniModel(parent, subEngineCodeContentProvider,
            subEngineOperationCodeContentProvider, subEngineOperationCodeCombo, propertiesList,
            externalViewModel, metadata);

    // Bind
    DataBindingContext bindingContext = new DataBindingContext();
    IObservableValue uiElement = SWTObservables.observeSelection(subEngineCodeCombo.getCombo());
    IObservableValue modelElement = BeansObservables.observeValue(model,
            SubEngineComboPairMiniModel.PROPERTY_VALUE_SUB_ENGINE);
    bindingContext.bindValue(uiElement, modelElement, null, null);

    bindingContext = new DataBindingContext();
    uiElement = SWTObservables.observeSelection(subEngineOperationCodeCombo.getCombo());
    modelElement = BeansObservables.observeValue(model,
            SubEngineComboPairMiniModel.PROPERTY_VALUE_SUB_ENGINE_OPERATION);
    bindingContext.bindValue(uiElement, modelElement, null, null);

    // Add listeners
    subEngineCodeCombo.addSelectionListener(new SubEngineCodeComboBoxHandler(model));
    subEngineOperationCodeCombo.addSelectionListener(new SubEngineOperationCodeComboBoxHandler(model));
    return result;
}

From source file:org.objectstyle.wolips.eogenerator.ui.editors.EOGeneratorFormPage.java

License:Open Source License

private TableViewer createModelsSection(String title, String description, FormToolkit toolkit, Composite parent,
        IStructuredContentProvider contentProvider, ITableLabelProvider labelProvider,
        SelectionListener addListener, SelectionListener removeListener) {
    Composite modelsSection = createSection(toolkit, parent, title, description, 1, 2);

    if (contentProvider instanceof RefModelsTableContentProvider) {
        Button loadModelGroupButton = toolkit.createButton(modelsSection, "", SWT.CHECK);
        loadModelGroupButton.setText("Load Model Group");
        GridData loadModelGroupButtonGridData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
        loadModelGroupButtonGridData.horizontalSpan = 2;
        loadModelGroupButtonGridData.verticalIndent = 5;
        loadModelGroupButton.setLayoutData(loadModelGroupButtonGridData);
        _bindingContext.bindValue(SWTObservables.observeSelection(loadModelGroupButton),
                BeansObservables.observeValue(_model, EOGeneratorModel.LOAD_MODEL_GROUP), null, null);
    }//from www  .j a v a 2  s .c  o m

    Table modelsTable = toolkit.createTable(modelsSection,
            SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);

    GridData modelsTableGridData = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING);
    modelsTableGridData.heightHint = 75;
    modelsTable.setLayoutData(modelsTableGridData);

    TableViewer modelsTableViewer = new TableViewer(modelsTable);
    modelsTableViewer.setContentProvider(contentProvider);
    modelsTableViewer.setLabelProvider(labelProvider);

    Composite modelsButtonsComposite = toolkit.createComposite(modelsSection);
    modelsButtonsComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    GridLayout modelsButtonsLayout = new GridLayout();
    modelsButtonsLayout.marginTop = 0;
    modelsButtonsLayout.marginBottom = 0;
    modelsButtonsLayout.verticalSpacing = 0;
    modelsButtonsLayout.horizontalSpacing = 0;
    modelsButtonsLayout.numColumns = 1;
    modelsButtonsComposite.setLayout(modelsButtonsLayout);

    Button modelsAddButton = toolkit.createButton(modelsButtonsComposite, "Add...", SWT.PUSH);
    GridData modelsAddButtonGridData = new GridData(
            GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    modelsAddButton.setLayoutData(modelsAddButtonGridData);
    modelsAddButton.addSelectionListener(addListener);

    Button modelsRemoveButton = toolkit.createButton(modelsButtonsComposite, "Remove", SWT.PUSH);
    GridData modelsRemoveButtonGridData = new GridData(
            GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    modelsRemoveButton.setLayoutData(modelsRemoveButtonGridData);
    modelsRemoveButton.addSelectionListener(removeListener);

    return modelsTableViewer;
}

From source file:org.objectstyle.wolips.eogenerator.ui.editors.EOGeneratorFormPage.java

License:Open Source License

protected void createPathsSection(FormToolkit toolkit, Composite parent) {
    FileEditorInput editorInput = (FileEditorInput) getEditorInput();
    IFile eogenFile = editorInput.getFile();
    final IProject project = eogenFile.getProject();

    Composite pathsSection = createSection(toolkit, parent, "Destination Paths",
            "These paths specify where generated files will be written and are project-relative.", 1, 3);
    GridLayout pathsSectionLayout = (GridLayout) pathsSection.getLayout();
    pathsSectionLayout.horizontalSpacing = 10;

    Label superclassPackageLabel = toolkit.createLabel(pathsSection, "Superclass Package (e.g. \"base\"):");
    superclassPackageLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    final Text superclassPackage = toolkit.createText(pathsSection, null);
    superclassPackage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    _bindingContext.bindValue(SWTObservables.observeText(superclassPackage, SWT.Modify),
            BeansObservables.observeValue(_model, EOGeneratorModel.SUPERCLASS_PACKAGE), null, null);
    toolkit.createLabel(pathsSection, "");

    Label destinationLabel = toolkit.createLabel(pathsSection, "Destination:");
    destinationLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    final Text destination = toolkit.createText(pathsSection, null);
    destination.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    _bindingContext.bindValue(SWTObservables.observeText(destination, SWT.Modify),
            BeansObservables.observeValue(_model, EOGeneratorModel.DESTINATION), null, null);

    Button destinationBrowse = toolkit.createButton(pathsSection, "Browse...", SWT.PUSH);
    destinationBrowse.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent selectionevent) {
            widgetSelected(selectionevent);
        }/*from  w  ww .  j  a  v a 2  s  .  com*/

        public void widgetSelected(SelectionEvent selectionevent) {
            ContainerSelectionDialog containerDialog = new ContainerSelectionDialog(getEditorSite().getShell(),
                    project, false, "Select the folder to write autogenerated files into.");
            containerDialog.open();
            Object[] selectedContainers = containerDialog.getResult();
            if (selectedContainers != null && selectedContainers.length > 0) {
                IPath selectedPath = (IPath) selectedContainers[0];
                IFolder selectedFolder = project.getParent().getFolder(selectedPath);
                IPath projectRelativePath = selectedFolder.getProjectRelativePath();
                EOGeneratorFormPage.this.getModel().setDestination(projectRelativePath.toPortableString());
            }
            destination.forceFocus();
        }
    });

    Label subclassDestinationLabel = toolkit.createLabel(pathsSection, "Subclass Destination:");
    subclassDestinationLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    final Text subclassDestination = toolkit.createText(pathsSection, null);
    subclassDestination.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    _bindingContext.bindValue(SWTObservables.observeText(subclassDestination, SWT.Modify),
            BeansObservables.observeValue(_model, EOGeneratorModel.SUBCLASS_DESTINATION), null, null);

    Button subclassDestinationBrowse = toolkit.createButton(pathsSection, "Browse...", SWT.PUSH);
    subclassDestinationBrowse.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent selectionevent) {
            widgetSelected(selectionevent);
        }

        public void widgetSelected(SelectionEvent selectionevent) {
            ContainerSelectionDialog containerDialog = new ContainerSelectionDialog(getEditorSite().getShell(),
                    project, false, "Select the folder to generate customizable files into.");
            containerDialog.open();
            Object[] selectedContainers = containerDialog.getResult();
            if (selectedContainers != null && selectedContainers.length > 0) {
                IPath selectedPath = (IPath) selectedContainers[0];
                IFolder selectedFolder = project.getParent().getFolder(selectedPath);
                IPath projectRelativePath = selectedFolder.getProjectRelativePath();
                EOGeneratorFormPage.this.getModel()
                        .setSubclassDestination(projectRelativePath.toPortableString());
            }
            subclassDestination.forceFocus();
        }
    });

    Composite templatesSection = createSection(toolkit, parent, "Templates",
            "These paths specify the templates that will be used to generate files.  If left blank, the defaults from the EOGenerator preference page will be used.",
            1, 3);
    GridLayout templatesSectionLayout = (GridLayout) templatesSection.getLayout();
    templatesSectionLayout.horizontalSpacing = 10;

    Label templatesFolderLabel = toolkit.createLabel(templatesSection, "Templates Folder:");
    templatesFolderLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    final Text templatesFolder = toolkit.createText(templatesSection, null);
    templatesFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    _bindingContext.bindValue(SWTObservables.observeText(templatesFolder, SWT.Modify),
            BeansObservables.observeValue(_model, EOGeneratorModel.TEMPLATE_DIR), null, null);

    Button templatesFolderBrowse = toolkit.createButton(templatesSection, "Browse...", SWT.PUSH);
    templatesFolderBrowse.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent selectionevent) {
            widgetSelected(selectionevent);
        }

        public void widgetSelected(SelectionEvent selectionevent) {
            DirectoryDialog directoryDialog = new DirectoryDialog(getEditorSite().getShell());
            directoryDialog.setMessage("Select the folder that contains your EOGenerator templates.");
            directoryDialog.setFilterPath(EOGeneratorFormPage.this.getModel().getTemplateDir());
            String selectedDirectory = directoryDialog.open();
            if (selectedDirectory != null) {
                EOGeneratorFormPage.this.getModel().setTemplateDir(selectedDirectory);
            }
            templatesFolder.forceFocus();
        }
    });

    Label templateLabel = toolkit.createLabel(templatesSection, "Template:");
    templateLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    final Text template = toolkit.createText(templatesSection, null);
    template.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    _bindingContext.bindValue(SWTObservables.observeText(template, SWT.Modify),
            BeansObservables.observeValue(_model, EOGeneratorModel.JAVA_TEMPLATE), null, null);

    Button templateBrowse = toolkit.createButton(templatesSection, "Browse...", SWT.PUSH);
    templateBrowse.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent selectionevent) {
            widgetSelected(selectionevent);
        }

        public void widgetSelected(SelectionEvent selectionevent) {
            String selectedTemplate = EOGeneratorFormPage.this
                    .selectTemplate("Select the superclass template.");
            if (selectedTemplate != null) {
                EOGeneratorFormPage.this.getModel().setJavaTemplate(selectedTemplate);
            }
            template.forceFocus();
        }
    });

    Label subclassTemplateLabel = toolkit.createLabel(templatesSection, "Subclass Template:");
    subclassTemplateLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    final Text subclassTemplate = toolkit.createText(templatesSection, null);
    subclassTemplate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    _bindingContext.bindValue(SWTObservables.observeText(subclassTemplate, SWT.Modify),
            BeansObservables.observeValue(_model, EOGeneratorModel.SUBCLASS_JAVA_TEMPLATE), null, null);

    Button subclassTemplateBrowse = toolkit.createButton(templatesSection, "Browse...", SWT.PUSH);
    subclassTemplateBrowse.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent selectionevent) {
            widgetSelected(selectionevent);
        }

        public void widgetSelected(SelectionEvent selectionevent) {
            String selectedTemplate = EOGeneratorFormPage.this.selectTemplate("Select the subclass template.");
            if (selectedTemplate != null) {
                EOGeneratorFormPage.this.getModel().setSubclassJavaTemplate(selectedTemplate);
            }
            subclassTemplate.forceFocus();
        }
    });

    Composite outputOptionsSection = createSection(toolkit, parent, "Options",
            "These flags control various output options for generated source.", 1, 3);
    GridLayout outputOptionsLayout = (GridLayout) outputOptionsSection.getLayout();
    outputOptionsLayout.horizontalSpacing = 10;
    outputOptionsLayout.verticalSpacing = 5;

    // Label packageDirsLabel = toolkit.createLabel(pathsSection, "Create
    // Packages?");
    // packageDirsLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    Button packageDirsButton = toolkit.createButton(outputOptionsSection, "", SWT.CHECK);
    packageDirsButton.setText("Create Packages");
    GridData packageDirsButtonGridData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
    packageDirsButtonGridData.horizontalSpan = 3;
    packageDirsButton.setLayoutData(packageDirsButtonGridData);
    _bindingContext.bindValue(SWTObservables.observeSelection(packageDirsButton),
            BeansObservables.observeValue(_model, EOGeneratorModel.PACKAGE_DIRS), null, null);

    Button javaButton = toolkit.createButton(outputOptionsSection, "", SWT.CHECK);
    GridData javaButtonGridData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
    javaButtonGridData.horizontalSpan = 3;
    javaButton.setLayoutData(javaButtonGridData);
    javaButton.setText("Java");
    _bindingContext.bindValue(SWTObservables.observeSelection(javaButton),
            BeansObservables.observeValue(_model, EOGeneratorModel.JAVA), null, null);

    Button javaClientButton = toolkit.createButton(outputOptionsSection, "", SWT.CHECK);
    javaClientButton.setText("Java Client");
    GridData javaClientButtonGridData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
    javaClientButtonGridData.horizontalSpan = 3;
    javaClientButton.setLayoutData(javaClientButtonGridData);
    _bindingContext.bindValue(SWTObservables.observeSelection(javaClientButton),
            BeansObservables.observeValue(_model, EOGeneratorModel.JAVA_CLIENT), null, null);

    Button javaClientCommonButton = toolkit.createButton(outputOptionsSection, "", SWT.CHECK);
    javaClientCommonButton.setText("Java Client Common");
    GridData javaClientCommonButtonGridData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
    javaClientCommonButtonGridData.horizontalSpan = 3;
    javaClientCommonButton.setLayoutData(javaClientCommonButtonGridData);
    _bindingContext.bindValue(SWTObservables.observeSelection(javaClientCommonButton),
            BeansObservables.observeValue(_model, EOGeneratorModel.JAVA_CLIENT_COMMON), null, null);
}

From source file:org.objectstyle.wolips.eomodeler.editors.attribute.AbstractEOArgumentBasicEditorSection.java

License:Open Source License

public void setArgument(AbstractEOArgument argument) {
    if (!ComparisonUtils.equals(argument, _argument)) {
        disposeBindings();/*www .  j ava  2 s.  co m*/

        _argument = argument;

        if (_argument != null) {
            // myArgumentTypeComboViewer.setInput(myAttribute);
            _bindingContext = new DataBindingContext();
            _bindingContext.bindValue(SWTObservables.observeText(_nameText, SWT.Modify),
                    BeansObservables.observeValue(_argument, AbstractEOArgument.NAME), null, null);
            _bindingContext.bindValue(SWTObservables.observeText(_columnNameText, SWT.Modify),
                    BeansObservables.observeValue(_argument, AbstractEOArgument.COLUMN_NAME), null, null);
            _bindingContext.bindValue(SWTObservables.observeText(_definitionText, SWT.Modify),
                    BeansObservables.observeValue(_argument, AbstractEOArgument.DEFINITION), null, null);
            _bindingContext.bindValue(SWTObservables.observeText(_externalTypeText, SWT.Modify),
                    BeansObservables.observeValue(_argument, AbstractEOArgument.EXTERNAL_TYPE), null, null);
            _bindingContext.bindValue(SWTObservables.observeText(_classNameText, SWT.Modify),
                    BeansObservables.observeValue(_argument, AbstractEOArgument.CLASS_NAME), null, null);
            _bindingContext.bindValue(SWTObservables.observeSelection(_allowNullsButton),
                    BeansObservables.observeValue(_argument, AbstractEOArgument.ALLOWS_NULL), null,
                    new BooleanUpdateValueStrategy());

            _argumentChanged(argument);

            _dataTypeBinding = new ComboViewerBinding(_dataTypeComboViewer, _argument,
                    AbstractEOArgument.DATA_TYPE, null, null, null);
            if (_argument.getDefinition() == null) {
                _derivedComboViewer
                        .setSelection(new StructuredSelection(AbstractEOArgumentBasicEditorSection.COLUMN));
            } else {
                _derivedComboViewer
                        .setSelection(new StructuredSelection(AbstractEOArgumentBasicEditorSection.DERIVED));
            }

            // Iterator dataTypePanelsIter =
            // myDataTypeToDataTypePanel.values().iterator();
            // while (dataTypePanelsIter.hasNext()) {
            // IDataTypePanel dataTypePanel = (IDataTypePanel)
            // dataTypePanelsIter.next();
            // dataTypePanel.setArgument(_argument);
            // }
            updateAttributePanel(null);
            if (_argument != null) {
                _argument.addPropertyChangeListener(AbstractEOArgument.DATA_TYPE, _dataTypeChangeListener);
            }
        }
    }
}

From source file:org.objectstyle.wolips.eomodeler.editors.attribute.EOAttributeAdvancedEditorSection.java

License:Open Source License

public void setInput(IWorkbenchPart part, ISelection selection) {
    if (ComparisonUtils.equals(selection, getSelection())) {
        return;//ww w.j  ava2 s .c  o m
    }

    super.setInput(part, selection);
    disposeBindings();

    Object selectedObject = ((IStructuredSelection) selection).getFirstElement();
    if (selectedObject instanceof EOAttribute) {
        _attribute = (EOAttribute) selectedObject;
    } else if (selectedObject instanceof EOAttributePath) {
        _attribute = ((EOAttributePath) selectedObject).getChildAttribute();
    }

    if (_attribute != null) {
        _bindingContext = new DataBindingContext();
        _bindingContext.bindValue(SWTObservables.observeSelection(_readOnlyButton),
                BeansObservables.observeValue(_attribute, EOAttribute.READ_ONLY), null,
                new BooleanUpdateValueStrategy());
        _bindingContext.bindValue(SWTObservables.observeSelection(_clientClassPropertyButton),
                BeansObservables.observeValue(_attribute, EOAttribute.CLIENT_CLASS_PROPERTY), null,
                new BooleanUpdateValueStrategy());
        _bindingContext.bindValue(SWTObservables.observeSelection(_commonClassPropertyButton),
                BeansObservables.observeValue(_attribute, EOAttribute.COMMON_CLASS_PROPERTY), null,
                new BooleanUpdateValueStrategy());
        _bindingContext.bindValue(SWTObservables.observeSelection(_generateSourceButton),
                BeansObservables.observeValue(_attribute, EOAttribute.GENERATE_SOURCE), null,
                new BooleanUpdateValueStrategy());
        _bindingContext.bindValue(SWTObservables.observeText(_readFormatText, SWT.Modify),
                BeansObservables.observeValue(_attribute, EOAttribute.READ_FORMAT), null, null);
        _bindingContext.bindValue(SWTObservables.observeText(_writeFormatText, SWT.Modify),
                BeansObservables.observeValue(_attribute, EOAttribute.WRITE_FORMAT), null, null);
    }
}

From source file:org.objectstyle.wolips.eomodeler.editors.attribute.EOAttributeBasicEditorSection.java

License:Open Source License

protected void _argumentChanged(AbstractEOArgument argument) {
    EOAttribute attribute = (EOAttribute) argument;
    if (attribute != null) {
        _prototypeComboViewer.setInput(attribute);
        _prototypeBinding = new ComboViewerBinding(_prototypeComboViewer, attribute, EOAttribute.PROTOTYPE,
                attribute.getEntity().getModel(), EOModel.ENTITIES, EOEntityListContentProvider.BLANK_ENTITY);

        getBindingContext().bindValue(SWTObservables.observeSelection(_primaryKeyButton),
                BeansObservables.observeValue(attribute, EOAttribute.PRIMARY_KEY), null,
                new BooleanUpdateValueStrategy());
        getBindingContext().bindValue(SWTObservables.observeSelection(_classPropertyButton),
                BeansObservables.observeValue(attribute, EOAttribute.CLASS_PROPERTY), null,
                new BooleanUpdateValueStrategy());
        getBindingContext().bindValue(SWTObservables.observeSelection(_lockingButton),
                BeansObservables.observeValue(attribute, EOAttribute.USED_FOR_LOCKING), null,
                new BooleanUpdateValueStrategy());
    }//from  w  ww  .j  a va  2  s . co  m
}