Example usage for com.intellij.openapi.actionSystem ActionPlaces CONTEXT_TOOLBAR

List of usage examples for com.intellij.openapi.actionSystem ActionPlaces CONTEXT_TOOLBAR

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem ActionPlaces CONTEXT_TOOLBAR.

Prototype

String CONTEXT_TOOLBAR

To view the source code for com.intellij.openapi.actionSystem ActionPlaces CONTEXT_TOOLBAR.

Click Source Link

Usage

From source file:automation.RobotControlWindow.java

License:Apache License

public RobotControlWindow(@NotNull final Component component) throws HeadlessException {
    super(findWindow(component));

    myRobotControl = RobotControlManager.getInstance().getRobotControl();

    Window window = findWindow(component);
    setModal(window instanceof JDialog && ((JDialog) window).isModal());
    getRootPane().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    setLayout(new BorderLayout());
    setTitle(component.getClass().getName());

    DefaultActionGroup actions = new DefaultActionGroup();
    actions.addAction(new IconWithTextAction("Push the ActionLink") {
        @Override//from  w  w  w  . j ava  2s  . c o  m
        public void actionPerformed(AnActionEvent e) {
            //  Component actionLink = GuiUtil.findComponentByText("Create New Project", component);
            //  if(actionLink != null) {
            //    try {
            //      RobotControlManager.getInstance().getRobotControl().navigateAndClickScript(actionLink);
            //    }
            //    catch (InterruptedException e1) {
            //      e1.printStackTrace();
            //    }
            //    catch (Exception e1) {
            //      e1.printStackTrace();
            //    }
            //  }
            //}
            try {
                ScriptProcessor.process();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

        @Override
        public void update(AnActionEvent e) {
            //do nothing
        }
    });

    //actions.addSeparator();

    //actions.add(new IconWithTextAction("Refresh") {
    //
    // @Override
    // public void actionPerformed(AnActionEvent e) {
    //   getCurrentTable().refresh();
    // }
    //
    // @Override
    // public void update(AnActionEvent e) {
    //   e.getPresentation().setEnabled(myComponent != null && myComponent.isVisible());
    // }
    //});

    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.CONTEXT_TOOLBAR,
            actions, true);
    add(toolbar.getComponent(), BorderLayout.NORTH);
    statusLabel = new JLabel("Ok");
    add(statusLabel);

    myWrapperPanel = new JPanel(new BorderLayout());

    //myHierarchyTree = new HierarchyTree(component) {
    //  @Override
    //  public void onComponentChanged(Component c) {
    //    boolean wasHighlighted = myHighlightComponent != null;
    //    setHighlightingEnabled(false);
    //    switchInfo(c);
    //    setHighlightingEnabled(wasHighlighted);
    //  }
    //};

    //myWrapperPanel.add(myInspectorTable, BorderLayout.CENTER);

    //JSplitPane splitPane = new JSplitPane();
    //splitPane.setDividerLocation(0.5);
    //splitPane.setRightComponent(myWrapperPanel);

    JScrollPane pane = new JBScrollPane(myHierarchyTree);
    //splitPane.setLeftComponent(pane);
    //add(splitPane, BorderLayout.CENTER);

    //myHierarchyTree.expandPath();

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            close();
        }
    });

    getRootPane().getActionMap().put("CLOSE", new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            close();
        }
    });
    //setHighlightingEnabled(true);
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "CLOSE");
}

From source file:com.intellij.ide.browsers.actions.BaseOpenInBrowserAction.java

License:Apache License

@Override
public final void update(AnActionEvent e) {
    WebBrowser browser = getBrowser(e);//from   w w w  . j  ava  2s  .  c  o m
    if (browser == null) {
        e.getPresentation().setEnabledAndVisible(false);
        return;
    }

    Pair<OpenInBrowserRequest, WebBrowserUrlProvider> result = doUpdate(e);
    if (result == null) {
        return;
    }

    String description = getTemplatePresentation().getText();
    if (ActionPlaces.CONTEXT_TOOLBAR.equals(e.getPlace())) {
        StringBuilder builder = new StringBuilder(description);
        builder.append(" (");
        Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("WebOpenInAction");
        boolean exists = shortcuts.length > 0;
        if (exists) {
            builder.append(KeymapUtil.getShortcutText(shortcuts[0]));
        }

        if (HtmlUtil.isHtmlFile(result.first.getFile())) {
            builder.append(exists ? ", " : "").append("hold Shift to open URL of local file");
        }
        builder.append(')');
        description = builder.toString();
    }
    e.getPresentation().setText(description);
}