Java Code Examples for com.intellij.openapi.wm.ToolWindow

The following are top voted examples for showing how to use com.intellij.openapi.wm.ToolWindow. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: IdeaCurrency   File: IdeaCurrencyToolWindow.java   View source code 6 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Set<SelectedExchangeCurrencyPair> selectedExchangeCurrencyPairs = IdeaCurrencyConfig.getInstance().getSelectedExchangeCurrencyPairs();
    if (IdeaCurrencyConfig.getInstance().getActive()) {
        List<TickerDto> data = IdeaCurrencyApp.getInstance().getTickers(selectedExchangeCurrencyPairs);
        fillData(data);
    }
    Content content = contentFactory.createContent(contentPane, "", false);
    toolWindow.getContentManager().addContent(content);

    MessageBus messageBus = project.getMessageBus();
    messageBusConnection = messageBus.connect();
    messageBusConnection.subscribe(ConfigChangeNotifier.CONFIG_TOPIC, active -> {
        if (active) {
            scheduleNextTask();
        }
    });
}
 
Example 2
Project: react-native-console   File: ReactNativeConsole.java   View source code 6 votes vote down vote up
/**
 * 获取 RN Console实例.
 *
 * @param displayName - the tab's display name must be unique.
 * @param icon        - used to set a tab icon, not used for search
 * @return
 */
public RNConsoleImpl getRNConsole(String displayName, Icon icon) {
    ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
    if (window != null) {
        Content existingContent = createConsoleTabContent(window, false, displayName, icon);
        if (existingContent != null) {
            final JComponent existingComponent = existingContent.getComponent();

            if (existingComponent instanceof SimpleToolWindowPanel) {
                JComponent component = ((SimpleToolWindowPanel) existingComponent).getContent();
                if (component instanceof RNConsoleImpl) {
                    RNConsoleImpl rnConsole = (RNConsoleImpl) component;
                    return rnConsole;
                }
            }
        }
    }

    return null;
}
 
Example 3
Project: react-native-console   File: ReactNativeTerminal.java   View source code 6 votes vote down vote up
/**
 * Create a terminal panel
 *
 * @param terminalRunner
 * @param toolWindow
 * @return
 */
private Content createTerminalInContentPanel(@NotNull AbstractTerminalRunner terminalRunner, @NotNull final ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(true);
    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
    content.setCloseable(true);
    myTerminalWidget = terminalRunner.createTerminalWidget(content);
    panel.setContent(myTerminalWidget.getComponent());
    panel.addFocusListener(this);

    createToolbar(terminalRunner, myTerminalWidget, toolWindow, panel);// west toolbar

    ActionToolbar toolbar = createTopToolbar(terminalRunner, myTerminalWidget, toolWindow);
    toolbar.setTargetComponent(panel);
    panel.setToolbar(toolbar.getComponent(), false);

    content.setPreferredFocusableComponent(myTerminalWidget.getComponent());
    return content;
}
 
Example 4
Project: intellij-circleci-integration   File: RecentBuildsToolWindowFactory.java   View source code 6 votes vote down vote up
@Override
public void init(ToolWindow window) {
    builds = BuildsModel.getInstance();
    rootNode = new DefaultMutableTreeNode("CircleCI");
    TreeModel treeModel = new DefaultTreeModel(rootNode);
    tree1.setModel(treeModel);
    tree1.setShowsRootHandles(true);
    tree1.setCellRenderer(new RecentBuildTreeCellRenderer());
    PropertiesComponent component = PropertiesComponent.getInstance();
    Integer refreshInterval;
    try {
        refreshInterval = new Integer(component.getValue("com.bkv.intellij.icons.refresh_interval"));
    } catch (Exception e) {
        refreshInterval = new Integer(99999999);
    }
    enableAutoRefresh(refreshInterval);
    refresh();
}
 
Example 5
Project: reasonml-idea-plugin   File: BsToolWindowFactory.java   View source code 6 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    BsConsole console = new BsConsole(project);
    panel.setContent(console.getComponent());

    ActionToolbar toolbar = console.createToolbar();
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true);
    toolWindow.getContentManager().addContent(content);

    // Start compiler
    BsCompiler bsc = BucklescriptProjectComponent.getInstance(project).getCompiler();
    if (bsc != null) {
        bsc.addListener(new BsOutputListener(project));
        ProcessHandler handler = bsc.getHandler();
        if (handler == null) {
            console.print("Bsb not found, check the event logs.", ERROR_OUTPUT);
        } else {
            console.attachToProcess(handler);
        }
        bsc.startNotify();
    }
}
 
