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

The following examples show how to use org.eclipse.jface.fieldassist.ControlDecoration#setShowOnlyOnFocus() . 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: FieldAssistHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void showErrorDecoration( AssistField smartField, boolean show )
{
	FieldDecoration dec = smartField.getErrorDecoration( );
	ControlDecoration cd = smartField.controlDecoration;
	if ( show )
	{
		cd.setImage( dec.getImage( ) );
		cd.setDescriptionText( dec.getDescription( ) );
		cd.setShowOnlyOnFocus( false );
		cd.show( );
	}
	else
	{
		cd.hide( );
	}
}
 
Example 3
Source File: FieldAssistHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void showWarningDecoration( AssistField smartField, boolean show )
{
	FieldDecoration dec = smartField.getWarningDecoration( );
	ControlDecoration cd = smartField.controlDecoration;
	if ( show )
	{
		cd.setImage( dec.getImage( ) );
		cd.setDescriptionText( dec.getDescription( ) );
		cd.setShowOnlyOnFocus( false );
		cd.show( );
	}
	else
	{
		cd.hide( );
	}
}
 
Example 4
Source File: FieldAssistHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void showContentAssistDecoration( AssistField smartField,
		boolean show )
{
	FieldDecoration dec = getCueDecoration( );
	ControlDecoration cd = smartField.controlDecoration;
	if ( show )
	{
		cd.setImage( dec.getImage( ) );
		cd.setDescriptionText( dec.getDescription( ) );
		cd.setShowOnlyOnFocus( true );
		cd.show( );
	}
	else
	{
		cd.hide( );
	}
}
 
Example 5
Source File: DataViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createTitle(Composite parent) {
    Composite titleComposite = widgetFactory.createComposite(parent);
    titleComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    titleComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    Label label = widgetFactory.createLabel(titleComposite, getTitle(), SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().grab(false, false).create());

    ControlDecoration controlDecoration = new ControlDecoration(label, SWT.RIGHT, titleComposite);
    controlDecoration.setShowOnlyOnFocus(false);
    controlDecoration.setDescriptionText(getTitleDescripiton());
    controlDecoration.setImage(Pics.getImage(PicsConstants.hint));

    Composite toolBarComposite = widgetFactory.createComposite(titleComposite);
    toolBarComposite.setLayout(GridLayoutFactory.fillDefaults().create());
    toolBarComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).grab(true, false).create());
    ToolBar toolBar = new ToolBar(toolBarComposite, SWT.HORIZONTAL | SWT.RIGHT | SWT.NO_FOCUS | SWT.FLAT);
    widgetFactory.adapt(toolBar);
    toolBar.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
    createToolItems(toolBar);
}
 
Example 6
Source File: WorkspaceWizardPage.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds the content proposal field decoration to a given control.
 *
 * @param control
 *            The control to decorate
 */
private ControlDecoration createContentProposalDecoration(Control control) {
	ControlDecoration decoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT);
	decoration.setImage(contentProposalDecorationImage);
	decoration.setShowOnlyOnFocus(true);
	return decoration;
}
 
Example 7
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 8
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 9
Source File: BusinessObjectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected ExpressionViewer createDefaultValueControl(final Composite mainComposite, final EMFDataBindingContext ctx) {
    final Label defaultValue = new Label(mainComposite, SWT.NONE);
    defaultValue.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create());
    defaultValue.setText(Messages.defaultValue);

    final ExpressionViewer defaultValueExpressionViewer = new ExpressionViewer(mainComposite, SWT.BORDER);
    defaultValueExpressionViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    defaultValueExpressionViewer
            .addFilter(new AvailableExpressionTypeFilter(ExpressionConstants.SCRIPT_TYPE, ExpressionConstants.QUERY_TYPE,
                    ExpressionConstants.CONTRACT_INPUT_TYPE, ExpressionConstants.PARAMETER_TYPE));
    defaultValueExpressionViewer.addEditorFilter(ExpressionConstants.CONTRACT_INPUT_TYPE,
            ExpressionConstants.PARAMETER_TYPE);
    defaultValueExpressionViewer
            .setExpressionNameResolver(new DataDefaultValueExpressionNameResolver(businessObjectData));
    final ControlDecoration hint = new ControlDecoration(defaultValueExpressionViewer.getTextControl(), SWT.LEFT);//TODO: remove me for 7.0.0 GA
    hint.setShowOnlyOnFocus(false);
    hint.setImage(imageProvider.getHintImage());
    hint.setDescriptionText(
            Messages.defaultValueBusinessDataTooltip);

    defaultValueExpressionViewer.setInput(container);
    ctx.bindValue(ViewersObservables.observeSingleSelection(defaultValueExpressionViewer),
            EMFObservables.observeValue(businessObjectData, ProcessPackage.Literals.DATA__DEFAULT_VALUE));
    defaultReturnTypeObservable = PojoObservables.observeValue(defaultValueExpressionViewer, "defaultReturnType");
    ctx.bindValue(defaultReturnTypeObservable, classNameObservable, neverUpdateValueStrategy().create(),
            updateValueStrategy().withConverter(listConverter()).create());
    ctx.bindValue(defaultReturnTypeObservable, multipleObservableValue, neverUpdateValueStrategy().create(),
            updateValueStrategy().withConverter(multipleConverter()).create());
    return defaultValueExpressionViewer;

}
 
