Search in sources :

Example 16 with ComponentItem

use of com.intellij.uiDesigner.palette.ComponentItem 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)

Aggregations

ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)16 Palette (com.intellij.uiDesigner.palette.Palette)5 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)4 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)4 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)3 ArrayList (java.util.ArrayList)3 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)2 ListPopup (com.intellij.openapi.ui.popup.ListPopup)2 UIDesignerBundle (com.intellij.uiDesigner.UIDesignerBundle)2 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)2 GuiEditor (com.intellij.uiDesigner.designSurface.GuiEditor)2 IComponent (com.intellij.uiDesigner.lw.IComponent)2 IProperty (com.intellij.uiDesigner.lw.IProperty)2 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)2 RadRootContainer (com.intellij.uiDesigner.radComponents.RadRootContainer)2 XYLayoutManager (com.intellij.uiDesigner.shared.XYLayoutManager)2 Processor (com.intellij.util.Processor)2 List (java.util.List)2 CommandProcessor (com.intellij.openapi.command.CommandProcessor)1