예제 #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));
      }
    };
  }
예제 #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);
  }
예제 #3
0
 public String[] getFilterFlags() {
   return itemPropertyDescriptor.getFilterFlags(object);
 }
예제 #4
0
 public String getDisplayName() {
   return itemPropertyDescriptor.getDisplayName(object);
 }
예제 #5
0
 public String getDescription() {
   return itemPropertyDescriptor.getDescription(object);
 }
예제 #6
0
 public String getCategory() {
   return itemPropertyDescriptor.getCategory(object);
 }
예제 #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;
  }
예제 #8
0
 public Object getId() {
   return itemPropertyDescriptor.getId(object);
 }
예제 #9
0
 public Object getHelpContextIds() {
   return itemPropertyDescriptor.getHelpContextIds(object);
 }