Example usage for org.eclipse.jface.fieldassist ControlDecoration setMarginWidth

List of usage examples for org.eclipse.jface.fieldassist ControlDecoration setMarginWidth

Introduction

In this page you can find the example usage for org.eclipse.jface.fieldassist ControlDecoration setMarginWidth.

Prototype

public void setMarginWidth(int marginWidth) 

Source Link

Document

Set the margin width in pixels that should be used between the decorator and the horizontal edge of the control.

Usage

From source file:bndtools.editor.contents.GeneralInfoPart.java

License:Open Source License

private void createSection(Section section, FormToolkit toolkit) {
    section.setText("Basic Information");

    KeyStroke assistKeyStroke = null;
    try {/*from  ww  w  .ja  v a 2 s .  co m*/
        assistKeyStroke = KeyStroke.getInstance("Ctrl+Space");
    } catch (ParseException x) {
        // Ignore
    }
    FieldDecoration contentAssistDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);

    Composite composite = toolkit.createComposite(section);
    section.setClient(composite);

    toolkit.createLabel(composite, "Version:");
    txtVersion = toolkit.createText(composite, "", SWT.BORDER);
    ToolTips.setupMessageAndToolTipFromSyntax(txtVersion, Constants.BUNDLE_VERSION);

    Hyperlink linkActivator = toolkit.createHyperlink(composite, "Activator:", SWT.NONE);
    txtActivator = toolkit.createText(composite, "", SWT.BORDER);
    ToolTips.setupMessageAndToolTipFromSyntax(txtActivator, Constants.BUNDLE_ACTIVATOR);

    toolkit.createLabel(composite, "Declarative Services:");
    cmbComponents = new Combo(composite, SWT.READ_ONLY);

    // Content Proposal for the Activator field
    ContentProposalAdapter activatorProposalAdapter = null;

    ActivatorClassProposalProvider proposalProvider = new ActivatorClassProposalProvider();
    activatorProposalAdapter = new ContentProposalAdapter(txtActivator, new TextContentAdapter(),
            proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters());
    activatorProposalAdapter.addContentProposalListener(proposalProvider);
    activatorProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    activatorProposalAdapter.setLabelProvider(new JavaContentProposalLabelProvider());
    activatorProposalAdapter.setAutoActivationDelay(1000);

    // Decorator for the Activator field
    ControlDecoration decorActivator = new ControlDecoration(txtActivator, SWT.LEFT | SWT.CENTER, composite);
    decorActivator.setImage(contentAssistDecoration.getImage());
    decorActivator.setMarginWidth(3);
    if (assistKeyStroke == null) {
        decorActivator.setDescriptionText("Content Assist is available. Start typing to activate");
    } else {
        decorActivator.setDescriptionText(
                MessageFormat.format("Content Assist is available. Press {0} or start typing to activate",
                        assistKeyStroke.format()));
    }
    decorActivator.setShowOnlyOnFocus(true);
    decorActivator.setShowHover(true);

    // Decorator for the Components combo
    ControlDecoration decorComponents = new ControlDecoration(cmbComponents, SWT.LEFT | SWT.CENTER, composite);
    decorComponents.setImage(FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
    decorComponents.setMarginWidth(3);
    decorComponents.setDescriptionText("Use Java annotations to detect Declarative Service Components.");
    decorComponents.setShowOnlyOnFocus(false);
    decorComponents.setShowHover(true);

    // Listeners
    txtVersion.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            lock.ifNotModifying(new Runnable() {
                @Override
                public void run() {
                    addDirtyProperty(Constants.BUNDLE_VERSION);
                }
            });
        }
    });
    cmbComponents.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            lock.ifNotModifying(new Runnable() {
                @Override
                public void run() {
                    ComponentChoice old = componentChoice;

                    int index = cmbComponents.getSelectionIndex();
                    if (index >= 0 && index < ComponentChoice.values().length) {
                        componentChoice = ComponentChoice.values()[cmbComponents.getSelectionIndex()];
                        if (old != componentChoice) {
                            addDirtyProperty(aQute.bnd.osgi.Constants.SERVICE_COMPONENT);
                            addDirtyProperty(aQute.bnd.osgi.Constants.DSANNOTATIONS);
                            if (old == null) {
                                cmbComponents.remove(ComponentChoice.values().length);
                            }
                        }
                    }
                }
            });
        }
    });
    txtActivator.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent ev) {
            lock.ifNotModifying(new Runnable() {
                @Override
                public void run() {
                    addDirtyProperty(Constants.BUNDLE_ACTIVATOR);
                }
            });
        }
    });
    linkActivator.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        public void linkActivated(HyperlinkEvent ev) {
            String activatorClassName = txtActivator.getText();
            if (activatorClassName != null && activatorClassName.length() > 0) {
                try {
                    IJavaProject javaProject = getJavaProject();
                    if (javaProject == null)
                        return;

                    IType activatorType = javaProject.findType(activatorClassName);
                    if (activatorType != null) {
                        JavaUI.openInEditor(activatorType, true, true);
                    }
                } catch (PartInitException e) {
                    ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null,
                            new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0,
                                    MessageFormat.format("Error opening an editor for activator class '{0}'.",
                                            activatorClassName),
                                    e));
                } catch (JavaModelException e) {
                    ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null,
                            new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format(
                                    "Error searching for activator class '{0}'.", activatorClassName), e));
                }
            }
        }
    });
    activatorProposalAdapter.addContentProposalListener(new IContentProposalListener() {
        @Override
        public void proposalAccepted(IContentProposal proposal) {
            if (proposal instanceof JavaContentProposal) {
                String selectedPackageName = ((JavaContentProposal) proposal).getPackageName();
                if (!model.isIncludedPackage(selectedPackageName)) {
                    model.addPrivatePackage(selectedPackageName);
                }
            }
        }
    });

    // Layout
    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 15;

    composite.setLayout(layout);

    GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);

    txtVersion.setLayoutData(gd);
    txtActivator.setLayoutData(gd);
    cmbComponents.setLayoutData(gd);
}

