use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class InsertBeforeAction method actionPerformed.
protected void actionPerformed(CaptionSelection selection) {
RadContainer container = selection.getContainer();
container.getGridLayoutManager().insertGridCells(container, selection.getFocusedIndex(), selection.isRow(), true, false);
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class ComponentPtr method validate.
/**
* Validates (updates) the state of the pointer
*/
public void validate() {
// Try to find component with myId starting from root container
final RadContainer container = myEditor.getRootContainer();
myComponent = (RadComponent) FormEditingUtil.findComponent(container, myId);
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class ComponentTreeBuilder method syncSelection.
/**
* This method synchronizes selection in the tree with the selected
* RadComponent in the component hierarchy
*/
private void syncSelection() {
// Found selected components
final RadContainer rootContainer = myEditor.getRootContainer();
final ArrayList<RadComponent> selection = new ArrayList<>();
FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor<RadComponent>() {
public boolean visit(final RadComponent component) {
if (component.isSelected()) {
selection.add(component);
}
return true;
}
});
if (selection.size() == 0) {
// If there is no selected component in the hierarchy, then
// we have to select RadRootContainer
selection.add(rootContainer);
}
final ComponentPtr[] componentPtrs = new ComponentPtr[selection.size()];
for (int i = 0; i < selection.size(); i++) {
componentPtrs[i] = new ComponentPtr(myEditor, selection.get(i));
}
// Set selection in the tree
select(componentPtrs, null);
// Notify the ComponentTree that selected component changed
myEditor.fireSelectedComponentChanged();
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class ComponentTreeStructure method getChildElements.
public Object[] getChildElements(final Object element) {
if (element == myRootElement) {
ArrayList<Object> elements = new ArrayList<>();
final RadRootContainer rootContainer = myEditor.getRootContainer();
elements.add(new ComponentPtr(myEditor, rootContainer));
final LwInspectionSuppression[] suppressions = rootContainer.getInspectionSuppressions();
if (suppressions.length > 0) {
elements.add(suppressions);
}
RadButtonGroup[] buttonGroups = rootContainer.getButtonGroups();
if (buttonGroups.length > 0) {
elements.add(buttonGroups);
}
return elements.toArray();
} else if (element instanceof ComponentPtr) {
final ComponentPtr ptr = (ComponentPtr) element;
// pointer must be valid
LOG.assertTrue(ptr.isValid());
final RadComponent component = ptr.getComponent();
if (component instanceof RadContainer) {
final RadContainer container = (RadContainer) component;
final ComponentPtr[] ptrs = new ComponentPtr[container.getComponentCount()];
for (int i = 0; i < ptrs.length; i++) {
ptrs[i] = new ComponentPtr(myEditor, container.getComponent(i));
}
return ptrs;
} else {
return ourEmptyObjectArray;
}
} else if (element instanceof LwInspectionSuppression[]) {
ArrayList<LwInspectionSuppression> result = new ArrayList<>();
for (LwInspectionSuppression suppression : (LwInspectionSuppression[]) element) {
if (suppression.getComponentId() == null || FormEditingUtil.findComponent(myEditor.getRootContainer(), suppression.getComponentId()) != null) {
result.add(suppression);
}
}
return ArrayUtil.toObjectArray(result);
} else if (element instanceof RadButtonGroup[]) {
return (RadButtonGroup[]) element;
} else if (element instanceof LwInspectionSuppression || element instanceof RadButtonGroup) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
} else {
throw new IllegalArgumentException("unknown element: " + element);
}
}
use of com.intellij.uiDesigner.radComponents.RadContainer in project intellij-community by JetBrains.
the class DesignDropTargetListener method processDrop.
private boolean processDrop(final DraggedComponentList dcl, final Point dropPoint, final int dropAction) {
myEditor.getActiveDecorationLayer().removeFeedback();
final ArrayList<RadComponent> dclComponents = dcl.getComponents();
final int componentCount = dclComponents.size();
ComponentDropLocation location = GridInsertProcessor.getDropLocation(myEditor.getRootContainer(), dropPoint);
if (FormEditingUtil.isDropOnChild(dcl, location)) {
setDraggingState(dcl, false);
return false;
}
if (!location.canDrop(dcl)) {
setDraggingState(dcl, false);
return false;
}
if (!myEditor.ensureEditable()) {
setDraggingState(dcl, false);
return false;
}
List<RadComponent> droppedComponents;
RadContainer[] originalParents = dcl.getOriginalParents();
cancelDrag();
if (dropAction == DnDConstants.ACTION_COPY) {
setDraggingState(dcl, false);
droppedComponents = myDraggedComponentsCopy;
if (droppedComponents == null) {
return false;
}
} else {
for (int i = 0; i < dclComponents.size(); i++) {
LOG.info("Removing component " + dclComponents.get(i).getId() + " with constraints " + dcl.getOriginalConstraints()[i]);
originalParents[i].removeComponent(dclComponents.get(i));
}
droppedComponents = dclComponents;
}
final RadComponent[] components = droppedComponents.toArray(new RadComponent[componentCount]);
final GridConstraints[] originalConstraints = dcl.getOriginalConstraints();
location.processDrop(myEditor, components, originalConstraints, dcl);
if (dropAction == DnDConstants.ACTION_COPY) {
for (RadComponent component : droppedComponents) {
InsertComponentProcessor.createBindingWhenDrop(myEditor, component, false);
}
FormEditingUtil.selectComponents(myEditor, droppedComponents);
} else {
setDraggingState(dcl, false);
}
for (int i = 0; i < originalConstraints.length; i++) {
if (originalParents[i].getLayoutManager().isGrid()) {
FormEditingUtil.deleteEmptyGridCells(originalParents[i], originalConstraints[i]);
}
}
return true;
}
Aggregations