Ejemplo n.º 1
0
  @Override
  protected Command getCreateCommand(CreateRequest request) {
    Rectangle bounds = getConstraintFor(request);

    if (request.getNewObjectType() instanceof EClass) {
      EClass eClass = (EClass) request.getNewObjectType();

      // Archimate type object
      if (IArchimatePackage.eINSTANCE.getArchimateElement().isSuperTypeOf(eClass)) {
        return new CreateDiagramArchimateObjectCommand(getHost(), request, bounds);
      }
    }

    return super.getCreateCommand(request);
  }
Ejemplo n.º 2
0
  /*
   * Over-ride this to get any extra constraints for an object
   */
  @Override
  protected Rectangle getConstraintFor(CreateRequest request) {
    Rectangle bounds = (Rectangle) super.getConstraintFor(request);

    Dimension d = getMaximumSizeFor(request.getNewObjectType());
    bounds.width = Math.min(d.width, bounds.width);
    bounds.height = Math.min(d.height, bounds.height);

    return bounds;
  }
 /* (non-Javadoc)
  * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
  */
 protected Command getCreateCommand(CreateRequest request) {
   Object newObjectType = request.getNewObjectType();
   Command createCommand = null;
   if (newObjectType == ProvidesDef.class
       || newObjectType == UsesDef.class
       || newObjectType == PublishesDef.class
       || newObjectType == ConsumesDef.class) {
     CreateNodeCommand create = new CreateNodeCommand();
     Dimension dim = request.getSize();
     if (dim == null) dim = new Dimension(100, 20);
     create.setConstraint(new Rectangle(request.getLocation(), dim));
     create.setParent((View) getHost().getModel());
     create.setModelParent(((View) getHost().getModel()).getModuleDef());
     create.setModelObject((Contained) request.getNewObject());
     create.setLabel("create a node");
     createCommand = create;
   }
   return createCommand;
 }