Java 类org.eclipse.gef.requests.CreateRequest 实例源码

项目:Open_Source_ECOA_Toolset_AS5    文件:ModuleInstanceLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ModuleInstancePropertyNode.class) && getHost().getModel() instanceof ModuleInstanceNode) {
        ModuleInstancePropertyCreateCommand cmd = new ModuleInstancePropertyCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 2);
        cmd.setNode((ModuleInstancePropertyNode) node);
        cmd.setParent((ModuleInstanceNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, ModuleInstancePropertyNode.DEF_WIDTH, ModuleInstancePropertyNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ModuleOperationLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ModuleOperationParameterNode.class) && (getHost().getModel() instanceof ModuleOperationNode)) {
        ModuleOperationNode par = (ModuleOperationNode) getHost().getModel();
        if (!(par.getType().equalsIgnoreCase(Enums.ModuleOperationTypes.DATA_READ.name()) || par.getType().equalsIgnoreCase(Enums.ModuleOperationTypes.DATA_WRITE.name()))) {
            ModuleOperationParameterCreateCommand cmd = new ModuleOperationParameterCreateCommand();
            Node node = (Node) request.getNewObject();
            node.setParent((Node) getHost().getModel());
            Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
            Point viewSize = vp.getViewLocation();
            Point p = request.getLocation();
            p.setX(p.x + viewSize.x);
            p.setY(p.y + viewSize.y);
            p = node.getAnchor(p, 2);
            cmd.setNode((ModuleOperationParameterNode) node);
            cmd.setParent((ModuleOperationNode) node.getParent());
            cmd.setLocation(new Rectangle(p.x, p.y, ModuleOperationParameterNode.DEF_WIDTH, ModuleOperationParameterNode.DEF_HEIGHT));
            ret = cmd;
        }
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:PlatformConfigurationLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ComputingNodeConfigurationNode.class) && (getHost().getModel() instanceof PlatformConfigurationNode)) {
        ComputingNodeConfigurationCreateCommand cmd = new ComputingNodeConfigurationCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 1);
        cmd.setNode((ComputingNodeConfigurationNode) node);
        cmd.setParent((PlatformConfigurationNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, ComputingNodeConfigurationNode.DEF_WIDTH, ComputingNodeConfigurationNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:LogicalSystemLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(LogicalComputingPlatformNode.class) && (getHost().getModel() instanceof LogicalSystemNode)) {
        LogicalComputingPlatformCreateCommand cmd = new LogicalComputingPlatformCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        cmd.setNode((LogicalComputingPlatformNode) node);
        cmd.setParent((LogicalSystemNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, LogicalComputingPlatformNode.DEF_WIDTH, LogicalComputingPlatformNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:LogicalComputingLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(LogicalProcessorsNode.class) && (getHost().getModel() instanceof LogicalComputingNode)) {
        LogicalProcessorsCreateCommand cmd = new LogicalProcessorsCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 2);
        cmd.setNode((LogicalProcessorsNode) node);
        cmd.setParent((LogicalComputingNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, LogicalProcessorsNode.DEF_WIDTH, LogicalProcessorsNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:LogicalComputingPlatformLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(LogicalComputingNode.class) && (getHost().getModel() instanceof LogicalComputingPlatformNode)) {
        LogicalComputingCreateCommand cmd = new LogicalComputingCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 1);
        cmd.setNode((LogicalComputingNode) node);
        cmd.setParent((LogicalComputingPlatformNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, LogicalComputingNode.DEF_WIDTH, LogicalComputingNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ComponentNodeLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ComponentPropertyNode.class) && (getHost().getModel() instanceof ComponentNode)) {
        ComponentPropertyNodeCreateCommand cmd = new ComponentPropertyNodeCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 1);
        cmd.setNode((ComponentPropertyNode) node);
        cmd.setParent((ComponentNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, ComponentPropertyNode.DEF_WIDTH, ComponentPropertyNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:Open_Source_ECOA_Toolset_AS5    文件:ComponentNodeLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command ret = null;
    if (request.getNewObjectType().equals(ComponentPropertyNode.class) && (getHost().getModel() instanceof ComponentNode)) {
        ComponentPropertyNodeCreateCommand cmd = new ComponentPropertyNodeCreateCommand();
        Node node = (Node) request.getNewObject();
        node.setParent((Node) getHost().getModel());
        Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport();
        Point viewSize = vp.getViewLocation();
        Point p = request.getLocation();
        p.setX(p.x + viewSize.x);
        p.setY(p.y + viewSize.y);
        p = node.getAnchor(p, 1);
        cmd.setNode((ComponentPropertyNode) node);
        cmd.setParent((ComponentNode) node.getParent());
        cmd.setLocation(new Rectangle(p.x, p.y, ComponentPropertyNode.DEF_WIDTH, ComponentPropertyNode.DEF_HEIGHT));
        ret = cmd;
    }
    return ret;
}
项目:gemoc-studio    文件:PossibleStepEditPart.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
 */
@Override
protected void createEditPolicies() {
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicy() {

        /**
         * {@inheritDoc}
         * 
         * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
         */
        @Override
        protected Command getCreateCommand(CreateRequest request) {
            return null;
        }
    });
}
项目:Hydrograph    文件:PaletteContainerListener.java   
@Override
public void mouseDoubleClick(MouseEvent mouseEvent) {
    CreateRequest componentRequest = getComponentRequest(mouseEvent);
    placeComponentOnCanvasByDoubleClickOnPalette(componentRequest);
    logger.info(
            "Component is positioned at respective x and y location"
                    + defaultComponentLocation.getCopy().x + 20 + " and "
                    + defaultComponentLocation.getCopy().y + 20);
    logger.info(
            "Component is positioned at respective x and y location"
                    + defaultComponentLocation.getCopy().x + 20 + " and "
                    + defaultComponentLocation.getCopy().y + 20);

    viewer.getEditDomain().loadDefaultTool();
    graphicalViewer.getEditDomain().loadDefaultTool();

}
项目:Hydrograph    文件:PaletteContainerListener.java   
/**
 * 
 * set genericComponent to selected/hovered component in palette
 * 
 * @param paletteInternalController
 * @return
 */
private CreateRequest setGenericComponent(EditPart paletteInternalController) {
    CombinedTemplateCreationEntry addedPaletteTool = (CombinedTemplateCreationEntry) paletteInternalController
            .getModel();

        CreateRequest componentRequest = new CreateRequest();
        componentRequest.setFactory(new SimpleFactory((Class) addedPaletteTool
                .getTemplate()));

    genericComponent = (Component) componentRequest
            .getNewObject();

    logger.debug("genericComponent - " + genericComponent.toString());

    return componentRequest;
}
项目:ermaster-k    文件:ERDiagramLayoutEditPolicy.java   
/**
 * {@inheritDoc}
 */
@Override
protected void showSizeOnDropFeedback(CreateRequest request) {
    Point p = new Point(request.getLocation().getCopy());

    ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
            .getHost().getRoot()).getZoomManager();
    double zoom = zoomManager.getZoom();

    IFigure feedback = getSizeOnDropFeedback(request);

    Dimension size = request.getSize().getCopy();
    feedback.translateToRelative(size);
    feedback.setBounds(new Rectangle((int) (p.x * zoom),
            (int) (p.y * zoom), size.width, size.height)
            .expand(getCreationFeedbackOffset(request)));
}
项目:ForgedUI-Eclipse    文件:TableViewSectionEditPart.java   
@Override
protected void createEditPolicies() {
    stackEditPolicy = new AddStackElementEditPolicy(validator);
    installEditPolicy(AddStackElementEditPolicy.KEY, stackEditPolicy);
    super.createEditPolicies();
    installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ContainerHighlightEditPolicy(){
        @Override
        public void showTargetFeedback(Request request) {
            if (request instanceof CreateRequest) {
                CreateRequest createRequest = (CreateRequest) request;
                if (stackEditPolicy.acceptCreate(createRequest)){
                    eraseTargetFeedback(createRequest);
                    return;//this will be handled by the stackEditPolicy
                }
            }
            super.showTargetFeedback(request);
        }
    });
    installEditPolicy(ContainerEditPolicy.KEY, new TableViewSectionEditPolicy());
    installEditPolicy(EditPolicy.LAYOUT_ROLE, NullEditPolicy.getInstance());
}
项目:ForgedUI-Eclipse    文件:AddStackElementEditPolicy.java   
@Override
protected void showLayoutTargetFeedback(Request request) {
    eraseLayoutTargetFeedback(request);
    if (request instanceof ChangeBoundsRequest || (request instanceof CreateRequest
            && acceptCreate((CreateRequest) request))){
        targetFeedback = new RectangleFigure();
        Rectangle parentBounds = ((ElementEditPart)getHost()).getBounds();
        translateToAbsolute(getContainerFigure(), parentBounds);
        Rectangle lineBounds = parentBounds.getCopy();
        lineBounds.height = 4;
        lineBounds.y--;
        targetFeedback.setForegroundColor(ColorConstants.green);
        targetFeedback.setBackgroundColor(ColorConstants.green);
        if (isInsertAfter((DropRequest) request)){
            lineBounds.y += parentBounds.height;
        }
        targetFeedback.setBounds(lineBounds);
        addFeedback(targetFeedback);
    } else if (request instanceof ChangeBoundsRequest){

    }

}
项目:ForgedUI-Eclipse    文件:WindowAddElementEditPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    // And then passed those to the validate facility.
    Object newObject = request.getNewObject();
    Object container = getHost().getModel();
    if (!GUIEditorPlugin.getComponentValidator().validate(newObject, container))
        return null;

    if (request.getNewObject() instanceof TitleBar
            && getHost().getModel() instanceof Window) {
        TitleBar titleBar = (TitleBar) request.getNewObject();
        Window window = (Window)getHost().getModel();
        if (window.getTitleBar() == null){
            return new AddTitleBarCommand(window,
                    titleBar, 
                    new Rectangle(0, 0, window.getDimension().width, -1));
        }
    } else if (request.getNewObject() instanceof TitaniumUIBaseElement
            && getHost().getModel() instanceof TitaniumUIContainer) {
        return super.getCreateCommand(request);
    }
    return null;
}
项目:ForgedUI-Eclipse    文件:ContainerHighlightEditPolicy.java   
public void showTargetFeedback(Request request) {
    if (request.getType().equals(RequestConstants.REQ_MOVE)
            || request.getType().equals(RequestConstants.REQ_ADD)
            //|| request.getType().equals(RequestConstants.REQ_CLONE)
            || request.getType().equals(RequestConstants.REQ_CREATE)) {

        List<Element> children = new ArrayList<Element>();
        if (request instanceof ChangeBoundsRequest) { 
            ChangeBoundsRequest req = (ChangeBoundsRequest)request;
            List<?> editParts = req.getEditParts();
            for (Object editPart : editParts) {
                children.add((Element) ((EditPart)editPart).getModel());
            }
        } else if (request instanceof CreateRequest){
            children.add((Element) ((CreateRequest)request).getNewObject());
        } else {
            //what is this???
        }

        showHighlight(children);
    }

}
项目:NEXCORE-UML-Modeler    文件:ActivityPartitionLayoutPolicy.java   
/**
 * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
 */
@Override
protected Command getCreateCommand(CreateRequest request) {
    diagramEditDomain = (DiagramEditDomain) getHost().getViewer().getEditDomain();
    Point location = new Point(request.getLocation());
    getHostFigure().translateToRelative(location);

    // 파티션안에 파티션 생성. 계층 구조 생성.
    // if (request.getNewObject() instanceof ContainerNode) {
    // return new ActivityCreateContainerNodeCommand(diagramEditDomain,
    // getHost().getModel(), request, location);
    // }
    if (request.getNewObject() instanceof NotationNode) {
        return new ActivityCreateNotationNodeCommand(diagramEditDomain, getHost(), request, location);
    } else {
        return null;
    }

}
项目:NEXCORE-UML-Modeler    文件:ActivityDiagramLayoutEditPolicy.java   
/**
 * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
 */
@Override
protected Command getCreateCommand(CreateRequest request) {
    diagramEditDomain = (DiagramEditDomain) getHost().getViewer().getEditDomain();
    Point location = new Point(request.getLocation());
    getHostFigure().translateToRelative(location);

    if (request.getNewObject() instanceof ContainerNode) {
        return new ActivityCreateContainerNodeCommand(diagramEditDomain, getHost(), request, location);
    } else if (request.getNewObject() instanceof NotationNode) {
        return new ActivityCreateNotationNodeCommand(diagramEditDomain, getHost(), request, location);
    } else {
        return null;
    }

}
项目:NEXCORE-UML-Modeler    文件:ActivityCreateContainerNodeCommand.java   
/**
 * @param editDomain
 * @param parentNodeModel
 * @param request
 * @param location
 */
public ActivityCreateContainerNodeCommand(EditDomain editDomain, EditPart parentEditPart, CreateRequest request,
Point location) {
    super(editDomain, parentEditPart.getModel(), request, location);
    this.parentEditPart = parentEditPart;
    this.parentNodeModel = (AbstractNode) parentEditPart.getModel();
    if( this.parentNodeModel instanceof Diagram ) {
        this.diagram = (Diagram) this.parentNodeModel;
    }

    IDialogSettings dialogSetting = ActivityDiagramUtil.getDialogSetting();
    String partitionDirection = AnalysisConstant.EMPTY_STRING;

    partitionDirection = dialogSetting.get(AnalysisConstant.DIRECTION);
    if( null == partitionDirection ) {
        isHorizontal = false;
        dialogSetting.put(AnalysisConstant.DIRECTION, AnalysisConstant.VERTICAL);
    }
    if( AnalysisConstant.HORIZONTAL.equals(partitionDirection) ) {
        isHorizontal = true;
    } else if( AnalysisConstant.VERTICAL.equals(partitionDirection) ) {
        isHorizontal = false;
    }
}
项目:NEXCORE-UML-Modeler    文件:SequenceDiagramLayoutEditPolicy.java   
/**
 * combinedFragment를 생성 할 수 있는지 검사한다.
 *  
 * @param location
 * @return boolean
 */
private boolean checkAvailableCreateCombinedFragment(CreateRequest request, Point location) {

    if(isThereOtherCombinedFragment(location)) {
        return false;
    }

    AbstractNode parentNode = (AbstractNode) getHost().getModel();
    if(parentNode instanceof ContainerNode) {
        ContainerNode containerNode = (ContainerNode) parentNode;
        if(isOverParentOperandSize(containerNode, location, request.getSize())) {
           return false;
        }
    }

    return true;
}
项目:PDFReporter-Studio    文件:JDTreeContainerEditPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    int index = -1;
    if (((TreeEditPart) getHost()).getWidget() != null)
        index = findIndexOfTreeItemAt(request.getLocation());
    if (index < 0)
        index = CreateRequestUtil.getNewIndex(request);

    if (request.getNewObject() instanceof ANode) {
        return createCreateCommand((ANode) request.getNewObject(), index);
    } else if (request.getNewObject() instanceof CreateElementAction) {
        CreateElementAction action = (CreateElementAction) request.getNewObject();
        action.dropInto(getHost().getModel(), new Rectangle(), index);
        action.run();
        return action.getCommand();
    }
    return null;
}
项目:ermaster-nhit    文件:ERDiagramLayoutEditPolicy.java   
/**
 * {@inheritDoc}
 */
