List of usage examples for org.eclipse.jface.fieldassist FieldDecorationRegistry getFieldDecoration
public FieldDecoration getFieldDecoration(String id)
From source file:com.google.cloud.tools.eclipse.appengine.localserver.ui.ServerPortExtension.java
License:Apache License
@Override public void createControl(UI_POSITION position, Composite parent) { // We add controls only to the BOTTOM position. if (position == UI_POSITION.BOTTOM) { portLabel = new Label(parent, SWT.NONE); portLabel.setVisible(false);/* w w w. j a v a 2 s . c o m*/ portLabel.setText(Messages.NEW_SERVER_DIALOG_PORT); portText = new Text(parent, SWT.SINGLE | SWT.BORDER); portText.setVisible(false); portText.setText(String.valueOf(LocalAppEngineServerBehaviour.DEFAULT_SERVER_PORT)); portText.addVerifyListener(new PortChangeMonitor()); portText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); Image errorImage = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage(); portDecoration = new ControlDecoration(portText, SWT.LEFT | SWT.TOP); portDecoration.setDescriptionText(Messages.NEW_SERVER_DIALOG_INVALID_PORT_VALUE); portDecoration.setImage(errorImage); portDecoration.hide(); } }
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;/*from ww w. jav a 2 s . com*/ 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:net.refractions.udig.catalog.ui.operation.ReshapeDialog.java
License:Open Source License
/** * Show an error in the UI/*from ww w.j av a 2s . c om*/ * @param t */ private void showFeedback(String message, Throwable t) { feedbackDecorator.hide(); feedbackDecorator.hideHover(); if (t == null && message != null) { // warning feedback! FieldDecorationRegistry decorations = FieldDecorationRegistry.getDefault(); FieldDecoration errorDecoration = decorations.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); feedbackDecorator.setImage(errorDecoration.getImage()); feedbackDecorator.setDescriptionText(message); feedbackDecorator.showHoverText(message); feedbackDecorator.show(); } else if (t != null) { // if(! (t instanceof ReshapeException) ){ // CatalogUIPlugin.log("error with reshape", t); //$NON-NLS-1$ // } String errormessage = t.getLocalizedMessage(); if (errormessage == null) { errormessage = Messages.ReshapeOperation_2; } else { // fix up really long CQL messages errormessage = errormessage.replaceAll("\\n\\s+", " "); } if (message == null) { message = MessageFormat.format(Messages.ReshapeOperation_3, errormessage); } FieldDecorationRegistry decorations = FieldDecorationRegistry.getDefault(); FieldDecoration errorDecoration = decorations.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); feedbackDecorator.setImage(errorDecoration.getImage()); feedbackDecorator.setDescriptionText(message); feedbackDecorator.showHoverText(message); feedbackDecorator.show(); } }
From source file:net.refractions.udig.ui.filter.IExpressionViewer.java
License:Open Source License
/** * Provide warning feedback./* w w w. j a va2s . com*/ * <p> * This method will make use of an associated ControlDecoration if available. * </p> */ protected void feedback(String warning) { if (input != null && input.getFeedback() != null) { ControlDecoration feedback = input.getFeedback(); feedback.setDescriptionText(warning); FieldDecorationRegistry decorations = FieldDecorationRegistry.getDefault(); FieldDecoration errorDecoration = decorations.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); feedback.setImage(errorDecoration.getImage()); feedback.show(); } Control control = getControl(); if (control != null && !control.isDisposed()) { control.setToolTipText(warning); } }
From source file:net.refractions.udig.ui.filter.IExpressionViewer.java
License:Open Source License
/** * Provide required feedback.//from ww w . j a va 2 s . c o m * <p> * This method will make use of an associated ControlDecoration if available. * </p> */ protected void feedback(String warning, boolean isRequired) { if (isRequired) { if (input != null && input.getFeedback() != null) { ControlDecoration feedback = input.getFeedback(); feedback.setDescriptionText(warning); FieldDecorationRegistry decorations = FieldDecorationRegistry.getDefault(); if (isRequired) { FieldDecoration requiredDecoration = decorations .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED); feedback.setImage(requiredDecoration.getImage()); } else { FieldDecoration warningDecoration = decorations .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); feedback.setImage(warningDecoration.getImage()); } feedback.show(); } Control control = getControl(); if (control != null && !control.isDisposed()) { control.setToolTipText(warning); } } else { feedback(warning); } }
From source file:net.refractions.udig.ui.filter.IExpressionViewer.java
License:Open Source License
/** * Provide error feedback.//from www. j av a 2 s . c o m * <p> * This method will make use of an associated ControlDecoration if available. * </p> */ protected void feedback(String error, Throwable exception) { if (input != null && input.getFeedback() != null) { ControlDecoration feedback = input.getFeedback(); feedback.setDescriptionText(error); FieldDecorationRegistry decorations = FieldDecorationRegistry.getDefault(); FieldDecoration warningDecoration = decorations.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); feedback.setImage(warningDecoration.getImage()); feedback.show(); } Control control = getControl(); if (control != null && !control.isDisposed()) { control.setToolTipText(error + ":" + exception); } }
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 . jav a 2 s .c om*/ 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.jpt.jpa.ui.internal.jpql.JpaJpqlContentProposalProvider.java
License:Open Source License
private Image contentAssistImage() { FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); return registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage(); }
From source file:org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage.java
License:Open Source License
private void showError(BugzillaStatus bugzillaStatus) { int count = 0; BugzillaUserMatchResponse response = bugzillaStatus.getUserMatchResponse(); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fieldDecoration = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); FieldDecoration fieldDecorationWarning = registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING); StringBuilder fields = new StringBuilder(); StringBuilder detail = new StringBuilder(); count += decorateControlsAndUpdateMessages(response.getAssignedToMsg(), response.getAssignedToProposals(), getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.ASSIGNED_TO.getKey()), fields, detail, fieldDecoration, fieldDecorationWarning); count += decorateControlsAndUpdateMessages(response.getQaContactMsg(), response.getQaContactProposals(), getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.QA_CONTACT.getKey()), fields, detail, fieldDecoration, fieldDecorationWarning); count += decorateControlsAndUpdateMessages(response.getNewCCMsg(), response.getNewCCProposals(), getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.NEWCC.getKey()), fields, detail, fieldDecoration, fieldDecorationWarning); updateTaskEditorPageMessageWithError(bugzillaStatus, detail.toString(), count == 1, fields.toString()); }
From source file:org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage.java
License:Open Source License
@Override public boolean isPageComplete() { setMessage(""); //$NON-NLS-1$ if (errorDecorations.size() > 0) { for (ControlDecoration decoration : errorDecorations) { decoration.hide();/* w ww. j a v a2 s.c o m*/ decoration.dispose(); } errorDecorations.clear(); } if (daysText != null) { String days = daysText.getText(); if (days.length() > 0) { try { if (Integer.parseInt(days) < 0) { throw new NumberFormatException(); } } catch (NumberFormatException ex) { if (getContainer() != null) { setMessage(NLS.bind(Messages.BugzillaSearchPage_Number_of_days_must_be_a_positive_integer, days), IMessageProvider.ERROR); } else { ErrorDialog.openError(getShell(), Messages.BugzillaSearchPage_ValidationTitle, Messages.BugzillaSearchPage_Number_of_days_is_invalid, new Status(IStatus.ERROR, BugzillaUiPlugin.ID_PLUGIN, NLS.bind( Messages.BugzillaSearchPage_days_must_be_an_positve_integer_value_but_is, days))); } return false; } } } if (emailPattern != null) { String email = emailPattern.getText(); if (email.length() > 0) { boolean selectionMade = false; for (Button button : emailButtons) { if (button.getSelection()) { selectionMade = true; break; } } if (!selectionMade) { FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fieldDecoration = registry .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); final ControlDecoration decoration = new ControlDecoration(emailPattern, SWT.LEFT | SWT.DOWN); decoration.setImage(fieldDecoration.getImage()); decoration.setDescriptionText(NLS.bind(Messages.BugzillaSearchPage_ValidationMessage, new String[] { Messages.BugzillaSearchPage_Email.replace('&', ' '), Messages.BugzillaSearchPage_owner, Messages.BugzillaSearchPage_reporter, Messages.BugzillaSearchPage_cc, Messages.BugzillaSearchPage_commenter, Messages.BugzillaSearchPage_qacontact })); errorDecorations.add(decoration); if (getContainer() != null) { setMessage(NLS.bind(Messages.BugzillaSearchPage_ValidationMessage, new String[] { Messages.BugzillaSearchPage_Email.replace('&', ' '), Messages.BugzillaSearchPage_owner, Messages.BugzillaSearchPage_reporter, Messages.BugzillaSearchPage_cc, Messages.BugzillaSearchPage_commenter, Messages.BugzillaSearchPage_qacontact }), IMessageProvider.ERROR); } return false; } } } if (emailPattern2 != null) { String email2 = emailPattern2.getText(); if (email2.length() > 0) { boolean selectionMade = false; for (Button button : emailButtons2) { if (button.getSelection()) { selectionMade = true; break; } } if (!selectionMade) { FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fieldDecoration = registry .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); final ControlDecoration decoration = new ControlDecoration(emailPattern, SWT.LEFT | SWT.DOWN); decoration.setImage(fieldDecoration.getImage()); decoration.setDescriptionText(NLS.bind(Messages.BugzillaSearchPage_ValidationMessage, new String[] { Messages.BugzillaSearchPage_Email_2.replace('&', ' '), Messages.BugzillaSearchPage_owner, Messages.BugzillaSearchPage_reporter, Messages.BugzillaSearchPage_cc, Messages.BugzillaSearchPage_commenter, Messages.BugzillaSearchPage_qacontact })); errorDecorations.add(decoration); if (getContainer() != null) { setMessage(NLS.bind(Messages.BugzillaSearchPage_ValidationMessage, new String[] { Messages.BugzillaSearchPage_Email_2.replace('&', ' '), Messages.BugzillaSearchPage_owner, Messages.BugzillaSearchPage_reporter, Messages.BugzillaSearchPage_cc, Messages.BugzillaSearchPage_commenter, Messages.BugzillaSearchPage_qacontact }), IMessageProvider.ERROR); } return false; } } } if (getWizard() == null) { return canQuery(); } else { if (super.isPageComplete()) { if (canQuery()) { return true; } } return false; } }