Example 6
Project: SmartQQ4IntelliJ   File: ReviewDialog.java   View source code 6 votes vote down vote up
private void updateTarget() {
    targetPanel.setLayout(new GridLayout(0, 1, 0, 0));
    if (IMWindowFactory.getDefault() == null || IMWindowFactory.getDefault().getProject() == null) {
        return;
    }
    ToolWindow window = ToolWindowManager.getInstance(IMWindowFactory.getDefault().getProject()).getToolWindow(IMWindowFactory.TOOL_WINDOW_ID);
    if (window != null) {
        Content[] contents = window.getContentManager().getContents();
        if (contents != null) {
            for (Content content : contents) {
                if (content.getComponent() != null && content.getComponent() instanceof IMPanel) {
                    IMPanel panel = (IMPanel) content.getComponent();
                    List<IMChatConsole> chats = panel.getConsoleList();
                    if (!chats.isEmpty()) {
                        consoles.addAll(chats);
                        targetPanel.add(new GroupPanel(content.getDisplayName(), chats));
                    }
                }
            }
        }
    }
}
 
Example 7
Project: deps-checker   File: CheckVersionAction.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent event)
{
    project = event.getProject();
    if (project == null)
    {
        return;
    }
    ToolWindowManager toolWindowMgr = ToolWindowManager.getInstance(project);
    ToolWindow tw = toolWindowMgr.getToolWindow(TOOL_WINDOW_ID);
    if (tw == null)
    {
        tw = toolWindowMgr.registerToolWindow(TOOL_WINDOW_ID, true, ToolWindowAnchor.BOTTOM, true);
    }
    final ToolWindow toolWindow = tw;
    toolWindow.activate(() -> updateContent(toolWindow, project.getName()), true);
}
 
Example 8
Project: hybris-integration-intellij-idea-plugin   File: AntTreeUpdatingHack.java   View source code 6 votes vote down vote up
private void onProjectInitialized() {
    if (!CommonIdeaService.getInstance().isHybrisProject(myProject)) {
        return;
    }
    final ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(myProject);
    final ToolWindow antToolWindow = toolWindowManager.getToolWindow(ANT_TOOL_WINDOW_ID);

    if (antToolWindow == null) {
        LOG.info("Cannot get Ant tool window");
        return;
    }
    if (!tryToPatchToolWindow(antToolWindow)) {
        toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter() {

            private boolean pending = true;

            @Override
            public void stateChanged() {
                if (pending && tryToPatchToolWindow(antToolWindow)) {
                    pending = false;
                    toolWindowManager.removeToolWindowManagerListener(this);
                }
            }
        });
    }
}
 
Example 9
Project: hybris-integration-intellij-idea-plugin   File: AntTreeUpdatingHack.java   View source code 6 votes vote down vote up
@Nullable
private static AntExplorer getAntExplorer(final @NotNull ToolWindow antToolWindow) {
    final AntExplorer antExplorer = Arrays
        .stream(antToolWindow.getContentManager().getContents())
        .map(content -> {
            final JComponent component = content.getComponent();
            return component instanceof AntExplorer ? (AntExplorer) component : null;
        })
        .filter(Objects::nonNull)
        .findFirst()
        .orElse(null);

    if (antExplorer == null) {
        LOG.info("Cannot get AntExplorer object");
    }
    return antExplorer;
}
 
Example 10
Project: hybris-integration-intellij-idea-plugin   File: ConsoleToolWindowUtil.java   View source code 6 votes vote down vote up
public void showConsoleToolWindow(final Project project, final ConsoleView... consoles) {
    Integer currentSelectedContentIndex = 0;
    if (toolWindow == null) {
        createNewToolWindow(project);
    } else if (!toolWindow.getTitle().equals("Hybris Console")) {
        final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow("Hybris Console");
        if (window == null) {
            createNewToolWindow(project);
        } else {
            toolWindow = window;
            currentSelectedContentIndex = getCurrentSelectedTab();
            toolWindow.getContentManager().removeAllContents(false);
        }
    } else {
        currentSelectedContentIndex = getCurrentSelectedTab();
        toolWindow.getContentManager().removeAllContents(false);
    }
    setConsolesInToolWindow(consoles);
    toolWindow.activate(null);
    selectTab(currentSelectedContentIndex);
}
 
