Search in sources :

Example 36 with RadComponent

use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.

the class AbstractGuiEditorAction method actionPerformed.

public final void actionPerformed(final AnActionEvent e) {
    final GuiEditor editor = FormEditingUtil.getEditorFromContext(e.getDataContext());
    if (editor != null) {
        final ArrayList<RadComponent> selection = FormEditingUtil.getSelectedComponents(editor);
        if (myModifying) {
            if (!editor.ensureEditable())
                return;
        }
        InplaceEditingLayer editingLayer = editor.getInplaceEditingLayer();
        if (editingLayer.isEditing()) {
            editingLayer.finishInplaceEditing();
        }
        Runnable runnable = () -> {
            actionPerformed(editor, selection, e);
            if (myModifying) {
                editor.refreshAndSave(true);
            }
        };
        if (getCommandName() != null) {
            CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, getCommandName(), null);
        } else {
            runnable.run();
        }
    }
}
Also used : InplaceEditingLayer(com.intellij.uiDesigner.designSurface.InplaceEditingLayer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor)

Example 37 with RadComponent

use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.

the class AbstractMoveSelectionAction method actionPerformed.

public final void actionPerformed(final AnActionEvent e) {
    final ArrayList<RadComponent> selectedComponents = FormEditingUtil.getSelectedComponents(myEditor);
    final JComponent rootContainerDelegee = myEditor.getRootContainer().getDelegee();
    if (selectedComponents.size() == 0) {
        moveToFirstComponent(rootContainerDelegee);
        return;
    }
    RadComponent selectedComponent = myEditor.getSelectionLead();
    if (selectedComponent == null || !selectedComponents.contains(selectedComponent)) {
        selectedComponent = selectedComponents.get(0);
    }
    if (moveSelectionByGrid(selectedComponent) || myMoveToLast) {
        return;
    }
    // 1. We need to get coordinates of all editor's component in the same
    // coordinate system. For example, in the RadRootContainer rootContainerDelegee's coordinate system.
    final ArrayList<RadComponent> components = new ArrayList<>();
    final ArrayList<Point> points = new ArrayList<>();
    final RadComponent selectedComponent1 = selectedComponent;
    FormEditingUtil.iterate(myEditor.getRootContainer(), new FormEditingUtil.ComponentVisitor<RadComponent>() {

        public boolean visit(final RadComponent component) {
            if (component instanceof RadAtomicComponent) {
                if (selectedComponent1.equals(component)) {
                    return true;
                }
                if (!FormEditingUtil.isComponentSwitchedInView(component)) {
                    return true;
                }
                components.add(component);
                final JComponent _delegee = component.getDelegee();
                final Point p = SwingUtilities.convertPoint(_delegee, new Point(0, 0), rootContainerDelegee);
                p.x += _delegee.getWidth() / 2;
                p.y += _delegee.getHeight() / 2;
                points.add(p);
            }
            return true;
        }
    });
    if (components.size() == 0) {
        return;
    }
    // 2.
    final Point source = SwingUtilities.convertPoint(selectedComponent.getDelegee(), new Point(0, 0), rootContainerDelegee);
    source.x += selectedComponent.getDelegee().getWidth() / 2;
    source.y += selectedComponent.getDelegee().getHeight() / 2;
    int min = Integer.MAX_VALUE;
    int nextSelectedIndex = -1;
    for (int i = points.size() - 1; i >= 0; i--) {
        final int distance = calcDistance(source, points.get(i));
        if (distance < min) {
            min = distance;
            nextSelectedIndex = i;
        }
    }
    if (min == Integer.MAX_VALUE) {
        return;
    }
    LOG.assertTrue(nextSelectedIndex != -1);
    final RadComponent component = components.get(nextSelectedIndex);
    selectOrExtend(component);
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) ArrayList(java.util.ArrayList) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) RadAtomicComponent(com.intellij.uiDesigner.radComponents.RadAtomicComponent)

Example 38 with RadComponent

use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.