@Override
protected void showSizeOnDropFeedback(CreateRequest request) {
    Point p = new Point(request.getLocation().getCopy());

    ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
            .getHost().getRoot()).getZoomManager();
    double zoom = zoomManager.getZoom();

    IFigure feedback = getSizeOnDropFeedback(request);

    Dimension size = request.getSize().getCopy();
    feedback.translateToRelative(size);
    feedback.setBounds(new Rectangle((int) (p.x * zoom),
            (int) (p.y * zoom), size.width, size.height)
            .expand(getCreationFeedbackOffset(request)));
}
项目:gef-gwt    文件:LayoutEditPolicy.java   
/**
 * Factors incoming requests into various specific methods.
 * 
 * @see org.eclipse.gef.EditPolicy#getCommand(Request)
 */
public Command getCommand(Request request) {
    if (REQ_DELETE_DEPENDANT.equals(request.getType()))
        return getDeleteDependantCommand(request);

    if (REQ_ADD.equals(request.getType()))
        return getAddCommand(request);

    if (REQ_ORPHAN_CHILDREN.equals(request.getType()))
        return getOrphanChildrenCommand(request);

    if (REQ_MOVE_CHILDREN.equals(request.getType()))
        return getMoveChildrenCommand(request);

    if (REQ_CLONE.equals(request.getType()))
        return getCloneCommand((ChangeBoundsRequest) request);

    if (REQ_CREATE.equals(request.getType()))
        return getCreateCommand((CreateRequest) request);

    return null;
}
项目:gef-gwt    文件:LayoutEditPolicy.java   
/**
 * Factors feedback requests into two more specific methods.
 * 
 * @see org.eclipse.gef.EditPolicy#showTargetFeedback(Request)
 */
