Java 类org.eclipse.gef.commands.UnexecutableCommand 实例源码

项目:ForgedUI-Eclipse    文件:TitaniumTreeContainerEditPolicy.java   
protected Command getAddCommand(ChangeBoundsRequest request) {
    CompoundCommand command = new CompoundCommand();
    List editparts = request.getEditParts();
    int index = findIndexOfTreeItemAt(request.getLocation());

    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        if (GUIEditorPlugin.getComponentValidator().isAncestor((Element)child.getModel(),(Element)getHost().getModel()))
            command.add(UnexecutableCommand.INSTANCE);
        else {
            TitaniumUIBoundedElement childModel = (TitaniumUIBoundedElement) child.getModel();
            command.add(createCreateCommand(childModel,
                    new Rectangle(new org.eclipse.draw2d.geometry.Point(),
                            new Dimension(-1, -1)), index,
                    "Reparent LogicSubpart"));//$NON-NLS-1$
        }
    }
    return command;
}
项目:ForgedUI-Eclipse    文件:TitaniumTreeContainerEditPolicy.java   
protected Command getMoveChildrenCommand(ChangeBoundsRequest request) {
    CompoundCommand command = new CompoundCommand();
    List editparts = request.getEditParts();
    List children = getHost().getChildren();
    int newIndex = findIndexOfTreeItemAt(request.getLocation());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        int tempIndex = newIndex;
        int oldIndex = children.indexOf(child);
        if (tempIndex == -1 || oldIndex == tempIndex || oldIndex + 1 == tempIndex) {
            command.add(UnexecutableCommand.INSTANCE);
            return command;
        } else if (oldIndex <= tempIndex) {
            tempIndex--;
        }
        command.add(new MoveChildCommand((Element) child.getModel(),tempIndex));
    }
    return command;
}
项目:statecharts    文件:StateCompartmentCreationEditPolicy.java   
@Override
protected Command getCreateCommand(CreateViewRequest request) {
    StateEditPart parent = (StateEditPart) getHost().getParent();
    BooleanValueStyle isInline = GMFNotationUtil.getBooleanValueStyle(parent.getNotationView(),
            DiagramPartitioningUtil.INLINE_STYLE);
    if (isInline != null && !isInline.isBooleanValue())
        return UnexecutableCommand.INSTANCE;

    List<? extends ViewDescriptor> viewDescriptors = request.getViewDescriptors();
    for (ViewDescriptor viewDescriptor : viewDescriptors) {
        String semanticHint = viewDescriptor.getSemanticHint();
        if (ViewType.NOTE.equals(semanticHint) || ViewType.NOTEATTACHMENT.equals(semanticHint)
                || ViewType.TEXT.equals(semanticHint)) {
            return UnexecutableCommand.INSTANCE;
        }
    }
    return super.getCreateCommand(request);
}
项目:statecharts    文件:TreeLayoutEditPolicy.java   
@Override
protected Command createChangeConstraintCommand(EditPart child,
        Object constraint) {
    if (constraint instanceof TreeLayoutConstraint) {
        if (((TreeLayoutConstraint) constraint).isRoot()) {
            return UnexecutableCommand.INSTANCE;
        } else {
            return new ICommandProxy(new UpdateAnnotationsOnMoveCommand(
                    getHost().getEditingDomain(),
                    (IGraphicalEditPart) child,
                    (TreeLayoutConstraint) constraint));
        }

    }
    return super.createChangeConstraintCommand(child, constraint);
}
项目:PDFReporter-Studio    文件:JDDragGuidePolicy.java   
public Command getCommand(Request request) {
    Command cmd = null;
    final ChangeBoundsRequest req = (ChangeBoundsRequest) request;
    if (isDeleteRequest(req)) {
        cmd = getGuideEditPart().getRulerProvider().getDeleteGuideCommand(getHost().getModel());
    } else {
        int pDelta = 0;
        if (getGuideEditPart().isHorizontal()) {
            pDelta = req.getMoveDelta().y;
        } else {
            pDelta = req.getMoveDelta().x;
        }
        if (isMoveValid(getGuideEditPart().getZoomedPosition() + pDelta)) {
            ZoomManager zoomManager = getGuideEditPart().getZoomManager();
            if (zoomManager != null) {
                pDelta = (int) Math.round(pDelta / zoomManager.getZoom());
            }
            cmd = getGuideEditPart().getRulerProvider().getMoveGuideCommand(getHost().getModel(), pDelta);
        } else {
            cmd = UnexecutableCommand.INSTANCE;
        }
    }
    return cmd;
}
项目:PDFReporter-Studio    文件:OutlineTreeEditPartFactory.java   
/**
 * Gets the orphan command.
 * 
 * @param parent
 *          the parent
 * @param child
 *          the child
 * @return the orphan command
 */