the class AddTabAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    RadTabbedPane tabbedPane = (RadTabbedPane) selection.get(0);
    Palette palette = Palette.getInstance(editor.getProject());
    final RadComponent radComponent = InsertComponentProcessor.createPanelComponent(editor);
    final ComponentDropLocation dropLocation = tabbedPane.getDropLocation(null);
    dropLocation.processDrop(editor, new RadComponent[] { radComponent }, null, new ComponentItemDragObject(palette.getPanelItem()));
}
Also used : Palette(com.intellij.uiDesigner.palette.Palette) RadTabbedPane(com.intellij.uiDesigner.radComponents.RadTabbedPane) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) ComponentItemDragObject(com.intellij.uiDesigner.designSurface.ComponentItemDragObject) ComponentDropLocation(com.intellij.uiDesigner.designSurface.ComponentDropLocation)

Example 39 with RadComponent

use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.

the class SelectionState method getSelection.

public static ComponentPtr[] getSelection(final GuiEditor editor) {
    final ArrayList<RadComponent> selection = FormEditingUtil.getAllSelectedComponents(editor);
    final ComponentPtr[] ptrs = new ComponentPtr[selection.size()];
    for (int i = selection.size() - 1; i >= 0; i--) {
        ptrs[i] = new ComponentPtr(editor, selection.get(i));
    }
    return ptrs;
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) ComponentPtr(com.intellij.uiDesigner.componentTree.ComponentPtr)

Example 40 with RadComponent

use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.

the class SnapshotContext method postProcess.

public void postProcess() {
    for (ButtonGroup group : myButtonGroups) {
        RadButtonGroup radButtonGroup = myRootContainer.createGroup(myRootContainer.suggestGroupName());
        Enumeration<AbstractButton> elements = group.getElements();
        while (elements.hasMoreElements()) {
            AbstractButton btn = elements.nextElement();
            RadComponent c = myImportMap.get(btn);
            if (c != null) {
                radButtonGroup.add(c);
            }
        }
    }
    for (ComponentProperty prop : myComponentProperties) {
        RadComponent radOwner = myImportMap.get(prop.owner);
        RadComponent radValue = myImportMap.get(prop.value);
        if (radOwner != null && radValue != null) {
            final IntrospectedProperty property = radOwner.getPalette().getIntrospectedProperty(radOwner, prop.name);
            assert property != null;
            //noinspection unchecked
            IntroComponentProperty icp = (IntroComponentProperty) property;
            try {
                icp.setValue(radOwner, radValue.getId());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
Also used : IntroComponentProperty(com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty) RadButtonGroup(com.intellij.uiDesigner.radComponents.RadButtonGroup) IntroComponentProperty(com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty) RadButtonGroup(com.intellij.uiDesigner.radComponents.RadButtonGroup) IntrospectedProperty(com.intellij.uiDesigner.propertyInspector.IntrospectedProperty) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent)

Aggregations

RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)86 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)22 RadRootContainer (com.intellij.uiDesigner.radComponents.RadRootContainer)18 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)15 ArrayList (java.util.ArrayList)12 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)8 GuiEditor (com.intellij.uiDesigner.designSurface.GuiEditor)8 IComponent (com.intellij.uiDesigner.lw.IComponent)7 IProperty (com.intellij.uiDesigner.lw.IProperty)6 ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)5 RadButtonGroup (com.intellij.uiDesigner.radComponents.RadButtonGroup)5 ListPopup (com.intellij.openapi.ui.popup.ListPopup)4 ComponentTree (com.intellij.uiDesigner.componentTree.ComponentTree)4 IntrospectedProperty (com.intellij.uiDesigner.propertyInspector.IntrospectedProperty)4 IntroComponentProperty (com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty)4 QuickFix (com.intellij.uiDesigner.quickFixes.QuickFix)4 Nullable (org.jetbrains.annotations.Nullable)4 RelativePoint (com.intellij.ui.awt.RelativePoint)3 Palette (com.intellij.uiDesigner.palette.Palette)3 IncorrectOperationException (com.intellij.util.IncorrectOperationException)3