org.eclipse.jface.fieldassist.ControlDecoration Java Examples

The following examples show how to use org.eclipse.jface.fieldassist.ControlDecoration. 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: 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 #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: 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 #5
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 #6
Source File: WrappingValidator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param controlDecoration
 * @param validator
 */
public WrappingValidator(ControlDecoration controlDecoration, IValidator validator, boolean onlyChangeDecoration, boolean updateMessage) {
    this.controlDecoration = controlDecoration;
    this.validator = validator;
    this.onlyChangeDecoration = onlyChangeDecoration;
    this.updateMessage = updateMessage;

    FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
    error = fieldDecoration.getImage();
    fieldDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING);
    warn = fieldDecoration.getImage();
    fieldDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
    info = fieldDecoration.getImage();

}
 
Example #7
Source File: ServerPortExtension.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public void createControl(UI_POSITION position, Composite parent) {
  // We add controls only to the BOTTOM position.
  if (position == UI_POSITION.BOTTOM) {
    portLabel = new Label(parent, SWT.NONE);
    portLabel.setVisible(false);
    portLabel.setText(Messages.getString("NEW_SERVER_DIALOG_PORT"));

    portText = new Text(parent, SWT.SINGLE | SWT.BORDER);
    portText.setVisible(false);
    portText.setText(String.valueOf(LocalAppEngineServerBehaviour.DEFAULT_SERVER_PORT));
    portText.addVerifyListener(new PortChangeMonitor());
    portText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
    Image errorImage = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();

    portDecoration = new ControlDecoration(portText, SWT.LEFT | SWT.TOP);
    portDecoration.setDescriptionText(Messages.getString("NEW_SERVER_DIALOG_INVALID_PORT_VALUE"));
    portDecoration.setImage(errorImage);
    portDecoration.hide();
  }
}
 
Example #8
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 #9
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 #10
Source File: DynamicLabelPropertySectionContribution.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
   public void createControl(final Composite composite, final TabbedPropertySheetWidgetFactory widgetFactory, final ExtensibleGridPropertySection extensibleGridPropertySection) {
GridData gd = (GridData) composite.getLayoutData();
gd.grabExcessHorizontalSpace = true;
ControlDecoration controlDecoration = new ControlDecoration(composite.getChildren()[0], SWT.RIGHT);
       controlDecoration.setDescriptionText(Messages.bind(Messages.warningDisplayLabelMaxLength, MAX_LENGTH, MAX_LENGTH));
       controlDecoration.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
       expressionViewer = new ExpressionViewer(composite,SWT.BORDER,widgetFactory,editingDomain, ProcessPackage.Literals.FLOW_ELEMENT__DYNAMIC_LABEL);
       expressionViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
       expressionViewer.addFilter(new AvailableExpressionTypeFilter(new String[]{ExpressionConstants.CONSTANT_TYPE,ExpressionConstants.VARIABLE_TYPE,ExpressionConstants.PARAMETER_TYPE,ExpressionConstants.SCRIPT_TYPE}));
       expressionViewer.setExpressionNameResolver(new DefaultExpressionNameResolver("displayName"));
       expressionViewer.setInput(eObject) ;
       expressionViewer.setMessage(Messages.dynamicLabelHint) ;
       expressionViewer.addExpressionValidator(new ExpressionLengthValidator(MAX_LENGTH));
       refreshDataBindingContext();
   }
 
Example #11
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 #12
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 #13
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 #14
Source File: ExtractClassWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createParameterNameInput(Composite group) {
	Label l= new Label(group, SWT.NONE);
	l.setText(RefactoringMessages.ExtractClassWizard_field_name);

	final Text text= new Text(group, SWT.BORDER);
	fParameterNameDecoration= new ControlDecoration(text, SWT.TOP | SWT.LEAD);
	text.setText(fDescriptor.getFieldName());
	text.addModifyListener(new ModifyListener() {

		public void modifyText(ModifyEvent e) {
			fDescriptor.setFieldName(text.getText());
			validateRefactoring();
		}

	});
	GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
	gridData.horizontalIndent= FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
	text.setLayoutData(gridData);
}
 