public void showTargetFeedback(Request request) {
    if (REQ_ADD.equals(request.getType())
            || REQ_CLONE.equals(request.getType())
            || REQ_MOVE.equals(request.getType())
            || REQ_RESIZE_CHILDREN.equals(request.getType())
            || REQ_CREATE.equals(request.getType()))
        showLayoutTargetFeedback(request);

    if (REQ_CREATE.equals(request.getType())) {
        CreateRequest createReq = (CreateRequest) request;
        if (createReq.getSize() != null) {
            showSizeOnDropFeedback(createReq);
        }
    }
}
项目:gef-gwt    文件:CreationTool.java   
/**
 * Ensures size constraints (by default minimum and maximum) are respected
 * by the given request. May be overwritten by clients to enforce additional
 * constraints.
 * 
 * @since 3.7
 */
protected void enforceConstraintsForSizeOnDropCreate(CreateRequest request) {
    CreateRequest createRequest = (CreateRequest) getTargetRequest();
    if (createRequest.getSize() != null) {
        // ensure create request respects minimum and maximum size
        // constraints
        PrecisionRectangle constraint = new PrecisionRectangle(
                createRequest.getLocation(), createRequest.getSize());
        ((GraphicalEditPart) getTargetEditPart()).getContentPane()
                .translateToRelative(constraint);
        constraint.setSize(Dimension.max(constraint.getSize(),
                getMinimumSizeFor(createRequest)));
        constraint.setSize(Dimension.min(constraint.getSize(),
                getMaximumSizeFor(createRequest)));
        ((GraphicalEditPart) getTargetEditPart()).getContentPane()
                .translateToAbsolute(constraint);
        createRequest.setSize(constraint.getSize());
    }
}
项目:FRaMED    文件:ORMModelXYLayoutPolicy.java   
/**
 * This method creates, set ups and return the {@link ORMShapeCreateCommand} for a new
 * {@link Shape}.
 * 
 * @param request {@link CreateRequest}, attributeSegment {@link Segment}, operationsSegment
 *        {@link Segment}, description {@link NamedElement}, childmodel {@link Model}
 * */
