Search in sources :

Example 6 with RadComponent

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

the class SelectSameTypeAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    RadComponent rootComponent = myArea.getRootComponent();
    if (rootComponent != null) {
        final List<RadComponent> selection = myArea.getSelection();
        final List<RadComponent> components = new ArrayList<>();
        rootComponent.accept(new RadComponentVisitor() {

            @Override
            public void endVisit(RadComponent component) {
                if (!component.isBackground()) {
                    for (RadComponent selected : selection) {
                        if (selected.isSameType(component)) {
                            components.add(component);
                            break;
                        }
                    }
                }
            }
        }, true);
        myArea.setSelection(components);
    }
}
Also used : RadComponentVisitor(com.intellij.designer.model.RadComponentVisitor) RadComponent(com.intellij.designer.model.RadComponent) ArrayList(java.util.ArrayList)

Example 7 with RadComponent

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

the class SelectSiblingsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    RadComponent rootComponent = myArea.getRootComponent();
    if (rootComponent != null) {
        final Set<RadComponent> parents = RadComponent.getParents(myArea.getSelection());
        final List<RadComponent> components = new ArrayList<>();
        rootComponent.accept(new RadComponentVisitor() {

            @Override
            public void endVisit(RadComponent component) {
                if (parents.contains(component.getParent())) {
                    components.add(component);
                }
            }
        }, true);
        myArea.setSelection(components);
    }
}
Also used : RadComponentVisitor(com.intellij.designer.model.RadComponentVisitor) RadComponent(com.intellij.designer.model.RadComponent) ArrayList(java.util.ArrayList)

Example 8 with RadComponent

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

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

the class ComponentTree method extractComponent.

@Nullable
public RadComponent extractComponent(Object value) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    Object userObject = node.getUserObject();
    if (myDesigner != null && userObject instanceof TreeNodeDescriptor) {
        TreeNodeDescriptor descriptor = (TreeNodeDescriptor) userObject;
        Object element = descriptor.getElement();
        if (element instanceof RadComponent) {
            return (RadComponent) element;
        }
    }
    return null;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RadComponent(com.intellij.designer.model.RadComponent) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with RadComponent

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

the class TreeEditOperation method isTarget.

public static boolean isTarget(RadComponent container, OperationContext context) {
    Point location = context.getLocation();
    RadComponent target = context.getArea().findTarget(location.x, location.y, null);
    if (target == container) {
        FeedbackTreeLayer layer = context.getArea().getFeedbackTreeLayer();
        return !layer.isBeforeLocation(target, location.x, location.y) && !layer.isAfterLocation(target, location.x, location.y);
    }
    return true;
}
Also used : RadComponent(com.intellij.designer.model.RadComponent) FeedbackTreeLayer(com.intellij.designer.designSurface.FeedbackTreeLayer)

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