Java Code Examples for com.intellij.openapi.actionSystem.ActionToolbar#setTargetComponent()

The following examples show how to use com.intellij.openapi.actionSystem.ActionToolbar#setTargetComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IMPanel.java    From SmartIM4IntelliJ with Apache License 2.0 6 votes vote down vote up
private void initUI() {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new LoginAction(this));
    group.add(new HideContactAction(this));
    group.add(new DisconnectAction(this));
    createBroadcastAction(group);
    group.add(new SettingsAction(this));
    MockConsoleAction test = new MockConsoleAction(this);
    //group.add(test);

    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("SmartQQ", group, false);
    // toolbar.getComponent().addFocusListener(createFocusListener());
    toolbar.setTargetComponent(this);
    setToolbar(toolbar.getComponent());

    left = createContactsUI();
    left.onLoadContacts(false);

    tabbedChat = new ClosableTabHost(this);

    splitter = new JBSplitter(false);
    splitter.setSplitterProportionKey("main.splitter.key");
    splitter.setFirstComponent(left.getPanel());
    splitter.setSecondComponent(tabbedChat);
    splitter.setProportion(0.3f);
    setContent(splitter);
}
 
Example 2
Source File: IMChatConsole.java    From SmartIM4IntelliJ with Apache License 2.0 5 votes vote down vote up
protected void initToolBar() {
    DefaultActionGroup group = new DefaultActionGroup();
    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("SmartQQ", group, false);
    // toolbar.getComponent().addFocusListener(createFocusListener());
    toolbar.setTargetComponent(this);
    setToolbar(toolbar.getComponent());

    initToolBar(group);
}
 
Example 3
Source File: BsToolWindowFactory.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@NotNull
private ActionToolbar createToolbar(@NotNull BsConsole console) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new ScrollToTheEndToolbarAction(console.getEditor()));
    group.add(new ClearLogAction(console));
    group.add(new BsMakeAction());
    group.add(new BsMakeWorldAction());

    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("left", group, false);
    toolbar.setTargetComponent(console.getComponent());

    return toolbar;
}
 
Example 4
Source File: DuneToolWindowFactory.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@NotNull
private ActionToolbar createToolbar(@NotNull BsConsole console) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new ScrollToTheEndToolbarAction(console.getEditor()));
    group.add(new ClearLogAction(console));
    group.add(new DuneBuildAction());
    group.add(new DuneCleanAction());
    group.add(new DuneInstallAction());

    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("left", group, false);
    toolbar.setTargetComponent(console.getComponent());

    return toolbar;
}
 
Example 5
Source File: EsyToolWindowFactory.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@NotNull
private ActionToolbar createToolbar(@NotNull BsConsole console) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new ScrollToTheEndToolbarAction(console.getEditor()));
    group.add(new ClearLogAction(console));
    group.add(new EsyInstallAction());
    group.add(new EsyBuildAction());
    group.add(new EsyShellAction());

    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("left", group, false);
    toolbar.setTargetComponent(console.getComponent());

    return toolbar;
}
 
Example 6
Source File: FreelineTerminal.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 创建Terminal panel
 *
 * @param terminalRunner
 * @param toolWindow
 * @return
 */
private Content createTerminalInContentPanel(@NotNull AbstractTerminalRunner terminalRunner, @NotNull final ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
    content.setCloseable(true);
    myTerminalWidget = terminalRunner.createTerminalWidget(content);
    panel.setContent(myTerminalWidget.getComponent());
    panel.addFocusListener(this);
    ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow);
    toolbar.setTargetComponent(panel);
    panel.setToolbar(toolbar.getComponent());
    content.setPreferredFocusableComponent(myTerminalWidget.getComponent());
    return content;
}
 
Example 7
Source File: ConsoleLogToolWindowFactory.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
static void createContent(Project project, ToolWindow toolWindow, ConsoleLogConsole console, String title) {
    // update default Event Log tab title
    ContentManager contentManager = toolWindow.getContentManager();
    Content generalContent = contentManager.getContent(0);
    if (generalContent != null && contentManager.getContentCount() == 1) {
        generalContent.setDisplayName("General");
    }

    final Editor editor = console.getConsoleEditor();

    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
        @Override
        public Object getData(@NonNls String dataId) {
            return PlatformDataKeys.HELP_ID.is(dataId) ? ConsoleLog.HELP_ID : super.getData(dataId);
        }
    };
    panel.setContent(editor.getComponent());
    panel.addAncestorListener(new LogShownTracker(project));

    ActionToolbar toolbar = createToolbar(project, editor, console);
    toolbar.setTargetComponent(editor.getContentComponent());
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content);
}
 
