@Override public Object getNewObject() { if (fTemplate == null) { return null; } Object object = fTemplate.create(Util.verifyNonNull(folder)); // Connection created from Relationship ITemplate if (object instanceof IBasicRelationship) { IDiagramModelZentaConnection connection = IZentaFactory.eINSTANCE.createDiagramModelZentaConnection(); connection.setRelationship((IBasicRelationship) object); return connection; } // Zenta Diagram Object created from Zenta Element ITemplate else if (object instanceof IZentaElement) { IZentaElement element = (IZentaElement) object; element.setName(fTemplate.getName()); return createDiagramModelZentaObject(element); } // Group else if (object instanceof IDiagramModelGroup) { ((IDiagramModelGroup) object).setName(Messages.ZentaDiagramModelFactory_0); } return object; }
/** * @param relation * @return A sentence that describes the relationship between the relationship's source and target * elements */ public String getRelationshipSentence(IBasicRelationship relation) { if (relation != null) { String nameSource = ZentaLabelProvider.INSTANCE.getLabel(relation.getSource()); String nameTarget = ZentaLabelProvider.INSTANCE.getLabel(relation.getTarget()); IBasicObject klass = relation.getDefiningElement(); String relname = klass.getName(); return String.format("%s %s %s", nameSource, relname, nameTarget); } return ""; //$NON-NLS-1$ }
public ImageDescriptor getImageDescriptor(IBasicObject obj) { if (!obj.isTemplate()) obj = obj.getAncestor(); return getImageDescriptorNonTemplate(obj.eClass()); }