use of com.intellij.uiDesigner.palette.ComponentItem in project intellij-community by JetBrains.
the class DesignDropTargetListener method dragEnter.
public void dragEnter(DropTargetDragEvent dtde) {
try {
DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
if (dcl != null) {
myDraggedComponentList = dcl;
myComponentDragObject = dcl;
processDragEnter(dcl, dtde.getLocation(), dtde.getDropAction());
dtde.acceptDrag(dtde.getDropAction());
myLastPoint = dtde.getLocation();
} else {
ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
if (componentItem != null) {
myComponentDragObject = new ComponentItemDragObject(componentItem);
dtde.acceptDrag(dtde.getDropAction());
myLastPoint = dtde.getLocation();
}
}
} catch (Exception e) {
LOG.error(e);
}
}
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);
}
}
use of com.intellij.uiDesigner.palette.ComponentItem in project intellij-community by JetBrains.
the class FormPropertyTableCellRenderer method customizeCellRenderer.
protected void customizeCellRenderer(final JTable table, final Object value, final boolean selected, final boolean hasFocus, final int row, final int column) {
if (value == null) {
return;
}
final FormProperty property = (FormProperty) value;
final LwComponent component = property.getLwComponent();
// Icon
final Icon icon;
final String fqClassName = component.getComponentClassName();
final ComponentItem item = myPalette.getItem(fqClassName);
if (item != null) {
icon = item.getSmallIcon();
} else {
icon = UIDesignerIcons.Unknown_small;
}
setIcon(icon);
// Binding
append(component.getBinding(), myAttrs1);
// Component class name and package
final String shortClassName;
final String packageName;
final int lastDotIndex = fqClassName.lastIndexOf('.');
if (lastDotIndex != -1) {
shortClassName = fqClassName.substring(lastDotIndex + 1);
packageName = fqClassName.substring(0, lastDotIndex);
} else {
// default package
shortClassName = fqClassName;
packageName = null;
}
LOG.assertTrue(shortClassName.length() > 0);
append(" ", myAttrs2);
/*small gap between icon and class name*/
append(shortClassName, myAttrs2);
if (packageName != null) {
append(" (", myAttrs3);
append(packageName, myAttrs3);
append(")", myAttrs3);
}
}
use of com.intellij.uiDesigner.palette.ComponentItem in project intellij-community by JetBrains.
the class InsertComponentProcessor method replaceAnyComponentItem.
@Nullable
public static ComponentItem replaceAnyComponentItem(GuiEditor editor, ComponentItem item, final String title) {
if (item.isAnyComponent()) {
ComponentItem newItem = item.clone();
ComponentItemDialog dlg = new ComponentItemDialog(editor.getProject(), editor, newItem, true);
dlg.setTitle(title);
if (!dlg.showAndGet()) {
return null;
}
return newItem;
}
return item;
}
use of com.intellij.uiDesigner.palette.ComponentItem in project intellij-community by JetBrains.
the class MainProcessor method processMousePressed.
private void processMousePressed(final MouseEvent e) {
if (myCurrentProcessor != null) {
if (myCurrentProcessor.needMousePressed()) {
myCurrentProcessor.processMouseEvent(e);
return;
}
// Sun sometimes skips mouse released events...
myCurrentProcessor.cancelOperation();
myCurrentProcessor = null;
}
RadComponent component = null;
final RadComponent draggerHost = FormEditingUtil.getDraggerHost(myEditor);
// Try to understand whether we pressed inside dragger area
if (draggerHost != null) {
final JComponent delegee = draggerHost.getDelegee();
final Point p = SwingUtilities.convertPoint(delegee, 0, 0, e.getComponent());
if (p.x - MainProcessor.DRAGGER_SIZE <= e.getX() && e.getX() <= p.x && p.y - MainProcessor.DRAGGER_SIZE <= e.getY() && e.getY() <= p.y) {
component = draggerHost;
}
}
// If user clicked not inside dragger then we have find RadComponent at the click point
if (component == null) {
component = FormEditingUtil.getRadComponentAt(myEditor.getRootContainer(), e.getX(), e.getY());
}
if (component == null) {
return;
}
final ComponentItem selectedItem = PaletteToolWindowManager.getInstance(myEditor).getActiveItem(ComponentItem.class);
if (selectedItem != null) {
myInsertComponentProcessor.setSticky(UIUtil.isControlKeyDown(e));
myCurrentProcessor = myInsertComponentProcessor;
return;
}
if (!UIUtil.isControlKeyDown(e) && !e.isShiftDown()) {
if (!component.isSelected() || FormEditingUtil.getSelectedComponents(myEditor).size() != 1) {
FormEditingUtil.selectSingleComponent(myEditor, component);
}
}
final Point point = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), component.getDelegee());
final int resizeMask = Painter.getResizeMask(component, point.x, point.y);
LOG.debug("MainProcessor.processMousePressed: resizeMask at (" + point.x + "," + point.y + ") is " + resizeMask);
if (resizeMask != 0) {
if (component.getParent() != null) {
component = component.getParent().getActionTargetComponent(component);
}
myCurrentProcessor = new ResizeProcessor(myEditor, component, resizeMask);
} else if (component instanceof RadRootContainer || e.isShiftDown()) {
myCurrentProcessor = new GroupSelectionProcessor(myEditor, component);
} else if (!e.isShiftDown()) {
myCurrentProcessor = new DragSelectionProcessor(myEditor);
}
updateDragger(e);
}
Aggregations