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

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

Introduction

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

Prototype

public void showHoverText(String text) 

Source Link

Document

Show the specified text using the same hover dialog as is used to show decorator descriptions.

Usage

From source file:carisma.ui.eclipse.editors.AdfEditorCheckDetailsPage.java

License:Open Source License

/**
 * Handles Integer parameter./*ww  w.  j a  v a  2s . co m*/
 * 
 * @param comp
 *            the composite for the parameter input elements
 * @param checkParameter
 *            the checkParameter to handle
 */
private void handleIntParameter(final Composite comp, final CheckParameter checkParameter) {
    final String errorText = "Please insert an integer value!";

    final Text text = this.toolkit.createText(comp, "", SWT.SINGLE);
    GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
    layoutData.horizontalSpan = 2;
    text.setLayoutData(layoutData);

    int value = ((IntegerParameter) checkParameter).getValue();
    text.setText(String.valueOf(value));
    text.setToolTipText(checkParameter.getDescriptor().getDescription());

    final ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
    Image contpro = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR)
            .getImage();
    decoration.setImage(contpro);
    decoration.hide();

    text.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            try {
                AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter,
                        Integer.valueOf(text.getText()));
                decoration.hide();
            } catch (Exception exc) {
                AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, new Integer(0));
                decoration.show();
                decoration.showHoverText(errorText);
            }
            if (text.getText().isEmpty()) {
                if (!checkParameter.getDescriptor().isOptional()) {
                    AdfEditorCheckDetailsPage.this.controller.setParameterQod(checkParameter, true);
                }
            } else {
                AdfEditorCheckDetailsPage.this.controller.setParameterQod(checkParameter, false);
            }
            AdfEditorCheckDetailsPage.this.qodButtonMap.get(checkParameter)
                    .setSelection(checkParameter.isQueryOnDemand());
        }
    });

    text.addListener(SWT.Verify, new Listener() {
        @Override
        public void handleEvent(final Event e) {
            String newCharacter = e.text;
            String newText = applyEventToText(text, e);
            try {
                if (!newCharacter.equals("") && !newCharacter.equals("-")) {
                    Integer.parseInt(newCharacter);
                }
                if (!newText.equals("")) {
                    Integer.parseInt(newText);
                }
                decoration.hide();
            } catch (Exception exc) {
                e.doit = false;
                decoration.show();
                decoration.showHoverText(errorText);
            }
        }
    });

    text.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
        }

        @Override
        public void focusLost(final FocusEvent e) {
            decoration.hide();
        }
    });

    text.addListener(SWT.Modify, this.masterListener);
}

From source file:carisma.ui.eclipse.editors.AdfEditorCheckDetailsPage.java

License:Open Source License

/**
 * Handles Float parameter.//from w  ww  .  ja va2 s  .  c om
 * 
 * @param comp
 *            the composite for the parameter input elements
 * @param checkParameter
 *            the checkParamter to handle
 */
private void handleFloatParameter(final Composite comp, final CheckParameter checkParameter) {
    final String errorText = "Please insert a float value!";

    final Text text = this.toolkit.createText(comp, "", SWT.SINGLE);
    GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
    layoutData.horizontalSpan = 2;
    text.setLayoutData(layoutData);

    float value = ((FloatParameter) checkParameter).getValue();
    text.setText(String.valueOf(value));

    text.setToolTipText(checkParameter.getDescriptor().getDescription());
    final ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
    Image contpro = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR)
            .getImage();
    decoration.setImage(contpro);
    decoration.hide();

    text.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            try {
                AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter,
                        Float.valueOf(text.getText()));
                AdfEditorCheckDetailsPage.this.controller.setParameterQod(checkParameter, false);
                decoration.hide();
            } catch (Exception exc) { // e.g. field is empty
                AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, new Float(0.0f));
                if (!checkParameter.getDescriptor().isOptional()) {
                    AdfEditorCheckDetailsPage.this.controller.setParameterQod(checkParameter, true);
                }
                decoration.show();
                decoration.showHoverText(errorText);
            }
            AdfEditorCheckDetailsPage.this.qodButtonMap.get(checkParameter)
                    .setSelection(checkParameter.isQueryOnDemand());
        }
    });

    text.addListener(SWT.Verify, new Listener() {
        @Override
        public void handleEvent(final Event e) {
            e.text = e.text.replace(",", ".");
            String newCharacter = e.text;
            String newText = applyEventToText(text, e);
            try {
                if (!newCharacter.equals("") && !newCharacter.equals("-") && !newCharacter.equals(".")) {
                    Float.parseFloat(newCharacter);
                }
                if (!newText.equals("")) {
                    float newFloat = Float.parseFloat(newText);
                    if (newFloat != 0) {
                        if ((newFloat > Float.MAX_VALUE || newFloat < Float.MIN_VALUE)
                                && ((newFloat * -1) > Float.MAX_VALUE || (newFloat * -1) < Float.MIN_VALUE)) {
                            throw new NumberFormatException("Float out of range");
                        }
                    }
                }
                decoration.hide();
            } catch (Exception exc) {
                e.doit = false;
                decoration.show();
                decoration.showHoverText(errorText);
            }
        }
    });

    text.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
        }

        @Override
        public void focusLost(final FocusEvent e) {
            decoration.hide();
        }
    });

    text.addListener(SWT.Modify, this.masterListener);
}

