コード例 #1
0
  @Override
  protected Object run(final Presentation context) {
    final FormComponentPresentation p = (FormComponentPresentation) context;
    final SapphirePart part = (SapphirePart) getPart();

    final Set<Property> properties = new LinkedHashSet<Property>();
    collectProperties(part, properties);

    for (Iterator<Property> itr = properties.iterator(); itr.hasNext(); ) {
      if (itr.next().empty()) {
        itr.remove();
      }
    }

    if (properties.isEmpty()) {
      MessageDialog.openInformation(p.shell(), dialogTitle.text(), nothingToDoMessage.text());
    } else {
      final Set<Property> selectedProperties = PromptDialog.open(p.shell(), properties);

      for (Property property : selectedProperties) {
        property.clear();
      }
    }

    return null;
  }
コード例 #2
0
  @Override
  protected void facts(final SortedSet<String> facts) {
    final Value<?> value = context(Value.class);
    final String def = value.getDefaultText();

    if (def != null) {
      if (value.definition().hasAnnotation(SensitiveData.class)) {
        facts.add(statementForSensitive.text());
      } else {
        facts.add(statement.format(new ValueSnapshot(value.definition(), def)));
      }
    }
  }
コード例 #3
0
  protected void initBindingMetadata() {
    final XmlListBinding annotation = property().definition().getAnnotation(XmlListBinding.class);
    final XmlNamespaceResolver xmlNamespaceResolver =
        ((XmlResource) property().element().resource()).getXmlNamespaceResolver();

    final SortedSet<ElementType> possible = this.possibleTypesService.types();
    this.modelElementTypes = possible.toArray(new ElementType[possible.size()]);

    if (annotation == null) {
      this.path = new XmlPath(property().name(), xmlNamespaceResolver);

      this.xmlElementNames = new QName[this.modelElementTypes.length];

      for (int i = 0; i < this.modelElementTypes.length; i++) {
        this.xmlElementNames[i] =
            createDefaultElementName(this.modelElementTypes[i], xmlNamespaceResolver);
      }
    } else {
      if (annotation.path().length() > 0) {
        this.path = new XmlPath(annotation.path(), xmlNamespaceResolver);
      }

      final XmlListBinding.Mapping[] mappings = annotation.mappings();
      this.xmlElementNames = new QName[this.modelElementTypes.length];

      for (int i = 0; i < this.modelElementTypes.length; i++) {
        final ElementType type = this.modelElementTypes[i];

        for (XmlListBinding.Mapping mapping : mappings) {
          if (mapping.type() == type.getModelElementClass()) {
            final String mappingElementName = mapping.element().trim();

            if (mappingElementName.length() == 0) {
              throw new RuntimeException(mustSpecifyElementNameMsg.text());
            }

            this.xmlElementNames[i] = createQualifiedName(mappingElementName, xmlNamespaceResolver);

            break;
          }
        }

        if (this.xmlElementNames[i] == null) {
          this.xmlElementNames[i] = createDefaultElementName(type, xmlNamespaceResolver);
        }
      }
    }
  }
コード例 #4
0
  @Override
  protected Status compute() {
    if (!this.versionCompatibilityService.compatible() && !context(Property.class).empty()) {
      final String message;

      final Version version = this.versionCompatibilityService.version();
      final String versioned = this.versionCompatibilityService.versioned();

      if (version == null) {
        message = versionConstraintTargetNotFoundMessage.text();
      } else {
        message = notCompatibleWithVersionMessage.format(version.toString(), versioned);
      }

      return Status.createErrorStatus(message);
    }

    return Status.createOkStatus();
  }
コード例 #5
0
    @Override
    protected Control createDialogArea(final Composite parent) {
      getShell().setText(dialogTitle.text());

      final Composite composite = (Composite) super.createDialogArea(parent);

      final Label messageLabel = new Label(composite, SWT.WRAP);
      messageLabel.setText(dialogMessage.text());
      messageLabel.setLayoutData(gdwhint(gdhfill(), 300));

      final CheckboxTableViewer tableViewer =
          CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
      final Table table = tableViewer.getTable();

      table.setLayoutData(gdhhint(gdwhint(gdfill(), 300), 300));

      tableViewer.setContentProvider(
          new IStructuredContentProvider() {
            public Object[] getElements(final Object inputElement) {
              return PromptDialog.this.allProperties.toArray();
            }

            public void inputChanged(
                final Viewer viewer, final Object oldInput, final Object newInput) {}

            public void dispose() {}
          });

      tableViewer.setLabelProvider(
          new ITableLabelProvider() {
            public String getColumnText(final Object element, final int columnIndex) {
              final PropertyDef property = ((Property) element).definition();
              return property.getLabel(true, CapitalizationType.FIRST_WORD_ONLY, false);
            }

            public Image getColumnImage(final Object element, final int columnIndex) {
              return null;
            }

            public boolean isLabelProperty(final Object element, final String property) {
              return false;
            }

            public void addListener(final ILabelProviderListener listener) {}

            public void removeListener(final ILabelProviderListener listener) {}

            public void dispose() {}
          });

      tableViewer.setCheckStateProvider(
          new ICheckStateProvider() {
            public boolean isChecked(final Object element) {
              return PromptDialog.this.selectedProperties.contains(element);
            }

            public boolean isGrayed(final Object element) {
              return false;
            }
          });

      tableViewer.addCheckStateListener(
          new ICheckStateListener() {
            public void checkStateChanged(final CheckStateChangedEvent event) {
              final Property property = (Property) event.getElement();

              if (event.getChecked() == true) {
                PromptDialog.this.selectedProperties.add(property);
              } else {
                PromptDialog.this.selectedProperties.remove(property);
              }
            }
          });

      tableViewer.setInput(this);

      return composite;
    }