/** @see ContainerEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest) */
 protected Command getCreateCommand(CreateRequest request) {
   CreateAndAssignSourceCommand cmd = new CreateAndAssignSourceCommand();
   cmd.setParent((StructuredActivity) getHost().getParent().getModel());
   cmd.setChild((Activity) request.getNewObject());
   cmd.setSource((Activity) getHost().getModel());
   return cmd;
 }
 protected Command getCreateCommand(CreateRequest request) {
   NodeCreateCommand createCommand = new NodeCreateCommand();
   createCommand.setNode((Node) request.getNewObject());
   createCommand.setParent((ProcessDefinition) getHost().getModel());
   createCommand.setLocation(request.getLocation());
   createCommand.setLabel("create a node");
   return createCommand;
 }
 /** @see LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest) */
 @Override
 protected Command getCreateCommand(CreateRequest request) {
   StructuredActivity parent = (StructuredActivity) getHost().getModel();
   EditPartViewer viewer = getHost().getViewer();
   CreateCommand command = new CreateCommand(parent.getDiagram().getTextEditor(), viewer);
   command.setParent(parent);
   command.setChild((Activity) request.getNewObject());
   return command;
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.gef.editpolicies.LayoutEditPolicy#createSizeOnDropFeedback
   * (org.eclipse.gef.requests.CreateRequest)
   */
  protected IFigure createSizeOnDropFeedback(CreateRequest createRequest) {
    IFigure figure;

    if (createRequest.getNewObject() instanceof Circuit) figure = new CircuitFeedbackFigure();
    else if (createRequest.getNewObject() instanceof LogicFlowContainer)
      figure = new LogicFlowFeedbackFigure();
    else if (createRequest.getNewObject() instanceof LogicLabel) figure = new LabelFeedbackFigure();
    else {
      figure = new RectangleFigure();
      ((RectangleFigure) figure).setXOR(true);
      ((RectangleFigure) figure).setFill(true);
      figure.setBackgroundColor(LogicColorConstants.ghostFillColor);
      figure.setForegroundColor(ColorConstants.white);
    }

    addFeedback(figure);

    return figure;
  }
 @Override
 protected Command getCreateCommand(CreateRequest request) {
   IEntity child = (IEntity) request.getNewObject();
   IContainer container = (IContainer) getHost().getModel();
   S2InterceptorsChildAddCommand command = new S2InterceptorsChildAddCommand(child, container);
   EditPart after = getInsertionReference(request);
   int index = getHost().getChildren().indexOf(after);
   command.setIndex(index);
   return command;
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse
  * .gef.requests.CreateRequest)
  */
 @Override
 protected Command getCreateCommand(CreateRequest request) {
   Command command = null;
   if (request.getNewObject() instanceof Attribute) {
     Node node = (Node) getHost().getModel();
     if (node.getType() != null)
       if ((node.getType().getEAllAttributes().size() - node.getAttributes().size() > 0))
         command = new CreateAttributesCommand(node);
   }
   return command;
 }
  protected Command getCreateCommand(CreateRequest request) {
    CreateCommand create = new CreateCommand();
    create.setParent((LogicDiagram) getHost().getModel());
    LogicSubpart newPart = (LogicSubpart) request.getNewObject();
    create.setChild(newPart);
    Rectangle constraint = (Rectangle) getConstraintFor(request);
    create.setLocation(constraint);
    create.setLabel(LogicMessages.LogicXYLayoutEditPolicy_CreateCommandLabelText);

    Command cmd = chainGuideAttachmentCommand(request, newPart, create, true);
    return chainGuideAttachmentCommand(request, newPart, cmd, false);
  }
 @Override
 protected Command getCreateCommand(CreateRequest request) {
   if (request.getType() == REQ_CREATE && getHost() instanceof UMLContainerFigurePart) {
     UMLCreateCommand cmd = new UMLCreateCommand();
     cmd.setUMLContainer(getHost().getModel());
     cmd.setUML(request.getNewObject());
     Rectangle constraint = (Rectangle) getConstraintFor(request);
     constraint.x = (constraint.x < 0) ? 0 : constraint.x;
     constraint.y = (constraint.y < 0) ? 0 : constraint.y;
     constraint.width =
         (constraint.width <= 0) ? UMLClassFigure.SERVICE_FIGURE_DEFWIDTH : constraint.width;
     constraint.height =
         (constraint.height <= 0) ? UMLClassFigure.SERVICE_FIGURE_DEFHEIGHT : constraint.height;
     cmd.setLayout(constraint);
     return cmd;
   }
   return null;
 }
  @Override
  protected Command getCreateCommand(CreateRequest request) {
    CreateModelCommand command = new CreateModelCommand();

    // 产生创建图形的尺寸和位置
    Rectangle constraint = (Rectangle) getConstraintFor(request);

    // 获得新创建的模型
    AbstractModel model = (AbstractModel) request.getNewObject();

    // 为该图形设置前面获得的位置和尺寸
    model.setConstraint(constraint);

    command.setWorkFlowModel((WorkFlowModel) getHost().getModel());
    command.setModel(model);

    return command;
  }
 /* (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;
 }
Esempio n. 11
0
  @Override
  protected Command getCreateCommand(CreateRequest request) {
    final Rectangle constraint = (Rectangle) getConstraintFor(request);
    // get the child object to create
    final Object newObject = request.getNewObject();
    final EditPart editPart = getHost();
    final MyRentalAgency parentAgency = (MyRentalAgency) editPart.getModel();
    Command command = UnexecutableCommand.INSTANCE;

    if (parentAgency != null) {
      if (newObject instanceof Customer) {
        command = new CreateCustomerCommand((Customer) newObject, parentAgency, constraint);
      } else if (newObject instanceof RentalObject) {
        command = new CreateRentalObjectCommand((RentalObject) newObject, parentAgency, constraint);
      }
    }

    return command;
  }
Esempio n. 12
0
  @Override
  protected Command getCreateCommand(CreateRequest request) {

    if (request.getType() == REQ_CREATE && getHost() instanceof AppAbstractEditPart) {

      if (((BControl) ((AppAbstractEditPart) getHost()).getModel()).canHaveChildren()) {

        BControl newObj = (BControl) request.getNewObject();

        CreateCommand createCmd = new CreateCommand(newObj, (BControl) getHost().getModel());

        Rectangle constraint = (Rectangle) getConstraintFor(request);
        constraint.x = (constraint.x < 0) ? 0 : constraint.x;
        constraint.y = (constraint.y < 0) ? 0 : constraint.y;

        BAttributeWidth atrWidth =
            (BAttributeWidth) newObj.getAttributes().get(AttributeConstants.ATTRIBUTE_WIDTH);
        BAttributeHeight atrHeight =
            (BAttributeHeight) newObj.getAttributes().get(AttributeConstants.ATTRIBUTE_HEIGHT);

        if (atrWidth != null) {
          constraint.width = Integer.valueOf(atrWidth.getValue().toString());
        } else {
          constraint.width = (constraint.width <= 0) ? 100 : constraint.width;
        }

        if (atrHeight != null) {
          constraint.height = Integer.valueOf(atrHeight.getValue().toString());
        } else {
          constraint.height = (constraint.height <= 0) ? 100 : constraint.height;
        }

        createCmd.setLayout(constraint);

        Command cmd = chainGuideAttachmentCommand(request, newObj, createCmd, true);
        return chainGuideAttachmentCommand(request, newObj, cmd, false);
      }
    }

    return null;
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreationFeedbackOffset
  * (org.eclipse.gef.requests.CreateRequest)
  */
 protected Insets getCreationFeedbackOffset(CreateRequest request) {
   if (request.getNewObject() instanceof LED || request.getNewObject() instanceof Circuit)
     return new Insets(2, 0, 2, 0);
   return new Insets();
 }