Search in sources :

Example 11 with RadComponent

use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.

the class AbstractFlowBaseOperation method getSideChildTarget.

private RadComponent getSideChildTarget() {
    Point location = myContext.getLocation();
    List<RadComponent> children = getChildren();
    RadComponent lastChild = children.get(children.size() - 1);
    Rectangle childBounds = lastChild.getBounds(myContext.getArea().getFeedbackLayer());
    if (myHorizontal) {
        if (location.x >= childBounds.getMaxX()) {
            return lastChild;
        }
        return children.get(0);
    }
    if (location.y >= childBounds.getMaxY()) {
        return lastChild;
    }
    return children.get(0);
}
Also used : RadComponent(com.intellij.designer.model.RadComponent)

Example 12 with RadComponent

use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.

the class CommonEditActionsProvider method handleDeletion.

private static void handleDeletion(@NotNull List<RadComponent> components) throws Exception {
    // Segment the deleted components into lists of siblings
    Map<RadComponent, List<RadComponent>> siblingLists = RadComponent.groupSiblings(components);
    // Notify parent components about children getting deleted
    for (Map.Entry<RadComponent, List<RadComponent>> entry : siblingLists.entrySet()) {
        RadComponent parent = entry.getKey();
        List<RadComponent> children = entry.getValue();
        boolean finished = false;
        if (parent instanceof IComponentDeletionParticipant) {
            IComponentDeletionParticipant handler = (IComponentDeletionParticipant) parent;
            finished = handler.deleteChildren(parent, children);
        } else if (parent != null && /*check root*/
        parent.getLayout() instanceof IComponentDeletionParticipant) {
            IComponentDeletionParticipant handler = (IComponentDeletionParticipant) parent.getLayout();
            finished = handler.deleteChildren(parent, children);
        }
        if (!finished) {
            deleteComponents(children);
        }
    }
}
Also used : IComponentDeletionParticipant(com.intellij.designer.model.IComponentDeletionParticipant) RadComponent(com.intellij.designer.model.RadComponent) List(java.util.List) Map(java.util.Map)

Example 13 with RadComponent

use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.

the class CommonEditActionsProvider method doCopy.

private boolean doCopy(DataContext dataContext) {
    try {
        Element root = new Element("designer");
        root.setAttribute("target", myDesigner.getPlatformTarget());
        List<RadComponent> components = RadComponent.getPureSelection(getArea(dataContext).getSelection());
        RadComponent rootComponent = myDesigner.getRootComponent();
        if (rootComponent instanceof IComponentCopyProvider) {
            IComponentCopyProvider copyProvider = (IComponentCopyProvider) rootComponent;
            copyProvider.copyTo(root, components);
        } else {
            for (RadComponent component : components) {
                component.copyTo(root);
            }
        }
        SerializedComponentData data = new SerializedComponentData(new XMLOutputter().outputString(root));
        CopyPasteManager.getInstance().setContents(new SimpleTransferable(data, DATA_FLAVOR));
        return true;
    } catch (Throwable e) {
        myDesigner.showError("Copy error", e);
        return false;
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) SerializedComponentData(com.intellij.uiDesigner.SerializedComponentData) SimpleTransferable(com.intellij.designer.clipboard.SimpleTransferable) Element(org.jdom.Element) RadComponent(com.intellij.designer.model.RadComponent) IComponentCopyProvider(com.intellij.designer.model.IComponentCopyProvider)

Example 14 with RadComponent

use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.

the class CommonEditActionsProvider method getNewSelection.

@Nullable
private static RadComponent getNewSelection(RadComponent component, List<RadComponent> excludes) {
    RadComponent parent = component.getParent();
    if (parent == null) {
        return null;
    }
    List<RadComponent> children = parent.getChildren();
    int size = children.size();
    for (int i = children.indexOf(component) + 1; i < size; i++) {
        RadComponent next = children.get(i);
        if (!excludes.contains(next)) {
            return next;
        }
    }
    return parent;
}
Also used : RadComponent(com.intellij.designer.model.RadComponent) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with RadComponent

use of com.intellij.designer.model.RadComponent in project intellij-community by JetBrains.

the class CommonEditActionsProvider method deleteElement.

@Override
public void deleteElement(@NotNull final DataContext dataContext) {
    myDesigner.getToolProvider().execute(() -> {
        EditableArea area = getArea(dataContext);
        List<RadComponent> selection = area.getSelection();
        if (selection.isEmpty()) {
            return;
        }
        myDesigner.getToolProvider().loadDefaultTool();
        List<RadComponent> components = RadComponent.getPureSelection(selection);
        updateSelectionBeforeDelete(area, components.get(0), selection);
        handleDeletion(components);
    }, DesignerBundle.message("command.delete.selection"), true);
}
Also used : EditableArea(com.intellij.designer.designSurface.EditableArea) RadComponent(com.intellij.designer.model.RadComponent)

Aggregations

RadComponent (com.intellij.designer.model.RadComponent)28 ArrayList (java.util.ArrayList)8 RadComponentVisitor (com.intellij.designer.model.RadComponentVisitor)6 Nullable (org.jetbrains.annotations.Nullable)3 EditOperation (com.intellij.designer.designSurface.EditOperation)2 IComponentCopyProvider (com.intellij.designer.model.IComponentCopyProvider)2 MetaModel (com.intellij.designer.model.MetaModel)2 RadLayout (com.intellij.designer.model.RadLayout)2 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)2 SimpleTransferable (com.intellij.designer.clipboard.SimpleTransferable)1 ComponentTargetFilter (com.intellij.designer.designSurface.ComponentTargetFilter)1 EditableArea (com.intellij.designer.designSurface.EditableArea)1 FeedbackTreeLayer (com.intellij.designer.designSurface.FeedbackTreeLayer)1 LineMarginBorder (com.intellij.designer.designSurface.feedbacks.LineMarginBorder)1 CreationTool (com.intellij.designer.designSurface.tools.CreationTool)1 InputTool (com.intellij.designer.designSurface.tools.InputTool)1 IComponentDeletionParticipant (com.intellij.designer.model.IComponentDeletionParticipant)1 Property (com.intellij.designer.model.Property)1 WrapInProvider (com.intellij.designer.model.WrapInProvider)1 InplaceContext (com.intellij.designer.propertyTable.InplaceContext)1