private ORMShapeCreateCommand setUpCreateCommand(final CreateRequest request,
    Segment attributeSegment, Segment operationSegment, NamedElement description, Model childmodel) {

  ORMShapeCreateCommand command = new ORMShapeCreateCommand();
  Rectangle boundaries = (Rectangle) getConstraintFor(request);

  command.setShape((Shape) request.getNewObject());
  command.setBoundaries(createModelReactangle(new Rectangle(boundaries.getLocation(),
      ORMAbstractXYLayoutPolicy.dynamicDimensions(request.getNewObjectType()))));
  command.setContainer((Model) getHost().getModel());

  command.setAttributeSegment(attributeSegment);
  command.setOperationSegment(operationSegment);
  command.setChildmodel(childmodel);
  command.setDescription(description);

  return command;
}
项目:snaker-designer    文件:FormXYEditLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    if (request.getType() == REQ_CREATE) {
        String newObjectType = (String) request.getNewObjectType();
        FieldCreateCommand cmd = new FieldCreateCommand();
        cmd.setParent((BaseElement) getHost().getModel());
        cmd.setField(request.getNewObject());
        cmd.setLabel(newObjectType);

        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) ? 120 : constraint.width;
        constraint.height = (constraint.height <= 0) ? 40
                : constraint.height;
        cmd.setLayout(constraint);
        return cmd;
    }
    return null;
}
项目:birt    文件:BasePaletteFactory.java   
public boolean preHandleMouseUp( )
{
    CreateRequest request = getRequest( );
    if ( IReportElementConstants.REPORT_ELEMENT_DATA.equalsIgnoreCase( (String) request.getNewObjectType( ) ) )
    {
        // DataItemHandle dataHandle = SessionHandleAdapter.getInstance(
        // )
        // .getReportDesignHandle( )
        // .getElementFactory( )
        // .newDataItem( null );
        DataItemHandle dataHandle = DesignElementFactory.getInstance( )
                .newDataItem( null );
        setModel( dataHandle );
        // disable this dialog
        // dialog will pop-up after image is create
        // see ReportCreationTool.selectAddedObject()
        // BindingColumnDialog dialog = new BindingColumnDialog( true );
        // dialog.setInput( dataHandle );
        // if ( dialog.open( ) == Window.OK )
        // {
        return super.preHandleMouseUp( );
        // }
    }
    return false;
}
项目:birt    文件:BasePaletteFactory.java   
public boolean preHandleMouseUp( )
{
    CreateRequest request = getRequest( );
    if ( IReportElementConstants.REPORT_ELEMENT_LABEL.equalsIgnoreCase( (String) request.getNewObjectType( ) ) )
    {
        // LabelHandle labelItemHandle =
        // SessionHandleAdapter.getInstance( )
        // .getReportDesignHandle( )
        // .getElementFactory( )
        // .newLabel( null );

        LabelHandle labelItemHandle = DesignElementFactory.getInstance( )
                .newLabel( null );

        setModel( labelItemHandle );
        return super.preHandleMouseUp( );

    }
    return false;
}
项目:birt    文件:BasePaletteFactory.java   
public boolean preHandleMouseUp( )
{
    CreateRequest request = getRequest( );
    if ( IReportElementConstants.REPORT_ELEMENT_LIST.equalsIgnoreCase( (String) request.getNewObjectType( ) ) )
    {
        // ListHandle list = SessionHandleAdapter.getInstance( )
        // .getReportDesignHandle( )
        // .getElementFactory( )
        // .newList( null );

        ListHandle list = DesignElementFactory.getInstance( )
                .newList( null );

        setModel( list );
        return super.preHandleMouseUp( );
    }
    return false;
}
项目:seg.jUCMNav    文件:PathNodeComponentEditPolicy.java   
/**
 * jkealey: This method is supposed to handle requests. However, it seems to have been implemented early on when we didn't know too well how GEF worked. The
 * function runs but I don't think it ever ends up running LINE A or LINE B, but we may be able to simply delete it.
 * 
 * I'm not 100% sure though, so I am leaving the code here and adding debug information to help us resolve this matter.
 * 
 * This method returns an UnexecutableCommand when trying to resize a PathNode, used to indicate that this action is illegal.
 * 
 * @see org.eclipse.gef.EditPolicy#getCommand(org.eclipse.gef.Request)
 */
