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

The following examples show how to use org.eclipse.jface.fieldassist.ControlDecoration#setImage() . 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: 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 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: 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 4
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 5
Source File: FieldDecoratorProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ControlDecoration createControlDecorator(final Control control, final String description, final String fieldDecorationType, final int style) {
    final FieldDecoration decorator = getDecorator(fieldDecorationType);
    final ControlDecoration controlDecoration = newControlDecoration(control, style);
    controlDecoration.setImage(decorator.getImage());
    controlDecoration.setDescriptionText(description);
    control.addControlListener(new CellEditorControlAdapter(control));
    return controlDecoration;
}
 
Example 6
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;

}
 
Example 7
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 8
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 9
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 10
Source File: CheckBoxVar.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public CheckBoxVar( final VariableSpace space, final Composite composite, int flags, String variable ) {
  super( composite, SWT.NONE );

  props.setLook( this );

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  // add a text field on it...
  wBox = new Button( this, flags );
  props.setLook( wBox );
  wText = new TextVar( space, this, flags | SWT.NO_BACKGROUND );
  wText.getTextWidget().setForeground( GUIResource.getInstance().getColorRed() ); // Put it in a red color to make it
                                                                                  // shine...
  wText.getTextWidget().setBackground( composite.getBackground() ); // make it blend in with the rest...

  setVariableOnCheckBox( variable );

  controlDecoration = new ControlDecoration( wBox, SWT.CENTER | SWT.LEFT );
  Image image = GUIResource.getInstance().getImageVariable();
  controlDecoration.setImage( image );
  controlDecoration.setDescriptionText( BaseMessages.getString( PKG, "CheckBoxVar.tooltip.InsertVariable" ) );
  controlDecoration.addSelectionListener( new SelectionAdapter() {

    @Override
    public void widgetSelected( SelectionEvent arg0 ) {
      String variableName = VariableButtonListenerFactory.getVariableName( composite.getShell(), space );
      if ( variableName != null ) {
        setVariableOnCheckBox( "${" + variableName + "}" );
      }
    }
  } );

  FormData fdBox = new FormData();
  fdBox.top = new FormAttachment( 0, 0 );
  fdBox.left = new FormAttachment( 0, image.getBounds().width );
  wBox.setLayoutData( fdBox );

  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( wBox, Const.MARGIN );
  fdText.right = new FormAttachment( 100, 0 );
  wText.setLayoutData( fdText );
}
 
Example 11
Source File: TextVarButton.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected void initialize( VariableSpace space, Composite composite, int flags, String toolTipText,
    GetCaretPositionInterface getCaretPositionInterface, InsertTextInterface insertTextInterface,
    SelectionListener selectionListener ) {
  this.toolTipText = toolTipText;
  this.getCaretPositionInterface = getCaretPositionInterface;
  this.insertTextInterface = insertTextInterface;
  this.variables = space;

  PropsUI.getInstance().setLook( this );

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;
  this.setLayout( formLayout );

  Button button = new Button( this, SWT.PUSH );
  PropsUI.getInstance().setLook( button );
  button.setText( "..." );
  FormData fdButton = new FormData();
  fdButton.top = new FormAttachment( 0, 0 );
  fdButton.right = new FormAttachment( 100, 0 );
  fdButton.height = 25;
  fdButton.width = 30;
  button.setLayoutData( fdButton );
  if ( selectionListener != null ) {
    button.addSelectionListener( selectionListener );
  }

  wText = new Text( this, flags );
  controlDecoration = new ControlDecoration( wText, SWT.CENTER | SWT.RIGHT, this );
  Image image = GUIResource.getInstance().getImageVariable();
  controlDecoration.setImage( image );
  controlDecoration.setDescriptionText( BaseMessages.getString( PKG, "TextVar.tooltip.InsertVariable" ) );
  PropsUI.getInstance().setLook( controlDecoration.getControl() );

  modifyListenerTooltipText = getModifyListenerTooltipText( wText );
  wText.addModifyListener( modifyListenerTooltipText );

  controlSpaceKeyAdapter =
      new ControlSpaceKeyAdapter( variables, wText, getCaretPositionInterface, insertTextInterface );
  wText.addKeyListener( controlSpaceKeyAdapter );

  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( 0, 0 );
  fdText.right = new FormAttachment( button, -image.getBounds().width );
  wText.setLayoutData( fdText );
}
 