From source file:com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectPage.java

License:Open Source License

private ControlDecoration createFieldDecoration(Control control, String description) {
    ControlDecoration dec = new ControlDecoration(control, SWT.LEFT);
    dec.setMarginWidth(2);
    FieldDecoration errorFieldIndicator = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
    dec.setImage(errorFieldIndicator.getImage());
    dec.setDescriptionText(description);
    control.setToolTipText(description);

    return dec;//w w  w. j av  a2 s.c  o  m
}

From source file:com.android.ide.eclipse.adt.internal.wizards.templates.NewTemplatePage.java

License:Open Source License

private ControlDecoration createFieldDecoration(String id, Control control, String description) {
    ControlDecoration decoration = new ControlDecoration(control, SWT.LEFT);
    decoration.setMarginWidth(2);
    FieldDecoration errorFieldIndicator = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
    decoration.setImage(errorFieldIndicator.getImage());
    decoration.setDescriptionText(description);
    control.setToolTipText(description);
    mDecorations.put(id, decoration);/*from  w w w  .j a v  a  2s  .c om*/

    return decoration;
}

From source file:com.predic8.plugin.membrane_client.ui.ControlUtil.java

License:Apache License

public static void createDeco(Control control, String text, int side) {
    ControlDecoration deco = new ControlDecoration(control, side);
    deco.setDescriptionText(text);//from  ww  w . j a v a2 s.  co  m
    deco.setImage(FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
    deco.setShowOnlyOnFocus(false);
    deco.setMarginWidth(5);
}

From source file:com.siemens.ct.mp3m.ui.editors.id3.databinding.Id3TagPage.java

License:Open Source License

private ControlDecoration createTextDecoration(Text text) {
    ControlDecoration controlDecoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
    controlDecoration.setMarginWidth(0);
    FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
    controlDecoration.setImage(fieldDecoration.getImage());
    return controlDecoration;
}

From source file:com.siteview.mde.internal.ui.util.PDEJavaHelperUI.java

License:Open Source License

/**
 * Disposer returned used to dispose of label provider and remove listeners
 * Callers responsibility to call dispose method when underlying text 
 * widget is being disposed/*from w  w w  . j  a  v  a 2s .  c  o  m*/
 * @param text
 * @param project
 */
public static TypeFieldAssistDisposer addTypeFieldAssistToText(Text text, IProject project, int searchScope) {
    // Decorate the text widget with the light-bulb image denoting content
    // assist
    int bits = SWT.TOP | SWT.LEFT;
    ControlDecoration controlDecoration = new ControlDecoration(text, bits);
    // Configure text widget decoration
    // No margin
    controlDecoration.setMarginWidth(0);
    // Custom hover tip text
    String description = null;
    IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench()
            .getAdapter(IBindingService.class);
    TriggerSequence[] activeBindings = bindingService
            .getActiveBindingsFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    if (activeBindings.length == 0)
        description = MDEUIMessages.PDEJavaHelper_msgContentAssistAvailable;
    else
        description = NLS.bind(MDEUIMessages.PDEJavaHelper_msgContentAssistAvailableWithKeyBinding,
                activeBindings[0].format());

    controlDecoration.setDescriptionText(description);

    // Custom hover properties
    controlDecoration.setShowHover(true);
    controlDecoration.setShowOnlyOnFocus(true);
    // Hover image to use
    FieldDecoration contentProposalImage = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    controlDecoration.setImage(contentProposalImage.getImage());

    // Create the proposal provider
    TypeContentProposalProvider proposalProvider = new TypeContentProposalProvider(project, searchScope);
    // Default text widget adapter for field assist
    TextContentAdapter textContentAdapter = new TextContentAdapter();
    // Set auto activation character to be a '.'
    char[] autoActivationChars = new char[] { TypeContentProposalProvider.F_DOT };
    // Create the adapter
    ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(text, textContentAdapter,
            proposalProvider, IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST, autoActivationChars);
    // Configure the adapter
    // Add label provider
    ILabelProvider labelProvider = new TypeProposalLabelProvider();
    adapter.setLabelProvider(labelProvider);
    // Replace text field contents with accepted proposals
    adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    // Disable default filtering - custom filtering done
    adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
    // Add listeners required to reset state for custom filtering
    TypeContentProposalListener proposalListener = new TypeContentProposalListener();
    adapter.addContentProposalListener((IContentProposalListener) proposalListener);
    adapter.addContentProposalListener((IContentProposalListener2) proposalListener);

    return new TypeFieldAssistDisposer(adapter, proposalListener);
}

From source file:eu.esdihumboldt.hale.ui.function.generic.pages.internal.Field.java

License:Open Source License

/**
 * Create a field/*from ww  w  .  j a  v  a2  s  .co m*/
 * 
 * @param definition the field definition
 * @param ssid the schema space
 * @param parent the parent composite
 * @param candidates the entity candidates
 * @param initialCell the initial cell
 */
public Field(F definition, SchemaSpaceID ssid, final Composite parent, Set<EntityDefinition> candidates,
        Cell initialCell) {
    super();

    this.definition = definition;
    this.ssid = ssid;

    ControlDecoration descriptionDecoration = null;

    // field name
    if (!definition.getDisplayName().isEmpty()) {
        Label name = new Label(parent, SWT.NONE);
        name.setText(definition.getDisplayName());
        name.setLayoutData(GridDataFactory.swtDefaults().create());

        if (definition.getDescription() != null) {
            // add decoration
            descriptionDecoration = new ControlDecoration(name, SWT.RIGHT, parent);
        }
    }

    selectorContainer = new Composite(parent, SWT.NONE);
    selectorContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    // left margin 6 pixels for ControlDecorations to have place within this
    // component
    // so they're not drawn outside of the ScrolledComposite in case it's
    // present.
    selectorContainer.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(6, 0, 0, 0).create());

    selectionChangedListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            int changedIndex = selectors.indexOf(event.getSelectionProvider());
            S changedSelector = selectors.get(changedIndex);

            // add/remove selector
            // check whether all selectors are valid (so must the changed
            // one be)
            if (countValidEntities() == selectors.size()) {
                // maybe last invalid entity was set, check whether to add
                // another one
                if (Field.this.definition.getMaxOccurrence() != selectors.size()) {
                    S newSelector = createEntitySelector(Field.this.ssid, Field.this.definition,
                            selectorContainer);
                    newSelector.getControl().setLayoutData(GridDataFactory.swtDefaults()
                            .align(SWT.FILL, SWT.CENTER).grab(true, false).create());
                    addSelector(newSelector);

                    // layout new selector in scrolled pane
                    selectorContainer.getParent().getParent().layout();
                }
            } else {
                // check whether a field was set to None and remove the
                // field if it isn't the last one and minOccurrence is still
                // met
                if (event.getSelection().isEmpty() && changedIndex != selectors.size() - 1
                        && Field.this.definition.getMinOccurrence() < selectors.size()) {
                    // check whether first selector will be removed and it
                    // had the fields description
                    boolean createDescriptionDecoration = changedIndex == 0
                            && Field.this.definition.getDisplayName().isEmpty()
                            && !Field.this.definition.getDescription().isEmpty();
                    removeSelector(changedSelector);

                    // add new description decoration if necessary
                    if (createDescriptionDecoration) {
                        ControlDecoration descriptionDecoration = new ControlDecoration(
                                selectors.get(0).getControl(), SWT.RIGHT | SWT.TOP, parent);
                        descriptionDecoration.setDescriptionText(Field.this.definition.getDescription());
                        FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
                        descriptionDecoration.setImage(fieldDecoration.getImage());
                        descriptionDecoration.setMarginWidth(2);
                    }

                    // necessary layout call for control decoration to
                    // appear at the correct place
                    selectorContainer.getParent().getParent().layout();

                    // add mandatory decoration to next selector if needed
                    if (changedIndex < Field.this.definition.getMinOccurrence()) {
                        S newMandatorySelector = selectors.get(Field.this.definition.getMinOccurrence() - 1);

                        ControlDecoration mandatory = new ControlDecoration(newMandatorySelector.getControl(),
                                SWT.LEFT | SWT.TOP, parent);
                        FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
                                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
                        mandatory.setImage(CommonSharedImages.getImageRegistry()
                                .get(CommonSharedImages.IMG_DECORATION_MANDATORY));
                        mandatory.setDescriptionText(fieldDecoration.getDescription());
                    }
                }
            }

            // update state
            updateState();
        }
    };

    // determine number of contained fields and the corresponding values
    int initialFieldCount = definition.getMinOccurrence();

    // TODO determine filters from definition

    List<EntityDefinition> fieldValues = new ArrayList<EntityDefinition>();
    if (initialCell != null) {
        // entities from cell
        List<? extends Entity> entities = null;
        switch (ssid) {
        case SOURCE:
            if (initialCell.getSource() != null) {
                entities = initialCell.getSource().get(definition.getName());
            }
            break;
        case TARGET:
            if (initialCell.getTarget() != null) {
                entities = initialCell.getTarget().get(definition.getName());
            }
            break;
        default:
            throw new IllegalStateException("Illegal schema space");
        }
        if (entities != null) {
            for (Entity entity : entities) {
                fieldValues.add(entity.getDefinition()); // FIXME what about
                // the
                // information
                // in the
                // entity?!
            }
        }
    } else if (candidates != null && !candidates.isEmpty()) {
        // populate from candidates
        LinkedHashSet<EntityDefinition> rotatingCandidates = new LinkedHashSet<EntityDefinition>(candidates);

        // try to add candidates for each required entity
        int limit = Math.max(initialFieldCount, candidates.size());
        for (int i = 0; i < limit; i++) {
            boolean found = false;
            for (EntityDefinition candidate : rotatingCandidates) {
                // XXX checked against filters later, because here filters
                // aren't present yet.
                // if (true) {
                fieldValues.add(candidate);
                rotatingCandidates.remove(candidate);
                rotatingCandidates.add(candidate);
                found = true;
                break;
                // }
            }
            if (!found) {
                fieldValues.add(null);
            }
        }
    }

    // adapt initialFieldCount if needed (and possible)
    if (fieldValues.size() >= initialFieldCount) {
        initialFieldCount = fieldValues.size() + 1;
        if (definition.getMaxOccurrence() != F.UNBOUNDED) {
            initialFieldCount = Math.min(initialFieldCount, definition.getMaxOccurrence());
        }
    }

    // add fields
    for (int num = 0; num < initialFieldCount; num++) {
        // create entity selector
        S selector = createEntitySelector(ssid, definition, selectorContainer);
        selector.getControl().setLayoutData(
                GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());

        // do initial selection (before adding it to not trigger selection
        // event)
        EntityDefinition value = (num < fieldValues.size()) ? (fieldValues.get(num)) : (null);
        if (value == null || !selector.accepts(value))
            selector.setSelection(new StructuredSelection());
        else
            selector.setSelection(new StructuredSelection(value));

        // add the selector now
        addSelector(selector);

        // add decorations
        if (num < definition.getMinOccurrence()) {
            ControlDecoration mandatory = new ControlDecoration(selector.getControl(), SWT.LEFT | SWT.TOP,
                    parent);
            FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
                    .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
            mandatory.setImage(
                    CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_DECORATION_MANDATORY));
            mandatory.setDescriptionText(fieldDecoration.getDescription());
        }

        if (descriptionDecoration == null && definition.getDescription() != null)
            descriptionDecoration = new ControlDecoration(selector.getControl(), SWT.RIGHT | SWT.TOP, parent);
    }

    // setup description decoration
    if (descriptionDecoration != null) {
        descriptionDecoration.setDescriptionText(definition.getDescription());
        FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
        descriptionDecoration.setImage(fieldDecoration.getImage());
        descriptionDecoration.setMarginWidth(2);
    }

    updateState();
}

