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

The following examples show how to use org.eclipse.jface.fieldassist.ControlDecoration#show() . 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: ClaferValidation.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * check if the given string is a valid clafer name and use the {@link ControlDecoration} to give feedback
 *
 * @param claferName {@link String} name to be tested
 * @param decoration {@link ControlDecoration} to display the error message in, hide if the string is valid
 * @return
 */
public static boolean validateClaferName(final String claferName, final boolean required, final ControlDecoration decoration) {
	boolean valid = true;

	final String result = getNameValidationMessage(claferName, required);
	if (!result.isEmpty()) {
		decoration.setImage(UIConstants.DEC_ERROR);
		decoration.setDescriptionText(result);
		decoration.show();
		valid = false;
	} else {
		decoration.hide();
	}

	return valid;
}
 
Example 2
Source File: ExtractClassWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void updateDecoration(ControlDecoration decoration, RefactoringStatus status) {
	RefactoringStatusEntry highestSeverity= status.getEntryWithHighestSeverity();
	if (highestSeverity != null) {
		Image newImage= null;
		FieldDecorationRegistry registry= FieldDecorationRegistry.getDefault();
		switch (highestSeverity.getSeverity()) {
			case RefactoringStatus.INFO:
				newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage();
				break;
			case RefactoringStatus.WARNING:
				newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage();
				break;
			case RefactoringStatus.FATAL:
			case RefactoringStatus.ERROR:
				newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();
		}
		decoration.setDescriptionText(highestSeverity.getMessage());
		decoration.setImage(newImage);
		decoration.show();
	} else {
		decoration.setDescriptionText(null);
		decoration.hide();
	}
}
 
Example 3
Source File: GenericTransactionWizard.java    From offspring with MIT License 6 votes vote down vote up
public void requestVerification() {
  boolean verified = true;
  for (IGenericTransactionField field : transaction.getFields()) {
    String[] message = new String[1];
    ControlDecoration deco = decorators.get(field.getLabel());
    if (field.verify(message)) {
      deco.hide();
    }
    else {
      deco.setDescriptionText(message[0]);
      deco.show();
      verified = false;
    }
  }

  createPage._canFlipToNextPage = verified;
  try {
    getContainer().updateButtons();
  }
  catch (Exception e) {}
}
 
Example 4
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 5
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 6
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 7
Source File: DocumentWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private Button createRadioButtonMultiple(final Composite compo) {
    final Button radioButtonMultiple = new Button(compo, SWT.RADIO);
    radioButtonMultiple.setText(Messages.radioButtonMultiple);
    radioButtonMultiple.setLayoutData(GridDataFactory.swtDefaults().create());
    final ControlDecoration infoBonita = new ControlDecoration(radioButtonMultiple, SWT.RIGHT);
    infoBonita.show();
    infoBonita.setImage(Pics.getImage(PicsConstants.hint));
    infoBonita.setDescriptionText(Messages.radioButtonMultipleToolTip);

    radioButtonMultiple.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (radioButtonMultiple.getSelection()) {
                updateSingleMultipleStack(true);
            }
        }
    });
    return radioButtonMultiple;
}
 
Example 8
Source File: DocumentWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private Button createRadioButtonExternal(final Composite compo) {
    final Button radioButtonExternal = new Button(compo, SWT.RADIO);
    radioButtonExternal.setText(Messages.initialValueButtonExternal);
    final ControlDecoration infoExternal = new ControlDecoration(radioButtonExternal, SWT.RIGHT);
    infoExternal.show();
    infoExternal.setImage(Pics.getImage(PicsConstants.hint));
    infoExternal.setDescriptionText(Messages.initialValueButtonExternalToolTip);
    radioButtonExternal.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            super.widgetSelected(e);
            if (radioButtonExternal.getSelection()) {
                updateStack(DocumentType.EXTERNAL);
                updateMimeTypeEnabled(true);
            }
        }

    });
    return radioButtonExternal;
}
 
Example 9
Source File: DocumentWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private Button createRadioButtonInternal(final Composite compo) {
    final Button radioButtonInternal = new Button(compo, SWT.RADIO);
    radioButtonInternal.setText(Messages.initialValueButtonInternal);
    final ControlDecoration infoBonita = new ControlDecoration(radioButtonInternal, SWT.RIGHT);
    infoBonita.show();
    infoBonita.setImage(Pics.getImage(PicsConstants.hint));
    infoBonita.setDescriptionText(Messages.initialValueButtonInternalToolTip);
    radioButtonInternal.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            super.widgetSelected(e);
            if (radioButtonInternal.getSelection()) {
                updateStack(DocumentType.INTERNAL);
                updateMimeTypeEnabled(true);
            }
        }

    });
    return radioButtonInternal;
}
 
Example 10
Source File: ClaferValidation.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
public static boolean validateClaferInheritance(final String inheritanceName, final boolean required, final ControlDecoration decoration) {
	boolean valid = true;

	final String result = getInheritanceValidationMessage(inheritanceName, required);
	if (!result.isEmpty()) {
		decoration.setImage(UIConstants.DEC_ERROR);
		decoration.setDescriptionText(result);
		decoration.show();
		valid = false;
	} else {
		decoration.hide();
	}

	return valid;
}
 
Example 11
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 12
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 13
Source File: DataExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void updateTypeTextControlDecorationVisibility(final ControlDecoration cd) {
    final String typeAsString = typeText.getText();
    if (Date.class.getName().equals(typeAsString)
            || String.class.getName().equals(
                    typeAsString)) {
        cd.hide();
    } else {
        cd.show();
    }
}
 
Example 14
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();
	}

}