Search in sources :

Example 16 with RadComponent

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

the class MorphingAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    myDesigner.getToolProvider().execute(() -> {
        List<RadComponent> newComponents = new ArrayList<>();
        for (RadComponent component : myComponents) {
            RadComponent newComponent = component.morphingTo(myTarget);
            if (newComponent != null) {
                newComponents.add(newComponent);
            }
        }
        myArea.setSelection(newComponents);
    }, "Run Morphing action", true);
}
Also used : ArrayList(java.util.ArrayList) RadComponent(com.intellij.designer.model.RadComponent)

Example 17 with RadComponent

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

the class SelectionTool method handleButtonDown.

@Override
protected void handleButtonDown(int button) {
    if (myState == STATE_INIT) {
        myState = STATE_DRAG;
        deactivateTracker();
        if (handleTracker()) {
            return;
        }
        if (!myArea.isTree()) {
            InputTool tracker = myArea.findTargetTool(myCurrentScreenX, myCurrentScreenY);
            if (tracker != null) {
                setTracker(tracker);
                if (tracker instanceof ResizeTracker) {
                    myArea.showSelection(false);
                }
                return;
            }
        }
        RadComponent component = myArea.findTarget(myCurrentScreenX, myCurrentScreenY, null);
        if (component == null || component.isBackground()) {
            if (!myArea.isTree()) {
                MarqueeTracker tracker = new MarqueeTracker();
                // Allow marquee dragging within the root (background) layout, and if you click
                // without dragging, select that background component
                tracker.setSelectBackground(component != null && component.isBackground());
                setTracker(tracker);
            }
        } else {
            Point location = component.convertPoint(myArea.getNativeComponent(), myCurrentScreenX, myCurrentScreenY);
            setTracker(component.getDragTracker(location, myInputEvent, myArea.isTree()));
        }
    }
}
Also used : RadComponent(com.intellij.designer.model.RadComponent)

Example 18 with RadComponent

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

the class CommonEditActionsProvider method updateSelectionBeforeDelete.

public static void updateSelectionBeforeDelete(EditableArea area, RadComponent component, List<RadComponent> excludes) {
    try {
        isDeleting = true;
        RadComponent newSelection = getNewSelection(component, excludes);
        if (newSelection == null) {
            area.deselectAll();
        } else {
            area.select(newSelection);
        }
    } finally {
        isDeleting = false;
    }
}
Also used : RadComponent(com.intellij.designer.model.RadComponent)

Example 19 with RadComponent

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

the class CommonEditActionsProvider method isCopyEnabled.

@Override
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
    if (myDesigner.getInplaceEditingLayer().isEditing()) {
        return false;
    }
    List<RadComponent> selection = getArea(dataContext).getSelection();
    if (selection.isEmpty()) {
        return false;
    }
    RadComponent rootComponent = myDesigner.getRootComponent();
    if (rootComponent instanceof IComponentCopyProvider) {
        IComponentCopyProvider copyProvider = (IComponentCopyProvider) rootComponent;
        return copyProvider.isCopyEnabled(selection);
    }
    return true;
}
Also used : RadComponent(com.intellij.designer.model.RadComponent) IComponentCopyProvider(com.intellij.designer.model.IComponentCopyProvider)

Example 20 with RadComponent

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

the class MorphingAction method fill.

public static void fill(DesignerEditorPanel designer, DefaultActionGroup group, EditableArea area) {
    List<RadComponent> selection = area.getSelection();
    if (selection.isEmpty()) {
        return;
    }
    MetaModel model = null;
    for (RadComponent component : selection) {
        if (model == null) {
            model = component.getMetaModel();
        } else if (model != component.getMetaModel()) {
            return;
        }
    }
    if (model == null) {
        return;
    }
    List<MetaModel> models = model.getMorphingModels();
    if (models.isEmpty()) {
        return;
    }
    DefaultActionGroup morphingGroup = new DefaultActionGroup("Morphing", true);
    for (MetaModel morphingModel : models) {
        morphingGroup.add(new MorphingAction(designer, area, selection, morphingModel));
    }
    group.add(morphingGroup);
}
Also used : MetaModel(com.intellij.designer.model.MetaModel) RadComponent(com.intellij.designer.model.RadComponent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

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