Search in sources :

Example 1 with RadLayout

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

the class WrapInAction method fill.

public static void fill(DesignerEditorPanel designer, DefaultActionGroup group, EditableArea area) {
    List<RadComponent> selection = area.getSelection();
    if (selection.isEmpty()) {
        return;
    }
    Set<RadComponent> parents = RadComponent.getParents(selection);
    if (parents.size() != 1) {
        return;
    }
    RadComponent parent = parents.iterator().next();
    if (selection.size() > 1) {
        RadLayout layout = parent.getLayout();
        if (layout != null && !layout.isWrapIn(selection)) {
            return;
        }
    }
    WrapInProvider provider = designer.getWrapInProvider();
    if (provider == null) {
        return;
    }
    List<MetaModel> models = provider.getModels();
    if (models.isEmpty()) {
        return;
    }
    DefaultActionGroup wrapGroup = new DefaultActionGroup("Wrap In", true);
    for (MetaModel wrapModel : models) {
        wrapGroup.add(new WrapInAction(designer, area, provider, parent, selection, wrapModel));
    }
//group.add(wrapGroup); // XXX
}
Also used : MetaModel(com.intellij.designer.model.MetaModel) RadLayout(com.intellij.designer.model.RadLayout) RadComponent(com.intellij.designer.model.RadComponent) WrapInProvider(com.intellij.designer.model.WrapInProvider) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 2 with RadLayout

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

RadComponent (com.intellij.designer.model.RadComponent)2 RadLayout (com.intellij.designer.model.RadLayout)2 ComponentTargetFilter (com.intellij.designer.designSurface.ComponentTargetFilter)1 EditOperation (com.intellij.designer.designSurface.EditOperation)1 MetaModel (com.intellij.designer.model.MetaModel)1 RadComponentVisitor (com.intellij.designer.model.RadComponentVisitor)1 WrapInProvider (com.intellij.designer.model.WrapInProvider)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 ArrayList (java.util.ArrayList)1