Esempio n. 1
0
  /** Adds validation overlay component to the control. */
  private void addValidationOverlay(
      final AttributeDescriptor descriptor,
      final IAttributeEditor editor,
      final Object defaultValue,
      final Control label) {
    final ControlDecoration decoration = new ControlDecoration(label, SWT.LEFT | SWT.BOTTOM);
    decoration.hide();

    final FieldDecoration requiredDecoration =
        FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);

    decoration.setImage(requiredDecoration.getImage());
    decoration.setDescriptionText("Invalid value");

    final IAttributeListener validationListener =
        new InvalidStateDecorationListener(decoration, descriptor, defaultValue);

    globalEventsProvider.addAttributeListener(validationListener);
    editor.addAttributeListener(validationListener);

    label.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            globalEventsProvider.removeAttributeListener(validationListener);
            editor.removeAttributeListener(validationListener);
            decoration.dispose();
          }
        });
  }
 private void createUIFieldDecorationTemplate() {
   // Decorate the combo with the info image
   int bits = SWT.TOP | SWT.LEFT;
   fControlDecoration = new ControlDecoration(fFieldTemplateCombo.getControl(), bits);
   // Configure decoration
   // No margin
   fControlDecoration.setMarginWidth(0);
   // Custom hover tip text
   fControlDecoration.setDescriptionText(
       PDEUIMessages.SplashConfigurationSection_msgDecorationTemplateSupport);
   // Custom hover properties
   fControlDecoration.setShowHover(true);
   // Hover image to use
   FieldDecoration contentProposalImage =
       FieldDecorationRegistry.getDefault()
           .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
   fControlDecoration.setImage(contentProposalImage.getImage());
   // Hide the decoration initially
   fControlDecoration.hide();
 }