Search in sources :

Example 1 with ComponentTree

use of com.intellij.uiDesigner.componentTree.ComponentTree in project intellij-community by JetBrains.

the class DesignDropTargetListener method drop.

public void drop(final DropTargetDropEvent dtde) {
    try {
        ComponentTree componentTree = DesignerToolWindowManager.getInstance(myEditor).getComponentTree();
        if (componentTree != null) {
            componentTree.setDropTargetComponent(null);
        }
        final DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
        if (dcl != null) {
            CommandProcessor.getInstance().executeCommand(myEditor.getProject(), () -> {
                if (processDrop(dcl, dtde.getLocation(), dtde.getDropAction())) {
                    myEditor.refreshAndSave(true);
                }
            }, UIDesignerBundle.message("command.drop.components"), null);
        } else {
            ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
            if (componentItem != null) {
                myEditor.getMainProcessor().setInsertFeedbackEnabled(false);
                new InsertComponentProcessor(myEditor).processComponentInsert(dtde.getLocation(), componentItem);
                ApplicationManager.getApplication().invokeLater(() -> {
                    PaletteToolWindowManager.getInstance(myEditor).clearActiveItem();
                    myEditor.getActiveDecorationLayer().removeFeedback();
                    myEditor.getLayeredPane().setCursor(null);
                    IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                        IdeFocusManager.getGlobalInstance().requestFocus(myEditor.getGlassLayer(), true);
                    });
                    myEditor.getMainProcessor().setInsertFeedbackEnabled(true);
                });
            }
        }
        myDraggedComponentsCopy = null;
        myEditor.repaintLayeredPane();
    } catch (Exception e) {
        LOG.error(e);
    }
}
Also used : ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) ComponentTree(com.intellij.uiDesigner.componentTree.ComponentTree)

Example 2 with ComponentTree

use of com.intellij.uiDesigner.componentTree.ComponentTree in project intellij-community by JetBrains.

the class DesignDropTargetListener method dragExit.

public void dragExit(DropTargetEvent dte) {
    try {
        ComponentTree componentTree = DesignerToolWindowManager.getInstance(myEditor).getComponentTree();
        if (componentTree != null) {
            componentTree.setDropTargetComponent(null);
        }
        myUseDragDelta = false;
        if (myDraggedComponentList != null) {
            cancelDrag();
            setDraggingState(myDraggedComponentList, false);
            myEditor.getActiveDecorationLayer().removeFeedback();
            myDraggedComponentList = null;
            myEditor.setDesignTimeInsets(2);
        }
        myDraggedComponentsCopy = null;
    } catch (Exception e) {
        LOG.error(e);
    }
}
Also used : ComponentTree(com.intellij.uiDesigner.componentTree.ComponentTree)

Example 3 with ComponentTree

use of com.intellij.uiDesigner.componentTree.ComponentTree in project intellij-community by JetBrains.

the class DesignDropTargetListener method dragOver.

public void dragOver(DropTargetDragEvent dtde) {
    try {
        if (myComponentDragObject == null) {
            dtde.rejectDrag();
            return;
        }
        final int dx = dtde.getLocation().x - myLastPoint.x;
        final int dy = dtde.getLocation().y - myLastPoint.y;
        if (myDraggedComponentsCopy != null && myDraggedComponentList != null) {
            for (RadComponent aMySelection : myDraggedComponentsCopy) {
                aMySelection.shift(dx, dy);
            }
        }
        myLastPoint = dtde.getLocation();
        myEditor.getDragLayer().repaint();
        ComponentDropLocation location = myGridInsertProcessor.processDragEvent(dtde.getLocation(), myComponentDragObject);
        ComponentTree componentTree = DesignerToolWindowManager.getInstance(myEditor).getComponentTree();
        if (!location.canDrop(myComponentDragObject) || (myDraggedComponentList != null && FormEditingUtil.isDropOnChild(myDraggedComponentList, location))) {
            if (componentTree != null) {
                componentTree.setDropTargetComponent(null);
            }
            dtde.rejectDrag();
        } else {
            if (componentTree != null) {
                componentTree.setDropTargetComponent(location.getContainer());
            }
            dtde.acceptDrag(dtde.getDropAction());
        }
    } catch (Exception e) {
        LOG.error(e);
    }
}
Also used : RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) ComponentTree(com.intellij.uiDesigner.componentTree.ComponentTree)

Example 4 with ComponentTree

use of com.intellij.uiDesigner.componentTree.ComponentTree in project intellij-community by JetBrains.

the class SurroundPopupAction method actionPerformed.

protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
    final ListPopup groupPopup = JBPopupFactory.getInstance().createActionGroupPopup(UIDesignerBundle.message("surround.with.popup.title"), myActionGroup, e.getDataContext(), JBPopupFactory.ActionSelectionAid.ALPHA_NUMBERING, true);
    final JComponent component = (JComponent) e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
    if (component instanceof ComponentTree) {
        groupPopup.show(JBPopupFactory.getInstance().guessBestPopupLocation(component));
    } else {
        RadComponent selComponent = selection.get(0);
        FormEditingUtil.showPopupUnderComponent(groupPopup, selComponent);
    }
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) ComponentTree(com.intellij.uiDesigner.componentTree.ComponentTree)

Example 5 with ComponentTree

use of com.intellij.uiDesigner.componentTree.ComponentTree 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

ComponentTree (com.intellij.uiDesigner.componentTree.ComponentTree)6 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)4 ListPopup (com.intellij.openapi.ui.popup.ListPopup)1 Ref (com.intellij.openapi.util.Ref)1 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)1 IComponent (com.intellij.uiDesigner.lw.IComponent)1 IProperty (com.intellij.uiDesigner.lw.IProperty)1 ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)1 DesignerToolWindow (com.intellij.uiDesigner.propertyInspector.DesignerToolWindow)1 PropertyInspector (com.intellij.uiDesigner.propertyInspector.PropertyInspector)1 IntroStringProperty (com.intellij.uiDesigner.propertyInspector.properties.IntroStringProperty)1 RadButtonGroup (com.intellij.uiDesigner.radComponents.RadButtonGroup)1 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)1 RadRootContainer (com.intellij.uiDesigner.radComponents.RadRootContainer)1 RadTabbedPane (com.intellij.uiDesigner.radComponents.RadTabbedPane)1 HashSet (com.intellij.util.containers.HashSet)1