use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class GuiEditor method refreshProperties.
private void refreshProperties() {
final Ref<Boolean> anythingModified = new Ref<>();
FormEditingUtil.iterate(myRootContainer, new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
final RadComponent radComponent = (RadComponent) component;
boolean componentModified = false;
for (IProperty prop : component.getModifiedProperties()) {
if (prop instanceof IntroStringProperty) {
IntroStringProperty strProp = (IntroStringProperty) prop;
componentModified = strProp.refreshValue(radComponent) || componentModified;
}
}
if (component instanceof RadContainer) {
componentModified = ((RadContainer) component).updateBorder() || componentModified;
}
if (component.getParentContainer() instanceof RadTabbedPane) {
componentModified = ((RadTabbedPane) component.getParentContainer()).refreshChildTitle(radComponent) || componentModified;
}
if (componentModified) {
anythingModified.set(Boolean.TRUE);
}
return true;
}
});
if (!anythingModified.isNull()) {
refresh();
DesignerToolWindow designerToolWindow = DesignerToolWindowManager.getInstance(this);
ComponentTree tree = designerToolWindow.getComponentTree();
if (tree != null)
tree.repaint();
PropertyInspector inspector = designerToolWindow.getPropertyInspector();
if (inspector != null)
inspector.synchWithTree(true);
}
}
use of com.intellij.uiDesigner.radComponents.RadContainer 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.RadContainer 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.RadContainer in project intellij-community by JetBrains.
the class DuplicateComponentsAction method update.
protected void update(@NotNull GuiEditor editor, final ArrayList<RadComponent> selection, final AnActionEvent e) {
FormEditingUtil.remapToActionTargets(selection);
final RadContainer parent = FormEditingUtil.getSelectionParent(selection);
e.getPresentation().setEnabled(parent != null && (parent.getLayoutManager().isGrid() || parent.getLayoutManager().isIndexed()));
// 3) all selected components have the same row and rowspan
if (selection.size() > 1 && parent != null && parent.getLayoutManager().isGrid()) {
e.getPresentation().setEnabled(canDuplicate(selection, true) || canDuplicate(selection, false));
}
}
use of com.intellij.uiDesigner.radComponents.RadContainer 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);
}
}
Aggregations