Example 10
Source File: SelectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createActionModeSelectionRadioButtons(DataBindingContext dbc, Composite parent) {
    Label actionLabel = new Label(parent, SWT.NONE);
    actionLabel.setLayoutData(GridDataFactory.fillDefaults().create());
    actionLabel.setText(Messages.action);
    actionLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));

    Composite buttonComposite = new Composite(parent, SWT.NONE);
    buttonComposite.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
    buttonComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).spacing(20, 0).create());

    Button createButton = new Button(buttonComposite, SWT.RADIO);
    createButton.setText(Messages.createDataFromContractChoice);

    ControlDecoration createModeCcontrolDecoration = new ControlDecoration(createButton, SWT.RIGHT);
    createModeCcontrolDecoration.setDescriptionText(Messages.createActionHint);
    createModeCcontrolDecoration.setImage(Pics.getImage(PicsConstants.hint));
    createModeCcontrolDecoration.setShowOnlyOnFocus(false);
    createModeCcontrolDecoration.setMarginWidth(-5);

    Button editButton = new Button(buttonComposite, SWT.RADIO);
    editButton.setText(Messages.editDataFromContractChoice);

    ControlDecoration editModeCcontrolDecoration = new ControlDecoration(editButton, SWT.RIGHT);
    editModeCcontrolDecoration.setDescriptionText(Messages.editActionHint);
    editModeCcontrolDecoration.setImage(Pics.getImage(PicsConstants.hint));
    editModeCcontrolDecoration.setShowOnlyOnFocus(false);
    editModeCcontrolDecoration.setMarginWidth(-5);

    SelectObservableValue creationTypeObservable = new SelectObservableValue<EditMode>(EditMode.class);
    creationTypeObservable.addOption(EditMode.CREATE, WidgetProperties.selection().observe(createButton));
    creationTypeObservable.addOption(EditMode.EDIT, WidgetProperties.selection().observe(editButton));
    editButton.setEnabled(contract.eContainer() instanceof Task);
    generateOptions.setEditMode(contract.eContainer() instanceof Task ? EditMode.EDIT : EditMode.CREATE);
    dbc.bindValue(creationTypeObservable, generateOptions.getEditModeObservable());
}
 
Example 11
Source File: MethodSelectorPage.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createControl(final Composite parent) {
	final Composite container = new Composite(parent, SWT.NULL);
	setControl(container);
	container.setLayout(new GridLayout(2, false));
	new Label(container, SWT.NONE);
	new Label(container, SWT.NONE);

	this.encryptionLabel = new Label(container, SWT.NULL);
	this.encryptionLabel.setText("Select the encryption method:   ");

	final Combo encryptionCombo = new Combo(container, SWT.NONE);
	final GridData gd_combo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
	gd_combo.widthHint = 140;
	encryptionCombo.setLayoutData(gd_combo);
	new Label(container, SWT.NONE);
	new Label(container, SWT.NONE);

	// Field assist
	final ControlDecoration deco = new ControlDecoration(encryptionCombo, SWT.CENTER | SWT.RIGHT);
	final Image image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
	deco.setDescriptionText("Sample text");
	deco.setImage(image);
	deco.setShowOnlyOnFocus(false);
	deco.show();

	final Label decryptionLabel = new Label(container, SWT.NONE);
	decryptionLabel.setText("Select the decryption method:   ");

	final Combo decryptionCombo = new Combo(container, SWT.NONE);
	decryptionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	new Label(container, SWT.NONE);
	new Label(container, SWT.NONE);

	final Label keyGenerationLabel = new Label(container, SWT.NONE);
	keyGenerationLabel.setText("Select the keyGeneration method: ");
	final Combo keyGenerationCombo = new Combo(container, SWT.NONE);
	keyGenerationCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

	try {
		// import project
		this.project.ImportProject(this.projectPath);
		this.project.setProject(UserJavaProject.cloneProject(this.project.getProject().getName()));
		this.project.addPackage(Constants.PRIMITIVE_PACKAGE);
		// Display methods from the imported project in the combo box
		for (final IMethod method : this.project.listOfAllMethods()) {
			encryptionCombo.add(method.getElementName());
			decryptionCombo.add(method.getElementName());
		}

	}
	catch (final CoreException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
Example 12
Source File: QueryExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createQueryParametersTable(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true).create());
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 2).create());

    final Label parameterLabel = new Label(composite, SWT.NONE);
    parameterLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create());
    parameterLabel.setText(Messages.parameters);

    final ControlDecoration parameterDecoration = new ControlDecoration(parameterLabel, SWT.RIGHT);
    parameterDecoration.setShowOnlyOnFocus(false);
    parameterDecoration.setDescriptionText(Messages.paginationParameterHint);
    parameterDecoration.setImage(Pics.getImage(PicsConstants.hint));
    parameterDecoration.hide();
    observeQuerySingleSelection.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final Object newValue = event.diff.getNewValue();
            if (newValue instanceof Expression) {
                if (List.class.getName().equals(((Expression) newValue).getReturnType())) {
                    parameterDecoration.show();
                } else {
                    parameterDecoration.hide();
                }
            }

        }
    });

    final TableViewer parametersTableViewer = new TableViewer(composite,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
    parametersTableViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80).create());
    parametersTableViewer.getTable().setLinesVisible(true);
    parametersTableViewer.getTable().setHeaderVisible(true);
    parametersTableViewer.setContentProvider(new ObservableListContentProvider());

    queryParameterObserveDetailList = EMFObservables.observeDetailList(Realm.getDefault(),
            observeQuerySingleSelection,
            ExpressionPackage.Literals.EXPRESSION__REFERENCED_ELEMENTS);

    final TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnWeightData(1, true));
    tableLayout.addColumnData(new ColumnWeightData(1, true));
    parametersTableViewer.getTable().setLayout(tableLayout);

    createNameColumn(parametersTableViewer);
    createValueColumn(parametersTableViewer);

    parametersTableViewer.setInput(queryParameterObserveDetailList);
}