public static Command getOrphanCommand(ANode parent, ANode child) {
    ExtensionManager m = JaspersoftStudioPlugin.getExtensionManager();
    Command c = m.getOrphanCommand(parent, child);
    if (c != null)
        return c;

    if (child instanceof MField)
        return new NoActionCommand();
    if (child instanceof MParameterSystem)
        return new NoActionCommand();
    if (child instanceof MVariableSystem)
        return new NoActionCommand();
    if (child instanceof MStyle)
        return new NoActionCommand();

    if (child instanceof MGraphicElement)
        return new OrphanElementCommand(parent, (MGraphicElement) child);
    if (child instanceof MElementGroup)
        return new OrphanElementGroupCommand(parent, (MElementGroup) child);
    if (child instanceof MConditionalStyle)
        if (parent instanceof MStyle)
            return new OrphanConditionalStyleCommand((MStyle) parent, (MConditionalStyle) child);
    return UnexecutableCommand.INSTANCE;
}
项目:PDFReporter-Studio    文件:JDTreeContainerEditPolicy.java   
@Override
protected Command getAddCommand(ChangeBoundsRequest request) {
    JSSCompoundCommand command = new JSSCompoundCommand(null);
    List<?> editparts = request.getEditParts();
    int index = findIndexOfTreeItemAt(request.getLocation());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        command.setReferenceNodeIfNull(child.getModel());
        if (isAncestor(child, getHost())) {
            command.add(UnexecutableCommand.INSTANCE);
        } else {
            ANode childModel = (ANode) child.getModel();
            command.add(createCreateCommand(childModel, index));
        }
    }
    return command;
}
项目:PDFReporter-Studio    文件:JDTreeContainerEditPolicy.java   
@Override
protected Command getMoveChildrenCommand(ChangeBoundsRequest request) {
    JSSCompoundCommand command = new JSSCompoundCommand(null);
    List<?> editparts = request.getEditParts();
    List<?> children = getHost().getChildren();
    int newIndex = findIndexOfTreeItemAt(request.getLocation());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        command.setReferenceNodeIfNull(child.getModel());
        int tempIndex = newIndex;
        int oldIndex = children.indexOf(child);
        if (oldIndex == tempIndex || oldIndex + 1 == tempIndex) {
            command.add(UnexecutableCommand.INSTANCE);
            return command;
        } else if (oldIndex <= tempIndex) {
            tempIndex--;
        }
        command.add(OutlineTreeEditPartFactory.getReorderCommand((ANode) child.getModel(), (ANode) getHost().getModel(),
                tempIndex));
    }
    return command;
}
项目:PDFReporter-Studio    文件:JDStyleTreeContainerEditPolicy.java   
protected Command getAddCommand(ChangeBoundsRequest request) {
    JSSCompoundCommand command = new JSSCompoundCommand(null);
    List<?> editparts = request.getEditParts();
    int index = findIndexOfTreeItemAt(request.getLocation());

    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        command.setReferenceNodeIfNull(child.getModel());
        if (isAncestor(child, getHost())) {
            command.add(UnexecutableCommand.INSTANCE);
        } else {
            ANode childModel = (ANode) child.getModel();
            command.add(createCreateCommand(childModel, index));
        }
    }
    return command;
}
项目:PDFReporter-Studio    文件:JDStyleTreeContainerEditPolicy.java   
protected Command getMoveChildrenCommand(ChangeBoundsRequest request) {
    JSSCompoundCommand command = new JSSCompoundCommand(null);
    List<?> editparts = request.getEditParts();
    List<?> children = getHost().getChildren();
    int newIndex = findIndexOfTreeItemAt(request.getLocation());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart child = (EditPart) editparts.get(i);
        command.setReferenceNodeIfNull(child.getModel());
        int tempIndex = newIndex;
        int oldIndex = children.indexOf(child);
        if (oldIndex == tempIndex || oldIndex + 1 == tempIndex) {
            command.add(UnexecutableCommand.INSTANCE);
            return command;
        } else if (oldIndex <= tempIndex) {
            tempIndex--;
        }
        command.add(OutlineTreeEditPartFactory.getReorderCommand((ANode) child.getModel(), (ANode) getHost().getModel(),
                tempIndex));
    }
    return command;
}
项目:gef-gwt    文件:TreeViewerTransferDropListener.java   
protected Command getCommand() {
    CompoundCommand command = new CompoundCommand();

    Iterator iter = ((List) TreeViewerTransfer.getInstance().getObject())
            .iterator();

    Request request = getTargetRequest();
    request.setType(isMove() ? RequestConstants.REQ_MOVE
            : RequestConstants.REQ_ORPHAN);

    while (iter.hasNext()) {
        EditPart editPart = (EditPart) iter.next();
        command.add(editPart.getCommand(request));
    }

    // If reparenting, add all editparts to target editpart.
    if (!isMove()) {
        request.setType(RequestConstants.REQ_ADD);
        if (getTargetEditPart() == null)
            command.add(UnexecutableCommand.INSTANCE);
        else
            command.add(getTargetEditPart().getCommand(getTargetRequest()));
    }
    return command;
}
项目:gef-gwt    文件:DragGuidePolicy.java   
public Command getCommand(Request request) {
    Command cmd;
    final ChangeBoundsRequest req = (ChangeBoundsRequest) request;
    if (isDeleteRequest(req)) {
        cmd = getGuideEditPart().getRulerProvider().getDeleteGuideCommand(
                getHost().getModel());
    } else {
        int pDelta;
        if (getGuideEditPart().isHorizontal()) {
            pDelta = req.getMoveDelta().y;
        } else {
            pDelta = req.getMoveDelta().x;
        }
        if (isMoveValid(getGuideEditPart().getZoomedPosition() + pDelta)) {
            ZoomManager zoomManager = getGuideEditPart().getZoomManager();
            if (zoomManager != null) {
                pDelta = (int) Math.round(pDelta / zoomManager.getZoom());
            }
            cmd = getGuideEditPart().getRulerProvider()
                    .getMoveGuideCommand(getHost().getModel(), pDelta);
        } else {
            cmd = UnexecutableCommand.INSTANCE;
        }
    }
    return cmd;
}
项目:ROADDesigner    文件:DeleteElementAction.java   
/**
 * @generated
 */
