Java Code Examples for org.eclipse.jface.fieldassist.ControlDecoration#setShowHover()

The following examples show how to use org.eclipse.jface.fieldassist.ControlDecoration#setShowHover() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StyledTextXtextAdapter.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
private ControlDecoration createContentAssistDecoration(StyledText styledText) {
	final ControlDecoration result = new ControlDecoration(styledText, SWT.TOP | SWT.LEFT);
	result.setShowHover(true);
	result.setShowOnlyOnFocus(true);

	final Image image = ImageDescriptor
			.createFromFile(XtextStyledTextCellEditor.class, "images/content_assist_cue.gif").createImage();
	result.setImage(image);
	result.setDescriptionText("Content Assist Available (CTRL + Space)");
	result.setMarginWidth(2);
	styledText.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			if (getDecoration() != null) {
				getDecoration().dispose();
			}
			if (image != null) {
				image.dispose();
			}
		}
	});
	return result;
}
 
Example 2
Source File: AdvancedNewProjectPage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected ControlDecoration InfoDecoration(Control control, String text) {
	FieldDecoration infoField = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
	ControlDecoration controlDecoration = new ControlDecoration(control, (SWT.TOP + SWT.RIGHT));
	controlDecoration.setImage(infoField.getImage());
	controlDecoration.setDescriptionText(text);
	controlDecoration.setShowHover(true);
	return controlDecoration;
}
 
Example 3
Source File: PageComponentSwitchBuilder.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createDescriptionDecorator(final Composite composite,
        final Label labelField, final String desc) {
    final ControlDecoration descriptionDecoration = new ControlDecoration(labelField, SWT.RIGHT, composite);
    descriptionDecoration.setMarginWidth(0);
    descriptionDecoration
            .setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK));
    descriptionDecoration.setDescriptionText(desc);
    descriptionDecoration.setShowOnlyOnFocus(false);
    descriptionDecoration.setShowHover(true);
    descriptionDecoration.show();
}
 
Example 4
Source File: PatternExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createTextViewer() {
	viewer = createViewer(mc);
	viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	configureTextViewer();
	addLineStyleListener();
	helpDecoration = new ControlDecoration(viewer.getControl(), SWT.TOP | SWT.RIGHT, this);
	helpDecoration.setImage(JFaceResources.getImage(Dialog.DLG_IMG_HELP));
	helpDecoration.setDescriptionText(Messages.patternViewerHint);
	helpDecoration.setMarginWidth(2);
	helpDecoration.hide();

	hintDecoration = new ControlDecoration(viewer.getControl(), SWT.TOP | SWT.LEFT, this);
	hintDecoration.setImage(Pics.getImage(PicsConstants.hint));
	hintDecoration.setMarginWidth(2);
	hintDecoration.setShowHover(true);
	hintDecoration.setShowOnlyOnFocus(true);
	hintDecoration.hide();

	viewer.addTextListener(new ITextListener() {

		@Override
		public void textChanged(final TextEvent event) {
			viewer.getTextWidget().notifyListeners(SWT.Modify, new Event());
		}
	});

	helpDecoration.show();
}
 
Example 5
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void createTextControl(final int style, final TabbedPropertySheetWidgetFactory widgetFactory) {
    if (expressionProposalLableProvider == null) {
        expressionProposalLableProvider = new ExpressionLabelProvider();
    }
    contentAssistText = new ContentAssistText(control, expressionProposalLableProvider, style);

    textControl = contentAssistText.getTextControl();
    if (widgetFactory != null) {
        widgetFactory.adapt(textControl, false, false);
    }
    textControl.addDisposeListener(disposeListener);
    textTooltip = new DefaultToolTip(textControl) {

        @Override
        protected boolean shouldCreateToolTip(final Event event) {
            return super.shouldCreateToolTip(event) && getText(event) != null;
        }
    };
    textTooltip.setShift(new Point(5, 5));
    textTooltip.setRespectMonitorBounds(true);
    textTooltip.setPopupDelay(100);

    typeDecoration = new ControlDecoration(contentAssistText.getToolbar(), SWT.LEFT, control);
    typeDecoration.setMarginWidth(0);

    messageDecoration = new ControlDecoration(contentAssistText, SWT.LEFT, control);
    messageDecoration.setShowHover(true);
    messageDecoration.setMarginWidth(1);
    messageDecoration.hide();

    contentAssistText.addContentAssistListener(this);
    autoCompletion = contentAssistText.getAutocompletion();
    autoCompletion.addExpressionProposalListener(this);

    int indent = 0;
    if ((style & SWT.PASSWORD) != 0) {
        isPassword = true;
    }
    if ((style & SWT.BORDER) != 0) {
        indent = 16;
    }
    contentAssistText.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).indent(indent, 0)
            .grab(true, false).create());
}