From source file:carisma.ui.eclipse.editors.AdfEditorCheckDetailsPage.java

License:Open Source License

/**
 * Handles InputFile parameter./*from w  w w .  j a va2 s.  c o  m*/
 * 
 * @param comp
 *            the composite for the parameter input elements
 * @param checkParameter
 *            the checkParamter to handle
 */
private void handleInputFileParameter(final Composite comp, final CheckParameter checkParameter) {
    final Text text = this.toolkit.createText(comp, "");
    text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    text.setEditable(false);
    text.setToolTipText(checkParameter.getDescriptor().getDescription());

    Button browse = this.toolkit.createButton(comp, AdfEditorCheckDetailsPage.BROWSE, SWT.PUSH);
    browse.setToolTipText("Browse for an\ninput file");
    browse.setLayoutData(new GridData(SWT.NONE, SWT.TOP, false, false));

    final ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
    Image contpro = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR)
            .getImage();
    decoration.setImage(contpro);
    decoration.hide();

    // Initially check if the file can be read
    final String parameterValue;
    if (((InputFileParameter) checkParameter).getValue() != null) {
        if (((InputFileParameter) checkParameter).getValue().canRead()) {
            parameterValue = ((InputFileParameter) checkParameter).getValue().toString();
        } else {
            parameterValue = "";
            decoration.show();
            decoration.setShowHover(true);
            decoration.showHoverText("Invalid input file.\nFully qualified path is needed and has to exist.");
        }
    } else {
        parameterValue = "";
    }
    text.setText(parameterValue);

    // Hide decoration if focus has been lost
    text.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
        }

        @Override
        public void focusLost(final FocusEvent e) {
            decoration.hide();
        }
    });

    text.addListener(SWT.Modify, this.masterListener);

    // Open file dialog
    browse.addSelectionListener(new SelectionAdapter() {
        private FileDialog fileDialog = null;

        @Override
        public void widgetSelected(final SelectionEvent e) {
            this.fileDialog = new FileDialog(comp.getShell());
            this.fileDialog.setText("Input File Selection");
            if (!text.getText().isEmpty()) {
                this.fileDialog.setFilterPath(text.getText());
            } else {
                this.fileDialog
                        .setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
            }
            String path = this.fileDialog.open();
            if (path != null) {
                File inputFile = new File(path);
                if (inputFile.canRead()) {
                    AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, inputFile);
                    decoration.hide();
                    text.setText(inputFile.getPath());
                    text.update();
                    AdfEditorCheckDetailsPage.this.controller.setParameterQod(checkParameter, false);
                    AdfEditorCheckDetailsPage.this.qodButtonMap.get(checkParameter).setSelection(false);
                } else {
                    AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, null);
                    decoration.show();
                    decoration.setShowHover(true);
                    decoration.showHoverText(
                            "Invalid input file.\nFully qualified path is needed and has to exist.");
                    text.setText("");
                    text.update();
                    if (!checkParameter.getDescriptor().isOptional()) {
                        AdfEditorCheckDetailsPage.this.controller.setParameterQod(checkParameter, true);
                        AdfEditorCheckDetailsPage.this.qodButtonMap.get(checkParameter).setSelection(true);
                    }
                }
            }
        }
    });
}

From source file:carisma.ui.eclipse.editors.AdfEditorCheckDetailsPage.java

License:Open Source License

/**
 * Handles Folder parameter./* w ww  . ja  v  a2s. c  o  m*/
 * 
 * @param comp
 *            the composite for the parameter input elements
 * @param checkParameter
 *            the checkParamter to handle
 */
