コード例 #1
0
 public static String getText(Object object) {
   if (object instanceof EObject) {
     EObject eObject = (EObject) object;
     ExtendedPropertiesAdapter adapter =
         (ExtendedPropertiesAdapter) AdapterUtil.adapt(eObject, ExtendedPropertiesAdapter.class);
     if (adapter != null) return adapter.getObjectDescriptor().getText(eObject);
     return getDisplayName(eObject);
   }
   return object.toString();
 }
コード例 #2
0
 /*
  * Various model object and feature UI property methods
  */
 public static String getLabel(Object object) {
   String label = "";
   if (object instanceof EObject) {
     EObject eObject = (EObject) object;
     ExtendedPropertiesAdapter adapter =
         (ExtendedPropertiesAdapter) AdapterUtil.adapt(eObject, ExtendedPropertiesAdapter.class);
     if (adapter != null) label = adapter.getObjectDescriptor().getLabel(eObject);
     else label = ModelUtil.toDisplayName(eObject.eClass().getName());
   } else label = object.toString();
   label = label.replaceAll(" Ref$", "");
   return label;
 }
コード例 #3
0
    @SuppressWarnings("unchecked")
    @Override
    protected void internalSet(
        DataAssociation association, EStructuralFeature feature, Object value, int index) {
      EObject container = null;
      EStructuralFeature containerFeature = null;
      if (value instanceof Property) {
        if (((Property) value).eContainer() == null) {
          // this Property isn't owned by anything yet - figure out who the owner is
          container = ModelUtil.findNearestAncestor(association, new Class[] {Activity.class});
          if (container == null)
            container = ModelUtil.findNearestAncestor(association, new Class[] {Event.class});
          if (container == null)
            container = ModelUtil.findNearestAncestor(association, new Class[] {Process.class});
          containerFeature = container.eClass().getEStructuralFeature("properties"); // $NON-NLS-1$
        }
      } else if (value instanceof DataStore) {
        if (((DataStore) value).eContainer() == null) {
          // this DataStore isn't owned by anything yet - figure out who the owner is
          container = ModelUtil.findNearestAncestor(association, new Class[] {DocumentRoot.class});
          containerFeature = container.eClass().getEStructuralFeature("dataStore"); // $NON-NLS-1$
        }
      } else if (value instanceof String) {
        // first check if a property with this name already exists
        Hashtable<String, Object> choices = getChoiceOfValues();
        Property property = (Property) choices.get(value);
        if (property == null) {
          // need to create a new one!
          DiagramEditor editor = ModelUtil.getEditor(object);
          ModelEnablements modelEnablement =
              (ModelEnablements) editor.getAdapter(ModelEnablements.class);
          // find nearest element that can contain a Property and create one
          container = association;
          for (; ; ) {
            container =
                ModelUtil.findNearestAncestor(
                    container, new Class[] {Activity.class, Event.class, Process.class});
            if (container == null) return;
            containerFeature =
                container.eClass().getEStructuralFeature("properties"); // $NON-NLS-1$
            if (modelEnablement.isEnabled(container.eClass(), containerFeature)) break;
          }

          containerFeature = container.eClass().getEStructuralFeature("properties"); // $NON-NLS-1$
          property = Bpmn2ModelerFactory.create(Property.class);
          ExtendedPropertiesAdapter adapter = ExtendedPropertiesAdapter.adapt(property);
          adapter.getObjectDescriptor().setTextValue((String) value);
        }
        value = property;
      }

      final EObject c = container;
      final EStructuralFeature cf = containerFeature;
      final ItemAwareElement v = (ItemAwareElement) value;

      if (feature == Bpmn2Package.eINSTANCE.getDataAssociation_SourceRef()) {
        setSourceRef(association, v, c, cf);
      } else {
        setTargetRef(association, v, c, cf);
      }
    }