Example #15
Source File: ExtractClassWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createClassNameInput(Composite result) {
	Label label= new Label(result, SWT.LEAD);
	label.setText(RefactoringMessages.ExtractClassWizard_label_class_name);
	final Text text= new Text(result, SWT.SINGLE | SWT.BORDER);
	fClassNameDecoration= new ControlDecoration(text, SWT.TOP | SWT.LEAD);
	text.setText(fDescriptor.getClassName());
	text.selectAll();
	text.setFocus();
	text.addModifyListener(new ModifyListener() {

		public void modifyText(ModifyEvent e) {
			fDescriptor.setClassName(text.getText());
			validateRefactoring();
		}

	});
	GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
	gridData.horizontalIndent= FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
	text.setLayoutData(gridData);
}
 
Example #16
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 #17
Source File: RelationFieldDetailsControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createLoadingModeRadioButtons() {
    Composite buttonsComposite = formPage.getToolkit().createComposite(this);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).spacing(20, 5).create());
    buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().create());

    Button lazyRadio = formPage.getToolkit().createButton(buttonsComposite, Messages.loadOnDemand, SWT.RADIO);
    lazyRadio.setLayoutData(GridDataFactory.fillDefaults().create());

    ControlDecoration lazyDecorator = new ControlDecoration(lazyRadio, SWT.RIGHT);
    lazyDecorator.setImage(Pics.getImage(PicsConstants.hint));
    lazyDecorator.setDescriptionText(Messages.loadOnDemandHint);

    Button eagerRadio = formPage.getToolkit().createButton(buttonsComposite, Messages.alwaysLoad, SWT.RADIO);
    eagerRadio.setLayoutData(GridDataFactory.fillDefaults().create());

    ControlDecoration eagerDecorator = new ControlDecoration(eagerRadio, SWT.RIGHT);
    eagerDecorator.setImage(Pics.getImage(PicsConstants.hint));
    eagerDecorator.setDescriptionText(Messages.alwaysLoadHint);

    SelectObservableValue<FetchType> radioGroupObservable = new SelectObservableValue<>(FetchType.class);
    radioGroupObservable.addOption(FetchType.LAZY, WidgetProperties.selection().observe(lazyRadio));
    radioGroupObservable.addOption(FetchType.EAGER, WidgetProperties.selection().observe(eagerRadio));

    IObservableValue<FetchType> fetchTypeObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
            selectedFieldObservable, BusinessDataModelPackage.Literals.RELATION_FIELD__FETCH_TYPE);
    ctx.bindValue(radioGroupObservable, fetchTypeObservable);
}
 
Example #18
Source File: GenericTransactionWizard.java    From offspring with MIT License 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
  Composite composite = new Composite(parent, SWT.NONE);
  GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10)
      .spacing(20, 5).applyTo(composite);

  /* generate the wizard fields */
  for (IGenericTransactionField field : transaction.getFields()) {
    Label label = new Label(composite, SWT.NONE);
    label.setText(field.getLabel());

    Control control = field.createControl(composite);
    if (control instanceof Text && (control.getStyle() & SWT.V_SCROLL) != 0) {
      GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL)
          .grab(true, true).applyTo(control);
    }
    else {
      GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
          .grab(true, false).applyTo(control);
    }
    ControlDecoration deco = new ControlDecoration(control, SWT.TOP
        | SWT.RIGHT);
    deco.setImage(errorImage);
    deco.hide();
    decorators.put(field.getLabel(), deco);
  }
  setControl(composite);
}
 
Example #19
Source File: SignalEventEventSelectionContribution.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory,
    ExtensibleGridPropertySection extensibleGridPropertySection) {
combo = new Combo(composite, SWT.NONE);
combo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

controlDecoration = new ControlDecoration(combo, SWT.RIGHT | SWT.TOP);
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
	.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
controlDecoration.setImage(fieldDecoration.getImage());
controlDecoration.setDescriptionText(Messages.mustBeSet);
controlDecoration.hide();
hint = new ControlDecoration(combo, SWT.LEFT | SWT.TOP);
hint.setImage(Pics.getImage(PicsConstants.hint));
   }
 
Example #20
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 #21
Source File: RelationFieldDetailsControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createRelationKindLabel() {
    Composite composite = formPage.getToolkit().createComposite(this);
    composite.setLayout(GridLayoutFactory.fillDefaults().create());
    composite.setLayoutData(GridDataFactory.fillDefaults().create());

    Label relationLabel = formPage.getToolkit().createLabel(composite, Messages.relation);
    relationLabel.setLayoutData(GridDataFactory.fillDefaults().create());

    ControlDecoration controlDecoration = new ControlDecoration(relationLabel, SWT.RIGHT);
    controlDecoration.setDescriptionText(Messages.realtionTooltip);
    controlDecoration.setImage(Pics.getImage(PicsConstants.hint));
}
 