protected Command getCommand(Request request) {
    List operationSet = getOperationSet();
    if (operationSet.isEmpty()) {
        return UnexecutableCommand.INSTANCE;
    }
    Iterator editParts = operationSet.iterator();
    CompositeTransactionalCommand command = new CompositeTransactionalCommand(
            getEditingDomain(), getCommandLabel());
    while (editParts.hasNext()) {
        EditPart editPart = (EditPart) editParts.next();
        Command curCommand = editPart.getCommand(request);
        if (curCommand != null) {
            command.compose(new CommandProxy(curCommand));
        }
    }
    if (command.isEmpty() || command.size() != operationSet.size()) {
        return UnexecutableCommand.INSTANCE;
    }
    return new ICommandProxy(command);
}
项目:birt    文件:CrosstabCellEditPart.java   
protected void createEditPolicies( )
{
    installEditPolicy( EditPolicy.COMPONENT_ROLE,
            new ReportComponentEditPolicy( ) {

                protected org.eclipse.gef.commands.Command createDeleteCommand(
                        GroupRequest deleteRequest )
                {
                    return UnexecutableCommand.INSTANCE;
                }

                protected Command getOrphanCommand( )
                {
                    return new Command( ) {

                    };
                }
            } );
    installEditPolicy( EditPolicy.LAYOUT_ROLE,
            new CrosstabCellFlowLayoutEditPolicy( ) );
    installEditPolicy( EditPolicy.CONTAINER_ROLE,
            new CrosstabCellContainerEditPolicy( ) );

}
项目:birt    文件:ReportFlowLayoutEditPolicy.java   
protected Command createMoveChildCommand( EditPart child, EditPart after )
{
    Object afterModel = null;
    if ( after != null )
    {
        afterModel = after.getModel( );
    }
    if(child.getParent( ).getModel( ) instanceof ReportItemHandle)
    {
        ReportItemHandle reportHandle = (ReportItemHandle)child.getParent( ).getModel( );
        if(reportHandle.getViews( ).contains( child.getModel( ) ))
        {
            return UnexecutableCommand.INSTANCE;
        }
    }
    FlowMoveChildCommand command = new FlowMoveChildCommand( child.getModel( ),
            afterModel,
            child.getParent( ).getModel( ) );
    return command;
}
项目: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);
}
项目:MMINT    文件:DeleteElementAction.java   
/**
 * @generated
 */
