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