List of usage examples for org.eclipse.jface.fieldassist ControlDecoration hideHover
public void hideHover()
From source file:openbiomind.gui.wizards.AbstractTaskWizardPage.java
License:Open Source License
/** * Creates the new optional file text button composite. * // w w w . j a v a 2 s .co m * @param parent the parent * @param numOfColumns the number of columns * * @return the text button composite */ protected TextButtonComposite createNewOptionalFileTextButtonComposite(final Composite parent, final int numOfColumns) { final TextButtonComposite textButtonComposite = new TextButtonComposite(parent) { @Override protected String buttonSelected() { return getFileDialog().open(); } }; textButtonComposite.setValid(true); textButtonComposite.setToolTipText(Messages.Tip_LeaveBlankOrSpecifyFile); // apply layout GUI.GRID_DATA_FILL_H_GRAB_H.copy().span(numOfColumns, 1).applyTo(textButtonComposite); // create decorations final ControlDecoration infoDecoration = WidgetHelper.createNewInformationDecoration( textButtonComposite.getTextField(), Messages.Tip_LeaveBlankOrSpecifyFile); infoDecoration.setShowOnlyOnFocus(true); final ControlDecoration errorDecoration = WidgetHelper.createNewErrorDecoration(textButtonComposite, Messages.Err_FileNotExist); errorDecoration.hide(); // apply listeners textButtonComposite.addModifyListenerOnTextField(new ModifyListener() { @Override public void modifyText(final ModifyEvent event) { handleModifyText(textButtonComposite, errorDecoration, Utility.isEmptyOrExistingFile(textButtonComposite.getText())); if (!textButtonComposite.isValid()) { infoDecoration.hideHover(); } } }); return textButtonComposite; }
From source file:openbiomind.gui.wizards.AbstractTaskWizardPage.java
License:Open Source License
/** * Show error or warning./*from ww w .java2s . c om*/ * * @param errorDecoration the error decoration * @param warningDecoration the warning decoration * @param inError the in error * @param inWarning the in warning * @param infoDecoration the info decoration */ protected void showErrorOrWarning(final boolean inError, final ControlDecoration errorDecoration, final boolean inWarning, final ControlDecoration warningDecoration, final ControlDecoration infoDecoration) { boolean shown = false; if (inError) { errorDecoration.show(); errorDecoration.showHoverText(errorDecoration.getDescriptionText()); shown = true; } else { errorDecoration.hide(); if (inWarning) { warningDecoration.show(); warningDecoration.showHoverText(warningDecoration.getDescriptionText()); shown = true; } else { warningDecoration.hide(); } } if (shown && infoDecoration != null) { infoDecoration.hideHover(); } }
From source file:org.eclipse.m2e.editor.pom.MavenPomEditorPage.java
License:Open Source License
/** * creates a text field/Ccombo decoration that shows the evaluated value * //from w w w . ja va2 s.co m * @param control */ public final void createEvaluatorInfo(final Control control) { if (!(control instanceof Text || control instanceof CCombo)) { throw new IllegalArgumentException("Not a Text or CCombo"); } FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION); final ControlDecoration decoration = new ControlDecoration(control, SWT.RIGHT | SWT.TOP) { /* (non-Javadoc) * @see org.eclipse.jface.fieldassist.ControlDecoration#getDescriptionText() */ @Override public String getDescriptionText() { MavenProject mp = getPomEditor().getMavenProject(); if (mp != null) { return FormUtils.simpleInterpolate(mp, control instanceof Text ? ((Text) control).getText() : ((CCombo) control).getText()); } return "Cannot interpolate expressions, not resolvable file."; } }; decoration.setShowOnlyOnFocus(false); decoration.setImage(fieldDecoration.getImage()); decoration.setShowHover(true); decoration.hide(); //hide and wait for the value to be set. decoration.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { decoration.showHoverText(decoration.getDescriptionText()); } }); ModifyListener listener = new ModifyListener() { public void modifyText(ModifyEvent e) { String text = control instanceof Text ? ((Text) control).getText() : ((CCombo) control).getText(); if (text.indexOf("${") != -1 && text.indexOf("}") != -1) { decoration.show(); } else { decoration.hide(); } } }; if (control instanceof Text) { ((Text) control).addModifyListener(listener); } else { ((CCombo) control).addModifyListener(listener); } control.addMouseTrackListener(new MouseTrackListener() { public void mouseHover(MouseEvent e) { decoration.showHoverText(decoration.getDescriptionText()); } public void mouseExit(MouseEvent e) { decoration.hideHover(); } public void mouseEnter(MouseEvent e) { } }); }
From source file:org.pentaho.pms.ui.concept.editor.NumberPropertyEditorWidget.java
License:Open Source License
protected void createContents(final Composite parent) { addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { NumberPropertyEditorWidget.this.widgetDisposed(e); }//from w w w. j a v a 2s . c om }); // final DecoratedField field = new DecoratedField(parent, SWT.BORDER, new TextControlCreator()); numberField = new Text(parent, SWT.BORDER); final ControlDecoration controlDecoration = new ControlDecoration(numberField, SWT.TOP | SWT.RIGHT); final FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fieldDecoration = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); Image decorationImage = fieldDecoration.getImage(); controlDecoration.setImage(decorationImage); controlDecoration.setDescriptionText(fieldDecoration.getDescription()); controlDecoration.hide(); numberLabel = new Label(parent, SWT.LEFT); numberLabel.setText("Value:"); FormData fdLabel = new FormData(); fdLabel.left = new FormAttachment(0, 0); fdLabel.top = new FormAttachment(numberField, 0, SWT.CENTER); numberLabel.setLayoutData(fdLabel); FormData fd1 = new FormData(); fd1.left = new FormAttachment(0, 0); fd1.top = new FormAttachment(0, 0); fd1.right = new FormAttachment(100, -decorationImage.getBounds().width); numberField.setLayoutData(fd1); Listener listener = new Listener() { public void handleEvent(final Event e) { if (logger.isDebugEnabled()) { logger.debug("heard event on numberField"); } String text = numberField.getText(); try { new BigDecimal(text); if (logger.isDebugEnabled()) { logger.debug("numberField contains a valid BigDecimal (" + text + ")"); } } catch (NumberFormatException nfe) { if (logger.isDebugEnabled()) { logger.debug("numberField contains a invalid BigDecimal (" + text + ")"); } controlDecoration.show(); if (Const.isEmpty(text)) { controlDecoration.showHoverText(Messages.getString( "NumberPropertyEditorWidget.USER_FEEDBACK_MESSAGE_NUMBER_CANT_BE_EMPTY", text)); } else { controlDecoration.showHoverText(Messages.getString( "NumberPropertyEditorWidget.USER_FEEDBACK_MESSAGE_NOT_A_BIGNUMBER", text)); } return; } controlDecoration.hide(); controlDecoration.hideHover(); } }; numberField.addListener(SWT.MouseDown, listener); numberField.addListener(SWT.MouseUp, listener); numberField.addListener(SWT.KeyDown, listener); numberField.addListener(SWT.KeyUp, listener); numberField.addFocusListener(this); }
From source file:org.pentaho.pms.ui.concept.editor.UrlPropertyEditorWidget.java
License:Open Source License
protected void createContents(final Composite parent) { addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { UrlPropertyEditorWidget.this.widgetDisposed(e); }/* w w w . jav a2 s . c o m*/ }); urlField = new Text(parent, SWT.BORDER); final ControlDecoration controlDecoration = new ControlDecoration(urlField, SWT.TOP | SWT.RIGHT); final FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fieldDecoration = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); Image decorationImage = fieldDecoration.getImage(); controlDecoration.setImage(decorationImage); controlDecoration.setDescriptionText(fieldDecoration.getDescription()); controlDecoration.hide(); urlLabel = new Label(parent, SWT.LEFT); urlLabel.setText("URL (including http://):"); FormData fdLabel = new FormData(); fdLabel.left = new FormAttachment(0, 0); fdLabel.top = new FormAttachment(urlField, 0, SWT.CENTER); urlLabel.setLayoutData(fdLabel); FormData fdField = new FormData(); fdField.left = new FormAttachment(urlLabel, 10); fdField.top = new FormAttachment(0, 0); fdField.right = new FormAttachment(100, -decorationImage.getBounds().width); urlField.setLayoutData(fdField); Listener listener = new Listener() { public void handleEvent(final Event e) { if (logger.isDebugEnabled()) { logger.debug("heard event on urlField"); } String text = urlField.getText(); try { new URL(text); if (logger.isDebugEnabled()) { logger.debug("urlField contains a valid URL (" + text + ")"); } } catch (MalformedURLException mue) { if (logger.isDebugEnabled()) { logger.debug("urlField contains a invalid URL (" + text + ")"); } controlDecoration.show(); if (Const.isEmpty(text)) { controlDecoration.showHoverText(Messages.getString( "UrlPropertyEditorWidget.USER_FEEDBACK_MESSAGE_URL_CANT_BE_EMPTY", text)); } else { controlDecoration.showHoverText(Messages .getString("UrlPropertyEditorWidget.USER_FEEDBACK_MESSAGE_NOT_A_VALID_URL", text)); } return; } controlDecoration.hide(); controlDecoration.hideHover(); } }; urlField.addListener(SWT.MouseDown, listener); urlField.addListener(SWT.MouseUp, listener); urlField.addListener(SWT.KeyDown, listener); urlField.addListener(SWT.KeyUp, listener); urlField.addFocusListener(this); }
From source file:org.rssowl.ui.internal.search.SearchConditionItem.java
License:Open Source License
@SuppressWarnings("unchecked") private void updateInputField(Composite inputField, final ISearchField field, final Object input) { /* Dispose any old Children first */ Control[] children = inputField.getChildren(); for (Control child : children) { child.dispose();//from www . ja va 2 s . co m } /* Specially treat News-State */ if (field.getId() == INews.STATE) { final StateConditionControl stateConditionControl = new StateConditionControl(inputField, SWT.NONE); stateConditionControl.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { fInputValue = stateConditionControl.getSelection(); if (fInputValue == null && input != null || (fInputValue != null && !fInputValue.equals(input))) fModified = true; } }); /* Pre-Select input if given */ Object presetInput = (input == null) ? fInputValue : input; if (presetInput != null && presetInput instanceof EnumSet) stateConditionControl.select((EnumSet<State>) presetInput); /* Update Input Value */ fInputValue = stateConditionControl.getSelection(); } /* Specially treat News-Location */ else if (field.getId() == INews.LOCATION) { final LocationControl locationConditionControl = new LocationControl(inputField, SWT.NONE); locationConditionControl.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { fInputValue = locationConditionControl.getSelection(); if (fInputValue == null && input != null || (fInputValue != null && !fInputValue.equals(input))) fModified = true; } }); /* Pre-Select input if given */ Object presetInput = (input == null) ? fInputValue : input; if (presetInput != null && presetInput instanceof Long[][]) locationConditionControl.select((Long[][]) presetInput); /* Update Input Value */ fInputValue = locationConditionControl.getSelection(); } /* Specially treat Age */ else if (field.getId() == INews.AGE_IN_DAYS || field.getId() == INews.AGE_IN_MINUTES) { Composite container = new Composite(inputField, SWT.NONE); container.setLayout(LayoutUtils.createGridLayout(2, 0, 0)); final Spinner spinner = new Spinner(container, SWT.BORDER); spinner.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); spinner.setMinimum(1); spinner.setMaximum(1000000); final Combo combo = new Combo(container, SWT.BORDER | SWT.READ_ONLY); combo.add(Messages.SearchConditionItem_DAYS); combo.add(Messages.SearchConditionItem_HOURS); combo.add(Messages.SearchConditionItem_MINUTES); Listener listener = new Listener() { public void handleEvent(Event event) { fInputValue = getAgeValue(spinner, combo); if (!fInputValue.equals(input)) fModified = true; } }; spinner.addListener(SWT.Modify, listener); combo.addListener(SWT.Modify, listener); /* Pre-Select input if given */ Object presetInput = (input == null) ? fInputValue : input; if (presetInput != null && presetInput instanceof Integer) { Integer inputValue = (Integer) presetInput; /* Day */ if (inputValue >= 0) { spinner.setSelection(inputValue); combo.select(0); } /* Hour */ else if (inputValue % 60 == 0) { spinner.setSelection(Math.abs(inputValue) / 60); combo.select(1); } /* Minute */ else { spinner.setSelection(Math.abs(inputValue)); combo.select(2); } } /* Otherwise use Default */ else { spinner.setSelection(1); combo.select(0); } /* Update Input Value */ fInputValue = getAgeValue(spinner, combo); } /* Create new Input Field based on search-value-type */ else { switch (field.getSearchValueType().getId()) { /* Type: Boolean */ case ISearchValueType.BOOLEAN: { final Combo combo = new Combo(inputField, SWT.BORDER | SWT.READ_ONLY); combo.add(Messages.SearchConditionItem_TRUE); combo.add(Messages.SearchConditionItem_FALSE); combo.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { fInputValue = Boolean.valueOf(combo.getItem(combo.getSelectionIndex())); if (!fInputValue.equals(input)) fModified = true; } }); /* Pre-Select input if given */ Object presetInput = (input == null) ? fInputValue : input; if (presetInput != null && presetInput instanceof Boolean) combo.select(((Boolean) presetInput) ? 0 : 1); else combo.select(0); /* Update Input Value */ fInputValue = Boolean.valueOf(combo.getItem(combo.getSelectionIndex())); break; } /* Type: Date / Time */ case ISearchValueType.DATE: case ISearchValueType.TIME: case ISearchValueType.DATETIME: { final Calendar cal = Calendar.getInstance(); final DateTime datetime = new DateTime(inputField, SWT.DATE | SWT.BORDER); datetime.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { cal.set(Calendar.DATE, datetime.getDay()); cal.set(Calendar.MONTH, datetime.getMonth()); cal.set(Calendar.YEAR, datetime.getYear()); fInputValue = cal.getTime(); if (!fInputValue.equals(input)) fModified = true; } }); /* Pre-Select input if given */ Object presetInput = (input == null) ? fInputValue : input; if (presetInput != null && presetInput instanceof Date) cal.setTime((Date) presetInput); datetime.setDay(cal.get(Calendar.DATE)); datetime.setMonth(cal.get(Calendar.MONTH)); datetime.setYear(cal.get(Calendar.YEAR)); /* Update Input Value */ fInputValue = cal.getTime(); break; } /* Type: Enumeration */ case ISearchValueType.ENUM: { final Text text = new Text(inputField, SWT.BORDER); text.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { fInputValue = text.getText(); if (!fInputValue.equals(input)) fModified = true; } }); /* Provide Auto-Complete Field */ OwlUI.hookAutoComplete(text, field.getSearchValueType().getEnumValues(), true, true); /* Pre-Select input if given */ String inputValue = (input != null ? input.toString() : null); if (inputValue != null) text.setText(inputValue); /* Update Input Value */ fInputValue = text.getText(); break; } /* Type: Number */ case ISearchValueType.NUMBER: case ISearchValueType.INTEGER: { final Spinner spinner = new Spinner(inputField, SWT.BORDER); spinner.setMinimum(0); spinner.setMaximum(1000); spinner.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { fInputValue = spinner.getSelection(); if (!fInputValue.equals(input)) fModified = true; } }); /* Pre-Select input if given */ Object presetInput = (input == null) ? fInputValue : input; if (presetInput != null && presetInput instanceof Integer) spinner.setSelection((Integer) presetInput); /* Update Input Value */ fInputValue = spinner.getSelection(); break; } /* Type: String */ case ISearchValueType.STRING: case ISearchValueType.LINK: { final Text text = new Text(inputField, SWT.BORDER); OwlUI.makeAccessible(text, NLS.bind(Messages.SearchConditionItem_SEARCH_VALUE_FIELD, field.getName())); /* Show UI Hint for extra information is available */ final ControlDecoration controlDeco = new ControlDecoration(text, SWT.LEFT | SWT.TOP); controlDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage()); controlDeco.setShowOnlyOnFocus(true); /* Listen to Changes of Input */ text.addListener(SWT.Modify, new Listener() { private boolean isShowingWarning = false; public void handleEvent(Event event) { String textValue = text.getText(); fInputValue = textValue; if (!fInputValue.equals(input)) fModified = true; if (isShowingWarning) controlDeco.hideHover(); /* Determine any Search Warning to show depending on field and text value */ SearchWarning warning = SearchWarning.NO_WARNING; if (field.getId() == INews.CATEGORIES || field.getId() == INews.SOURCE || field.getId() == INews.FEED || field.getId() == INews.LINK) { if (StringUtils.isPhraseSearch(textValue)) warning = SearchWarning.PHRASE_SEARCH_UNSUPPORTED; } else { if (StringUtils.isPhraseSearchWithWildcardToken(textValue)) warning = SearchWarning.PHRASE_AND_WILDCARD_SEARCH_COMBINED; else if (StringUtils.isSpecialCharacterSearchWithWildcardToken(textValue)) warning = SearchWarning.WILDCARD_AND_SPECIAL_CHAR_SEARCH; } /* Indicate a warning to the user if phrase search and wildcards combined or wrongly used */ if (warning != SearchWarning.NO_WARNING && !isShowingWarning) { updateFieldDecoration(text, controlDeco, warning, field); isShowingWarning = true; } /* Clear any error if shown previously */ else if (warning == SearchWarning.NO_WARNING && isShowingWarning) { updateFieldDecoration(text, controlDeco, warning, field); isShowingWarning = false; } } }); /* Provide auto-complete for Categories, Authors and Feeds */ if (field.getId() == INews.CATEGORIES || field.getId() == INews.AUTHOR || field.getId() == INews.FEED) { controlDeco.setDescriptionText(Messages.SearchConditionItem_CONTENT_ASSIST_INFO); final Pair<SimpleContentProposalProvider, ContentProposalAdapter> pair = OwlUI .hookAutoComplete(text, null, false, true); /* Load proposals in the Background */ JobRunner.runInBackgroundThread(100, new Runnable() { public void run() { if (!text.isDisposed()) { Set<String> values = new TreeSet<String>(new Comparator<String>() { public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }); if (field.getId() == INews.CATEGORIES) values.addAll(fDaoService.getCategoryDAO().loadAllNames()); else if (field.getId() == INews.AUTHOR) values.addAll(fDaoService.getPersonDAO().loadAllNames()); else if (field.getId() == INews.FEED) values.addAll(CoreUtils.getFeedLinks()); /* Apply Proposals */ if (!text.isDisposed()) OwlUI.applyAutoCompleteProposals(values, pair.getFirst(), pair.getSecond(), true); } } }); } /* Show UI Hint that Wildcards can be used */ else { controlDeco.setDescriptionText(Messages.SearchConditionItem_SEARCH_HELP); } /* Pre-Select input if given */ Object presetInput = (input == null && fInputValue instanceof String) ? fInputValue : input; if (presetInput != null) text.setText(presetInput.toString()); /* Update Input Value */ fInputValue = text.getText(); break; } } } /* Update Layout */ inputField.getParent().layout(); inputField.getParent().update(); inputField.layout(); inputField.update(); }
From source file:org.rssowl.ui.internal.search.StateConditionControl.java
License:Open Source License
private void initComponents() { /* Apply Gridlayout */ setLayout(LayoutUtils.createGridLayout(4, 0, 0)); /* State: New */ fNewState = new Button(this, SWT.CHECK); fNewState.setText(Messages.StateConditionControl_NEW); fNewState.setToolTipText(Messages.StateConditionControl_NEW_INFO); fNewState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true)); /* State: Unread */ fUnreadState = new Button(this, SWT.CHECK); fUnreadState.setText(Messages.StateConditionControl_UNREAD); fUnreadState.setToolTipText(Messages.StateConditionControl_UNREAD_INFO); fUnreadState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true)); /* Use Control Decoration on Mac */ if (Application.IS_MAC) { /* Use a decoration to help the user understand the State Semantic */ final ControlDecoration newControlDeco = new ControlDecoration(fNewState, SWT.LEFT | SWT.TOP); newControlDeco.setImage(OwlUI.getImage(fNewState, "icons/obj16/dotempty.gif")); //$NON-NLS-1$ newControlDeco.hide();/*w w w . j a va2 s .c o m*/ final ControlDecoration unreadControlDeco = new ControlDecoration(fUnreadState, SWT.LEFT | SWT.TOP); unreadControlDeco.setImage(OwlUI.getImage(fUnreadState, "icons/obj16/dotempty.gif")); //$NON-NLS-1$ unreadControlDeco.hide(); fNewState.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (fNewState.getSelection() && !fUnreadState.getSelection()) { unreadControlDeco.show(); unreadControlDeco.showHoverText(Messages.StateConditionControl_UNREAD_HINT); } else { unreadControlDeco.hide(); unreadControlDeco.hideHover(); } } }); fUnreadState.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (fUnreadState.getSelection() && !fNewState.getSelection()) { newControlDeco.show(); newControlDeco.showHoverText(Messages.StateConditionControl_NEW_HINT); } else { newControlDeco.hide(); newControlDeco.hideHover(); } } }); fNewState.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { newControlDeco.hide(); newControlDeco.hideHover(); } }); fUnreadState.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { unreadControlDeco.hide(); unreadControlDeco.hideHover(); } }); } /* Use Balloon Tooltip on Windows and Linux */ else { /* Use a Tooltip to help the user understand the State Semantic */ final ToolTip newStateToolTip = new ToolTip(getShell(), SWT.BALLOON); newStateToolTip.setMessage(Messages.StateConditionControl_NEW_HINT); newStateToolTip.setAutoHide(false); final ToolTip unreadStateToolTip = new ToolTip(getShell(), SWT.BALLOON); unreadStateToolTip.setMessage(Messages.StateConditionControl_UNREAD_HINT); unreadStateToolTip.setAutoHide(false); fNewState.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (fNewState.getSelection() && !fUnreadState.getSelection()) { Point toolTipLocation = toDisplay(fUnreadState.getLocation()); toolTipLocation.y += fUnreadState.getSize().y; if (Application.IS_WINDOWS) toolTipLocation.x += 5; else if (Application.IS_LINUX) toolTipLocation.x += 12; unreadStateToolTip.setLocation(toolTipLocation); unreadStateToolTip.setVisible(true); } else { unreadStateToolTip.setVisible(false); } } }); fUnreadState.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (fUnreadState.getSelection() && !fNewState.getSelection()) { Point toolTipLocation = toDisplay(fNewState.getLocation()); toolTipLocation.y += fNewState.getSize().y; if (Application.IS_WINDOWS) toolTipLocation.x += 5; else if (Application.IS_LINUX) toolTipLocation.x += 12; newStateToolTip.setLocation(toolTipLocation); newStateToolTip.setVisible(true); } else { newStateToolTip.setVisible(false); } } }); fNewState.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { newStateToolTip.setVisible(false); } @Override public void focusLost(FocusEvent e) { unreadStateToolTip.setVisible(false); } }); fUnreadState.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { unreadStateToolTip.setVisible(false); } @Override public void focusLost(FocusEvent e) { newStateToolTip.setVisible(false); } }); addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { unreadStateToolTip.dispose(); newStateToolTip.dispose(); } }); } /* State: Updated */ fUpdatedState = new Button(this, SWT.CHECK); fUpdatedState.setText(Messages.StateConditionControl_UPDATED); fUpdatedState.setToolTipText(Messages.StateConditionControl_UPDATED_INFO); fUpdatedState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true)); /* State: Read */ fReadState = new Button(this, SWT.CHECK); fReadState.setText(Messages.StateConditionControl_READ); fReadState.setToolTipText(Messages.StateConditionControl_READ_INFO); fReadState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true)); /* Selection Listener to issue modify events */ SelectionListener selectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { notifyListeners(SWT.Modify, new Event()); } }; fNewState.addSelectionListener(selectionListener); fUnreadState.addSelectionListener(selectionListener); fUpdatedState.addSelectionListener(selectionListener); fReadState.addSelectionListener(selectionListener); }
From source file:org.spotter.eclipse.ui.listeners.TextEditorErrorListener.java
License:Apache License
/** * Creates a new text editor error listener. * /*from ww w . ja va2 s . co m*/ * @param textCellEditor * the associated text cell editor * @param decor * the control decoration */ public TextEditorErrorListener(TextCellEditor textCellEditor, ControlDecoration decor) { this.textCellEditor = textCellEditor; textCtrl = (Text) textCellEditor.getControl(); this.decor = decor; decor.setImage(DECOR_IMG); decor.setShowOnlyOnFocus(true); decor.setShowHover(true); decor.hide(); decor.hideHover(); }