Example 8
Source File: TabFormImpl.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Creates the toolbar for top of the tab
 *
 * @param actions
 * @return
 */
protected ActionToolbar createToolbar(DefaultActionGroup actions) {
    final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(toolbarLocation, actions, false);
    toolbar.setOrientation(SwingConstants.HORIZONTAL);
    toolbar.setTargetComponent(scrollPanel);
    return toolbar;
}
 
Example 9
Source File: TitleWithToolbar.java    From consulo with Apache License 2.0 5 votes vote down vote up
public TitleWithToolbar(@Nonnull String title,
                        @Nonnull String actionGroupId,
                        @Nonnull String place,
                        @Nonnull JComponent targetComponent)
{
  super(new GridBagLayout());
  ActionManager actionManager = ActionManager.getInstance();
  ActionGroup group = (ActionGroup)actionManager.getAction(actionGroupId);
  ActionToolbar actionToolbar = actionManager.createActionToolbar(place, group, true);
  actionToolbar.setTargetComponent(targetComponent);
  actionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);

  add(new MyTitleComponent(title), new GridBag().weightx(1).anchor(GridBagConstraints.WEST).fillCellHorizontally());
  add(actionToolbar.getComponent(), new GridBag().anchor(GridBagConstraints.CENTER));
}
 
Example 10
Source File: DependencyViewer.java    From gradle-view with Apache License 2.0 4 votes vote down vote up
public DependencyViewer(Project p, ToolWindow t) {
    super(true, true);
    this.project = p;
    this.toolWindow = t;
    this.splitter = new Splitter(false, 0.75f);
    this.information = new JTextArea();
    this.toolingLogger = initToolingLogger();

    this.dependencyCellRenderer = new DependencyCellRenderer();
    this.dependencyCellRenderer.omittedSelected = JBColor.MAGENTA;
    this.dependencyCellRenderer.omittedUnselected = JBColor.GRAY;
    this.dependencyCellRenderer.normalSelected = JBColor.foreground();
    this.dependencyCellRenderer.normalUnselected = JBColor.BLACK;
    this.information.setEditable(false);

    this.shouldPromptForCurrentProject = true;

    // TODO clean all of this up
    GradleService gradleService = ServiceManager.getService(project, GradleService.class);
    gradleService.addListener(new ViewActionListener() {
        @Override
        public void refresh() {
            // prompt only on first use of tool panel
            if (shouldPromptForCurrentProject) {
                // ask to initialize view for this project to the current project
                if (useCurrentProjectBuild()) {
                    gradleBaseDir = project.getBasePath();
                }
                shouldPromptForCurrentProject = false;
            }

            // there's nothing to do when there is no gradleBaseDir set, instead issue a prompt
            if(gradleBaseDir == null) {
                promptForGradleBaseDir();
            }

            // initialize an empty view even if the gradleBaseDir is set while we load everything in the background
            updateView(null, null);

            new SwingWorker<GradleNode, Void>() {
                protected GradleNode doInBackground() throws Exception {
                    try {
                        Map<String, GradleNode> dependencyMap = loadProjectDependenciesFromModel(gradleBaseDir, toolingLogger);
                        GradleNode rootDependency = dependencyMap.get("root");

                        GradleNode target = dependencyCellRenderer.selectedGradleNode;
                        GradleNode selectedDependency;
                        if(target != null && target.group != null) {
                            selectedDependency = target;
                        } else {
                            selectedDependency = new GradleNode("No dependency selected");
                        }

                        updateView(rootDependency, selectedDependency);
                        return rootDependency;
                    } catch(Exception e) {
                        e.printStackTrace();
                        toolingLogger.log(ExceptionUtils.getFullStackTrace(e));
                        throw new RuntimeException(e);
                    }
                }
            }.execute();
        }

        @Override
        public void toggleShowReplaced() {
            dependencyCellRenderer.showReplaced = !dependencyCellRenderer.showReplaced;
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    splitter.repaint();
                    splitter.validate();
                }
            });
        }

        @Override
        public void reset() {
            gradleBaseDir = null;
            refresh();
        }
    });
    gradleService.refresh();

    setContent(splitter);
    final ActionManager actionManager = ActionManager.getInstance();
    ActionToolbar actionToolbar = actionManager.createActionToolbar("Gradle View Toolbar",
            (DefaultActionGroup)actionManager.getAction("GradleView.NavigatorActionsToolbar"), true);

    actionToolbar.setTargetComponent(splitter);
    setToolbar(actionToolbar.getComponent());
}