Example 11
Project: educational-plugin   File: StudyProjectComponent.java   View source code 6 votes vote down vote up
@Override
public void projectClosed() {
  final Course course = StudyTaskManager.getInstance(myProject).getCourse();
  if (course != null) {
    final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
    if (toolWindow != null) {
      toolWindow.getContentManager().removeAllContents(false);
    }
    KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
    for (Keymap keymap : keymapManager.getAllKeymaps()) {
      List<Pair<String, String>> pairs = myDeletedShortcuts.get(keymap);
      if (pairs != null && !pairs.isEmpty()) {
        for (Pair<String, String> actionShortcut : pairs) {
          keymap.addShortcut(actionShortcut.first, new KeyboardShortcut(KeyStroke.getKeyStroke(actionShortcut.second), null));
        }
      }
    }
  }
  myListener = null;
}
 
Example 12
Project: educational-plugin   File: StudyToolWindowFactory.java   View source code 6 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
  toolWindow.setIcon(EducationalCoreIcons.TaskDescription);
  final Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course != null) {
    final StudyToolWindow studyToolWindow;
    if (StudyUtils.hasJavaFx() && StudySettings.getInstance().shouldUseJavaFx()) {
      studyToolWindow = new StudyJavaFxToolWindow();
    }
    else {
      studyToolWindow = new StudySwingToolWindow();
    }
    studyToolWindow.init(project, true);
    final ContentManager contentManager = toolWindow.getContentManager();
    final Content content = contentManager.getFactory().createContent(studyToolWindow, null, false);
    contentManager.addContent(content);
    Disposer.register(project, studyToolWindow);
  }
}
 
Example 13
Project: educational-plugin   File: StudyCheckUtils.java   View source code 6 votes vote down vote up
public static void showTestResultsToolWindow(@NotNull final Project project, @NotNull final String message) {
  ApplicationManager.getApplication().invokeLater(() -> {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow window = toolWindowManager.getToolWindow(StudyTestResultsToolWindowFactoryKt.ID);
    if (window == null) {
      toolWindowManager.registerToolWindow(StudyTestResultsToolWindowFactoryKt.ID, true, ToolWindowAnchor.BOTTOM);
      window = toolWindowManager.getToolWindow(StudyTestResultsToolWindowFactoryKt.ID);
      new StudyTestResultsToolWindowFactory().createToolWindowContent(project, window);
    }

    final Content[] contents = window.getContentManager().getContents();
    for (Content content : contents) {
      final JComponent component = content.getComponent();
      if (component instanceof ConsoleViewImpl) {
        ((ConsoleViewImpl)component).clear();
        ((ConsoleViewImpl)component).print(message, ConsoleViewContentType.ERROR_OUTPUT);
        window.setAvailable(true,null);
        window.show(null);
      }
    }
  });
}
 
Example 14
Project: GravSupport   File: SystemSettingsToolWindowFactory.java   View source code 6 votes vote down vote up
@Override
public void init(ToolWindow window) {
    Project project = ProjectChecker.getFirstOpenedProject();
    String title = "Configuration";
    if (project != null) {
        title += " for '" + project.getName() + "'";
        PsiManager.getInstance(project).addPsiTreeChangeListener(this);
    }
    window.setTitle(title);
    componentList.add(new Triple<>(new String[]{"languages", "translations"}, Boolean.class, cbTranslationEnabled));
    componentList.add(new Triple<>(new String[]{"languages", "http_accept_language"}, Boolean.class, cbActiveLanguageBrowser));
    componentList.add(new Triple<>(new String[]{"languages", "include_default_lang"}, Boolean.class, cbIncludeDefaultLang));

    try {
        refreshComponents(true);
    } catch (Exception e) {
        errorOccurred = true;
    }
}
 