public Command getCommand(Request request) {
    if (request.getType() == CutPathAction.CUTPATH_REQUEST) {
        PathNode ep = ((PathNode) (getHost()).getModel());
        CutPathCommand cp = new CutPathCommand((UCMmap) ep.getDiagram(), ep);
        // LINE A
        // System.out.println("Please review PathNodeComponentEditPolicy.getCommand() and indicate how you managed to get LINE A to run."); //$NON-NLS-1$
        // CutPathAction on PathNode.
        return cp;
    }
    if (request.getType() == REQ_CREATE && request instanceof CreateRequest) {
        Object newObjectType = null;
        if (((CreateRequest) request).getNewObject() != null)
            newObjectType = ((CreateRequest) request).getNewObjectType();
        if (newObjectType instanceof EndPoint) {
            // LINE B
            System.out.println("Please review PathNodeComponentEditPolicy.getCommand() and indicate how you managed to get LINE B to run."); //$NON-NLS-1$
            getHost().getViewer().setSelection(new StructuredSelection(getHost()));
        }
    } else if (request.getType() == REQ_RESIZE) {
        // This line gives feedback to the user when he attempts to resize a pathnode. This is illegal.
        return UnexecutableCommand.INSTANCE;
    }

    return super.getCommand(request);
}
项目:seg.jUCMNav    文件:GrlGraphXYLayoutEditPolicy.java   
/**
 * Returns a command to be executed when the palette tries to create something
 * 
 * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
 */