Example #22
Source File: TransitionOrderingPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createExplanationLabel(final Composite mainComposite) {
    final Label explanationLabel = getWidgetFactory().createLabel(mainComposite, Messages.transitionOrderingExplanation_Short,SWT.WRAP);
    explanationLabel.setLayoutData(GridDataFactory.swtDefaults().grab(false, false).span(2, 1).create());
    final ControlDecoration cd = new ControlDecoration(explanationLabel, SWT.RIGHT);
    final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
    cd.setImage(fieldDecoration.getImage());
    cd.setDescriptionText(Messages.transitionOrderingExplanation);
}
 
Example #23
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 #24
Source File: GroupsWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createNameField(final Group group) {
    final Label groupNameLabel = new Label(group, SWT.NONE);
    groupNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    groupNameLabel.setText(Messages.name + " *");

    final Text groupNameText = new Text(group, SWT.BORDER);
    groupNameText.setMessage(Messages.groupIdExample);
    groupNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(130, SWT.DEFAULT).create());

    final IObservableValue groupParentPathValue = EMFObservables.observeDetailValue(Realm.getDefault(), groupSingleSelectionObservable,
            OrganizationPackage.Literals.GROUP__PARENT_PATH);

    final GroupParentPathLengthValidator groupParentPathLengthValidator = new GroupParentPathLengthValidator(groupParentPathValue);
    final Binding binding = context.bindValue(SWTObservables.observeText(groupNameText, SWT.Modify),
            EMFObservables.observeDetailValue(Realm.getDefault(), groupSingleSelectionObservable, OrganizationPackage.Literals.GROUP__NAME),
            updateValueStrategy().withValidator(
                    multiValidator()
                            .addValidator(mandatoryValidator(Messages.name))
                            .addValidator(maxLengthValidator(Messages.name, GROUP_NAME_MAX_LENGTH))
                            .addValidator(regExpValidator(Messages.illegalCharacter, "^[^/]*$"))
                            .addValidator(new UniqueGroupNameValidator())
                            .addValidator(groupParentPathLengthValidator).create())
                    .create(),
            null);
    ControlDecorationSupport.create(binding, SWT.LEFT, group, new ControlDecorationUpdater() {

        @Override
        protected void update(final ControlDecoration decoration, final IStatus status) {
            if (groupSingleSelectionObservable.getValue() != null) {
                super.update(decoration, status);
            }
        }
    });

}
 
Example #25
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createNameField(final Group group) {
    final Label roleName = new Label(group, SWT.NONE);
    roleName.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    roleName.setText(Messages.name + " *");

    final Text roleNameText = new Text(group, SWT.BORDER);
    roleNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(130, SWT.DEFAULT).create());

    final IObservableValue roleNameValue = EMFObservables.observeDetailValue(Realm.getDefault(),
            roleSingleSelectionObservable, OrganizationPackage.Literals.ROLE__NAME);
    final Binding binding = context.bindValue(SWTObservables.observeText(roleNameText, SWT.Modify),
            roleNameValue,
            updateValueStrategy().withValidator(multiValidator()
                    .addValidator(mandatoryValidator(Messages.name))
                    .addValidator(maxLengthValidator(Messages.name, LONG_FIELD_MAX_LENGTH))
                    .addValidator(new UniqueRoleNameValidator()).create()).create(),
            null);

    ControlDecorationSupport.create(binding, SWT.LEFT, group, new ControlDecorationUpdater() {

        @Override
        protected void update(final ControlDecoration decoration, final IStatus status) {
            if (roleSingleSelectionObservable.getValue() != null) {
                super.update(decoration, status);
            }
        }
    });
    roleNameValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            handleRoleNameChange(event);
        }
    });
}
 