Example 15
Project: mule-intellij-plugins   File: MuleFacet.java   View source code 6 votes vote down vote up
@Override
public void initFacet() {

    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            ToolWindowManager manager = ToolWindowManager.getInstance(MuleFacet.this.getModule().getProject());
            List<String> ids = Arrays.asList(manager.getToolWindowIds());

            if (manager.getToolWindow("Global Configs") == null && !ids.contains("Global Configs")) {

                try {
                    ToolWindow toolWindow = manager.registerToolWindow("Global Configs", true, ToolWindowAnchor.LEFT, false);
                    toolWindow.setIcon(MuleIcons.MuleIcon);

                    GlobalConfigsToolWindowPanel toolWindowPanel = new GlobalConfigsToolWindowPanel(MuleFacet.this.getModule().getProject());
                    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
                    Content content = contentFactory.createContent(toolWindowPanel, "", true);
                    toolWindow.getContentManager().addContent(content);
                } catch (Exception e) {
                    logger.error("Unable to initialize toolWindow: ", e);
                }
            }
        }
    });
}
 
Example 16
Project: intellij-ce-playground   File: ToggleDockModeAction.java   View source code 6 votes vote down vote up
public void setSelected(AnActionEvent event,boolean flag){
  Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
  if (project == null) {
    return;
  }
  ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
  String id=windowManager.getActiveToolWindowId();
  if(id==null){
    return;
  }
  ToolWindow toolWindow=windowManager.getToolWindow(id);
  ToolWindowType type=toolWindow.getType();
  if(ToolWindowType.DOCKED==type){
    toolWindow.setType(ToolWindowType.SLIDING, null);
  } else if(ToolWindowType.SLIDING==type){
    toolWindow.setType(ToolWindowType.DOCKED, null);
  }
}
 
Example 17
Project: intellij-ce-playground   File: SwitcherToolWindowsListRenderer.java   View source code 6 votes vote down vote up
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
  hide = false;
  setPaintFocusBorder(false);
  if (value instanceof ToolWindow) {
    final ToolWindow tw = (ToolWindow)value;
    setIcon(getIcon(tw));
    final String name;

    String stripeTitle = tw.getStripeTitle();
    String shortcut = shortcuts.get(tw);
    if (myPinned || shortcut == null) {
      name = stripeTitle;
    } else {
      append(shortcut, new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE, null));
      name = ": " + stripeTitle;
    }

    append(name);
    if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) {
      hide = mySpeedSearch.matchingFragments(stripeTitle) == null && !StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix());
    }
  }
}
 
Example 18
Project: intellij-ce-playground   File: BaseToolWindowToggleAction.java   View source code 6 votes vote down vote up
@Override
public final void update(AnActionEvent e) {
  super.update(e);
  Presentation presentation = e.getPresentation();
  Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }
  ToolWindowManager mgr=ToolWindowManager.getInstance(project);
  String id=mgr.getActiveToolWindowId();

  if (id == null) {
    presentation.setEnabled(false);
    return;
  }

  ToolWindow window = mgr.getToolWindow(id);

  if (window == null) {
    presentation.setEnabled(false);
    return;
  }

  update(window, presentation);
}
 
Example 19
Project: intellij-ce-playground   File: GradleConsoleView.java   View source code 6 votes vote down vote up
public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
  //Create runner UI layout
  RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(myProject);
  RunnerLayoutUi layoutUi = factory.create("", "", "session", myProject);

  // Adding actions
  DefaultActionGroup group = new DefaultActionGroup();
  layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN);

  Content console = layoutUi.createContent(GradleConsoleToolWindowFactory.ID, myConsoleView.getComponent(), "", null, null);
  AnAction[] consoleActions = myConsoleView.createConsoleActions();
  for (AnAction action : consoleActions) {
    if (!shouldIgnoreAction(action)) {
      group.add(action);
    }
  }
  layoutUi.addContent(console, 0, PlaceInGrid.right, false);

  JComponent layoutComponent = layoutUi.getComponent();
  myConsolePanel.add(layoutComponent, BorderLayout.CENTER);

  //noinspection ConstantConditions
  Content content = ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true);
  toolWindow.getContentManager().addContent(content);
}
 