protected Command getCreateCommand(CreateRequest request) {
    Object newObjectType = null;
    if (request.getNewObject() != null)
        newObjectType = request.getNewObjectType();

    // converts relative to absolute positions (so that zooms work properly)
    Rectangle constraint = (Rectangle) getConstraintFor(request);
    Command createCommand = null;

    if ((newObjectType == IntentionalElementRef.class) || (newObjectType == Belief.class) || (newObjectType == KPIInformationElementRef.class)) {
        createCommand = handleCreateGrlNode(request, constraint);
    } else if (newObjectType == ActorRef.class) {
        createCommand = handleCreateActorRef(request, constraint);
    } else if (newObjectType == Comment.class) {
        createCommand = handleCreateComment(request, constraint);
    }
    return createCommand;
}
项目:seg.jUCMNav    文件:GrlGraphXYLayoutEditPolicy.java   
/**
 * @param request
 *            the CreateRequest containing the new ComponentRef
 * @param constraint
 *            where the new object should be created
 * @return a command that adds a new IntentionalElementRef or KPIInformationElementRef on the Graph and moves/resizes it into place.
 */
private Command handleCreateGrlNode(CreateRequest request, Rectangle constraint) {
    Command createCommand = null;
    Command create = null;
    GRLNode node = null;
    if (request.getNewObject() instanceof IntentionalElementRef) {
        node = (IntentionalElementRef) request.getNewObject();
        create = buildCreateGrlNodeCommand(getGraph(), (IntentionalElementRef) node);
    } else if (request.getNewObject() instanceof KPIInformationElementRef) {
        node = (KPIInformationElementRef) request.getNewObject();
        KPIInformationElementRef info = (KPIInformationElementRef) node;
        create = buildCreateKPIInformationElementCommand(getGraph(), info);
    } else if (request.getNewObject() instanceof Belief) {
        node = (Belief) request.getNewObject();
        create = new AddBeliefCommand(getGraph(), (Belief) node);
    }
    SetConstraintGrlNodeCommand move = new SetConstraintGrlNodeCommand(node, constraint.x, constraint.y, constraint.width, constraint.height, false);

    // after creation, move and resize the node;
    if (create != null)
        createCommand = create.chain(move);

    return createCommand;
}
项目:seg.jUCMNav    文件:MapXYLayoutEditPolicy.java   
/**
 * Returns a command to be executed when the palette tries to create something on the MapAndPathGraphEditPart.
 * 
 * Extends path for PathTool and creates ComponentRefs. PathNodes are created on NodeConnections so are not handled here.
 * 
 * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
 */