protected Command getCommand(Request request) {
    List operationSet = getOperationSet();
    if (operationSet.isEmpty()) {
        return UnexecutableCommand.INSTANCE;
    }
    Iterator editParts = operationSet.iterator();
    CompositeTransactionalCommand command = new CompositeTransactionalCommand(
            getEditingDomain(), getCommandLabel());
    while (editParts.hasNext()) {
        EditPart editPart = (EditPart) editParts.next();
        Command curCommand = editPart.getCommand(request);
        if (curCommand != null) {
            command.compose(new CommandProxy(curCommand));
        }
    }
    if (command.isEmpty() || command.size() != operationSet.size()) {
        return UnexecutableCommand.INSTANCE;
    }
    return new ICommandProxy(command);
}
项目:MMINT    文件:DeleteElementAction.java   
/**
 * @generated
 */
protected Command getCommand(Request request) {
    List operationSet = getOperationSet();
    if (operationSet.isEmpty()) {
        return UnexecutableCommand.INSTANCE;
    }
    Iterator editParts = operationSet.iterator();
    CompositeTransactionalCommand command = new CompositeTransactionalCommand(
            getEditingDomain(), getCommandLabel());
    while (editParts.hasNext()) {
        EditPart editPart = (EditPart) editParts.next();
        Command curCommand = editPart.getCommand(request);
        if (curCommand != null) {
            command.compose(new CommandProxy(curCommand));
        }
    }
    if (command.isEmpty() || command.size() != operationSet.size()) {
        return UnexecutableCommand.INSTANCE;
    }
    return new ICommandProxy(command);
}
项目:d-case_editor    文件:DeleteElementAction.java   
/**
 * @generated
 */