From source file:eu.esdihumboldt.hale.ui.functions.custom.pages.internal.AbstractValueList.java

License:Open Source License

/**
 * Create a parameter list./*from ww  w  .j  ava2  s. co  m*/
 * 
 * @param caption the list caption
 * @param description the list description
 * @param parent the parent composite
 * @param params the existing parameter values
 */
public AbstractValueList(@Nullable String caption, @Nullable String description, final Composite parent,
        List<T> params) {
    super();

    ControlDecoration descriptionDecoration = null;

    // caption and description
    if (caption != null) {
        Label name = new Label(parent, SWT.NONE);
        name.setText(caption);
        name.setLayoutData(GridDataFactory.swtDefaults().create());

        if (description != null) {
            // add decoration
            descriptionDecoration = new ControlDecoration(name, SWT.RIGHT, parent);
        }
    }

    editorContainer = new Composite(parent, SWT.NONE);
    editorContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    // left margin 6 pixels for ControlDecorations to have place within this
    // component
    // so they're not drawn outside of the ScrolledComposite in case it's
    // present.
    editorContainer.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(6, 0, 0, 0).create());

    propertyChangeListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            // TODO check event type?

            int changedIndex = editors.indexOf(event.getSource());
            @SuppressWarnings("unused")
            C changedEditor = editors.get(changedIndex);

            //            // add/remove selector
            //            // check whether all selectors are valid (so must the changed
            //            // one be)
            //            if (countValidEntities() == editors.size()) {
            //               // maybe last invalid entity was set, check whether to add
            //               // another one
            //               if (AbstractParameterList.this.definition.getMaxOccurrence() != editors.size()) {
            //                  S newSelector = createEditor(AbstractParameterList.this.ssid,
            //                        AbstractParameterList.this.definition, editorContainer);
            //                  newSelector.getControl().setLayoutData(
            //                        GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER)
            //                              .grab(true, false).create());
            //                  addSelector(newSelector);
            //
            //                  // layout new selector in scrolled pane
            //                  editorContainer.getParent().getParent().layout();
            //               }
            //            }
            //            else {
            //               // check whether a field was set to None and remove the
            //               // field if it isn't the last one and minOccurrence is still
            //               // met
            //               if (event.getSelection().isEmpty()
            //                     && changedIndex != editors.size() - 1
            //                     && AbstractParameterList.this.definition.getMinOccurrence() < editors
            //                           .size()) {
            //                  // check whether first selector will be removed and it
            //                  // had the fields description
            //                  boolean createDescriptionDecoration = changedIndex == 0
            //                        && AbstractParameterList.this.definition.getDisplayName().isEmpty()
            //                        && !AbstractParameterList.this.definition.getDescription()
            //                              .isEmpty();
            //                  removeSelector(changedEditor);
            //
            //                  // add new description decoration if necessary
            //                  if (createDescriptionDecoration) {
            //                     ControlDecoration descriptionDecoration = new ControlDecoration(editors
            //                           .get(0).getControl(), SWT.RIGHT | SWT.TOP, parent);
            //                     descriptionDecoration
            //                           .setDescriptionText(AbstractParameterList.this.definition
            //                                 .getDescription());
            //                     FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
            //                           .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
            //                     descriptionDecoration.setImage(fieldDecoration.getImage());
            //                     descriptionDecoration.setMarginWidth(2);
            //                  }
            //
            //                  // necessary layout call for control decoration to
            //                  // appear at the correct place
            //                  editorContainer.getParent().getParent().layout();
            //
            //                  // add mandatory decoration to next selector if needed
            //                  if (changedIndex < AbstractParameterList.this.definition.getMinOccurrence()) {
            //                     S newMandatorySelector = editors
            //                           .get(AbstractParameterList.this.definition.getMinOccurrence() - 1);
            //
            //                     ControlDecoration mandatory = new ControlDecoration(
            //                           newMandatorySelector.getControl(), SWT.LEFT | SWT.TOP, parent);
            //                     FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
            //                           .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
            //                     mandatory.setImage(CommonSharedImages.getImageRegistry().get(
            //                           CommonSharedImages.IMG_DECORATION_MANDATORY));
            //                     mandatory.setDescriptionText(fieldDecoration.getDescription());
            //                  }
            //               }
            //            }

            // update state
            updateState();
        }
    };

    // add initial fields
    if (params != null) {
        for (T param : params) {
            // create editor
            EditorWrapper<C> wrapper = createEditorWrapper(editorContainer, param);

            // add the editor now
            addEditor(wrapper);
        }
    }

    createAddControl();

    // setup description decoration
    if (descriptionDecoration != null) {
        descriptionDecoration.setDescriptionText(description);
        FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
        descriptionDecoration.setImage(fieldDecoration.getImage());
        descriptionDecoration.setMarginWidth(2);
    }

    updateLayout();

    updateState();
}