Example 12
Source File: CheckBoxVar.java    From hop with Apache License 2.0 4 votes vote down vote up
public CheckBoxVar( final IVariables variables, final Composite composite, int flags, String variable ) {
  super( composite, SWT.NONE );

  props.setLook( this );

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  // add a text field on it...
  wBox = new Button( this, flags );
  props.setLook( wBox );
  wText = new TextVar( variables, this, flags | SWT.NO_BACKGROUND );
  wText.getTextWidget().setForeground( GuiResource.getInstance().getColorRed() ); // Put it in a red color to make it
  // shine...
  wText.getTextWidget().setBackground( composite.getBackground() ); // make it blend in with the rest...

  setVariableOnCheckBox( variable );

  controlDecoration = new ControlDecoration( wBox, SWT.CENTER | SWT.LEFT );
  Image image = GuiResource.getInstance().getImageVariable();
  controlDecoration.setImage( image );
  controlDecoration.setDescriptionText( BaseMessages.getString( PKG, "CheckBoxVar.tooltip.InsertVariable" ) );
  controlDecoration.addSelectionListener( new SelectionAdapter() {

    @Override
    public void widgetSelected( SelectionEvent arg0 ) {
      String variableName = VariableButtonListenerFactory.getVariableName( composite.getShell(), variables );
      if ( variableName != null ) {
        setVariableOnCheckBox( "${" + variableName + "}" );
      }
    }
  } );

  FormData fdBox = new FormData();
  fdBox.top = new FormAttachment( 0, 0 );
  fdBox.left = new FormAttachment( 0, image.getBounds().width );
  wBox.setLayoutData( fdBox );

  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( wBox, props.getMargin() );
  fdText.right = new FormAttachment( 100, 0 );
  wText.setLayoutData( fdText );
}
 
Example 13
Source File: TextVarWarning.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public TextVarWarning( VariableSpace space, Composite composite, int flags ) {
  super( composite, SWT.NONE );

  warningInterfaces = new ArrayList<WarningInterface>();

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  // add a text field on it...
  wText = new TextVar( space, this, flags );

  warningControlDecoration = new ControlDecoration( wText, SWT.CENTER | SWT.RIGHT );
  Image warningImage = GUIResource.getInstance().getImageWarning();
  warningControlDecoration.setImage( warningImage );
  warningControlDecoration.setDescriptionText( BaseMessages.getString( PKG, "TextVar.tooltip.FieldIsInUse" ) );
  warningControlDecoration.hide();

  // If something has changed, check the warning interfaces
  //
  wText.addModifyListener( new ModifyListener() {
    public void modifyText( ModifyEvent arg0 ) {

      // Verify all the warning interfaces.
      // Show the first that has a warning to show...
      //
      boolean foundOne = false;
      for ( WarningInterface warningInterface : warningInterfaces ) {
        WarningMessageInterface warningSituation =
          warningInterface.getWarningSituation( wText.getText(), wText, this );
        if ( warningSituation.isWarning() ) {
          foundOne = true;
          warningControlDecoration.show();
          warningControlDecoration.setDescriptionText( warningSituation.getWarningMessage() );
          break;
        }
      }
      if ( !foundOne ) {
        warningControlDecoration.hide();
      }
    }
  } );

  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( 0, 0 );
  fdText.right = new FormAttachment( 100, -warningImage.getBounds().width );
  wText.setLayoutData( fdText );
}
 
Example 14
Source File: ComboVar.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public ComboVar( VariableSpace space, Composite composite, int flags, String toolTipText,
                 GetCaretPositionInterface getCaretPositionInterface, InsertTextInterface insertTextInterface ) {
  super( composite, SWT.NONE );
  this.toolTipText = toolTipText;
  this.getCaretPositionInterface = getCaretPositionInterface;
  this.insertTextInterface = insertTextInterface;
  this.variables = space;

  // props.setLook(this);

  // int margin = Const.MARGIN;
  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  // add a text field on it...
  wCombo = new CCombo( this, flags );

  Image image = GUIResource.getInstance().getImageVariable();
  controlDecoration = new ControlDecoration( wCombo, SWT.CENTER | SWT.RIGHT, this );
  controlDecoration.setImage( image );
  controlDecoration.setDescriptionText( BaseMessages.getString( PKG, "TextVar.tooltip.InsertVariable" ) );

  // props.setLook(wText);
  modifyListenerTooltipText = getModifyListenerTooltipText( wCombo );
  wCombo.addModifyListener( modifyListenerTooltipText );

  // SelectionAdapter lsVar = null;
  // VariableButtonListenerFactory.getSelectionAdapter(this, wText, getCaretPositionInterface,
  // insertTextInterface, variables);
  // wText.addKeyListener(getControlSpaceKeyListener(variables, wText, lsVar, getCaretPositionInterface,
  // insertTextInterface));

  controlSpaceKeyAdapter =
    new ControlSpaceKeyAdapter( variables, wCombo, getCaretPositionInterface, insertTextInterface );
  wCombo.addKeyListener( controlSpaceKeyAdapter );

  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( 0, 0 );
  fdText.right = new FormAttachment( 100, -image.getBounds().width );
  wCombo.setLayoutData( fdText );
}
 
