Search in sources :

Example 1 with EditOperation

use of com.intellij.designer.designSurface.EditOperation in project intellij-community by JetBrains.

the class ResizeTracker method executeCommand.

private void executeCommand() {
    if (myExecuteEnabled) {
        List<EditOperation> operations = new ArrayList<>();
        for (EditOperation operation : getOperations()) {
            if (operation.canExecute()) {
                operations.add(operation);
            }
        }
        myToolProvider.execute(operations, DesignerBundle.message("command.tool_operation"));
    }
}
Also used : ArrayList(java.util.ArrayList) EditOperation(com.intellij.designer.designSurface.EditOperation)

Example 2 with EditOperation

use of com.intellij.designer.designSurface.EditOperation in project intellij-community by JetBrains.

the class ResizeTracker method getOperations.

private List<EditOperation> getOperations() {
    if (myOperations == null) {
        myContext.setComponents(new ArrayList<>(myArea.getSelection()));
        myOperations = new ArrayList<>();
        for (RadComponent component : myContext.getComponents()) {
            EditOperation operation;
            RadComponent parent = component.getParent();
            if (parent == null) {
                operation = myArea.processRootOperation(myContext);
            } else {
                operation = parent.getLayout().processChildOperation(myContext);
            }
            if (operation != null) {
                myOperations.add(operation);
                operation.setComponent(component);
            }
        }
    }
    return myOperations;
}
Also used : RadComponent(com.intellij.designer.model.RadComponent) EditOperation(com.intellij.designer.designSurface.EditOperation)

Example 3 with EditOperation

use of com.intellij.designer.designSurface.EditOperation in project intellij-community by JetBrains.

the class TreeDropListener method updateTargetUnderMouse.

private void updateTargetUnderMouse() {
    if (myContext.getComponents().isEmpty()) {
        return;
    }
    final List<RadComponent> excludeComponents = new ArrayList<>(myContext.getComponents());
    if (!myContext.isCreate()) {
        for (RadComponent component : myContext.getComponents()) {
            component.accept(new RadComponentVisitor() {

                @Override
                public void endVisit(RadComponent component) {
                    excludeComponents.add(component);
                }
            }, true);
        }
    }
    final EditOperation[] operation = new EditOperation[1];
    ComponentTargetFilter filter = new ComponentTargetFilter() {

        @Override
        public boolean preFilter(RadComponent component) {
            return myContext.isCreate() || !excludeComponents.contains(component);
        }

        @Override
        public boolean resultFilter(RadComponent target) {
            if (!myContext.isCreate()) {
                if (myContext.getComponents().get(0).getParent() == target) {
                    myContext.setType(OperationContext.MOVE);
                } else {
                    myContext.setType(OperationContext.ADD);
                }
            }
            if (myTarget == target) {
                return true;
            }
            RadLayout layout = target.getLayout();
            if (layout != null) {
                operation[0] = layout.processChildOperation(myContext);
            }
            return operation[0] != null;
        }
    };
    Point location = getLocation();
    RadComponent target = myArea.findTarget(location.x, location.y, filter);
    if (target != myTarget) {
        if (myTargetOperation != null) {
            eraseFeedback();
        }
        myTarget = target;
        myTargetOperation = operation[0];
    }
    if (target == null) {
        if (!myContext.isCreate()) {
            myContext.setType(null);
        }
    } else {
        myTargetOperation.setComponents(myContext.getComponents());
    }
}
Also used : RadComponentVisitor(com.intellij.designer.model.RadComponentVisitor) RadLayout(com.intellij.designer.model.RadLayout) ArrayList(java.util.ArrayList) RadComponent(com.intellij.designer.model.RadComponent) EditOperation(com.intellij.designer.designSurface.EditOperation) ComponentTargetFilter(com.intellij.designer.designSurface.ComponentTargetFilter)

Aggregations

EditOperation (com.intellij.designer.designSurface.EditOperation)3 RadComponent (com.intellij.designer.model.RadComponent)2 ArrayList (java.util.ArrayList)2 ComponentTargetFilter (com.intellij.designer.designSurface.ComponentTargetFilter)1 RadComponentVisitor (com.intellij.designer.model.RadComponentVisitor)1 RadLayout (com.intellij.designer.model.RadLayout)1