protected Command getCommand(Request request) {
    List operationSet = getOperationSet();
    if (operationSet.isEmpty()) {
        return UnexecutableCommand.INSTANCE;
    }
    Iterator editParts = operationSet.iterator();
    CompositeTransactionalCommand command = new CompositeTransactionalCommand(
            getEditingDomain(), getCommandLabel());
    while (editParts.hasNext()) {
        EditPart editPart = (EditPart) editParts.next();
        Command curCommand = editPart.getCommand(request);
        if (curCommand != null) {
            command.compose(new CommandProxy(curCommand));
        }
    }
    if (command.isEmpty() || command.size() != operationSet.size()) {
        return UnexecutableCommand.INSTANCE;
    }
    return new ICommandProxy(command);
}
项目:gw4e.project    文件:GW4EEditLayoutPolicy.java   
@Override
protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
    AbstractLayoutCommand command = null;
    if (child instanceof VertexPart) {
        command = new VertexChangeLayoutCommand();
    }  
    if (command == null) {
        ResourceManager.logException(new Exception(""), "Dont know how to get comand for " + child.getClass().getName());
        return UnexecutableCommand.INSTANCE;
    }
    command.setModel(child.getModel());
    command.setConstraint((Rectangle) constraint);
    return command;
}
项目:gw4e.project    文件:GW4EVertexDeletePolicy.java   
protected Command createDeleteCommand(GroupRequest deleteRequest) {
    if (getHost().getModel() instanceof Vertex) {
        VertexDeleteCommand command = new VertexDeleteCommand();
        command.setModel(getHost().getModel());
        return command;
    }

    return UnexecutableCommand.INSTANCE;

}
项目:gw4e.project    文件:GW4ENodeGraphicalNodeEditPolicy.java   
@Override
protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
    LinkCreateCommand result = (LinkCreateCommand) request.getStartCommand();
    if (getHost().getModel() instanceof GraphElement) {
        GraphElement target = (GraphElement) getHost().getModel();
        result.setLink((GWLink) request.getNewObject());
        result.setTarget(target);
        return result;
    }
    return UnexecutableCommand.INSTANCE;
}
项目:gw4e.project    文件:GW4ENodeGraphicalNodeEditPolicy.java   
@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
    LinkCreateCommand result = new LinkCreateCommand();
    if (getHost().getModel() instanceof GraphElement) {
        result.setSource((GraphElement) getHost().getModel());

        result.setGraph(((GraphElement) getHost().getModel()).getGraph());
        request.setStartCommand(result);
        return result;
    }
    return UnexecutableCommand.INSTANCE;
}
项目:gw4e.project    文件:GW4ENodeGraphicalNodeEditPolicy.java   
@Override
protected Command getReconnectSourceCommand(ReconnectRequest request) {
    ConnectionReconnectCommand result = new ConnectionReconnectCommand();
    GWLink link = (GWLink) request.getConnectionEditPart().getModel();
    if (getHost().getModel() instanceof GraphElement) {
        result.setGraph(((GraphElement) getHost().getModel()).getGraph());
        result.setNewSource((GraphElement) getHost().getModel());
        result.setLink(link);
        return result;
    }
    return UnexecutableCommand.INSTANCE;
}
项目:gw4e.project    文件:GW4ENodeGraphicalNodeEditPolicy.java   
@Override
protected Command getReconnectTargetCommand(ReconnectRequest request) {
    ConnectionReconnectCommand result = new ConnectionReconnectCommand();
    GWLink link = (GWLink) request.getConnectionEditPart().getModel();
    if (getHost().getModel() instanceof GraphElement) {
        result.setGraph(((GraphElement) getHost().getModel()).getGraph());
        result.setNewTarget((GraphElement) getHost().getModel());
        result.setLink(link);
        return result;
    }
    return UnexecutableCommand.INSTANCE;
}
项目:gw4e.project    文件:GW4EVertexDirectEditPolicy.java   
@Override
protected Command getDirectEditCommand(DirectEditRequest request) {
    String value = (String) request.getCellEditor().getValue();
    if(Constant.START_VERTEX_NAME.equalsIgnoreCase(value.trim())) {
        return UnexecutableCommand.INSTANCE;
    }
    GraphElementRenameCommand command = new GraphElementRenameCommand();
    command.setOldName(((Vertex) getHost().getModel()).getName());
    command.setModel((Vertex) getHost().getModel());
    command.setNewName(value);
    return command;
}
项目:gw4e.project    文件:GW4EdgeDeletePolicy.java   
protected Command createDeleteCommand(GroupRequest deleteRequest) {
    if (getHost().getModel() instanceof GWLink) {
        LinkDeleteCommand command = new LinkDeleteCommand();
        command.setModel(getHost().getModel());
        return command;
    }
    return UnexecutableCommand.INSTANCE;

}
项目:ForgedUI-Eclipse    文件:TreeEditPolicy.java   
protected Command getMoveCommand(ChangeBoundsRequest req) {
    EditPart parent = getHost().getParent();
    if (parent != null) {
        ChangeBoundsRequest request = new ChangeBoundsRequest(
                REQ_MOVE_CHILDREN);
        request.setEditParts(getHost());
        request.setLocation(req.getLocation());
        return parent.getCommand(request);
    }
    return UnexecutableCommand.INSTANCE;
}
项目:statecharts    文件:RegionEditPart.java   
@Override
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new ConstrainedToolbarLayoutEditPolicy() {
        @Override
        protected Command getAutoSizeCommand(Request request) {
            return UnexecutableCommand.INSTANCE;
        }
    });
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PreferredSizeHandlerEditPolicy());
}
项目:statecharts    文件:CompartmentCreationEditPolicy.java   
@Override
protected Command getReparentCommand(ChangeBoundsRequest request) {
    if (!isValidSelection(request.getEditParts())) {
        return UnexecutableCommand.INSTANCE;
    }
    return super.getReparentCommand(request);
}
项目:PDFReporter-Studio    文件:ElementTreeEditPolicy.java   
/**
 * Gets the move command.
 * 
 * @param req
 *          the req
 * @return the move command
 */
