/** {@inheritDoc} */
  @Override
  public void paste(IPasteContext context) {
    // already verified, that pasting is allowed just directly in the diagram
    PictogramElement[] pes = context.getPictogramElements();
    Diagram diagram = (Diagram) pes[0];

    // get the PictogramElements from the clipboard and the linked business object.
    Object[] objects = getFromClipboard();
    for (Object object : objects) {
      PictogramElement pictogramElement = (PictogramElement) object;
      rootCon boRef = (rootCon) getBusinessObjectForPictogramElement(pictogramElement);
      rootCon bo = EcoreUtil.copy(boRef);
      addBusinessObjectToContainer(bo, pictogramElement);

      // create a new AddContext for the creation of a new shape.
      AddContext ac = new AddContext(new AddContext(), bo);
      ac.setLocation(0, 0); // for simplicity paste at (0, 0)
      ac.setTargetContainer(diagram); // paste on diagram
      // copy all properties from the shape (e.g. ALIAS etc.)
      for (Property prop : pictogramElement.getProperties()) {
        ac.putProperty(prop.getKey(), prop.getValue());
      }
      getFeatureProvider().addIfPossible(ac);
    }
  }
 public void paste(IPasteContext context) {
   // we already verified, that we paste directly in the diagram
   PictogramElement[] pes = context.getPictogramElements();
   Diagram diagram = (Diagram) pes[0];
   // get the EClasses from the clipboard without copying them
   // (only copy the pictogram element, not the business object)
   // then create new pictogram elements using the add feature
   Object[] objects = getFromClipboard();
   for (Object object : objects) {
     AddContext ac = new AddContext();
     // For simplicity paste all objects at the location given in the
     // context (no stacking or similar)
     ac.setLocation(context.getX(), context.getY());
     ac.setTargetContainer(diagram);
     addGraphicalRepresentation(ac, object);
   }
 }
  public boolean canPaste(IPasteContext context) {
    // only support pasting directly in the diagram (nothing else selected)
    PictogramElement[] pes = context.getPictogramElements();

    if (pes.length != 1 || !isPasteableContext(pes)) {
      return false;
    }

    List<FlowElement> copyList =
        ModelHandler.getKickstartProcessModel(EcoreUtil.getURI(getDiagram())).getClipboard();
    if (copyList.size() > 0) {
      return true;
    } else {
      return false;
    }
  }
Пример #4
0
  public boolean canPaste(IPasteContext context) {
    // only support pasting directly in the diagram (nothing else selected)
    PictogramElement[] pes = context.getPictogramElements();
    if (pes.length != 1 || !(pes[0] instanceof Diagram)) {
      return false;
    }

    // can paste, if all objects on the clipboard are AClasses
    Object[] fromClipboard = getFromClipboard();
    if (fromClipboard == null || fromClipboard.length == 0) {
      return false;
    }
    for (Object object : fromClipboard) {
      if (!(object instanceof AClass)) {
        return false;
      }
    }
    return true;
  }
 /** {@inheritDoc} */
 @Override
 public boolean canPaste(IPasteContext context) {
   // TODO: only support pasting directly in the diagram
   PictogramElement[] pes = context.getPictogramElements();
   if (pes.length != 1 || !(pes[0] instanceof Diagram)) {
     return false;
   }
   // can paste, if all objects on the clipboard are PictogramElements with link on subclasses of
   // rootCon
   Object[] fromClipboard = getFromClipboard();
   if (fromClipboard == null || fromClipboard.length == 0) {
     return false;
   }
   for (Object object : fromClipboard) {
     if (!(object instanceof PictogramElement)) {
       return false;
     } else if (!(getBusinessObjectForPictogramElement((PictogramElement) object)
         instanceof rootCon)) {
       return false;
     }
   }
   return true;
 }
  public boolean canPaste(IPasteContext context) {
    // only support pasting directly in the diagram (nothing else selected)
    PictogramElement[] pes = context.getPictogramElements();
    if (pes.length != 1 || !(pes[0] instanceof Diagram)) {
      return false;
    }

    // can paste, if clipboard is filled and all objects on the clipboard
    // are EClasses that can be resolved
    Object[] fromClipboard = getFromClipboard();
    if (fromClipboard == null || fromClipboard.length == 0) {
      return false;
    }
    for (Object object : fromClipboard) {
      if (object instanceof EObject) {
        if (!isResolvable((EObject) object)) {
          return false;
        }
      } else {
        return false;
      }
    }
    return true;
  }