Example 15
Source File: SuffixText.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a decoration with the given image for this text.
 *
 * Note that the decoration is only displayed in focus.
 */
public void createDecoration(Image decorationImage) {
	contentProposalDecoration = new ControlDecoration(this, SWT.TOP | SWT.LEFT);
	contentProposalDecoration.setImage(decorationImage);
	contentProposalDecoration.hide();
}
 
Example 16
Source File: DataWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void createDataOptions(final Composite parent) {

        new Label(parent, SWT.NONE); // FILLER
        final Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
        composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 0).spacing(25, 0).create());

        multiplicityButton = new Button(composite, SWT.CHECK);
        multiplicityButton.setLayoutData(GridDataFactory.fillDefaults().create());
        multiplicityButton.setText(Messages.isMultiple);
        final ControlDecoration multiplicityControlDecoration = new ControlDecoration(multiplicityButton, SWT.RIGHT);
        multiplicityControlDecoration.setImage(Pics.getImage(PicsConstants.hint));
        multiplicityControlDecoration.setDescriptionText(Messages.multiplicity_hint);

        if (showIsTransient) {
            isTransientButton = new Button(composite, SWT.CHECK);
            isTransientButton.setText(Messages.transientLabel);
            final ControlDecoration controlDecoration = new ControlDecoration(isTransientButton, SWT.RIGHT);
            controlDecoration.setImage(Pics.getImage(PicsConstants.hint));
            controlDecoration.setDescriptionText(Messages.transientHint);
        }

        if (showAutoGenerateform) {
            final IConfigurationElement[] elements = BonitaStudioExtensionRegistryManager.getInstance()
                    .getConfigurationElements(
                            "org.bonitasoft.studio.properties.widget"); //$NON-NLS-1$
            IWidgetContribtution generateDataContribution = null;
            for (final IConfigurationElement elem : elements) {
                try {
                    if (elem.getAttribute("id").equals(GENERATE_DATA_CONTRIBUTION_ID)) { //$NON-NLS-1$
                        generateDataContribution = (IWidgetContribtution) elem.createExecutableExtension("class"); //$NON-NLS-1$
                    }
                } catch (final CoreException e) {
                    BonitaStudioLog.error(e);
                }
            }

            if (generateDataContribution != null) {
                generateDataCheckbox = (Button) generateDataContribution.createControl(composite);
            }
        }

        if (showAutoGenerateform && showIsTransient) {
            if (generateDataCheckbox != null) {
                generateDataCheckbox.setLayoutData(GridDataFactory.swtDefaults().create());
            }
            isTransientButton.setLayoutData(GridDataFactory.fillDefaults().create());
        } else if (showAutoGenerateform && !showIsTransient && generateDataCheckbox != null) {
            generateDataCheckbox.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).create());
        } else if (!showAutoGenerateform && showIsTransient) {
            isTransientButton.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).create());
        }

        if (showIsTransient) {
            transientDataWarning = new CLabel(composite, SWT.WRAP);
            transientDataWarning.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create());
            transientDataWarning.setText(Messages.transientDataWarning);
            transientDataWarning
                    .setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
            transientDataWarning.setVisible(data.isTransient());
        }
    }
 
Example 17
Source File: PromptFeeDeadline.java    From offspring with MIT License 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
  Composite container = (Composite) super.createDialogArea(parent);
  GridLayout layout = new GridLayout(2, false);
  layout.marginRight = 5;
  layout.marginLeft = 10;
  container.setLayout(layout);

  Label feeLabel = new Label(container, SWT.NONE);
  feeLabel.setText("Fee");

  feeText = new Text(container, SWT.BORDER);
  feeText
      .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
  feeText.setText(Integer.toString(minimumFee));

  decoFee = new ControlDecoration(feeText, SWT.TOP | SWT.RIGHT);
  decoFee.setImage(errorImage);
  decoFee.hide();

  Label deadlineLabel = new Label(container, SWT.NONE);
  deadlineLabel.setText("Deadline");

  deadlineText = new Text(container, SWT.BORDER);
  deadlineText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
      1, 1));
  deadlineText.setText(Integer.toString(deadline));

  decoDeadline = new ControlDecoration(deadlineText, SWT.TOP | SWT.RIGHT);
  decoDeadline.setImage(errorImage);
  decoDeadline.hide();

  ModifyListener listener = new ModifyListener() {

    @Override
    public void modifyText(ModifyEvent e) {
      Button button = getButton(IDialogConstants.OK_ID);
      if (button != null) {
        button.setEnabled(verifyInput());
      }
    }
  };
  feeText.addModifyListener(listener);
  deadlineText.addModifyListener(listener);

  return container;
}
 
