Search in sources :

Example 1 with RadButtonGroup

use of com.intellij.uiDesigner.radComponents.RadButtonGroup 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 2 with RadButtonGroup

use of com.intellij.uiDesigner.radComponents.RadButtonGroup 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)

Example 3 with RadButtonGroup

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

the class GroupButtonsAction method groupButtons.

public static void groupButtons(final GuiEditor editor, final List<RadComponent> selectedComponents) {
    if (!editor.ensureEditable())
        return;
    String groupName = Messages.showInputDialog(editor.getProject(), UIDesignerBundle.message("group.buttons.name.prompt"), UIDesignerBundle.message("group.buttons.title"), Messages.getQuestionIcon(), editor.getRootContainer().suggestGroupName(), new IdentifierValidator(editor.getProject()));
    if (groupName == null)
        return;
    RadRootContainer rootContainer = editor.getRootContainer();
    RadButtonGroup group = rootContainer.createGroup(groupName);
    for (RadComponent component : selectedComponents) {
        rootContainer.setGroupForComponent(component, group);
    }
    editor.refreshAndSave(true);
}
Also used : RadButtonGroup(com.intellij.uiDesigner.radComponents.RadButtonGroup) RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) IdentifierValidator(com.intellij.uiDesigner.propertyInspector.properties.IdentifierValidator)

Example 4 with RadButtonGroup

use of com.intellij.uiDesigner.radComponents.RadButtonGroup 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)

Example 5 with RadButtonGroup

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

the class PassiveDecorationLayer method paintPassiveDecoration.

/**
   * Paints all necessary decoration for the specified <code>component</code>
   */
protected final void paintPassiveDecoration(final RadComponent component, final Graphics g) {
    // Paint component bounds and grid markers
    Painter.paintComponentDecoration(myEditor, component, g);
    final Set<RadButtonGroup> paintedGroups = new HashSet<>();
    final RadRootContainer rootContainer = myEditor.getRootContainer();
    final ComponentTree componentTree = DesignerToolWindowManager.getInstance(myEditor).getComponentTree();
    final Collection<RadButtonGroup> selectedGroups = componentTree != null ? componentTree.getSelectedElements(RadButtonGroup.class) : Collections.<RadButtonGroup>emptyList();
    // Paint selection and dragger
    FormEditingUtil.iterate(component, new FormEditingUtil.ComponentVisitor<RadComponent>() {

        public boolean visit(final RadComponent component) {
            final Point point = SwingUtilities.convertPoint(component.getDelegee(), 0, 0, rootContainer.getDelegee());
            RadButtonGroup group = (RadButtonGroup) FormEditingUtil.findGroupForComponent(rootContainer, component);
            if (group != null && !paintedGroups.contains(group) && (component.isSelected() || selectedGroups.contains(group))) {
                paintedGroups.add(group);
                Painter.paintButtonGroupLines(rootContainer, group, g);
            }
            g.translate(point.x, point.y);
            try {
                if (myEditor.isShowComponentTags() && FormEditingUtil.isComponentSwitchedInView(component)) {
                    Painter.paintComponentTag(component, g);
                }
                Painter.paintSelectionDecoration(component, g, myEditor.getGlassLayer().isFocusOwner());
                // Over selection we have to paint dragger
                if (component.hasDragger()) {
                    final Icon icon = getDragIcon();
                    icon.paintIcon(PassiveDecorationLayer.this, g, -icon.getIconWidth(), -icon.getIconHeight());
                }
            } finally {
                g.translate(-point.x, -point.y);
            }
            return true;
        }
    });
}
Also used : RadButtonGroup(com.intellij.uiDesigner.radComponents.RadButtonGroup) RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) ComponentTree(com.intellij.uiDesigner.componentTree.ComponentTree) HashSet(com.intellij.util.containers.HashSet)

Aggregations

RadButtonGroup (com.intellij.uiDesigner.radComponents.RadButtonGroup)5 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)5 RadRootContainer (com.intellij.uiDesigner.radComponents.RadRootContainer)4 LwInspectionSuppression (com.intellij.uiDesigner.lw.LwInspectionSuppression)2 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)1 ComponentTree (com.intellij.uiDesigner.componentTree.ComponentTree)1 IntrospectedProperty (com.intellij.uiDesigner.propertyInspector.IntrospectedProperty)1 IdentifierValidator (com.intellij.uiDesigner.propertyInspector.properties.IdentifierValidator)1 IntroComponentProperty (com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty)1 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)1 HashSet (com.intellij.util.containers.HashSet)1 ArrayList (java.util.ArrayList)1