Search in sources :

Example 1 with RadComponentVisitor

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

the class DecorationLayer method paintStaticDecorators.

private void paintStaticDecorators(Graphics2D g) {
    final List<StaticDecorator> decorators = new ArrayList<>();
    final List<RadComponent> selection = myArea.getSelection();
    myArea.getRootComponent().accept(new RadComponentVisitor() {

        @Override
        public void endVisit(RadComponent component) {
            component.addStaticDecorators(decorators, selection);
        }
    }, true);
    for (StaticDecorator decorator : decorators) {
        decorator.decorate(this, g);
    }
}
Also used : RadComponentVisitor(com.intellij.designer.model.RadComponentVisitor) ArrayList(java.util.ArrayList) RadComponent(com.intellij.designer.model.RadComponent)

Example 2 with RadComponentVisitor

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

the class SelectAllAction method actionPerformed.

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

            @Override
            public void endVisit(RadComponent component) {
                if (!component.isBackground()) {
                    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 3 with RadComponentVisitor

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

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

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

the class MarqueeTracker method performMarqueeSelect.

private void performMarqueeSelect() {
    final Rectangle selectionRectangle = getSelectionRectangle();
    final List<RadComponent> newSelection = new ArrayList<>();
    RadComponent rootComponent = myArea.getRootComponent();
    if (rootComponent != null) {
        rootComponent.accept(new RadComponentVisitor() {

            @Override
            public void endVisit(RadComponent component) {
                if (selectionRectangle.contains(component.getBounds(myArea.getNativeComponent())) && !component.isBackground()) {
                    newSelection.add(component);
                }
            }
        }, true);
        if (newSelection.isEmpty() && mySelectBackground) {
            rootComponent.accept(new RadComponentVisitor() {

                @Override
                public void endVisit(RadComponent component) {
                    // Only select the bottom-most background
                    if (newSelection.isEmpty() && component.getBounds(myArea.getNativeComponent()).contains(selectionRectangle.x, selectionRectangle.y) && component.isBackground()) {
                        newSelection.add(component);
                    }
                }
            }, true);
        }
    }
    if (mySelectionMode == TOGGLE_MODE) {
        List<RadComponent> selection = new ArrayList<>(myArea.getSelection());
        for (RadComponent component : newSelection) {
            int index = selection.indexOf(component);
            if (index == -1) {
                selection.add(component);
            } else {
                selection.remove(index);
            }
        }
        myArea.setSelection(selection);
    } else if (mySelectionMode == APPEND_MODE) {
        for (RadComponent component : newSelection) {
            myArea.appendSelection(component);
        }
    } else {
        myArea.setSelection(newSelection);
    }
}
Also used : RadComponentVisitor(com.intellij.designer.model.RadComponentVisitor) ArrayList(java.util.ArrayList) RadComponent(com.intellij.designer.model.RadComponent)

Aggregations

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