Search in sources :

Example 11 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 12 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 13 with RadComponent

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

the class MorphAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    Processor<ComponentItem> processor = selectedValue -> {
        Runnable runnable = () -> {
            for (RadComponent c : selection) {
                if (!morphComponent(editor, c, selectedValue))
                    break;
            }
            editor.refreshAndSave(true);
        };
        CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(editor.getGlassLayer(), true);
        });
        return true;
    };
    PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastMorphComponent, processor, UIDesignerBundle.message("morph.component.title"));
    step.hideNonAtomic();
    if (selection.size() == 1) {
        step.hideComponentClass(selection.get(0).getComponentClassName());
    }
    final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
    FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
}
Also used : PsiType(com.intellij.psi.PsiType) UIDesignerBundle(com.intellij.uiDesigner.UIDesignerBundle) RadAtomicComponent(com.intellij.uiDesigner.radComponents.RadAtomicComponent) JavaPsiFacade(com.intellij.psi.JavaPsiFacade) ChangeFieldTypeFix(com.intellij.uiDesigner.quickFixes.ChangeFieldTypeFix) ArrayList(java.util.ArrayList) GuiEditor(com.intellij.uiDesigner.designSurface.GuiEditor) Palette(com.intellij.uiDesigner.palette.Palette) PsiElementFactory(com.intellij.psi.PsiElementFactory) IProperty(com.intellij.uiDesigner.lw.IProperty) Logger(com.intellij.openapi.diagnostic.Logger) IntroComponentProperty(com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty) IncorrectOperationException(com.intellij.util.IncorrectOperationException) ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) BindingProperty(com.intellij.uiDesigner.propertyInspector.properties.BindingProperty) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) CommandProcessor(com.intellij.openapi.command.CommandProcessor) ListPopup(com.intellij.openapi.ui.popup.ListPopup) List(java.util.List) IComponent(com.intellij.uiDesigner.lw.IComponent) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) Processor(com.intellij.util.Processor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) PsiField(com.intellij.psi.PsiField) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer) NotNull(org.jetbrains.annotations.NotNull) InsertComponentProcessor(com.intellij.uiDesigner.designSurface.InsertComponentProcessor) FormInspectionUtil(com.intellij.uiDesigner.inspections.FormInspectionUtil) IntrospectedProperty(com.intellij.uiDesigner.propertyInspector.IntrospectedProperty) ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 14 with RadComponent

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

the class CreateListenerAction method canCreateListener.

private static boolean canCreateListener(final ArrayList<RadComponent> selection) {
    if (selection.size() == 0)
        return false;
    final RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(selection.get(0));
    if (root.getClassToBind() == null)
        return false;
    String componentClass = selection.get(0).getComponentClassName();
    for (RadComponent c : selection) {
        if (!c.getComponentClassName().equals(componentClass) || c.getBinding() == null)
            return false;
        if (BindingProperty.findBoundField(root, c.getBinding()) == null)
            return false;
    }
    return true;
}
Also used : RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent)

Example 15 with RadComponent

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

the class DuplicateComponentsAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    FormEditingUtil.remapToActionTargets(selection);
    RadContainer parent = FormEditingUtil.getSelectionParent(selection);
    assert parent != null;
    List<RadComponent> duplicates = new ArrayList<>();
    Map<RadComponent, RadComponent> duplicateMap = new HashMap<>();
    TIntHashSet insertedRows = new TIntHashSet();
    boolean incrementRow = true;
    if (selection.size() > 1 && canDuplicate(selection, false) && FormEditingUtil.getSelectionBounds(selection).width == 1) {
        incrementRow = false;
    }
    for (RadComponent c : selection) {
        final int row = c.getConstraints().getCell(incrementRow);
        int rowSpan = c.getConstraints().getSpan(incrementRow);
        int insertIndex = parent.indexOfComponent(c);
        if (parent.getLayoutManager().isGrid()) {
            if (!insertedRows.contains(row) && !isSpaceBelowEmpty(c, incrementRow)) {
                insertedRows.add(row);
                parent.getGridLayoutManager().copyGridCells(parent, parent, incrementRow, row, rowSpan, row + rowSpan);
            }
        }
        List<RadComponent> copyList = CutCopyPasteSupport.copyComponents(editor, Collections.singletonList(c));
        if (copyList != null) {
            RadComponent copy = copyList.get(0);
            if (parent.getLayoutManager().isGrid()) {
                copy.getConstraints().setCell(incrementRow, row + rowSpan + parent.getGridLayoutManager().getGapCellCount());
                copy.getConstraints().setSpan(incrementRow, rowSpan);
            }
            parent.addComponent(copy, insertIndex + 1);
            fillDuplicateMap(duplicateMap, c, copy);
            duplicates.add(copy);
        }
    }
    adjustDuplicates(duplicateMap);
    FormEditingUtil.selectComponents(editor, duplicates);
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer) TIntHashSet(gnu.trove.TIntHashSet)

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