Example #26
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 #27
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 #28
Source File: SelectDatabaseOutputTypeWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Button createTableChoice(final Composite choicesComposite, EMFDataBindingContext context) {
    final Button tableRadio = new Button(choicesComposite, SWT.RADIO);
    tableRadio.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).create());
    tableRadio.setText(Messages.nRowsNcolumns);

    final ControlDecoration tableDeco = new ControlDecoration(tableRadio, SWT.RIGHT, choicesComposite);
    tableDeco.setImage(Pics.getImage(PicsConstants.hint));
    tableDeco.setDescriptionText(Messages.tableHint);

    final Label tableIcon = new Label(choicesComposite, SWT.NONE);
    tableIcon.setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(15, 0).grab(true, false).create());

    final UpdateValueStrategy selectImageStrategy = new UpdateValueStrategy();
    selectImageStrategy.setConverter(new Converter(Boolean.class, Image.class) {

        @Override
        public Object convert(Object fromObject) {
            if (fromObject != null && (Boolean) fromObject) {
                return Pics.getImage("table_placeholder.png", ConnectorPlugin.getDefault());
            } else {
                return Pics.getImage("table_placeholder_disabled.png", ConnectorPlugin.getDefault());
            }

        }

    });
    tableObserveEnabled = SWTObservables.observeEnabled(tableRadio);
    context.bindValue(SWTObservables.observeImage(tableIcon), tableObserveEnabled, null, selectImageStrategy);

    return tableRadio;
}
 
Example #29
Source File: SelectDatabaseOutputTypeWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Button createOneRowNColsChoice(final Composite choicesComposite, EMFDataBindingContext context) {
    final Button oneRowRadio = new Button(choicesComposite, SWT.RADIO);
    oneRowRadio.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).create());
    oneRowRadio.setText(Messages.oneRowNCol);

    final ControlDecoration oneRowDeco = new ControlDecoration(oneRowRadio, SWT.RIGHT, choicesComposite);
    oneRowDeco.setImage(Pics.getImage(PicsConstants.hint));
    oneRowDeco.setDescriptionText(Messages.oneRowHint);

    final Label oneRowIcon = new Label(choicesComposite, SWT.NONE);
    oneRowIcon.setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(15, 0).grab(true, false).create());

    final UpdateValueStrategy selectImageStrategy = new UpdateValueStrategy();
    selectImageStrategy.setConverter(new Converter(Boolean.class, Image.class) {

        @Override
        public Object convert(Object fromObject) {
            if (fromObject != null && (Boolean) fromObject) {
                return Pics.getImage("row_placeholder.png", ConnectorPlugin.getDefault());
            } else {
                return Pics.getImage("row_placeholder_disabled.png", ConnectorPlugin.getDefault());
            }

        }

    });
    oneRowNColModeRadioObserveEnabled = SWTObservables.observeEnabled(oneRowRadio);
    context.bindValue(SWTObservables.observeImage(oneRowIcon), oneRowNColModeRadioObserveEnabled, null,
            selectImageStrategy);

    return oneRowRadio;
}
 
Example #30
Source File: SelectDatabaseOutputTypeWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Button createNRowsOneColChoice(final Composite choicesComposite, EMFDataBindingContext context) {
    final Button oneColRadio = new Button(choicesComposite, SWT.RADIO);
    oneColRadio.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).create());
    oneColRadio.setText(Messages.nRowOneCol);

    final ControlDecoration oneColDeco = new ControlDecoration(oneColRadio, SWT.RIGHT, choicesComposite);
    oneColDeco.setImage(Pics.getImage(PicsConstants.hint));
    oneColDeco.setDescriptionText(Messages.oneColHint);

    final Label oneColIcon = new Label(choicesComposite, SWT.NONE);
    oneColIcon.setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(15, 0).grab(true, false).create());

    final UpdateValueStrategy selectImageStrategy = new UpdateValueStrategy();
    selectImageStrategy.setConverter(new Converter(Boolean.class, Image.class) {

        @Override
        public Object convert(Object fromObject) {
            if (fromObject != null && (Boolean) fromObject) {
                return Pics.getImage("column_placeholder.png", ConnectorPlugin.getDefault());
            } else {
                return Pics.getImage("column_placeholder_disabled.png", ConnectorPlugin.getDefault());
            }

        }

    });

    nRowsOneColModeRadioObserveEnabled = SWTObservables.observeEnabled(oneColRadio);
    context.bindValue(SWTObservables.observeImage(oneColIcon), nRowsOneColModeRadioObserveEnabled, null,
            selectImageStrategy);

    return oneColRadio;

}