Example 20
Project: intellij-ce-playground   File: SvnMergeSourceDetails.java   View source code 6 votes vote down vote up
public static void showMe(final Project project, final SvnFileRevision revision, final VirtualFile file) {
  if (ModalityState.NON_MODAL.equals(ModalityState.current())) {
  ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);
  final ContentManager contentManager = toolWindow.getContentManager();

  final MyDialog dialog = new MyDialog(project, revision, file);
  // TODO: Temporary memory leak fix - rewrite this part not to create dialog if only createCenterPanel(), but not show() is invoked
  Disposer.register(project, dialog.getDisposable());

  Content content = ContentFactory.SERVICE.getInstance().createContent(dialog.createCenterPanel(),
      SvnBundle.message("merge.source.details.title", (file == null) ? revision.getURL() : file.getName(), revision.getRevisionNumber().asString()), true);
  ContentsUtil.addOrReplaceContent(contentManager, content, true);

  toolWindow.activate(null);
  } else {
    new MyDialog(project, revision, file).show();
  }
}
 
Example 21
Project: intellij-ce-playground   File: Switcher.java   View source code 6 votes vote down vote up
@Override
public boolean dispatch(AWTEvent event) {
  ToolWindow tw;
  if (SWITCHER != null && event instanceof KeyEvent && !SWITCHER.isPinnedMode()) {
    final KeyEvent keyEvent = (KeyEvent)event;
    if (event.getID() == KEY_RELEASED && keyEvent.getKeyCode() == CTRL_KEY) {
      SwingUtilities.invokeLater(CHECKER);
    }
    else if (event.getID() == KEY_PRESSED && event != INIT_EVENT
             && (tw = SWITCHER.twShortcuts.get(String.valueOf((char)keyEvent.getKeyCode()))) != null) {
      SWITCHER.myPopup.closeOk(null);
      tw.activate(null, true, true);
    }
  }
  return false;
}
 
Example 22
Project: intellij-ce-playground   File: DebuggerSessionTabBase.java   View source code 6 votes vote down vote up
public void select() {
  if (ApplicationManager.getApplication().isUnitTestMode()) return;

  UIUtil.invokeLaterIfNeeded(new Runnable() {
    @Override
    public void run() {
      if (myRunContentDescriptor != null) {
        ToolWindow toolWindow = ExecutionManager.getInstance(myProject).getContentManager()
          .getToolWindowByDescriptor(myRunContentDescriptor);
        Content content = myRunContentDescriptor.getAttachedContent();
        if (toolWindow == null || content == null) return;
        ContentManager manager = toolWindow.getContentManager();
        if (ArrayUtil.contains(content, manager.getContents()) && !manager.isSelected(content)) {
          manager.setSelectedContent(content);
        }
      }
    }
  });
}
 
Example 23
Project: intellij-ce-playground   File: TerminalView.java   View source code 6 votes vote down vote up
private void openSession(@NotNull ToolWindow toolWindow, @NotNull AbstractTerminalRunner terminalRunner) {
  if (myTerminalWidget == null) {
    toolWindow.getContentManager().removeAllContents(true);
    final Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
    toolWindow.getContentManager().addContent(content);
  }
  else {
    terminalRunner.openSession(myTerminalWidget);
  }

  toolWindow.activate(new Runnable() {
    @Override
    public void run() {

    }
  }, true);
}
 
Example 24
Project: intellij-ce-playground   File: DynamicToolWindowWrapper.java   View source code 6 votes vote down vote up
public ToolWindow getToolWindow() {
  if (myToolWindow == null) {
    myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(GroovyBundle.message("dynamic.tool.window.id"), true, ToolWindowAnchor.RIGHT);
    myToolWindow.setIcon(JetgroovyIcons.Groovy.DynamicProperty_13);
    myToolWindow.setTitle(GroovyBundle.message("dynamic.window"));
    myToolWindow.setToHideOnEmptyContent(true);

    final JPanel panel = buildBigPanel();
    final ContentManager contentManager = myToolWindow.getContentManager();
    final Content content = contentManager.getFactory().createContent(panel, "", false);
    content.setPreferredFocusableComponent(myTreeTable);
    contentManager.addContent(content);
  }

  return myToolWindow;
}
 