protected Command getCreateCommand(CreateRequest request) {
    Object newObjectType = null;
    if (request.getNewObject() != null)
        newObjectType = request.getNewObjectType();

    // converts relative to absolute positions (so that zooms work properly)
    Rectangle constraint = (Rectangle) getConstraintFor(request);
    Command createCommand = null;

    // if PathTool
    if (newObjectType == EndPoint.class || newObjectType == StartPoint.class) {
        createCommand = handleCreateOrExtendPath(request, constraint);
    } else if (newObjectType == ComponentRef.class) {
        createCommand = handleCreateComponentRef(request, constraint);
    } else if (newObjectType == Comment.class) {
        createCommand = handleCreateComment(request, constraint);
    }

    return createCommand;
}
项目:seg.jUCMNav    文件:MapXYLayoutEditPolicy.java   
/**
 * @param request
 *            the CreateRequest containing the new object
 * @param constraint
 *            where the object (startpoint /endpoint) should be created
 * @return the command to extend an existing path in the appropriate direction or create a new one.
 */
private Command handleCreateOrExtendPath(CreateRequest request, Rectangle constraint) {
    Command createCommand = null;
    // Get the list of selected items
    List selectedParts = ((IStructuredSelection) getHost().getViewer().getSelection()).toList();

    // If there's only one item selected
    if (selectedParts.size() == 1) {
        EditPart selected = (EditPart) (selectedParts.get(0));
        if (selected.getModel() instanceof EndPoint) {
            // extend end point
            createCommand = new ExtendPathCommand(getMap(), (EndPoint) selected.getModel(), constraint.x, constraint.y);
        } else if (selected.getModel() instanceof StartPoint) {
            // extend start point
            createCommand = new ExtendPathCommand(getMap(), (StartPoint) selected.getModel(), constraint.x, constraint.y);
        } else {
            // create new path
            if (request.getNewObject() instanceof StartPoint)
                createCommand = new CreatePathCommand(getMap(), (StartPoint) request.getNewObject(), constraint.x, constraint.y);
            else
                createCommand = new CreatePathCommand(getMap(), constraint.x, constraint.y);
        }
    }
    return createCommand;
}
项目:seg.jUCMNav    文件:PathNodeXYLayoutEditPolicy.java   
/**
 * Replaces empty points and direction arrows with other new node created in palette.
 * 
 * Adds branches on existing forks/joins if palette tool is path tool or fork/join.
 * 
 * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
 */
