Exemplo n.º 1
0
  @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]);
      }
    }
  }
Exemplo n.º 2
0
 @Override
 public Fifo getFifoIded(String id) {
   for (Fifo fifo : this.getFifos()) {
     if (fifo.getId().equals(id)) {
       return fifo;
     }
   }
   return null;
 }
Exemplo n.º 3
0
 /**
  * Retrieve the {@link PictogramElement} of the {@link Diagram} corresponding to the given {@link
  * Fifo}.
  *
  * @param diagram the {@link Diagram} containing the {@link PictogramElement}
  * @param fifo the {@link Fifo} whose {@link PictogramElement} is searched.
  * @return the {@link PictogramElement} of the {@link Fifo}.
  * @throws RuntimeException if no {@link PictogramElement} could be found in this {@link Diagram}
  *     for this {@link Fifo}.
  */
 public static ContainerShape getDelayPE(Diagram diagram, Fifo fifo) throws RuntimeException {
   // Get all delays with identical attributes (may not be the
   // right delay is several delays have the same properties.)
   List<PictogramElement> pes =
       Graphiti.getLinkService().getPictogramElements(diagram, fifo.getDelay());
   PictogramElement pe = null;
   for (PictogramElement p : pes) {
     if (p instanceof ContainerShape
         && Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(p)
             == fifo.getDelay()) {
       pe = p;
     }
   }
   // if PE is still null.. something is deeply wrong with this
   // graph !
   if (pe == null) {
     throw new RuntimeException(
         "Pictogram element associated to delay of Fifo " + fifo.getId() + " could not be found.");
   }
   return (ContainerShape) pe;
 }