Example 25
Project: intellij-ce-playground   File: ConsoleManager.java   View source code 6 votes vote down vote up
private void createConsole(@NotNull final NetService netService) {
  TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(netService.getProject());
  netService.configureConsole(consoleBuilder);
  console = consoleBuilder.getConsole();

  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      ActionGroup actionGroup = netService.getConsoleToolWindowActions();
      ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, false);

      SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(false, true);
      toolWindowPanel.setContent(console.getComponent());
      toolWindowPanel.setToolbar(toolbar.getComponent());

      ToolWindow toolWindow = ToolWindowManager.getInstance(netService.getProject())
        .registerToolWindow(netService.getConsoleToolWindowId(), false, ToolWindowAnchor.BOTTOM, netService.getProject(), true);
      toolWindow.setIcon(netService.getConsoleToolWindowIcon());

      Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel, "", false);
      Disposer.register(content, console);

      toolWindow.getContentManager().addContent(content);
    }
  }, netService.getProject().getDisposed());
}
 
Example 26
Project: intellij-ce-playground   File: BrowseRepositoryAction.java   View source code 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    RepositoryBrowserDialog dialog = new RepositoryBrowserDialog(ProjectManager.getInstance().getDefaultProject());
    dialog.show();
  }
  else {
    ToolWindowManager manager = ToolWindowManager.getInstance(project);
    ToolWindow w = manager.getToolWindow(REPOSITORY_BROWSER_TOOLWINDOW);
    if (w == null) {
      RepositoryToolWindowPanel component = new RepositoryToolWindowPanel(project);
      w = manager.registerToolWindow(REPOSITORY_BROWSER_TOOLWINDOW, true, ToolWindowAnchor.BOTTOM, project, true);
      final Content content = ContentFactory.SERVICE.getInstance().createContent(component, "", false);
      Disposer.register(content, component);
      w.getContentManager().addContent(content);
    }
    w.show(null);
    w.activate(null);
  }
}
 
Example 27
Project: intellij-ce-playground   File: CloseActiveTabAction.java   View source code 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(e.getDataContext(), true);
  boolean processed = false;
  if (contentManager != null && contentManager.canCloseContents()) {
    final Content selectedContent = contentManager.getSelectedContent();
    if (selectedContent != null && selectedContent.isCloseable()) {
      contentManager.removeContent(selectedContent, true);
      processed = true;
    }
  }

  if (!processed && contentManager != null) {
    final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent());
    final ToolWindow tw = PlatformDataKeys.TOOL_WINDOW.getData(context);
    if (tw != null) {
      tw.hide(null);
    }
  }
}
 
Example 28
Project: intellij-ce-playground   File: FindByExpressionDialog.java   View source code 6 votes vote down vote up
protected void init() {
    final ToolWindow findWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND);
    final boolean available = findWindow != null && findWindow.isAvailable();

    myForm.getNewTabCheckbox().setEnabled(available);
    myForm.getNewTabCheckbox().setSelected(FindSettings.getInstance().isShowResultsInSeparateView());

    myForm.getScopePanel().addPropertyChangeListener("scope", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            updateOkAction();
        }
    });

    myForm.getMatchEachNode().setSelected(mySettings.MATCH_RECURSIVELY);
    myForm.getMatchRootNode().setSelected(!mySettings.MATCH_RECURSIVELY);

    Disposer.register(myDisposable, myForm);
    super.init();
}
 
Example 29
Project: IdeaCurrency   File: IdeaCurrencyToolWindow.java   View source code 5 votes vote down vote up
@Override
public void init(ToolWindow window) {
    myExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("DataFetch-%s").build());
    table.setDragEnabled(false);
    defaultTableModel = prepareTableHeader();
    reloadButton.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            scheduleTask(IdeaCurrencyConfig.getInstance().getReloadInterval());
        }
    });
    contentPane.setBackground(JBColor.LIGHT_GRAY);
    table.getEmptyText().setText(TABLE_EMPTY_TEXT);
    scheduleNextTask();
}
 
Example 30
Project: react-native-console   File: ReactNativeConsole.java   View source code 5 votes vote down vote up
public void initAndActiveRunRefresh(InputEvent e) {
    ToolWindow toolWindow = getToolWindow();
    if (!toolWindow.isActive()) {
        toolWindow.activate(new Runnable() {
            @Override
            public void run() {
                ActionManager.getInstance().tryToExecute(new AndroidRefreshAction(ReactNativeConsole.this), e, null, ActionPlaces.UNKNOWN, true);
            }
        });
    } else {
        ActionManager.getInstance().tryToExecute(new AndroidRefreshAction(this), e, null, ActionPlaces.UNKNOWN, true);
    }
}
 