protected Command getCreateCommand(CreateRequest request) {
    // allows empty points to be replaced by direction arrows
    if ((getHost().getModel() instanceof EmptyPoint) && (request.getNewObject() instanceof DirectionArrow)) {
        return new ReplaceEmptyPointCommand((PathNode) getHost().getModel(), (PathNode) request.getNewObject());
    }
    // can replace with new object?
    if (isReplaceable(getHost().getModel()) && !(isPathTool(request) || isReplaceable(request.getNewObject()))) {
        // because we don't want forks/joins without only 1 in/out
        if (request.getNewObject() instanceof AndFork || request.getNewObject() instanceof OrFork || request.getNewObject() instanceof AndJoin
                || request.getNewObject() instanceof OrJoin)
            return new DividePathCommand((PathNode) request.getNewObject(), (PathNode) getHost().getModel());
        else if (request.getNewObject() instanceof PathNode)
            return new ReplaceEmptyPointCommand((PathNode) getHost().getModel(), (PathNode) request.getNewObject());
        else
            return null;
    } else if (isForkOrJoin(getHost().getModel()) && (isForkOrJoin(request.getNewObject()) || isPathTool(request))) {
        return new AddBranchCommand((PathNode) getHost().getModel());
    } else if (getHost().getModel() instanceof Label) {
        UCMNavMultiPageEditor editor = (UCMNavMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        return new EditLabelCommand(editor, (LabelEditPart) getHost());
    } else
        return null;
}
项目:gw4e.project    文件:GW4EEditLayoutPolicy.java   
@Override
protected Command getCreateCommand(CreateRequest request) {
    Command retVal = null;
    Class clazz = (Class)request.getNewObjectType();
    if(Vertex.class.isAssignableFrom(clazz)) {
        VertexCreateCommand command = new VertexCreateCommand();
        command.setLocation(request.getLocation());
        Vertex vertex  = (Vertex)(request.getNewObject());
        vertex.setGraph((GWGraph)(getHost().getModel()));
        command.setVertex(vertex);
        retVal = command;
    }  
    return retVal;
}
项目:gemoc-studio    文件:TimelineWindowEditPart.java   
@Override
protected void createEditPolicies() {
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicy() {

        @Override
        protected Command getCreateCommand(CreateRequest request) {
            // TODO Auto-generated method stub
            return null;
        }
    });
}
项目:gemoc-studio    文件:BranchEditPart.java   
@Override
protected void createEditPolicies() {
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicy() {

        @Override
        protected Command getCreateCommand(CreateRequest request) {
            // TODO Auto-generated method stub
            return null;
        }
    });
}
项目:gemoc-studio    文件:ChoiceEditPart.java   
@Override
protected void createEditPolicies() {
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicy() {

        @Override
        protected Command getCreateCommand(CreateRequest request) {
            // TODO Auto-generated method stub
            return null;
        }
    });
}