use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class AbstractMoveSelectionAction method moveSelectionByGrid.
private boolean moveSelectionByGrid(final RadComponent selectedComponent) {
final RadContainer parent = selectedComponent.getParent();
if (parent == null || !parent.getLayoutManager().isGrid()) {
return false;
}
int row = selectedComponent.getConstraints().getRow();
int column = selectedComponent.getConstraints().getColumn();
RadComponent lastComponent = null;
do {
row += getRowMoveDelta();
column += getColumnMoveDelta();
if (row < 0 || row >= parent.getGridRowCount() || column < 0 || column >= parent.getGridColumnCount()) {
if (myMoveToLast) {
break;
}
return false;
}
final RadComponent component = parent.getComponentAtGrid(row, column);
if (component != null && component != selectedComponent) {
if (myMoveToLast) {
if (myExtend) {
FormEditingUtil.selectComponent(myEditor, component);
}
lastComponent = component;
} else {
selectOrExtend(component);
return true;
}
}
} while (true);
if (lastComponent != null) {
selectOrExtend(lastComponent);
return true;
}
return false;
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class CreateComponentAction method actionPerformed.
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
Processor<ComponentItem> processor = selectedValue -> {
if (selectedValue != null) {
myLastCreatedComponent = selectedValue;
editor.getMainProcessor().startInsertProcessor(selectedValue, getCreateLocation(editor, selection));
}
return true;
};
PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastCreatedComponent, processor, UIDesignerBundle.message("create.component.title"));
final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
if (selection.size() > 0) {
FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
} else {
listPopup.showInCenterOf(editor.getRootContainer().getDelegee());
}
}
use of com.intellij.uiDesigner.radComponents.RadComponent 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.RadComponent in project intellij-community by JetBrains.
the class DuplicateComponentsAction method canDuplicate.
private static boolean canDuplicate(final List<RadComponent> selection, final boolean incrementRow) {
int aRow = selection.get(0).getConstraints().getCell(incrementRow);
int aRowSpan = selection.get(0).getConstraints().getSpan(incrementRow);
for (int i = 1; i < selection.size(); i++) {
final RadComponent c = selection.get(i);
if (c.getConstraints().getSpan(incrementRow) > 1 || aRowSpan > 1) {
if (c.getConstraints().getCell(incrementRow) != aRow || c.getConstraints().getSpan(incrementRow) != aRowSpan) {
return false;
}
}
}
return true;
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class DuplicateComponentsAction method adjustDuplicates.
private static void adjustDuplicates(final Map<RadComponent, RadComponent> duplicates) {
for (RadComponent c : duplicates.keySet()) {
RadComponent copy = duplicates.get(c);
if (c.getBinding() != null) {
String binding = BindingProperty.getDefaultBinding(copy);
new BindingProperty(c.getProject()).setValueEx(copy, binding);
copy.setDefaultBinding(true);
}
for (IProperty prop : copy.getModifiedProperties()) {
if (prop instanceof IntroComponentProperty) {
final IntroComponentProperty componentProperty = (IntroComponentProperty) prop;
String copyValue = componentProperty.getValue(copy);
for (RadComponent original : duplicates.keySet()) {
if (original.getId().equals(copyValue)) {
componentProperty.setValueEx(copy, duplicates.get(original).getId());
}
}
}
}
}
}
Aggregations