Search in sources :

Example 26 with RadComponent

use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.

the class AbstractCreationTool method updateTargetUnderMouse.

private void updateTargetUnderMouse() {
    ContainerTargetFilter filter = new ContainerTargetFilter();
    RadComponent target = myArea.findTarget(myCurrentScreenX, myCurrentScreenY, filter);
    setTarget(target, filter);
    if (target != null) {
        updateTarget();
    }
}
Also used : RadComponent(com.intellij.designer.model.RadComponent)

Example 27 with RadComponent

use of com.intellij.designer.model.RadComponent 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)

Example 28 with RadComponent

use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.

the class TreeDropListener method updateContext.

private void updateContext() {
    myContext.setLocation(getLocation());
    if (myContext.getComponents() == null) {
        if (!ArrayUtil.contains(SimpleTransferable.getData(myEvent.getTransferable(), Class.class), myDragTargets)) {
            myContext.setComponents(Collections.<RadComponent>emptyList());
            return;
        }
        if (myToolProvider.getActiveTool() instanceof CreationTool) {
            myContext.setType(OperationContext.CREATE);
            CreationTool tool = (CreationTool) myToolProvider.getActiveTool();
            try {
                myContext.setComponents(Collections.singletonList(tool.getFactory().create()));
            } catch (Throwable e) {
                myContext.setComponents(Collections.<RadComponent>emptyList());
                myToolProvider.loadDefaultTool();
            }
            return;
        }
        List<RadComponent> components = RadComponent.getPureSelection(myArea.getSelection());
        RadComponent parent = null;
        for (RadComponent component : components) {
            if (parent == null) {
                parent = component.getParent();
            } else if (parent != component.getParent()) {
                components = Collections.emptyList();
                break;
            }
        }
        myContext.setComponents(components);
        myContext.resetMoveAddEnabled();
        for (RadComponent component : components) {
            component.processDropOperation(myContext);
        }
    }
}
Also used : CreationTool(com.intellij.designer.designSurface.tools.CreationTool) RadComponent(com.intellij.designer.model.RadComponent)

Aggregations

RadComponent (com.intellij.designer.model.RadComponent)28 ArrayList (java.util.ArrayList)8 RadComponentVisitor (com.intellij.designer.model.RadComponentVisitor)6 Nullable (org.jetbrains.annotations.Nullable)3 EditOperation (com.intellij.designer.designSurface.EditOperation)2 IComponentCopyProvider (com.intellij.designer.model.IComponentCopyProvider)2 MetaModel (com.intellij.designer.model.MetaModel)2 RadLayout (com.intellij.designer.model.RadLayout)2 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)2 SimpleTransferable (com.intellij.designer.clipboard.SimpleTransferable)1 ComponentTargetFilter (com.intellij.designer.designSurface.ComponentTargetFilter)1 EditableArea (com.intellij.designer.designSurface.EditableArea)1 FeedbackTreeLayer (com.intellij.designer.designSurface.FeedbackTreeLayer)1 LineMarginBorder (com.intellij.designer.designSurface.feedbacks.LineMarginBorder)1 CreationTool (com.intellij.designer.designSurface.tools.CreationTool)1 InputTool (com.intellij.designer.designSurface.tools.InputTool)1 IComponentDeletionParticipant (com.intellij.designer.model.IComponentDeletionParticipant)1 Property (com.intellij.designer.model.Property)1 WrapInProvider (com.intellij.designer.model.WrapInProvider)1 InplaceContext (com.intellij.designer.propertyTable.InplaceContext)1