protected Command getMoveCommand(ChangeBoundsRequest req) {
    EditPart parent = getHost().getParent();
    if (parent != null) {
        ChangeBoundsRequest request = new ChangeBoundsRequest(REQ_MOVE_CHILDREN);
        request.setEditParts(getHost());
        request.setLocation(req.getLocation());
        return parent.getCommand(request);
    }
    return UnexecutableCommand.INSTANCE;
}
项目:OpenSPIFe    文件:TimelineViewerEditPartsTracker.java   
@Override
protected Command getCommand() {
    CompoundCommand command = new CompoundCommand();
    command.setDebugLabel("Drag Object Tracker");//$NON-NLS-1$

    Iterator iter = getOperationSet().iterator();

    Request request = getTargetRequest();

    if (isCloneActive())
        request.setType(REQ_CLONE);
    else if (isAddValueActive())
        request.setType(REQ_ADD_VALUE_VIA_DROP);
    else if (isChangeValueActive())
        request.setType(REQ_CHANGE_VALUE_VIA_DROP);
    else if (isMove())
        request.setType(REQ_MOVE);
    else
        request.setType(REQ_ORPHAN);

    if (!isChangeValueActive() && !isAddValueActive()) {
        while (iter.hasNext()) {
            EditPart editPart = (EditPart) iter.next();
            command.add(editPart.getCommand(request));
        }
    }

    if (!isMove() || isChangeValueActive() || isAddValueActive()) {
        if (!isChangeValueActive() && !isAddValueActive())
            request.setType(REQ_ADD);

        if (getTargetEditPart() == null)
            command.add(UnexecutableCommand.INSTANCE);
        else
            command.add(getTargetEditPart().getCommand(getTargetRequest()));
    }

    return command.unwrap();
}
项目:gef-gwt    文件:RulerDragTracker.java   
protected Command getCommand() {
    if (isCreationValid() && !isDelete())
        return source.getRulerProvider().getCreateGuideCommand(
                getCurrentPosition());
    else
        return UnexecutableCommand.INSTANCE;
}
项目:gef-gwt    文件:DragEditPartsTracker.java   
/**
 * Asks each edit part in the {@link AbstractTool#getOperationSet()
 * operation set} to contribute to a {@link CompoundCommand} after first
 * setting the request type to either {@link RequestConstants#REQ_MOVE} or
 * {@link RequestConstants#REQ_ORPHAN}, depending on the result of
 * {@link #isMove()}.
 * 
 * @see org.eclipse.gef.tools.AbstractTool#getCommand()
 */