private void handleFolderParameter(final Composite comp, final CheckParameter checkParameter) {
    final String folderValue;
    if (((FolderParameter) checkParameter).getValue() != null) {
        folderValue = ((FolderParameter) checkParameter).getValue().getPath();
    } else {
        folderValue = "";
    }

    final Text text = this.toolkit.createText(comp, folderValue);
    text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    text.setEditable(false);
    text.setToolTipText(checkParameter.getDescriptor().getDescription());

    final ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
    Image contpro = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR)
            .getImage();
    decoration.setImage(contpro);
    decoration.hide();

    text.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            File inputFile = new File(text.getText());
            if (!inputFile.canRead() || !inputFile.isDirectory()) {
                AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, null);
                decoration.show();
                decoration.setShowHover(true);
                decoration.showHoverText(
                        "Invalid input folder.\nFully qualified path is needed and has to exist.");
            } else {
                AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, inputFile);
                decoration.hide();
            }
        }
    });

    text.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
        }

        @Override
        public void focusLost(final FocusEvent e) {
            decoration.hide();
        }
    });

    text.addListener(SWT.Modify, this.masterListener);

    Button folderOpen = this.toolkit.createButton(comp, AdfEditorCheckDetailsPage.BROWSE, SWT.PUSH);
    folderOpen.setLayoutData(new GridData(SWT.NONE, SWT.TOP, false, false));
    folderOpen.setToolTipText("Browse for a folder");

    folderOpen.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            DirectoryDialog dirDialog = new DirectoryDialog(comp.getShell());
            dirDialog.setText("Folder Selection");
            if (!text.getText().isEmpty()) {
                dirDialog.setFilterPath(text.getText());
            } else {
                dirDialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
            }
            String result = dirDialog.open();
            if (result != null && !result.isEmpty()) {
                File outputFile = new File(result);
                AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, outputFile);
                text.setText(outputFile.getPath());
                text.update();
                AdfEditorCheckDetailsPage.this.controller.setParameterQod(checkParameter, false);
                AdfEditorCheckDetailsPage.this.qodButtonMap.get(checkParameter).setSelection(false);
            }
        }
    });
}

From source file:carisma.ui.eclipse.editors.AdfEditorCheckDetailsPage.java

License:Open Source License

/**
 * Handles Output parameter.//  ww w  .j a v a  2 s.co m
 * 
 * @param comp
 *            the composite for the parameter input elements
 * @param checkParameter
 *            the checkParamter to handle
 */
private void handleOutputParameter(final Composite comp, final CheckParameter checkParameter) {

    final String outputFileValue;
    if (((OutputFileParameter) checkParameter).getValue() != null) {
        outputFileValue = (((OutputFileParameter) checkParameter).getValue()).getPath();
    } else {
        outputFileValue = "";
    }

    final Text text = this.toolkit.createText(comp, outputFileValue);
    text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    text.setEditable(false);
    text.setToolTipText(checkParameter.getDescriptor().getDescription());

    Button outputFileOpen = this.toolkit.createButton(comp, AdfEditorCheckDetailsPage.BROWSE, SWT.PUSH);
    outputFileOpen.setLayoutData(new GridData(SWT.NONE, SWT.TOP, false, false));
    outputFileOpen.setToolTipText("Browse for an\noutput file");

    final ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
    final Image errorImage = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();
    decoration.setImage(errorImage);
    decoration.setShowHover(true);
    decoration.hide();

    text.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            try {
                if (!text.getText().isEmpty()) {
                    AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter,
                            new File(text.getText()));
                } else {
                    AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, null);
                }
                if (((OutputFileParameter) checkParameter).isInsertedValueValid()) {
                    decoration.hide();
                } else {
                    decoration.show();
                    decoration.showHoverText(
                            "Invalid output file.\nFully qualified path is needed and has to exist.");
                }
            } catch (SWTException exc) {
                Logger.log(LogLevel.ERROR, "", exc);
            }
        }
    });

    text.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(final FocusEvent e) {
        }

        @Override
        public void focusLost(final FocusEvent e) {
            decoration.hide();
        }
    });

    text.addListener(SWT.Modify, this.masterListener);

    outputFileOpen.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            FileDialog fDialog = new FileDialog(comp.getShell(), SWT.SAVE);
            fDialog.setText("Output File Selection");
            if (!text.getText().isEmpty()) {
                fDialog.setFilterPath(text.getText());
            } else {
                fDialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
            }
            String selection = fDialog.open();
            if (selection != null && !selection.isEmpty()) {
                AdfEditorCheckDetailsPage.this.controller.setParameter(checkParameter, new File(selection));
                text.setText(selection);
                text.update();
                AdfEditorCheckDetailsPage.this.controller.setParameterQod(checkParameter, false);
                AdfEditorCheckDetailsPage.this.qodButtonMap.get(checkParameter).setSelection(false);
            }
        }
    });
}

From source file:jasima_gui.dialogs.streamEditor.DetailsPageBase.java

License:Open Source License