Example 31
Project: react-native-console   File: ReactNativeConsole.java   View source code 5 votes vote down vote up
public void initTerminal(final ToolWindow toolWindow) {
        toolWindow.setToHideOnEmptyContent(true);
        toolWindow.setStripeTitle("RN Console");
        toolWindow.setIcon(PluginIcons.React);
        Content content = createConsoleTabContent(toolWindow, true, "Welcome", null);
//        toolWindow.getContentManager().addContent(content);
//        toolWindow.getContentManager().addContent(new ContentImpl(new JButton("Test"), "Build2", false));

        // ======= test a terminal create ======
//        LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
//        Content testTerminalContent = createTerminalInContentPanel(terminalRunner, toolWindow);
//        toolWindow.getContentManager().addContent(testTerminalContent);

//        SimpleTerminal term  = new SimpleTerminal();
//        term.sendString("ls\n");
//        toolWindow.getContentManager().addContent(new ContentImpl(term.getComponent(), "terminal", false));
        toolWindow.setShowStripeButton(true);// if set to false, then sometimes the window will be hidden from the dock area for ever 2017-05-26
//        toolWindow.setTitle(" - ");
        ((ToolWindowManagerEx) ToolWindowManager.getInstance(this.myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
            @Override
            public void toolWindowRegistered(@NotNull String s) {
            }

            @Override
            public void stateChanged() {
                ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
                if (window != null) {
                    boolean visible = window.isVisible();
                    if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                        initTerminal(window);
                    }
                }
            }
        });
        toolWindow.show(null);
    }
 
Example 32
Project: react-native-console   File: ReactNativeConsole.java   View source code 5 votes vote down vote up
@Override
public void focusGained(FocusEvent e) {
    ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
    if (toolWindow != null) {
        try {
            ContentManager contentManager = toolWindow.getContentManager();
            JComponent component = contentManager.getSelectedContent().getComponent();
            if (component != null) {
                component.requestFocusInWindow();
            }
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }
}
 
Example 33
Project: react-native-console   File: ReactNativeTerminal.java   View source code 5 votes vote down vote up
public void initAndExecute(final String[] shell) {
    ToolWindow toolWindow = getToolWindow();
    if (toolWindow.isActive()) {
        executeShell(shell);
    } else {
        toolWindow.activate(new Runnable() {
            @Override
            public void run() {
                executeShell(shell);
            }
        });
    }
}
 
Example 34
Project: react-native-console   File: ReactNativeTerminal.java   View source code 5 votes vote down vote up
public void initTerminal(final ToolWindow toolWindow) {
    toolWindow.setToHideOnEmptyContent(true);
    LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
    myTerminalRunner = terminalRunner;
    toolWindow.setStripeTitle("React Native");
    Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
    toolWindow.getContentManager().addContent(content);
    toolWindow.setShowStripeButton(true);
    toolWindow.setTitle("Console");
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(this.myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {
        @Override
        public void toolWindowRegistered(@NotNull String s) {

        }

        @Override
        public void stateChanged() {
            ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(RNToolWindowFactory.TOOL_WINDOW_ID);
            if (window != null) {
                boolean visible = window.isVisible();
                if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                    initTerminal(window);
                }
            }
        }
    });
    toolWindow.show(null);
    JBTabbedTerminalWidget terminalWidget = getTerminalWidget(toolWindow);
    if (terminalWidget != null && terminalWidget.getCurrentSession() != null) {
        Terminal terminal = terminalWidget.getCurrentSession().getTerminal();
        if (terminal != null) {
            terminal.setCursorVisible(true);// 是否启用光标 BeanSoft
        }
    }
}
 
Example 35
Project: react-native-console   File: ReactNativeTerminal.java   View source code 5 votes vote down vote up
private void openSession(@NotNull ToolWindow toolWindow, @NotNull AbstractTerminalRunner terminalRunner) {
    if (this.myTerminalWidget == null) {
        toolWindow.getContentManager().removeAllContents(true);
        Content content = this.createTerminalInContentPanel(terminalRunner, toolWindow);
        toolWindow.getContentManager().addContent(content);
    } else {
        terminalRunner.openSession(this.myTerminalWidget);
    }

    toolWindow.activate(() -> {
    }, true);
}
 