protected Command getCommand() {
    CompoundCommand command = new CompoundCommand();
    command.setDebugLabel("Drag Object Tracker");//$NON-NLS-1$

    Iterator iter = getOperationSet().iterator();

    Request request = getTargetRequest();

    if (isCloneActive())
        request.setType(REQ_CLONE);
    else if (isMove())
        request.setType(REQ_MOVE);
    else
        request.setType(REQ_ORPHAN);

    if (!isCloneActive()) {
        while (iter.hasNext()) {
            EditPart editPart = (EditPart) iter.next();
            command.add(editPart.getCommand(request));
        }
    }

    if (!isMove() || isCloneActive()) {
        if (!isCloneActive())
            request.setType(REQ_ADD);

        if (getTargetEditPart() == null)
            command.add(UnexecutableCommand.INSTANCE);
        else
            command.add(getTargetEditPart().getCommand(getTargetRequest()));
    }

    return command.unwrap();
}
项目:birt    文件:CrosstavCellDragHandle.java   
protected DragTracker createDragTracker( )
{
    CrosstabHandleAdapter adapter = ((CrosstabTableEditPart)getOwner( ).getParent( )).getCrosstabHandleAdapter( );
    if (cursorDirection == PositionConstants.EAST && 
            (adapter.getColumnOprationCell( start )!=null||adapter.getColumnOprationCell( end )!=null))
    {
        return new CrosstabColumnDragTracker(getOwner( ), start, end);
    }
    if (cursorDirection == PositionConstants.SOUTH && adapter.getRowOprationCell( start ) != null)
    {
        return new CrosstabRowDragTracker(getOwner( ), start, end);
    }
    //return null;
    return new ResizeTracker( getOwner( ), cursorDirection )
    {
        protected void showTargetFeedback() 
        {

        }
        protected void eraseTargetFeedback() 
        {

        }

        protected void showSourceFeedback( )
        {
        }

        protected void eraseSourceFeedback( )
        {
        }

        protected Command getCommand( )
        {
            return UnexecutableCommand.INSTANCE;
        }
    };
}
项目:birt    文件:VirtualCrosstabCellFlowLayoutEditPolicy.java   
protected Command createAddCommand( EditPart parent, EditPart child,
        EditPart after )
{
    Object parentObj = parent.getModel( );
    // Object source = child.getModel( );
    Object afterObj = after == null ? null : after.getModel( );
    Object childParent = getOperator( child ).getModel( );
    if ( parentObj instanceof VirtualCrosstabCellAdapter
            && childParent instanceof CrosstabCellAdapter )
    {
        CrosstabCellAdapter childAdapter = (CrosstabCellAdapter) childParent;
        VirtualCrosstabCellAdapter parentAdapter = (VirtualCrosstabCellAdapter) parentObj;
        if ( parentAdapter.getType( ) == VirtualCrosstabCellAdapter.IMMACULATE_TYPE
                || parentAdapter.getType( ) == VirtualCrosstabCellAdapter.MEASURE_TYPE )
        {
            return UnexecutableCommand.INSTANCE;
        }
        if ( ICrosstabCellAdapterFactory.CELL_FIRST_LEVEL_HANDLE.equals( childAdapter.getPositionType( ) ) )
        {
            if ( !( after instanceof FirstLevelHandleDataItemEditPart ) )
            {
                afterObj = null;
            }
            if ( parent.getParent( ) == getOperator( child ).getParent( ) )
            {
                ChangeAreaCommand command = new ChangeAreaCommand( parentAdapter.getDesignElementHandle( ),
                        childAdapter.getDesignElementHandle( ),
                        DNDUtil.unwrapToModel( afterObj ) );

                command.setType( parentAdapter.getType( ) );
                return command;
            }
            else
            {
                return UnexecutableCommand.INSTANCE;
            }
        }
    }
    return UnexecutableCommand.INSTANCE;
}
项目:birt    文件:EditorDragGuidePolicy.java   
public Command getCommand( Request request )
{
    Command cmd;
    final ChangeBoundsRequest req = (ChangeBoundsRequest) request;
    if ( isDeleteRequest( req ) )
    {
        cmd = getGuideEditPart( ).getRulerProvider( )
                .getDeleteGuideCommand( getHost( ).getModel( ) );
    }
    else
    {
        int pDelta;
        if ( getGuideEditPart( ).isHorizontal( ) )
        {
            pDelta = req.getMoveDelta( ).y;
        }
        else
        {
            pDelta = req.getMoveDelta( ).x;
        }
        if ( isMoveValid( getGuideEditPart( ).getZoomedPosition( ) + pDelta ) )
        {
            ZoomManager zoomManager = getGuideEditPart( ).getZoomManager( );
            if ( zoomManager != null )
            {
                pDelta = (int) Math.round( pDelta / zoomManager.getZoom( ) );
            }
            cmd = getGuideEditPart( ).getRulerProvider( )
                    .getMoveGuideCommand( getHost( ).getModel( ), pDelta );
        }
        else
        {
            cmd = UnexecutableCommand.INSTANCE;
        }
    }
    return cmd;
}
项目:birt    文件:MultipleEditPart.java   
protected void createEditPolicies( )
{
    installEditPolicy( EditPolicy.COMPONENT_ROLE,
            new ReportComponentEditPolicy( ) );
    installEditPolicy( EditPolicy.LAYOUT_ROLE,
            new ReportFlowLayoutEditPolicy( )
    {
        @Override
        protected Command getAddCommand( Request req )
        {
            return UnexecutableCommand.INSTANCE;
        }

        @Override
        public EditPart getTargetEditPart( Request request )
        {
            if (REQ_CREATE.equals(request.getType()))
            {
                if (((ReportItemHandle)getHost( ).getModel( )).getCurrentView( ) != null)
                {
                    return null;
                }
            }
            return super.getTargetEditPart( request );
        }
    });
}
项目:birt    文件:TableCellDragHandle.java   
protected DragTracker createDragTracker( )
{

    if (cursorDirection == PositionConstants.EAST )
    {
        return new ColumnDragTracker(getOwner( ).getParent( ), start, end);
    }
    if (cursorDirection == PositionConstants.SOUTH)
    {
        return new RowDragTracker(getOwner( ).getParent( ), start, end);
    }
    //return null;
    return new ResizeTracker( getOwner( ), cursorDirection )
    {
        protected void showTargetFeedback() 
        {

        }
        protected void eraseTargetFeedback() 
        {

        }

        protected void showSourceFeedback( )
        {
        }

        protected void eraseSourceFeedback( )
        {
        }

        protected Command getCommand( )
        {
            return UnexecutableCommand.INSTANCE;
        }
    };
}
项目:birt    文件:ReportFlowLayoutEditPolicy.java   
/**
 * @param parent
 * @param child
 * @param insertionReference
 * @return command
 */
protected Command createAddCommand( EditPart parent, EditPart child,
        EditPart insertionReference )
{
    Object parentModel = null;
    if ( parent.getModel( ) instanceof ListBandProxy )
    {
        parentModel = ( (ListBandProxy) parent.getModel( ) ).getSlotHandle( );
    }
    else
    {
        parentModel = parent.getModel( );
    }
    if ( !( child.getModel( ) instanceof DesignElementHandle ) )
    {
        return UnexecutableCommand.INSTANCE;
    }
    if (insertionReference != null && !(insertionReference.getModel( ) instanceof DesignElementHandle))
    {
        return UnexecutableCommand.INSTANCE;
    }
    return new PasteCommand( (DesignElementHandle) child.getModel( ),
            parentModel,
            insertionReference == null ? null
                    : (DesignElementHandle) insertionReference.getModel( ),
            false );
}