From source file:hydrograph.ui.dataviewer.preferencepage.ViewDataPreferencesDialog.java

License:Apache License

private ControlDecoration addDecorator(Control control, String message) {
    ControlDecoration txtDecorator = new ControlDecoration(control, SWT.LEFT);
    FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
    Image img = fieldDecoration.getImage();
    txtDecorator.setImage(img);//from   w w  w . j  av a 2  s  .  c om
    txtDecorator.setDescriptionText(message);
    txtDecorator.setMarginWidth(3);
    return txtDecorator;
}

From source file:hydrograph.ui.propertywindow.ftp.FTPWidgetUtility.java

License:Apache License

/**
 * Validate text//from   w ww  .  j  av  a  2 s .c om
 * @param text
 */
public void validateWidgetText(Text text, PropertyDialogButtonBar propertyDialogButtonBar, Cursor cursor,
        ControlDecoration controlDecoration) {
    controlDecoration.setMarginWidth(2);
    ModifyAlphaNumbericTextListener alphaNumbericTextListener = new ModifyAlphaNumbericTextListener();
    ListenerHelper helper = new ListenerHelper();
    helper.put(HelperType.CONTROL_DECORATION, controlDecoration);
    text.addListener(SWT.Modify, alphaNumbericTextListener.getListener(propertyDialogButtonBar, helper, text));
}