コード例 #1
0
 /**
  * {@inheritDoc}
  *
  * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
  */
 @Override
 public Image getImage(Object element) {
   Image result = null;
   if (columnIndex == 0 && diagramPart != null) {
     final DiagramEditPart diaEditPart = diagramPart.getDiagramEditPart();
     final Object obj = diaEditPart.getModel();
     if (obj instanceof View) {
       final EObject designerElement = ((View) obj).getElement();
       if (designerElement instanceof DDiagram) {
         final List<Layer> activatedLayers = ((DDiagram) designerElement).getActivatedLayers();
         Image img = null;
         if (EqualityHelper.contains(activatedLayers, (EObject) element)) {
           img = DiagramUIPlugin.getPlugin().getBundledImage(DiagramImagesPath.ACTIVE_LAYER_ICON);
         } else {
           img =
               DiagramUIPlugin.getPlugin().getBundledImage(DiagramImagesPath.INACTIVE_LAYER_ICON);
         }
         result = img;
       }
     }
   } else if (columnIndex == 1) {
     if (element instanceof Layer) {
       Layer layer = (Layer) element;
       if (!StringUtil.isEmpty(layer.getIcon())) {
         result = ImageProvider.getImageFromPath(layer.getIcon());
       }
     }
   }
   return result;
 }
コード例 #2
0
 /**
  * This returns the label text for the adapted class.
  * <!-- begin-user-doc
  * -->
  * <!-- end-user-doc -->
  *
  * @not-generated
  */
 @Override
 public String getText(Object object) {
   String label = new IdentifiedElementQuery((IdentifiedElement) object).getLabel();
   return StringUtil.isEmpty(label)
       ? getString("_UI_DeleteTool_type")
       : getString("_UI_DeleteTool_type") + " " + label; // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 }
コード例 #3
0
 /**
  * Get the extension with the given id.
  *
  * @param id the requested id.
  * @return the format data manager descriptor with the requested id if it exists.
  */
 public static FormatDataManagerDescriptor getRegisteredExtension(String id) {
   for (FormatDataManagerDescriptor desc : EXTENSIONS.keySet()) {
     if (!StringUtil.isEmpty(desc.getId()) && desc.getId().equals(id)) {
       return desc;
     }
   }
   return null;
 }
コード例 #4
0
 /**
  * {@inheritDoc}
  *
  * @see org.eclipse.sirius.viewpoint.description.impl.AbstractNodeMappingImpl#getDomainClass()
  */
 @Override
 public String getDomainClass() {
   /*
    * Each import can have it owns domain class
    */
   if (StringUtil.isEmpty(super.getDomainClass()) && getImportedMapping() != null) {
     return getImportedMapping().getDomainClass();
   }
   return super.getDomainClass();
 }
コード例 #5
0
 @Override
 public boolean canExecute() {
   boolean canExecute = true;
   if (getCreationTool() != null) {
     if (getCreationTool().getFirstModelOperation() == null) {
       canExecute = false;
     } else {
       if (getCreationTool().getPrecondition() != null
           && !StringUtil.isEmpty(getCreationTool().getPrecondition().trim())) {
         IInterpreter interpreter = null;
         try {
           if (getTreeItem() != null) {
             interpreter = InterpreterUtil.getInterpreter(getTreeItem().getTarget());
             interpreter.setVariable(
                 IInterpreterSiriusVariables.ROOT, TreeHelper.getTree(getTreeItem()).getTarget());
             interpreter.setVariable(
                 IInterpreterSiriusVariables.ELEMENT, getTreeItem().getTarget());
             interpreter.setVariable(
                 IInterpreterSiriusVariables.CONTAINER,
                 ((DTreeItemContainer) getTreeItem().eContainer()).getTarget());
             canExecute =
                 interpreter.evaluateBoolean(
                     getTreeItem().getTarget(), getCreationTool().getPrecondition());
           } else {
             interpreter = InterpreterUtil.getInterpreter(getTable().getTarget());
             interpreter.setVariable(IInterpreterSiriusVariables.ROOT, getTable().getTarget());
             interpreter.setVariable(IInterpreterSiriusVariables.ELEMENT, getTable().getTarget());
             interpreter.setVariable(IInterpreterSiriusVariables.CONTAINER, null);
             canExecute =
                 interpreter.evaluateBoolean(
                     getTable().getTarget(), getCreationTool().getPrecondition());
           }
         } catch (final EvaluationException e) {
           RuntimeLoggerManager.INSTANCE.error(
               getCreationTool(),
               ToolPackage.eINSTANCE.getAbstractToolDescription_Precondition(),
               e);
         }
         interpreter.unSetVariable(IInterpreterSiriusVariables.ROOT);
         interpreter.unSetVariable(IInterpreterSiriusVariables.ELEMENT);
         interpreter.unSetVariable(IInterpreterSiriusVariables.CONTAINER);
       }
     }
   }
   return canExecute;
 }
 /**
  * @param semantic The semantic root of the diagram
  * @return The new diagram name
  * @throws InterruptedException If the user pressed cancel
  */
 private String askDiagramName(final EObject semantic) throws InterruptedException {
   final IInterpreter interpreter = InterpreterUtil.getInterpreter(semantic);
   String theName = new IdentifiedElementQuery(this.description).getLabel();
   if (!StringUtil.isEmpty(this.description.getTitleExpression())) {
     try {
       theName = interpreter.evaluateString(semantic, this.description.getTitleExpression());
     } catch (final EvaluationException e) {
       RuntimeLoggerManager.INSTANCE.error(
           this.description,
           DescriptionPackage.eINSTANCE.getRepresentationDescription_TitleExpression(),
           e);
     }
   }
   if (uiCallBack != null) {
     theName = uiCallBack.askForDetailName(theName, this.description.getEndUserDocumentation());
   }
   return theName;
 }
コード例 #7
0
 private static EObject tryToInstanciateType(
     TreeItemCreationTool createTool, EObject created, String map) {
   EObject result = created;
   if (!StringUtil.isEmpty(map)) {
     try {
       final EObject anInstance =
           SiriusPlugin.getDefault()
               .getModelAccessorRegistry()
               .getModelAccessor(createTool)
               .createInstance(map);
       result = anInstance;
     } catch (final MetaClassNotFoundException e) {
       /*
        * silent catch, it's just a bit more magic, if we're able to
        * retrieve the right type then we'll do.
        */
     }
   }
   return result;
 }