public boolean checkGlobalConstraints() {
    hideError();/*w ww  .j a v a 2s  . c o  m*/

    // any local error?
    boolean anyError = false;
    for (FormProperty p : props.values()) {
        ControlDecoration deco = p.getDecoration();
        if (p.error != null) {
            anyError = true;
            deco.setDescriptionText(p.error.errorMsg);
            deco.show();
            deco.showHoverText(p.error.hoverText);
        } else {
            deco.setDescriptionText(null);
            deco.hide();
        }
    }

    if (!anyError) {
        // check global constraints
        ArrayList<ConstraintValidator> failed = new ArrayList<ConstraintValidator>();
        for (ConstraintValidator v : getConstraints()) {
            if (!v.isValid())
                failed.add(v);
        }

        // report errors
        if (failed.size() > 0) {
            anyError = true;
            String mainMsg = failed.size() == 1 ? "1 error" : String.format("%d errors", failed.size());
            master.getManagedForm().getForm().setMessage(mainMsg, IMessageProvider.ERROR,
                    failed.toArray(new IMessage[failed.size()]));

            // show error decoration on causing properties
            for (ConstraintValidator cv : failed) {
                for (FormProperty p : cv.dependsOn()) {
                    ControlDecoration deco = p.getDecoration();
                    String s = deco.getDescriptionText();
                    if (s != null)
                        s += "\n" + cv.getMessage();
                    else
                        s = cv.getMessage();
                    deco.setDescriptionText(s);
                    deco.show();
                }
            }
        } else {
            anyError = false;
        }
    }

    master.okButton.setEnabled(!anyError);

    return !anyError;
}

From source file:openbiomind.gui.wizards.AbstractTaskWizardPage.java

License:Open Source License

/**
 * Handle error decoration.//from   w w  w . j  av  a  2 s .com
 * 
 * @param errorDecoration the error decoration
 * @param valid the valid
 */
protected void handleErrorDecoration(final ControlDecoration errorDecoration, final boolean valid) {
    if (valid) {
        errorDecoration.hide();
    } else {
        errorDecoration.show();
        errorDecoration.showHoverText(errorDecoration.getDescriptionText());
    }
}

From source file:openbiomind.gui.wizards.AbstractTaskWizardPage.java

License:Open Source License

/**
 * Show error or warning./* w ww. j  a  va 2  s. 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.caleydo.view.search.internal.RcpSearchView.java

License:Open Source License

private void createSearchGroup(Composite composite) {
    Group group = new Group(composite, SWT.SHADOW_ETCHED_IN);
    group.setLayout(new RowLayout(SWT.VERTICAL));
    group.setText("Search query");

    Composite row = new Composite(group, SWT.NONE);
    row.setLayout(new RowLayout());

    searchText = new Text(row, SWT.BORDER | SWT.SINGLE);
    searchText.setLayoutData(new RowData(550, 20));
    searchText.addFocusListener(new FocusAdapter() {
        @Override/*w  w  w  .  j  av  a  2 s  .  co  m*/
        public void focusGained(FocusEvent e) {
            e.display.asyncExec(new Runnable() {
                @Override
                public void run() {
                    searchText.selectAll();
                }
            });
        }
    });

    final Button searchButton = new Button(row, SWT.PUSH);
    searchButton.setText("Search");
    searchButton.setEnabled(false);

    final ControlDecoration dec = new ControlDecoration(searchText, SWT.TOP | SWT.LEFT);
    dec.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEC_FIELD_WARNING));
    dec.setShowOnlyOnFocus(true);
    dec.setDescriptionText("You have to enter at least 3 characters");
    dec.hide();

    this.nothingFound = new ControlDecoration(searchText, SWT.TOP | SWT.LEFT);
    nothingFound
            .setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEC_FIELD_ERROR));
    nothingFound.setShowOnlyOnFocus(false);
    nothingFound.setDescriptionText("No Entries were found matching your query");
    nothingFound.hide();

    searchText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            if (searchText.getText().length() >= 3) {
                dec.hide();
                searchButton.setEnabled(true);
            } else {
                dec.show();
                dec.showHoverText("You have to enter at least 3 characters");
                searchButton.setEnabled(false);
            }
        }
    });

    searchButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            search(searchText.getText(), caseSensitive.getSelection(), regexSearch.getSelection());
        }
    });
    searchText.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent event) {
            switch (event.keyCode) {
            case SWT.CR:
                if (searchButton.isEnabled())
                    search(searchText.getText(), caseSensitive.getSelection(), regexSearch.getSelection());
                break;
            default:
                break;
            }
        }
    });

    row = new Composite(group, SWT.NONE);
    row.setLayout(new RowLayout());

    caseSensitive = new Button(row, SWT.CHECK);
    caseSensitive.setText("Case sensitive");

    regexSearch = new Button(row, SWT.CHECK);
    regexSearch.setText("Regular expression");

}

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
 * /* w w w . java  2 s. c o 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) {
        }
    });
}