Esempio n. 1
0
  public ILabelProvider getLabelProvider() {
    final IItemLabelProvider itemLabelProvider = itemPropertyDescriptor.getLabelProvider(object);
    return new LabelProvider() {
      @Override
      public String getText(Object object) {
        return itemLabelProvider.getText(object);
      }

      @Override
      public Image getImage(Object object) {
        return ExtendedImageRegistry.getInstance().getImage(itemLabelProvider.getImage(object));
      }
    };
  }
Esempio n. 2
0
  protected CellEditor createDatatypeCellEditor(
      final Collection<? extends IReference> datatypes, Composite composite) {
    if (itemPropertyDescriptor.isMultiLine(object)) {
      return new ExtendedDialogCellEditor(composite, getEditLabelProvider()) {
        protected DatatypeValueHandler valueHandler = new DatatypeValueHandler(datatypes);

        @Override
        protected Object openDialogBox(Control cellEditorWindow) {
          InputDialog dialog =
              new MultiLineInputDialog(
                  cellEditorWindow.getShell(),
                  KommaEditUIPlugin.INSTANCE.getString(
                      "_UI_FeatureEditorDialog_title",
                      new Object[] {getDisplayName(), getEditLabelProvider().getText(object)}),
                  KommaEditUIPlugin.INSTANCE.getString("_UI_MultiLineInputDialog_message"),
                  valueHandler.toString(getValue()),
                  valueHandler);
          return dialog.open() == Window.OK ? valueHandler.toValue(dialog.getValue()) : null;
        }
      };
    }
    return new DatatypeCellEditor(datatypes, composite);
  }
Esempio n. 3
0
 public String[] getFilterFlags() {
   return itemPropertyDescriptor.getFilterFlags(object);
 }
Esempio n. 4
0
 public String getDisplayName() {
   return itemPropertyDescriptor.getDisplayName(object);
 }
Esempio n. 5
0
 public String getDescription() {
   return itemPropertyDescriptor.getDescription(object);
 }
Esempio n. 6
0
 public String getCategory() {
   return itemPropertyDescriptor.getCategory(object);
 }
Esempio n. 7
0
  /**
   * This returns the cell editor that will be used to edit the value of this property. This default
   * implementation determines the type of cell editor from the nature of the structural feature.
   */
  public CellEditor createPropertyEditor(Composite composite) {
    if (!itemPropertyDescriptor.canSetProperty(object)) {
      return null;
    }

    CellEditor result = null;

    Object genericProperty = itemPropertyDescriptor.getProperty(object);
    if (genericProperty instanceof IReference[]) {
      result =
          new ExtendedComboBoxCellEditor(
              composite,
              new ArrayList<Object>(itemPropertyDescriptor.getChoiceOfValues(object)),
              getEditLabelProvider(),
              itemPropertyDescriptor.isSortChoices(object));
    } else if (!(genericProperty instanceof AnnotationProperty
        || genericProperty instanceof DatatypeProperty
        || genericProperty instanceof OntologyProperty)) {
      final IProperty property = (IProperty) genericProperty;
      final Collection<?> choiceOfValues = itemPropertyDescriptor.getChoiceOfValues(object);
      if (choiceOfValues != null) {
        if (itemPropertyDescriptor.isMany(object)) {
          // boolean valid = true;
          // for (Object choice : choiceOfValues) {
          // if (!property.isRangeCompatible((IResource) object,
          // choice)) {
          // valid = false;
          // break;
          // }
          // }
          //
          // if (valid) {
          final ILabelProvider editLabelProvider = getEditLabelProvider();
          result =
              new ExtendedDialogCellEditor(composite, editLabelProvider) {
                @Override
                protected Object openDialogBox(Control cellEditorWindow) {
                  PropertyEditorDialog dialog =
                      new PropertyEditorDialog(
                          cellEditorWindow.getShell(),
                          adapterFactory,
                          editLabelProvider,
                          (IObject) object,
                          property.getNamedRanges((IObject) object, true).toSet(),
                          (Collection<?>) doGetValue(),
                          getDisplayName(),
                          new ArrayList<Object>(choiceOfValues),
                          false,
                          itemPropertyDescriptor.isSortChoices(object));
                  dialog.open();
                  return dialog.getResult();
                }
              };
          // }
        }

        if (result == null) {
          result =
              new ExtendedComboBoxCellEditor(
                  composite,
                  new ArrayList<Object>(choiceOfValues),
                  getEditLabelProvider(),
                  itemPropertyDescriptor.isSortChoices(object));
        }
      }
    } else if (genericProperty instanceof IProperty) {
      final IProperty property = (IProperty) genericProperty;
      if (itemPropertyDescriptor.isMany(object)) {
        final ILabelProvider editLabelProvider = getEditLabelProvider();
        result =
            new ExtendedDialogCellEditor(composite, editLabelProvider) {
              @Override
              protected Object openDialogBox(Control cellEditorWindow) {
                PropertyEditorDialog dialog =
                    new PropertyEditorDialog(
                        cellEditorWindow.getShell(),
                        adapterFactory,
                        editLabelProvider,
                        (IObject) object,
                        property.getRanges(true).toSet(),
                        (Collection<?>) doGetValue(),
                        getDisplayName(),
                        null,
                        itemPropertyDescriptor.isMultiLine(object),
                        false);
                dialog.open();
                return dialog.getResult();
              }
            };
      } else if (property.getRdfsRanges().contains(XMLSCHEMA.TYPE_BOOLEAN)) {
        result =
            new ExtendedComboBoxCellEditor(
                composite,
                Arrays.asList(new Object[] {Boolean.FALSE, Boolean.TRUE}),
                getEditLabelProvider(),
                itemPropertyDescriptor.isSortChoices(object));
      } else {
        result =
            createDatatypeCellEditor(
                property.getNamedRanges((IObject) object, true).toSet(), composite);
      }
    }

    return result;
  }
Esempio n. 8
0
 public Object getId() {
   return itemPropertyDescriptor.getId(object);
 }
Esempio n. 9
0
 public Object getHelpContextIds() {
   return itemPropertyDescriptor.getHelpContextIds(object);
 }