List of usage examples for org.eclipse.jface.fieldassist FieldDecoration setDescription
public void setDescription(String description)
From source file:ch.unibe.iam.scg.archie.ui.Decorators.java
License:Open Source License
/** * @param type/*from w w w . ja v a 2 s . com*/ * @param description * @return FieldDecoration */ public static FieldDecoration getFieldDecoration(int type, String description) { switch (type) { case VALID: FieldDecoration validDecoration = registry.getFieldDecoration(DEC_VALID); validDecoration.setDescription(description); return validDecoration; case WARNING: FieldDecoration warningDecoration = registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); warningDecoration.setDescription(description); return warningDecoration; case ERROR: FieldDecoration errorDecoration = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); errorDecoration.setDescription(description); return errorDecoration; case QUICKFIX: FieldDecoration quickfixDecoration = registry .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR_QUICKFIX); quickfixDecoration.setDescription(description); return quickfixDecoration; default: return null; } }
From source file:com.nokia.tools.s60.views.SearchViewPage.java
License:Open Source License
public void createCompositeArea(Composite parent) { Composite dialogArea = parent; GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginHeight = 0;/* w ww . j av a 2s.co m*/ gridLayout.marginWidth = 0; dialogArea.setLayout(gridLayout); fTypeMethodsSplitter = new SashForm(dialogArea, SWT.VERTICAL); fTypeMethodsSplitter.setLayoutData(new GridData(GridData.FILL_BOTH)); fTypeMethodsSplitter.setLayout(new GridLayout()); fTypeMethodsSplitter.setVisible(true); fTypeMethodsSplitter.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { SashForm splitter = (SashForm) e.widget; if (splitter.getOrientation() == SWT.HORIZONTAL) { int widthAll = fTypeMethodsSplitter.getSize().x; int patternMargin = ((GridLayout) c1.getLayout()).marginHeight; int spacing = ((GridLayout) c1.getLayout()).horizontalSpacing; if (widthAll > 0) { if (((patternHorizontalLayoutWidth + 4 * patternMargin + 2 * spacing)) <= widthAll) { horizontalSearchInput = (int) ((patternHorizontalLayoutWidth + 4 * patternMargin + 2 * spacing) * 100 / widthAll); } else { horizontalSearchInput = 100; } } else { horizontalSearchInput = 10; } fTypeMethodsSplitter .setWeights(new int[] { horizontalSearchInput, 100 - horizontalSearchInput }); } else if (splitter.getOrientation() == SWT.VERTICAL) { int heightAll = fTypeMethodsSplitter.getSize().y; int verticalSearchInputRatio = 0; if (heightAll > 0) { if (verticalSearchInput <= heightAll) { verticalSearchInputRatio = (verticalSearchInput * 100) / heightAll; } else { verticalSearchInputRatio = 100; } } else { verticalSearchInputRatio = 20; } fTypeMethodsSplitter .setWeights(new int[] { verticalSearchInputRatio, 100 - verticalSearchInputRatio }); } } }); c1 = new Composite(fTypeMethodsSplitter, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 3; layout.verticalSpacing = 0; c1.setLayout(layout); c1.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite c2 = new Composite(fTypeMethodsSplitter, SWT.NONE); layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; c2.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; c2.setLayoutData(data); tableViewer = new TableViewer(c2, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL); items = tableViewer.getTable(); data = new GridData(GridData.FILL_BOTH); data.grabExcessHorizontalSpace = true; data.grabExcessVerticalSpace = true; data.horizontalAlignment = SWT.BEGINNING; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; items.setLayoutData(data); // finds all component names in a system initSearchInput(); decoratedPattern = new DecoratedField(c1, SWT.BORDER, new TextControlCreator()); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration standardDecoration = registry .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); standardDecoration.setDescription("Press Ctrl+Space to see example search inputs and history"); decoratedPattern.addFieldDecoration(standardDecoration, SWT.TOP | SWT.LEFT, true); initSuggestionsAndHistory(); pattern = (Text) decoratedPattern.getControl(); pattern.setToolTipText("* = any string"); pattern.addFocusListener(new FocusAdapter() { // this is to ensure that after opening when user selects pattern // input can view all items public void focusGained(FocusEvent event) { initSearchInput(); tableViewer.setInput(filteredInput); if (tableViewer.getSelection() == null && tableViewer.getElementAt(0) != null) { tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(0))); } } }); installContentProposalAdapter(pattern, new TextContentAdapter()); pattern.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { updateInput(); } }); pattern.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if (event.keyCode == SWT.ARROW_DOWN) { tableViewer.scrollDown(0, 1); tableViewer.getTable().setFocus(); } else if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) { addToSuggestionsAndHistory(pattern.getText()); updateInput(); } } }); FormData formData = (FormData) pattern.getLayoutData(); formData.width = patternVerticalLayoutWidth; searchButton = new Button(c1, SWT.PUSH); searchButton.setText("&Go to Element"); searchButton.setLayoutData(new GridData()); searchButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { initSearchInput(); IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); ElementTableItem selectedElement = (ElementTableItem) selection.getFirstElement(); if (null != selectedElement) selectAndFocusElement(selectedElement); } }); int heightAll = fTypeMethodsSplitter.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; int heightSearchButton = searchButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; int buttonMargin = ((GridLayout) c1.getLayout()).marginHeight; int spacing = ((GridLayout) c1.getLayout()).verticalSpacing; verticalSearchInput = (int) (heightSearchButton + 2 * buttonMargin + spacing); int verticalSearchInputRatio = (verticalSearchInput * 100) / heightAll; fTypeMethodsSplitter.setWeights(new int[] { verticalSearchInputRatio, 100 - verticalSearchInputRatio }); tableViewer.setSorter(new SearchTableSorter(SearchTableSorter.COLUMN_0)); items.setLinesVisible(true); items.setHeaderVisible(true); // 1st column TableColumn column = new TableColumn(items, SWT.CENTER, 0); column.setText("Name"); column.setWidth(200); column.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSorter(SearchTableSorter.COLUMN_0, 0); } }); // 2nd column column = new TableColumn(items, SWT.LEFT, 1); column.setText("ID"); column.setWidth(180); column.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSorter(SearchTableSorter.COLUMN_1, 1); } }); // 3rd column column = new TableColumn(items, SWT.LEFT, 2); column.setText("Info"); column.setWidth(100); column.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSorter(SearchTableSorter.COLUMN_2, 2); } }); // 3rd column column = new TableColumn(items, SWT.LEFT, 3); column.setText("Resource path"); column.setWidth(200); column.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSorter(SearchTableSorter.COLUMN_3, 3); } }); // 4th column column = new TableColumn(items, SWT.LEFT, 4); column.setText("Special editing"); column.setWidth(100); column.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSorter(SearchTableSorter.COLUMN_4, 4); } }); items.setSortColumn(items.getColumn(0)); items.setSortDirection(SWT.UP); // 5th column /* * column = new TableColumn(items, SWT.LEFT, ); * column.setText("Skinned"); column.setWidth(60); * column.addSelectionListener(new SelectionAdapter() { public void * widgetSelected(SelectionEvent e) { tableViewer.setSorter(new * SearchTableSorter( SearchTableSorter.SKINNED)); } }); */ tableViewer.setLabelProvider(new SearchDataLabelProvider()); tableViewer.setContentProvider(new ArrayContentProvider() { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { super.inputChanged(viewer, oldInput, newInput); } @Override public Object[] getElements(Object inputElement) { if (inputElement instanceof IDGroupContainer) { IDGroupContainer gc = (IDGroupContainer) inputElement; ArrayList<ElementTableItem> allAllowedItems = gc.getAllAllowedItems(); return allAllowedItems.toArray(); } return super.getElements(inputElement); } @Override public void dispose() { super.dispose(); } }); tableViewer.setInput(container); tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); if (previousSelection == null || selection.getFirstElement() != previousSelection.getFirstElement()) { previousSelection = selection; } // TableViewer viewer = (TableViewer)source; } }); if (tableViewer.getElementAt(0) != null) { tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(0))); } tableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); ElementTableItem selectedElement = (ElementTableItem) selection.getFirstElement(); if (null != selectedElement) selectAndFocusElement(selectedElement); } }); }
From source file:org.eclipse.birt.chart.ui.swt.fieldassist.FieldAssistHelper.java
License:Open Source License
private FieldDecoration getCueDecoration() { // We use our own decoration which is based on the JFace version. FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration dec = registry.getFieldDecoration(DEC_CONTENTASSIST_ID); if (dec == null) { // Get the standard one. We use its image and our own customized // text.//from w w w. ja v a2s .c o m FieldDecoration standardDecoration = registry .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); registry.registerFieldDecoration(DEC_CONTENTASSIST_ID, Messages.getFormattedString("ssDecoratorContentAssist", //$NON-NLS-1$ getTriggerKeyText()), standardDecoration.getImage()); dec = registry.getFieldDecoration(DEC_CONTENTASSIST_ID); } else { dec.setDescription(Messages.getFormattedString("ssDecoratorContentAssist", //$NON-NLS-1$ getTriggerKeyText())); } return dec; }
From source file:org.eclipse.ui.fieldassist.ContentAssistCommandAdapter.java
License:Open Source License
private FieldDecoration getContentAssistFieldDecoration() { FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); // Look for a decoration installed for this particular command id. String decId = CONTENT_ASSIST_DECORATION_ID + getCommandId(); FieldDecoration dec = registry.getFieldDecoration(decId); // If there is not one, base ours on the standard JFace one. if (dec == null) { FieldDecoration originalDec = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); registry.registerFieldDecoration(decId, null, originalDec.getImage()); dec = registry.getFieldDecoration(decId); }//w ww .j av a 2 s.c om // Always update the decoration text since the key binding may // have changed since it was last retrieved. IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench() .getService(IBindingService.class); dec.setDescription(NLS.bind(WorkbenchMessages.ContentAssist_Cue_Description_Key, bindingService.getBestActiveBindingFormattedFor(getCommandId()))); // Now return the field decoration return dec; }
From source file:org.eclipse.ui.fieldassist.ContentAssistField.java
License:Open Source License
private FieldDecoration getFieldDecoration() { FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); // Look for a decoration installed for this particular command id. String decId = CONTENT_ASSIST_DECORATION_ID + adapter.getCommandId(); FieldDecoration dec = registry.getFieldDecoration(decId); // If there is not one, base ours on the standard JFace one. if (dec == null) { FieldDecoration originalDec = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); registry.registerFieldDecoration(decId, null, originalDec.getImage()); dec = registry.getFieldDecoration(decId); }//from w w w . j a v a 2 s .c om // Always update the decoration text since the key binding may // have changed since it was last retrieved. IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench() .getService(IBindingService.class); dec.setDescription(NLS.bind(WorkbenchMessages.ContentAssist_Cue_Description_Key, bindingService.getBestActiveBindingFormattedFor(adapter.getCommandId()))); // Now return the field decoration return dec; }
From source file:org.elbe.relations.internal.controls.SearchView.java
License:Open Source License
private int createInputControl(final Composite inSearch) { input = new Combo(inSearch, SWT.BORDER | SWT.SINGLE | SWT.DROP_DOWN | SWT.SEARCH); final ControlDecoration lDecoration = new ControlDecoration(input, SWT.LEFT | SWT.TOP); final FieldDecoration lProposeDeco = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); lProposeDeco.setDescription(QUERY_HINT); lDecoration.setImage(lProposeDeco.getImage()); lDecoration.setDescriptionText(lProposeDeco.getDescription()); final GridData lLayout = new GridData(GridData.FILL_HORIZONTAL); final int outIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); lLayout.horizontalIndent = outIndent; input.setLayoutData(lLayout);//from w ww . jav a 2s . c om input.addModifyListener(new ModifyListener() { @Override public void modifyText(final ModifyEvent inEvent) { if (!initialized) { return; } final int lLength = ((Combo) inEvent.widget).getText().length(); if (lLength == 0) { button.setEnabled(false); } else { button.setEnabled(true); } } }); input.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent inEvent) { final String lSelection = (String) selectionService.getSelection(RelationsConstants.PART_INSPECTOR); if (lSelection != null && !lSelection.isEmpty()) { input.setText(lSelection); } else { input.setText(""); //$NON-NLS-1$ } } @Override public void focusLost(final FocusEvent inEvent) { } }); input.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(final SelectionEvent inEvent) { searchFor(input.getText()); } @Override public void widgetDefaultSelected(final SelectionEvent inEvent) { searchFor(input.getText()); } }); return outIndent; }
From source file:org.jboss.tools.runtime.ui.download.DownloadRuntimeDialog.java
License:Open Source License
protected ControlDecoration addDecoration(Control control, String id, String description) { final ControlDecoration decPath = new ControlDecoration(control, SWT.TOP | SWT.LEFT); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fd = registry.getFieldDecoration(id); decPath.setImage(fd.getImage());/*from w w w .j a va 2s . co m*/ fd.setDescription(description); decPath.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(id).getImage()); decPath.setShowOnlyOnFocus(false); decPath.setShowHover(true); decPath.setDescriptionText(description); return decPath; }
From source file:org.jboss.tools.runtime.ui.internal.wizard.FinalizeRuntimeDownloadFragment.java
License:Open Source License
protected ControlDecoration addDecoration(Control control, String id, String description) { final ControlDecoration decPath = new ControlDecoration(control, SWT.TOP | SWT.LEFT); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fd = registry.getFieldDecoration(id); decPath.setImage(fd.getImage());/*from w w w.j av a 2 s.c o m*/ fd.setDescription(description); decPath.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(id).getImage()); decPath.setShowOnlyOnFocus(false); decPath.setShowHover(true); decPath.setDescriptionText(description); decPath.hide(); return decPath; }
From source file:org.talend.camel.designer.generator.RouteResourceController.java
License:Open Source License
/** * /*from w w w.j a va2 s . c o m*/ * @param subComposite * @param param * @param lastControl * @param numInRow * @param nbInRow * @param top * @return */ private Control addVersionCombo(Composite subComposite, IElementParameter param, Control lastControl, int numInRow, int nbInRow, int top) { DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl); if (param.isRequired()) { FieldDecoration decoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED); dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false); } if (param.isRepositoryValueUsed()) { FieldDecoration decoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setDescription(""); //$NON-NLS-1$ dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false); } Control cLayout = dField.getLayoutControl(); CCombo combo = (CCombo) dField.getControl(); FormData data; combo.setItems(getListToDisplay(param)); combo.setEditable(false); cLayout.setBackground(subComposite.getBackground()); combo.setEnabled(!param.isReadOnly()); combo.addSelectionListener(listenerSelection); combo.setData(PARAMETER_NAME, param.getName()); if (elem instanceof Node) { combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName()); } CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName()); data = new FormData(); if (lastControl != null) { data.left = new FormAttachment(lastControl, 0); } else { data.left = new FormAttachment(((numInRow - 1) * MAX_PERCENT) / nbInRow, 0); } data.top = new FormAttachment(0, top); labelLabel.setLayoutData(data); if (numInRow != 1) { labelLabel.setAlignment(SWT.RIGHT); } // ********************* data = new FormData(); int currentLabelWidth = STANDARD_LABEL_WIDTH; GC gc = new GC(labelLabel); Point labelSize = gc.stringExtent(param.getDisplayName()); gc.dispose(); if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) { currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE; } if (numInRow == 1) { if (lastControl != null) { data.left = new FormAttachment(lastControl, currentLabelWidth); } else { data.left = new FormAttachment(0, currentLabelWidth); } } else { data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT); } data.top = new FormAttachment(0, top); cLayout.setLayoutData(data); // ********************** hashCurControls.put(param.getName(), combo); return cLayout; }
From source file:org.talend.component.ui.wizard.controller.ComponentRefController.java
License:Open Source License
@Override public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) { DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl); if (param.isRequired()) { FieldDecoration decoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED); dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false); }/* w ww . j av a2s .com*/ if (param.isRepositoryValueUsed()) { FieldDecoration decoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setDescription(Messages.getString("ComboController.valueFromRepository")); //$NON-NLS-1$ dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false); } Control cLayout = dField.getLayoutControl(); CCombo combo = (CCombo) dField.getControl(); FormData data; combo.setEditable(false); cLayout.setBackground(subComposite.getBackground()); combo.setEnabled(!param.isReadOnly()); combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { Command cmd = createCommand(event); executeCommand(cmd); } }); combo.setData(PARAMETER_NAME, param.getName()); int nbLines = param.getNbLines(); if (nbLines > 5) { combo.setVisibleItemCount(nbLines); } if (elem instanceof Node) { combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName()); } CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName()); data = new FormData(); if (lastControl != null) { data.left = new FormAttachment(lastControl, 0); } else { data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0); } data.top = new FormAttachment(0, top); labelLabel.setLayoutData(data); if (numInRow != 1) { labelLabel.setAlignment(SWT.RIGHT); } // ********************* data = new FormData(); int currentLabelWidth = STANDARD_LABEL_WIDTH; GC gc = new GC(labelLabel); Point labelSize = gc.stringExtent(param.getDisplayName()); gc.dispose(); if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) { currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE; } if (numInRow == 1) { if (lastControl != null) { data.left = new FormAttachment(lastControl, currentLabelWidth); } else { data.left = new FormAttachment(0, currentLabelWidth); } } else { data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT); } data.top = new FormAttachment(0, top); cLayout.setLayoutData(data); // ********************** hashCurControls.put(param.getName(), combo); Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT); dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE); return cLayout; }