Search in sources :

Example 21 with RadContainer

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);
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 22 with RadContainer

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);
}
Also used : RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 23 with RadContainer

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();
}
Also used : ArrayList(java.util.ArrayList) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 24 with RadContainer

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);
    }
}
Also used : LwInspectionSuppression(com.intellij.uiDesigner.lw.LwInspectionSuppression) ArrayList(java.util.ArrayList) RadRootContainer(com.intellij.uiDesigner.radComponents.RadRootContainer) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadButtonGroup(com.intellij.uiDesigner.radComponents.RadButtonGroup) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 25 with RadContainer

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;
}
Also used : GridConstraints(com.intellij.uiDesigner.core.GridConstraints) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Aggregations

RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)51 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)20 RadRootContainer (com.intellij.uiDesigner.radComponents.RadRootContainer)6 ArrayList (java.util.ArrayList)6 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)5 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)3 IComponent (com.intellij.uiDesigner.lw.IComponent)3 ComponentTreeBuilder (com.intellij.uiDesigner.componentTree.ComponentTreeBuilder)2 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)2 GuiEditor (com.intellij.uiDesigner.designSurface.GuiEditor)2 IProperty (com.intellij.uiDesigner.lw.IProperty)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 LayoutManager (java.awt.LayoutManager)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 Ref (com.intellij.openapi.util.Ref)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 SelectionState (com.intellij.uiDesigner.SelectionState)1 ComponentPtr (com.intellij.uiDesigner.componentTree.ComponentPtr)1 ComponentTree (com.intellij.uiDesigner.componentTree.ComponentTree)1