use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class ExpandSelectionAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final GuiEditor editor = FormEditingUtil.getEditorFromContext(e.getDataContext());
assert editor != null;
final SelectionState selectionState = editor.getSelectionState();
selectionState.setInsideChange(true);
ComponentTreeBuilder builder = DesignerToolWindowManager.getInstance(editor).getComponentTreeBuilder();
if (builder != null) {
builder.beginUpdateSelection();
}
final Stack<ComponentPtr[]> history = selectionState.getSelectionHistory();
try {
final ComponentPtr[] ptrs = history.peek();
for (int i = ptrs.length - 1; i >= 0; i--) {
// Skip invalid components
final ComponentPtr ptr = ptrs[i];
ptr.validate();
if (!ptr.isValid()) {
continue;
}
// Extend selection
final RadComponent component = ptr.getComponent();
final RadContainer parent = component.getParent();
if (parent == null) {
// skip components without parents
continue;
}
boolean shouldSelectParent = true;
for (int j = parent.getComponentCount() - 1; j >= 0; j--) {
final RadComponent sibling = parent.getComponent(j);
if (!sibling.isSelected()) {
shouldSelectParent = false;
sibling.setSelected(true);
}
}
if (shouldSelectParent) {
parent.setSelected(true);
}
}
// Store new selection
history.push(SelectionState.getSelection(editor));
} finally {
if (builder != null) {
builder.endUpdateSelection();
}
selectionState.setInsideChange(false);
}
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class CutCopyPasteSupport method deserializeComponents.
@Nullable
private static ArrayList<RadComponent> deserializeComponents(final GuiEditor editor, final String serializedComponents) {
ArrayList<RadComponent> components = new ArrayList<>();
TIntArrayList xs = new TIntArrayList();
TIntArrayList ys = new TIntArrayList();
if (!loadComponentsToPaste(editor, serializedComponents, xs, ys, components)) {
return null;
}
return components;
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class CutCopyPasteSupport method performPaste.
public void performPaste(@NotNull final DataContext dataContext) {
final String serializedComponents = getSerializedComponents();
if (serializedComponents == null) {
return;
}
final ArrayList<RadComponent> componentsToPaste = new ArrayList<>();
final TIntArrayList xs = new TIntArrayList();
final TIntArrayList ys = new TIntArrayList();
loadComponentsToPaste(myEditor, serializedComponents, xs, ys, componentsToPaste);
myEditor.getMainProcessor().startPasteProcessor(componentsToPaste, xs, ys);
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class FormEditingUtil method getSelectionBounds.
public static Rectangle getSelectionBounds(List<RadComponent> selection) {
int minRow = Integer.MAX_VALUE;
int minCol = Integer.MAX_VALUE;
int maxRow = 0;
int maxCol = 0;
for (RadComponent c : selection) {
minRow = Math.min(minRow, c.getConstraints().getRow());
minCol = Math.min(minCol, c.getConstraints().getColumn());
maxRow = Math.max(maxRow, c.getConstraints().getRow() + c.getConstraints().getRowSpan());
maxCol = Math.max(maxCol, c.getConstraints().getColumn() + c.getConstraints().getColSpan());
}
return new Rectangle(minCol, minRow, maxCol - minCol, maxRow - minRow);
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class FormEditingUtil method selectComponents.
public static void selectComponents(final GuiEditor editor, List<RadComponent> components) {
if (components.size() > 0) {
RadComponent component = components.get(0);
ComponentTreeBuilder builder = DesignerToolWindowManager.getInstance(editor).getComponentTreeBuilder();
if (builder == null) {
// race condition when handling event?
return;
}
builder.beginUpdateSelection();
try {
clearSelection((RadContainer) getRoot(component));
for (RadComponent aComponent : components) {
selectComponent(editor, aComponent);
}
} finally {
builder.endUpdateSelection();
}
}
}
Aggregations