Search in sources :

Example 1 with IComponentDeletionParticipant

use of com.intellij.designer.model.IComponentDeletionParticipant 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)

Aggregations

IComponentDeletionParticipant (com.intellij.designer.model.IComponentDeletionParticipant)1 RadComponent (com.intellij.designer.model.RadComponent)1 List (java.util.List)1 Map (java.util.Map)1