Example 18
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);
}
 
Example 19
Source File: WarningText.java    From hop with Apache License 2.0 4 votes vote down vote up
public WarningText( Composite composite, int flags ) {
  super( composite, SWT.NONE );

  warningInterfaces = new ArrayList<IWarning>();

  FormLayout formLayout = new FormLayout();
  formLayout.marginWidth = 0;
  formLayout.marginHeight = 0;
  formLayout.marginTop = 0;
  formLayout.marginBottom = 0;

  this.setLayout( formLayout );

  // add a text field on it...
  wText = new Text( this, flags );

  warningControlDecoration = new ControlDecoration( wText, SWT.CENTER | SWT.RIGHT );
  Image warningImage = GuiResource.getInstance().getImageWarning();
  warningControlDecoration.setImage( warningImage );
  warningControlDecoration.setDescriptionText( BaseMessages.getString( PKG, "TextVar.tooltip.FieldIsInUse" ) );
  warningControlDecoration.hide();

  // If something has changed, check the warning interfaces
  //
  wText.addModifyListener( new ModifyListener() {
    public void modifyText( ModifyEvent arg0 ) {

      // Verify all the warning interfaces.
      // Show the first that has a warning to show...
      //
      boolean foundOne = false;
      for ( IWarning warningInterface : warningInterfaces ) {
        IWarningMessage warningSituation =
          warningInterface.getWarningSituation( wText.getText(), wText, this );
        if ( warningSituation.isWarning() ) {
          foundOne = true;
          warningControlDecoration.show();
          warningControlDecoration.setDescriptionText( warningSituation.getWarningMessage() );
          break;
        }
      }
      if ( !foundOne ) {
        warningControlDecoration.hide();
      }
    }
  } );

  FormData fdText = new FormData();
  fdText.top = new FormAttachment( 0, 0 );
  fdText.left = new FormAttachment( 0, 0 );
  fdText.right = new FormAttachment( 100, -warningImage.getBounds().width );
  wText.setLayoutData( fdText );
}
 
Example 20
Source File: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createReturnTypeComposite(Composite parent) {
    Composite returnTypeComposite = formPage.getToolkit().createComposite(parent);
    returnTypeComposite.setLayout(GridLayoutFactory.fillDefaults().create());
    returnTypeComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());

    Label queryResultTypeLabel = formPage.getToolkit().createLabel(returnTypeComposite, Messages.queryResultType);
    queryResultTypeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create());

    returnTypeComboViewer = new ComboViewer(returnTypeComposite, SWT.BORDER | SWT.READ_ONLY);
    returnTypeComboViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(false, false).hint(300, SWT.DEFAULT).create());
    returnTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    returnTypeComboViewer.setLabelProvider(new QueryResultTypeLabelProvider(boSelectedObservable));
    updateReturnTypeViewerInput();

    Label queryResultTypeInfoLabel = formPage.getToolkit().createLabel(returnTypeComposite,
            Messages.queryReturnTypeWarning);
    queryResultTypeInfoLabel
            .setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).indent(20, 0).create());

    ControlDecoration typeinfo = new ControlDecoration(queryResultTypeInfoLabel, SWT.LEFT);
    typeinfo.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO));
    typeinfo.setMarginWidth(5);

    querySelectedObservable.addValueChangeListener(e -> {
        if (isDefault()) {
            returnTypeComboViewer.getControl().setEnabled(false);
        } else {
            returnTypeComboViewer.getControl().setEnabled(true);
        }
    });

    boSelectedObservable.addValueChangeListener(e -> updateReturnTypeViewerInput());

    IObservableValue<String> returnTypeSelectionObservable = ViewerProperties.singleSelection(String.class)
            .observe(returnTypeComboViewer);
    IObservableValue<String> returnTypeObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
            querySelectedObservable, BusinessDataModelPackage.Literals.QUERY__RETURN_TYPE);
    ctx.bindValue(returnTypeSelectionObservable, returnTypeObservable);
    returnTypeObservable.addValueChangeListener(e -> queryViewer.refresh()); // might impact the info tooltip for the count queries
}