use of com.intellij.uiDesigner.radComponents.RadRootContainer 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);
}
use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class GroupSelectionProcessor method markRectangle.
private void markRectangle(final RadComponent component, final Rectangle rectangle, final Component coordinateOriginComponent) {
if (!(component instanceof RadRootContainer) && !component.equals(myComponent)) {
final Rectangle bounds = component.getBounds();
final Point point = SwingUtilities.convertPoint(component.getDelegee().getParent(), bounds.x, bounds.y, coordinateOriginComponent);
bounds.setLocation(point);
if (rectangle.intersects(bounds)) {
component.setSelected(true);
return;
}
}
if (component instanceof RadContainer) {
final RadContainer container = (RadContainer) component;
// [anton] it is very important to iterate through a STORED array because setSelected can
// change order of components so iteration via getComponent(i) is incorrect
final RadComponent[] components = container.getComponents();
for (RadComponent component1 : components) {
markRectangle(component1, rectangle, coordinateOriginComponent);
}
}
}
use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class CreateComponentAction method getCreateLocation.
private static ComponentDropLocation getCreateLocation(final GuiEditor editor, final List<RadComponent> selection) {
ComponentDropLocation dropLocation = null;
if (selection.size() > 0) {
RadComponent component = selection.get(0);
final RadContainer container = component.getParent();
if (container.getLayoutManager().isGrid()) {
GridConstraints c = component.getConstraints();
// try to insert in empty cell to the right or below the component; if not found -
// insert row below selected component
int nextCol = FormEditingUtil.adjustForGap(component.getParent(), c.getColumn() + c.getColSpan(), false, 1);
int nextRow = FormEditingUtil.adjustForGap(component.getParent(), c.getRow() + c.getRowSpan(), true, 1);
if (nextCol < container.getGridColumnCount() && container.getComponentAtGrid(c.getRow(), nextCol) == null) {
dropLocation = new GridDropLocation(container, c.getRow(), nextCol);
} else if (nextRow < container.getGridRowCount() && container.getComponentAtGrid(nextRow, c.getColumn()) == null) {
dropLocation = new GridDropLocation(container, nextRow, c.getColumn());
} else {
dropLocation = new GridInsertLocation(container, c.getRow() + c.getRowSpan() - 1, c.getColumn(), GridInsertMode.RowAfter);
}
}
}
if (dropLocation == null) {
final Point mousePosition = editor.getMainProcessor().getLastMousePosition();
if (mousePosition != null) {
RadContainer container = GridInsertProcessor.getDropTargetContainer(editor.getRootContainer(), mousePosition);
if (container == null) {
container = editor.getRootContainer();
}
if (container instanceof RadRootContainer && container.getComponentCount() == 1 && container.getComponent(0) instanceof RadContainer) {
RadContainer childContainer = (RadContainer) container.getComponent(0);
dropLocation = childContainer.getDropLocation(null);
} else {
dropLocation = GridInsertProcessor.getDropLocation(editor.getRootContainer(), mousePosition);
}
} else {
final RadRootContainer container = editor.getRootContainer();
if (container.getComponentCount() == 1 && container.getComponent(0) instanceof RadContainer) {
RadContainer childContainer = (RadContainer) container.getComponent(0);
dropLocation = childContainer.getDropLocation(null);
} else {
dropLocation = container.getDropLocation(null);
}
}
}
return dropLocation;
}
use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class IntroComponentProperty method updateLabelForBinding.
void updateLabelForBinding(final RadComponent component) {
String value = getValue(component);
String text = FormInspectionUtil.getText(component.getModule(), component);
if (text != null && value != null) {
RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
if (root != null) {
RadComponent valueComponent = (RadComponent) FormEditingUtil.findComponent(root, value);
if (valueComponent != null) {
if (valueComponent instanceof RadScrollPane && ((RadScrollPane) valueComponent).getComponentCount() == 1) {
valueComponent = ((RadScrollPane) valueComponent).getComponent(0);
}
BindingProperty.checkCreateBindingFromText(valueComponent, text);
}
}
}
}
use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class BindingProperty method getDefaultBinding.
public static String getDefaultBinding(final RadComponent c) {
RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(c);
String binding = null;
String text = FormInspectionUtil.getText(c.getModule(), c);
if (text != null) {
binding = suggestBindingFromText(c, text);
}
if (binding == null) {
binding = InsertComponentProcessor.suggestBinding(root, c.getComponentClassName());
}
return binding;
}
Aggregations