Example 36
Project: react-native-console   File: ReactNativeTerminal.java   View source code 5 votes vote down vote up
/**
     * 创建左侧工具栏
     *
     * @param terminalRunner
     * @param terminal
     * @param toolWindow
     * @return
     */
    private void createToolbar(@Nullable AbstractTerminalRunner terminalRunner, @NotNull JBTabbedTerminalWidget terminal,
                               @NotNull ToolWindow toolWindow, @NotNull SimpleToolWindowPanel panel) {
        // Termal basis
        createAndAddLeftToolbar(terminalRunner, myTerminalWidget, panel,
                new NewSession(terminalRunner, terminal),
                new CloseSession(terminal, toolWindow),
                new StopAction(this),
                new ClearAction(this));

        // Android
//        createAndAddLeftToolbar(terminalRunner, myTerminalWidget, panel,
//                new AndroidDevMenuAction(this),
//                new AdbForwardAction(this),
//                new RunAndroidAction(this),
//                new AndroidReleaseApkAction(this),
//                new NPMAndroidLogsAction(this));
//
//        // NPM
//        createAndAddLeftToolbar(terminalRunner, myTerminalWidget, panel,
//                new NPMStartAction(this),
//                new NPMInstallAction(this));
//
//        // iOS
//        createAndAddLeftToolbar(terminalRunner, myTerminalWidget, panel,
//                new RunLinkAction(this),
//                new RunIOSAction(this),
//                new NPMiOSLogsAction(this));
//
//        // General
//        createAndAddLeftToolbar(terminalRunner, myTerminalWidget, panel,
////                new ClearAction(this),
//                new DebugUiAction(this));
    }
 
Example 37
Project: intellij-circleci-integration   File: RecentBuildsToolWindowFactory.java   View source code 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(pnlMain, "", false);
    toolWindow.getContentManager().addContent(content);
    toolWindow.setIcon(Icons.PLUGIN_ICON);

    addBtnRefreshListener();
    addBtnGroupProjectListener();
    addBtnGroupCommitterListener();
    addBtnResetListener();
}
 
Example 38
Project: reasonml-idea-plugin   File: BucklescriptProjectComponent.java   View source code 5 votes vote down vote up
private BsConsole getBsbConsole() {
    BsConsole console = null;

    ToolWindow window = ToolWindowManager.getInstance(m_project).getToolWindow("Bucklescript");
    Content windowContent = window.getContentManager().getContent(0);
    if (windowContent != null) {
        SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent();
        JComponent panelComponent = component.getComponent();
        if (panelComponent != null) {
            console = (BsConsole) panelComponent.getComponent(0);
        }
    }

    return console;
}
 
Example 39
Project: SmartQQ4IntelliJ   File: IMWindowFactory.java   View source code 5 votes vote down vote up
@Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        instance = this;
        this.project = project;
        toolWindow.setToHideOnEmptyContent(true);
        createContents(project, toolWindow);
        ToolWindowManager manager = ToolWindowManager.getInstance(project);
        if (manager instanceof ToolWindowManagerEx) {
            ToolWindowManagerEx managerEx = ((ToolWindowManagerEx) manager);
            managerEx.addToolWindowManagerListener(new ToolWindowManagerListener() {
                @Override
                public void toolWindowRegistered(@NotNull String id) {
                }

                @Override
                public void stateChanged() {
                    ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(IMWindowFactory.TOOL_WINDOW_ID);
                    if (window != null) {
                        boolean visible = window.isVisible();
                        if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                            createContents(project, window);
                        }
                    }
                }
            });
        }

//        Disposer.register(project, new Disposable() {
//            @Override
//            public void dispose() {
//                if (panel != null && panel.isEnabled()) {
//                    panel.setEnabled(false);
//                    panel = null;
//                }
//            }
//        });
    }
 
Example 40
Project: SmartQQ4IntelliJ   File: IMWindowFactory.java   View source code 5 votes vote down vote up
private void createContents(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    SmartQQPanel qqPanel = new SmartQQPanel(project, toolWindow);
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(qqPanel, "SmartQQ", false);
    toolWindow.getContentManager().addContent(content, 0);

    WechatPanel wechatPanel = new WechatPanel(project, toolWindow);
    content = contentFactory.createContent(wechatPanel, "Wechat", false);
    toolWindow.getContentManager().addContent(content, 1);
}