List of usage examples for org.eclipse.jface.fieldassist FieldDecoration getDescription
public String getDescription()
From source file:com.aptana.ruby.debug.ui.breakpoints.RubyBreakpointConditionEditor.java
License:Open Source License
/** * Creates the condition editor widgets and returns the top level control. * /*from w w w . j ava 2 s.c o m*/ * @param parent * composite to embed the editor controls in * @return top level control */ public Control createControl(Composite parent) { Composite controls = SWTFactory.createComposite(parent, parent.getFont(), 2, 1, GridData.FILL_HORIZONTAL, 0, 0); fConditional = new Button(controls, SWT.CHECK); fConditional.setText(processMnemonics(PropertyPageMessages.RubyBreakpointConditionEditor_0)); fConditional.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); fConditional.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean checked = fConditional.getSelection(); setEnabled(checked, true); setDirty(PROP_CONDITION_ENABLED); } }); fViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.LEFT_TO_RIGHT); fViewer.setEditable(false); ControlDecoration decoration = new ControlDecoration(fViewer.getControl(), SWT.TOP | SWT.LEFT); decoration.setShowOnlyOnFocus(true); FieldDecoration dec = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(dec.getImage()); decoration.setDescriptionText(dec.getDescription()); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); // set height/width hints based on font GC gc = new GC(fViewer.getTextWidget()); gc.setFont(fViewer.getTextWidget().getFont()); FontMetrics fontMetrics = gc.getFontMetrics(); // gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 10); gd.widthHint = Dialog.convertWidthInCharsToPixels(fontMetrics, 40); gc.dispose(); fViewer.getControl().setLayoutData(gd); parent.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { dispose(); } }); return parent; }
From source file:com.bdaum.zoom.ui.internal.views.DataEntryView.java
License:Open Source License
public void updateField(QueryField qfield, FieldEntry fieldEntry) { Object widget = widgetMap.get(qfield); Control control = (widget instanceof ComboViewer ? ((ComboViewer) widget).getControl() : (Control) widget); if (!fieldEntry.applicable || (!fieldEntry.editable && fieldEntry != FieldEntry.PENDING)) { setControlVisible(control, false); return;//from ww w .j a va 2s . com } setControlVisible(control, true); updateSet.add(qfield); try { if (fieldEntry == FieldEntry.PENDING) { setControlEnabled(control, false); ControlDecoration fieldDec = getFieldDecoration(control); FieldDecoration deco = FieldDecorationRegistry.getDefault().getFieldDecoration(DEC_PENDING); fieldDec.setImage(deco.getImage()); fieldDec.setDescriptionText(deco.getDescription()); fieldDec.show(); } else { Object value = fieldEntry.value; if (value == QueryField.VALUE_MIXED) { setControlEnabled(control, qfield.getCard() == 1 || qfield.getCard() == QueryField.CARD_MODIFIABLEBAG); ControlDecoration fieldDec = getFieldDecoration(control); FieldDecoration deco = FieldDecorationRegistry.getDefault().getFieldDecoration(DEC_MIXED); fieldDec.setImage(deco.getImage()); fieldDec.setDescriptionText(deco.getDescription()); fieldDec.show(); if (control instanceof Combo) ((Combo) control).setText(QueryField.VALUE_MIXED); else if (control instanceof Text) ((Text) control).setText(QueryField.VALUE_MIXED); else if (control instanceof CheckedText) ((CheckedText) control).setText(QueryField.VALUE_MIXED); else if (control instanceof DateComponent) ((DateComponent) control).setSelection(QueryField.VALUE_MIXED); else if (control instanceof SpinnerComponent) ((SpinnerComponent) control).setSelection(QueryField.VALUE_MIXED); } else { setControlEnabled(control, value != QueryField.VALUE_NOTHING); String text = qfield.value2text(value, CLICK_TO_VIEW_DETAILS); if (text != null && value != QueryField.VALUE_MIXED) { if (!text.isEmpty() && value != QueryField.VALUE_NOTHING && text != Format.MISSINGENTRYSTRING) { if (widget instanceof ComboViewer) ((ComboViewer) widget).setSelection(new StructuredSelection(value)); else if (control instanceof Text) ((Text) control).setText(text); else if (control instanceof CheckedText) ((CheckedText) control).setText(text); else if (control instanceof DateComponent) ((DateComponent) control).setSelection(value); else if (control instanceof SpinnerComponent) { if (qfield.getType() == QueryField.T_CURRENCY) ((SpinnerComponent) control).setSelection( (int) ((Double) value * Math.pow(10, Format.getCurrencyDigits()) + 0.5)); else ((SpinnerComponent) control).setSelection(value); } } else { if (widget instanceof ComboViewer) ((ComboViewer) widget).setSelection(StructuredSelection.EMPTY); else if (control instanceof Text) ((Text) control).setText(text); else if (control instanceof CheckedText) ((CheckedText) control).setText(text); else if (control instanceof DateComponent) ((DateComponent) control).setSelection(text); else if (control instanceof SpinnerComponent) ((SpinnerComponent) control).setSelection(text); } } hideFieldDeco(control); } } } finally { updateSet.remove(qfield); } }
From source file:com.dubture.composer.ui.editor.composer.GeneralSection.java
private void createTypeEntry(Composite client, FormToolkit toolkit) { typeEntry = new FormEntry(client, toolkit, "Type", null, false); typeEntry.setValue(composerPackage.getType(), true); ControlDecoration decoration = new ControlDecoration(typeEntry.getText(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(indicator.getDescription() + "(Ctrl+Space)"); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(typeEntry.getText(), new TextContentAdapter(), ComposerConstants.TYPES); typeEntry.addFormEntryListener(new FormEntryAdapter() { public void textValueChanged(FormEntry entry) { composerPackage.set("type", entry.getValue()); }//from w ww . j a v a 2s .c o m }); composerPackage.addPropertyChangeListener("type", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { typeEntry.setValue(composerPackage.getType(), true); } }); }
From source file:com.dubture.composer.ui.editor.composer.GeneralSection.java
private void createLicenseEntry(Composite client, FormToolkit toolkit) { licenseEntry = new FormEntry(client, toolkit, "License", null, false); ControlDecoration decoration = new ControlDecoration(licenseEntry.getText(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(indicator.getDescription() + "(Ctrl+Space)"); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(licenseEntry.getText(), new LicenseContentAdapter(), ComposerConstants.LICENSES); final License2StringConverter converter = new License2StringConverter(); licenseEntry.setValue(converter.convert(composerPackage.getLicense()), true); licenseEntry.addFormEntryListener(new FormEntryAdapter() { String2LicenseConverter converter; public void focusGained(FormEntry entry) { converter = new String2LicenseConverter(composerPackage); }/*ww w .j av a2 s . c om*/ public void focusLost(FormEntry entry) { converter.convert(entry.getValue()); } }); composerPackage.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().startsWith("license")) { licenseEntry.setValue(converter.convert(composerPackage.getLicense()), true); } } }); }
From source file:com.dubture.composer.ui.wizard.project.BasicSettingsGroup.java
public void createControl(Composite composite, Shell shell) { this.shell = shell; nameComposite = new Composite(composite, SWT.NONE); nameComposite.setFont(composite.getFont()); nameComposite.setLayout(new GridLayout(2, false)); nameComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // text field for project vendor name vendorField = new StringDialogField(); vendorField.setLabelText("Vendor name"); vendorField.setDialogFieldListener(this); vendorField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(vendorField.getTextControl(null)); // text field for project type typeField = new StringDialogField(); typeField.setLabelText("Type"); typeField.setDialogFieldListener(this); typeField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(typeField.getTextControl(null)); ControlDecoration decoration = new ControlDecoration(typeField.getTextControl(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(indicator.getDescription() + "(Ctrl+Space)"); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(typeField.getTextControl(), new TextContentAdapter(), ComposerConstants.TYPES); // text field for project description descriptionField = new StringDialogField(); descriptionField.setLabelText("Description"); descriptionField.setDialogFieldListener(this); descriptionField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(descriptionField.getTextControl(null)); // text field for project description keywordField = new StringDialogField(); keywordField.setLabelText("Keywords"); keywordField.setDialogFieldListener(this); keywordField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(keywordField.getTextControl(null)); // text field for project description licenseField = new StringDialogField(); licenseField.setLabelText("License"); licenseField.setDialogFieldListener(this); licenseField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(licenseField.getTextControl(null)); ControlDecoration licenseDecoration = new ControlDecoration(licenseField.getTextControl(), SWT.TOP | SWT.LEFT);//from w w w . ja va 2s .co m licenseDecoration.setImage(indicator.getImage()); licenseDecoration.setDescriptionText(indicator.getDescription() + "(Ctrl+Space)"); licenseDecoration.setShowOnlyOnFocus(true); new AutoCompleteField(licenseField.getTextControl(), new LicenseContentAdapter(), ComposerConstants.LICENSES); }
From source file:com.nokia.tools.variant.common.ui.wizards.dialogfields.DialogField.java
License:Open Source License
public void showDecoration(int decor) { ControlDecoration controlDec = getControlDecoration(); if (controlDec == null) { return;/*from w w w . j a v a 2s . c om*/ } FieldDecoration fieldDecoration = null; switch (decor) { case DEC_ERROR: fieldDecoration = getErrorDecoration(); break; case DEC_WARNING: fieldDecoration = getWarningDecoration(); break; case DEC_REQUIRED: fieldDecoration = getRequiredFieldDecoration(); break; case DEC_NONE: default: fieldDecoration = null; break; } if (fieldDecoration == null) { controlDec.hide(); } else { controlDec.setImage(fieldDecoration.getImage()); controlDec.setDescriptionText(fieldDecoration.getDescription()); controlDec.show(); } }
From source file:eu.esdihumboldt.hale.ui.function.generic.pages.internal.Field.java
License:Open Source License
/** * Create a field/*from w w w . ja va 2 s. c om*/ * * @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:it.rcpvision.emf.components.binding.FormControlFactory.java
License:Open Source License
protected void addContentProposalAdapter(Text t, List<?> proposals) { if (proposals != null && !proposals.isEmpty()) { // TODO prevent adding null to a list, for example a Collection Type while (proposals.remove(null)) { // clear null entries }/* ww w .j a v a 2 s. c o m*/ ControlDecoration field = new ControlDecoration(t, SWT.BORDER); FieldDecoration requiredFieldIndicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); field.setImage(requiredFieldIndicator.getImage()); field.setDescriptionText(requiredFieldIndicator.getDescription()); KeyStroke keyStroke = null; String string = "Ctrl+Space"; try { keyStroke = KeyStroke.getInstance(string); } catch (ParseException e) { EmfComponentsCommonActivator.getDefault().getLog().log(new Status(IStatus.ERROR, EmfComponentsCommonActivator.PLUGIN_ID, "Error while parse: " + string, e)); } new ContentProposalAdapter(t, new TextContentAdapter(), new SimpleContentProposalProvider(proposals.toArray(new String[] {})), keyStroke, null); } }
From source file:it.rcpvision.emf.components.old.ui.binding._EmfSwtBindingFactory.java
License:Open Source License
protected void addContentProposalAdapter(Text t, List<?> proposals) { if (proposals != null && !proposals.isEmpty()) { // TODO prevent adding null to a list, for example a Collection Type while (proposals.remove(null)) { // clear null entries }// www .j a v a2 s .c om ControlDecoration field = new ControlDecoration(t, SWT.BORDER); FieldDecoration requiredFieldIndicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); field.setImage(requiredFieldIndicator.getImage()); field.setDescriptionText(requiredFieldIndicator.getDescription()); KeyStroke keyStroke = null; String string = "Ctrl+Space"; try { keyStroke = KeyStroke.getInstance(string); } catch (ParseException e) { EmfFormEditorActivator.getDefault().getLog().log(new Status(IStatus.ERROR, EmfFormEditorActivator.PLUGIN_ID, "Error while parse: " + string, e)); } new ContentProposalAdapter(t, new TextContentAdapter(), new SimpleContentProposalProvider(proposals.toArray(new String[] {})), keyStroke, null); } }
From source file:net.sf.eclipsensis.wizard.util.NSISWizardDialogUtil.java
License:Open Source License
/** * @param c/* w w w .j a v a2s . c om*/ * @param enabled */ private static void updateDecoration(Control c, boolean enabled) { ControlDecoration decoration = (ControlDecoration) c.getData(CONTROL_DECORATION); if (decoration != null) { FieldDecoration d = (enabled ? REQ_FIELD_DECORATION : DISABLED_REQ_FIELD_DECORATION); decoration.setImage(d.getImage()); decoration.setDescriptionText(d.getDescription()); } }