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);
}
}
Aggregations