@Override public Object[] create(ICreateContext context) { // Retrieve the graph PiGraph graph = (PiGraph) getBusinessObjectForPictogramElement(getDiagram()); // Ask user for Actor name until a valid name is entered. String question = "Enter new round buffer actor name"; String newActorName = "RoundBufferActorName"; newActorName = PiMMUtil.askString( "Create Round Buffer Actor", question, newActorName, new VertexNameValidator(graph, null)); if (newActorName == null || newActorName.trim().length() == 0) { this.hasDoneChanges = false; // If this is not done, the graph is considered modified. return EMPTY; } // create Actor RoundBufferActor newActor = PiMMFactory.eINSTANCE.createRoundBufferActor(); newActor.setName(newActorName); // Add new actor to the graph. if (graph.getVertices().add(newActor)) { this.hasDoneChanges = true; } // do the add to the Diagram addGraphicalRepresentation(context, newActor); // return newly created business object(s) return new Object[] {newActor}; }
@Override public void execute(ICustomContext context) { // Re-check if only one element is selected PictogramElement[] pes = context.getPictogramElements(); if (pes != null && pes.length == 1) { Object bo = getBusinessObjectForPictogramElement(pes[0]); if (bo instanceof Fifo) { Fifo fifo = (Fifo) bo; // Ask user for data type. String question = "Enter data type for the FIFO"; String oldType = fifo.getType(); String type = oldType; type = PiMMUtil.askString(getName(), question, type, null); if ((type == null && oldType == null) || (type != null && type.equals(oldType))) { this.hasDoneChanges = false; } else { this.hasDoneChanges = true; } fifo.setType(type); // Call the layout feature layoutPictogramElement(pes[0]); } } }