Search in sources :

Example 21 with RadComponent

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

the class FlattenAction method flattenGrid.

private static void flattenGrid(final RadContainer container) {
    RadContainer parent = container.getParent();
    GridConstraints containerConstraints = (GridConstraints) container.getConstraints().clone();
    // ensure there will be enough rows and columns to fit the container contents
    for (int i = containerConstraints.getRowSpan(); i < container.getGridRowCount(); i++) {
        GridChangeUtil.splitRow(parent, containerConstraints.getRow());
    }
    for (int i = containerConstraints.getColSpan(); i < container.getGridColumnCount(); i++) {
        GridChangeUtil.splitColumn(parent, containerConstraints.getColumn());
    }
    ArrayList<RadComponent> contents = new ArrayList<>();
    for (int i = container.getComponentCount() - 1; i >= 0; i--) {
        contents.add(0, container.getComponent(i));
        container.removeComponent(container.getComponent(i));
    }
    if (contents.size() == 1) {
        contents.get(0).setCustomLayoutConstraints(container.getCustomLayoutConstraints());
    }
    FormEditingUtil.deleteComponents(Collections.singletonList(container), false);
    for (RadComponent child : contents) {
        final GridConstraints childConstraints = child.getConstraints();
        childConstraints.setRow(childConstraints.getRow() + containerConstraints.getRow());
        childConstraints.setColumn(childConstraints.getColumn() + containerConstraints.getColumn());
        parent.addComponent(child);
        child.revalidate();
    }
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) ArrayList(java.util.ArrayList) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 22 with RadComponent

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

the class IncreaseIndentAction method update.

protected void update(@NotNull GuiEditor editor, final ArrayList<RadComponent> selection, final AnActionEvent e) {
    final boolean applicable = canAdjustIndent(selection);
    e.getPresentation().setVisible(applicable);
    final Component focusOwner = IdeFocusManager.findInstanceByComponent(editor).getFocusOwner();
    e.getPresentation().setEnabled(applicable && (focusOwner == editor || editor.isAncestorOf(focusOwner)));
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent)

Example 23 with RadComponent

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

the class ComponentTreeBuilder method syncSelection.

/**
   * This method synchronizes selection in the tree with the selected
   * RadComponent in the component hierarchy
   */
private void syncSelection() {
    // Found selected components
    final RadContainer rootContainer = myEditor.getRootContainer();
    final ArrayList<RadComponent> selection = new ArrayList<>();
    FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor<RadComponent>() {

        public boolean visit(final RadComponent component) {
            if (component.isSelected()) {
                selection.add(component);
            }
            return true;
        }
    });
    if (selection.size() == 0) {
        // If there is no selected component in the hierarchy, then
        // we have to select RadRootContainer
        selection.add(rootContainer);
    }
    final ComponentPtr[] componentPtrs = new ComponentPtr[selection.size()];
    for (int i = 0; i < selection.size(); i++) {
        componentPtrs[i] = new ComponentPtr(myEditor, selection.get(i));
    }
    // Set selection in the tree
    select(componentPtrs, null);
    // Notify the ComponentTree that selected component changed
    myEditor.fireSelectedComponentChanged();
}
Also used : ArrayList(java.util.ArrayList) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 24 with RadComponent

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

the class ComponentTreeStructure method getChildElements.

public Object[] getChildElements(final Object element) {
    if (element == myRootElement) {
        ArrayList<Object> elements = new ArrayList<>();
        final RadRootContainer rootContainer = myEditor.getRootContainer();
        elements.add(new ComponentPtr(myEditor, rootContainer));
        final LwInspectionSuppression[] suppressions = rootContainer.getInspectionSuppressions();
        if (suppressions.length > 0) {
            elements.add(suppressions);
        }
        RadButtonGroup[] buttonGroups = rootContainer.getButtonGroups();
        if (buttonGroups.length > 0) {
            elements.add(buttonGroups);
        }
        return elements.toArray();
    } else if (element instanceof ComponentPtr) {
        final ComponentPtr ptr = (ComponentPtr) element;
        // pointer must be valid
        LOG.assertTrue(ptr.isValid());
        final RadComponent component = ptr.getComponent();
        if (component instanceof RadContainer) {
            final RadContainer container = (RadContainer) component;
            final ComponentPtr[] ptrs = new ComponentPtr[container.getComponentCount()];
            for (int i = 0; i < ptrs.length; i++) {
                ptrs[i] = new ComponentPtr(myEditor, container.getComponent(i));
            }
            return ptrs;
        } else {
            return ourEmptyObjectArray;
        }
    } else if (element instanceof LwInspectionSuppression[]) {
        ArrayList<LwInspectionSuppression> result = new ArrayList<>();
        for (LwInspectionSuppression suppression : (LwInspectionSuppression[]) element) {
            if (suppression.getComponentId() == null || FormEditingUtil.findComponent(myEditor.getRootContainer(), suppression.getComponentId()) != null) {
                result.add(suppression);
            }
        }
        return ArrayUtil.toObjectArray(result);
    } else if (element instanceof RadButtonGroup[]) {
        return (RadButtonGroup[]) element;
    } else if (element instanceof LwInspectionSuppression || element instanceof RadButtonGroup) {
        return ArrayUtil.EMPTY_OBJECT_ARRAY;
    } else {
        throw new IllegalArgumentException("unknown element: " + element);
    }
}
Also used : LwInspectionSuppression(com.intellij.uiDesigner.lw.LwInspectionSuppression) ArrayList(java.util.ArrayList) RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadButtonGroup(com.intellij.uiDesigner.radComponents.RadButtonGroup) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 25 with RadComponent

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

the class ComponentTreeStructure method getParentElement.

public Object getParentElement(final Object element) {
    if (element instanceof ComponentTreeStructureRoot) {
        return null;
    } else if (element instanceof LwInspectionSuppression[] || element instanceof RadButtonGroup[]) {
        return myRootElement;
    } else if (element instanceof LwInspectionSuppression) {
        return myEditor.getRootContainer().getInspectionSuppressions();
    } else if (element instanceof RadButtonGroup) {
        return myEditor.getRootContainer().getButtonGroups();
    } else if (element instanceof ComponentPtr) {
        // RadContainer is also RadComponent
        final ComponentPtr ptr = (ComponentPtr) element;
        if (!ptr.isValid())
            return myRootElement;
        final RadComponent component = ptr.getComponent();
        if (component instanceof RadRootContainer) {
            return myRootElement;
        } else {
            return component.getParent() != null ? new ComponentPtr(myEditor, component.getParent(), false) : null;
        }
    } else {
        throw new IllegalArgumentException("unknown element: " + element);
    }
}
Also used : RadButtonGroup(com.intellij.uiDesigner.radComponents.RadButtonGroup) LwInspectionSuppression(com.intellij.uiDesigner.lw.LwInspectionSuppression) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer)

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