コード例 #1
0
  /**
   * Returns the modelObject ID string from the given Graphiti context.
   *
   * @param context
   * @return - ID string for this modelObject.
   */
  public static String getId(IContext context) {
    Object id = null;

    /**
     * IAddContext can also mean that a file is dragged, therefore we have to check if we are really
     * dragging a customTask
     */
    if (context instanceof IAddContext
        && ((IAddContext) context).getNewObject() instanceof EObject) {
      EObject object = (EObject) ((IAddContext) context).getNewObject();
      TargetRuntime rt = TargetRuntime.getCurrentRuntime();
      for (CustomTaskDescriptor ct : rt.getCustomTasks()) {
        id = ct.getFeatureContainer().getId(object);
        if (id != null) {
          context.putProperty(CUSTOM_TASK_ID, id);
          return (String) id;
        }
      }
    }

    if (context instanceof IPictogramElementContext) {
      PictogramElement pe = ((IPictogramElementContext) context).getPictogramElement();
      id = Graphiti.getPeService().getPropertyValue(pe, CUSTOM_TASK_ID);
    } else {
      id = context.getProperty(CUSTOM_TASK_ID);
    }
    return (String) id;
  }
コード例 #2
0
 private CustomTaskDescriptor getCustomTaskDescriptor(EObject object) {
   TargetRuntime rt = getTargetRuntime(object);
   if (rt != null) {
     for (CustomTaskDescriptor ctd : rt.getCustomTaskDescriptors()) {
       if (ctd.getFeatureContainer() != null) {
         String id = ctd.getFeatureContainer().getId(object);
         if (ctd.getId().equals(id)) {
           return ctd;
         }
       }
     }
   }
   return null;
 }
コード例 #3
0
 @Override
 public String getText(Object element) {
   EObject object = getBusinessObject(element);
   if (object != null) {
     String text = ExtendedPropertiesProvider.getTextValue(object);
     // check if this is a CustomTask
     CustomTaskDescriptor ctd = getCustomTaskDescriptor(object);
     if (ctd != null) {
       // it is! build the property tab title from the CustomTask name
       // and the object's name (which could be the same)
       String name = ctd.getName();
       if (!text.equals(name)) return name + ": " + text; // $NON-NLS-1$
     }
     return text;
   }
   //		PictogramElement pe =
   // BusinessObjectUtil.getPictogramElementForSelection((ISelection)element);
   //		if (pe!=null && pe.getGraphicsAlgorithm()!=null) {
   //			return ModelUtil.getLabel( pe.getGraphicsAlgorithm() );
   //		}
   return super.getText(element);
 }