Example usage for com.intellij.openapi.actionSystem IdeActions GROUP_GUI_DESIGNER_EDITOR_POPUP

List of usage examples for com.intellij.openapi.actionSystem IdeActions GROUP_GUI_DESIGNER_EDITOR_POPUP

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem IdeActions GROUP_GUI_DESIGNER_EDITOR_POPUP.

Prototype

String GROUP_GUI_DESIGNER_EDITOR_POPUP

To view the source code for com.intellij.openapi.actionSystem IdeActions GROUP_GUI_DESIGNER_EDITOR_POPUP.

Click Source Link

Usage

From source file:com.intellij.uiDesigner.designSurface.MainProcessor.java

License:Apache License

protected void processMouseEvent(final MouseEvent e) {
    myLastMousePosition = e.getPoint();//from   ww w .  ja va  2s  .c  o m

    if (myCurrentProcessor != null && myCurrentProcessor.isDragActive()) {
        return;
    }

    // Here is a good place to handle right and wheel mouse clicking. All mouse
    // motion events should go further
    if (e.isPopupTrigger()) {
        RadComponent component = FormEditingUtil.getRadComponentAt(myEditor.getRootContainer(), e.getX(),
                e.getY());
        if (component != null && !component.isSelected()) {
            FormEditingUtil.selectSingleComponent(myEditor, component);
        }

        final ActionManager actionManager = ActionManager.getInstance();
        final ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(
                ActionPlaces.GUI_DESIGNER_EDITOR_POPUP,
                (ActionGroup) actionManager.getAction(IdeActions.GROUP_GUI_DESIGNER_EDITOR_POPUP));
        popupMenu.getComponent().show(e.getComponent(), e.getX(), e.getY());
        return;
    }

    final int id = e.getID();
    if ((MouseEvent.BUTTON2 == e.getButton() || MouseEvent.BUTTON3 == e.getButton())
            && (MouseEvent.MOUSE_PRESSED == id || MouseEvent.MOUSE_RELEASED == id
                    || MouseEvent.MOUSE_CLICKED == id)) {
        return;
    }

    // Handle all left mouse events and all motion events
    final RadComponent componentAt = FormEditingUtil.getRadComponentAt(myEditor.getRootContainer(), e.getX(),
            e.getY());
    if (componentAt != null) {
        final Point p1 = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), componentAt.getDelegee());
        final Component deepestComponentAt = SwingUtilities.getDeepestComponentAt(componentAt.getDelegee(),
                p1.x, p1.y);
        final Point p2 = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), deepestComponentAt);

        EventProcessor processor = componentAt.getEventProcessor(e);
        if (processor != null) {
            myCurrentProcessor = processor;
        } else {
            final Component source = deepestComponentAt != null ? deepestComponentAt : componentAt.getDelegee();
            componentAt.processMouseEvent(new MouseEvent(source, id, e.getWhen(), e.getModifiers(), p2.x, p2.y,
                    e.getClickCount(), e.isPopupTrigger(), e.getButton()));
        }
    }

    Cursor cursor = Cursor.getDefaultCursor();
    if (id == MouseEvent.MOUSE_MOVED) {
        if (PaletteToolWindowManager.getInstance(myEditor).getActiveItem(ComponentItem.class) != null) {
            if (myInsertFeedbackEnabled) {
                cursor = myInsertComponentProcessor.processMouseMoveEvent(e);
            }
        } else if (myCurrentProcessor != null) {
            myCurrentProcessor.processMouseEvent(e);
        } else {
            final RadComponent component = FormEditingUtil.getRadComponentAt(myEditor.getRootContainer(),
                    e.getX(), e.getY());
            if (component != null) {
                final Point point = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(),
                        component.getDelegee());
                final int resizeMask = Painter.getResizeMask(component, point.x, point.y);
                if (resizeMask != 0) {
                    cursor = Cursor.getPredefinedCursor(Painter.getResizeCursor(resizeMask));
                }
                updateDragger(e);
            }
        }
    } else if (id == MouseEvent.MOUSE_PRESSED) {
        processMousePressed(e);
    } else if (id == MouseEvent.MOUSE_RELEASED) {
        // not every press sets processor so its not a redundant 'if'
        if (myCurrentProcessor != null) {
            myCurrentProcessor.processMouseEvent(e);
            myCurrentProcessor = null;
        }
    } else if (id == MouseEvent.MOUSE_CLICKED) {
        processMouseClicked(e);
    } else if (id == MouseEvent.MOUSE_EXITED) {
        myEditor.getActiveDecorationLayer().removeFeedback();
    }

    if (!e.isConsumed() && myCurrentProcessor != null) {
        myCurrentProcessor.processMouseEvent(e);
    }

    if (myCurrentProcessor != null && myCurrentProcessor.isDragActive()) {
        myEditor.getLayeredPane().setCursor(null);
    } else {
        if (myCurrentProcessor != null && myCurrentProcessor.getCursor() != null) {
            cursor = myCurrentProcessor.getCursor();
        }
        myEditor.getLayeredPane().setCursor(cursor);
    }
}