public int addTab(
     String s,
     JComponent component,
     boolean selectTab,
     boolean replaceContent,
     boolean lockable,
     boolean addDefaultToolbar,
     ActionGroup toolbarActions,
     String helpId) {
   int existing = getComponentNumNamed(s);
   ContentManager contentManager = getContentManager();
   if (existing != -1) {
     Content existingContent = contentManager.getContent(existing);
     if (!replaceContent) {
       contentManager.setSelectedContent(existingContent);
       return existing;
     }
     //            if (!existingContent.isPinned()) {
     //                getContentManager().removeContent(existingContent);
     //                existingContent.release();
     //            }
   }
   CommitLogWindowComponent newComponent =
       new CommitLogWindowComponent(
           component, addDefaultToolbar, toolbarActions, contentManager, helpId);
   Content content =
       ContentFactory.SERVICE
           .getInstance()
           .createContent(newComponent.getShownComponent(), s, lockable);
   newComponent.setContent(content);
   contentManager.addContent(content);
   return getComponentAt(contentManager.getContentCount() - 1, selectTab);
 }
  private Content getOrCreateConsoleContent(final ContentManager contentManager) {
    final String displayName = VcsBundle.message("vcs.console.toolwindow.display.name");
    Content content = contentManager.findContent(displayName);
    if (content == null) {
      releaseEditor();
      final EditorFactory editorFactory = EditorFactory.getInstance();
      final Editor editor = editorFactory.createViewer(editorFactory.createDocument(""), myProject);
      EditorSettings editorSettings = editor.getSettings();
      editorSettings.setLineMarkerAreaShown(false);
      editorSettings.setIndentGuidesShown(false);
      editorSettings.setLineNumbersShown(false);
      editorSettings.setFoldingOutlineShown(false);

      ((EditorEx) editor).getScrollPane().setBorder(null);
      myEditorAdapter = new EditorAdapter(editor, myProject, false);
      final JPanel panel = new JPanel(new BorderLayout());
      panel.add(editor.getComponent(), BorderLayout.CENTER);

      content = ContentFactory.SERVICE.getInstance().createContent(panel, displayName, true);
      contentManager.addContent(content);

      for (Pair<String, TextAttributes> pair : myPendingOutput) {
        myEditorAdapter.appendString(pair.first, pair.second);
      }
      myPendingOutput.clear();
    }
    return content;
  }
 @Override
 public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
   AntExplorer explorer = new AntExplorer(project);
   final ContentManager contentManager = toolWindow.getContentManager();
   final Content content = contentManager.getFactory().createContent(explorer, null, false);
   contentManager.addContent(content);
   Disposer.register(project, explorer);
 }
  public void setup(ToolWindowEx toolWindow) {

    ContentManager contentManager = toolWindow.getContentManager();
    Content content =
        contentManager
            .getFactory()
            .createContent(new Symfony2WebProfilerForm(this.project).createComponent(), null, true);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);
  }
 @Override
 public void createToolWindowContent(Project project, ToolWindow toolWindow) {
   DiffManager.getInstance().registerDiffTool(new CommentsDiffTool());
   final ContentManager contentManager = toolWindow.getContentManager();
   final CruciblePanel cruciblePanel = new CruciblePanel(project);
   final Content content =
       ContentFactory.SERVICE
           .getInstance()
           .createContent(cruciblePanel, CrucibleBundle.message("crucible.main.name"), false);
   content.setCloseable(false);
   contentManager.addContent(content);
 }
 private Content createNewContent(
     final ContentManager contentManager,
     final RunContentDescriptor descriptor,
     Executor executor) {
   final String processDisplayName = descriptor.getDisplayName();
   final Content content =
       ContentFactory.SERVICE
           .getInstance()
           .createContent(descriptor.getComponent(), processDisplayName, true);
   content.putUserData(DESCRIPTOR_KEY, descriptor);
   content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
   contentManager.addContent(content);
   new CloseListener(content, executor);
   return content;
 }
  public HerokuToolWindow addAsContent(ContentManager contentManager) {
    final Content content = contentManager.getFactory().createContent(this, null, false);

    setWindowInfo(
        new ContentInfo() {
          public void describe(String title, String icon, String description) {
            content.setIcon(icon(icon));
            content.setDescription(description);
            content.setDisplayName(title);
            content.setTabName(title);
            content.setToolwindowTitle(title);
          }
        });
    content.setCloseable(false);
    contentManager.addContent(content);
    return this;
  }
  private void initToolWindow() {
    myToolWindowForm = new AndroidLayoutPreviewToolWindowForm(this);
    final String toolWindowId = AndroidBundle.message("android.layout.preview.tool.window.title");
    myToolWindow =
        ToolWindowManager.getInstance(myProject)
            .registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, myProject, true);
    myToolWindow.setIcon(AndroidIcons.AndroidPreview);

    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject))
        .addToolWindowManagerListener(
            new ToolWindowManagerAdapter() {
              private boolean myVisible = false;

              @Override
              public void stateChanged() {
                if (myProject.isDisposed()) {
                  return;
                }

                final ToolWindow window =
                    ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId);
                if (window != null && window.isAvailable()) {
                  final boolean visible = window.isVisible();
                  AndroidEditorSettings.getInstance().getGlobalState().setVisible(visible);

                  if (visible && !myVisible) {
                    render();
                  }
                  myVisible = visible;
                }
              }
            });

    final JPanel contentPanel = myToolWindowForm.getContentPanel();
    final ContentManager contentManager = myToolWindow.getContentManager();
    @SuppressWarnings("ConstantConditions")
    final Content content = contentManager.getFactory().createContent(contentPanel, null, false);
    content.setDisposer(myToolWindowForm);
    content.setCloseable(false);
    content.setPreferredFocusableComponent(contentPanel);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);
    myToolWindow.setAvailable(false, null);
  }
예제 #9
0
 @Override
 public void createToolWindowContent(
     @NotNull final Project project, @NotNull final ToolWindow toolWindow) {
   toolWindow.setIcon(InteractiveLearningIcons.TaskDescription);
   StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
   final Course course = taskManager.getCourse();
   if (course != null) {
     final StudyToolWindow studyToolWindow;
     if (StudyUtils.hasJavaFx() && StudyTaskManager.getInstance(project).shouldUseJavaFx()) {
       studyToolWindow = new StudyJavaFxToolWindow();
     } else {
       studyToolWindow = new StudySwingToolWindow();
     }
     studyToolWindow.init(project);
     final ContentManager contentManager = toolWindow.getContentManager();
     final Content content =
         contentManager.getFactory().createContent(studyToolWindow, null, false);
     contentManager.addContent(content);
     Disposer.register(project, studyToolWindow);
   }
 }
예제 #10
0
  public void initToolWindow(ToolWindow toolWindow) {
    // Create panels

    Content allTodosContent =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(null, IdeBundle.message("title.project"), false);
    myAllTodos =
        new TodoPanel(myProject, myAllPanelSettings, false, allTodosContent) {
          protected TodoTreeBuilder createTreeBuilder(
              JTree tree, DefaultTreeModel treeModel, Project project) {
            AllTodosTreeBuilder builder = new AllTodosTreeBuilder(tree, treeModel, project);
            builder.init();
            return builder;
          }
        };
    allTodosContent.setComponent(myAllTodos);
    Disposer.register(this, myAllTodos);

    Content currentFileTodosContent =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(null, IdeBundle.message("title.todo.current.file"), false);
    myCurrentFileTodos =
        new CurrentFileTodosPanel(myProject, myCurrentPanelSettings, currentFileTodosContent) {
          protected TodoTreeBuilder createTreeBuilder(
              JTree tree, DefaultTreeModel treeModel, Project project) {
            CurrentFileTodosTreeBuilder builder =
                new CurrentFileTodosTreeBuilder(tree, treeModel, project);
            builder.init();
            return builder;
          }
        };
    Disposer.register(this, myCurrentFileTodos);
    currentFileTodosContent.setComponent(myCurrentFileTodos);

    myChangeListTodosContent =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(
                null,
                IdeBundle.message(
                    "changelist.todo.title",
                    ChangeListManager.getInstance(myProject).getDefaultChangeList().getName()),
                false);
    myChangeListTodos =
        new ChangeListTodosPanel(myProject, myCurrentPanelSettings, myChangeListTodosContent) {
          protected TodoTreeBuilder createTreeBuilder(
              JTree tree, DefaultTreeModel treeModel, Project project) {
            ChangeListTodosTreeBuilder builder =
                new ChangeListTodosTreeBuilder(tree, treeModel, project);
            builder.init();
            return builder;
          }
        };
    Disposer.register(this, myChangeListTodos);
    myChangeListTodosContent.setComponent(myChangeListTodos);

    myContentManager = toolWindow.getContentManager();

    myContentManager.addContent(allTodosContent);
    myContentManager.addContent(currentFileTodosContent);
    if (myVCSManager.getAllActiveVcss().length > 0) {
      myVcsListener.myIsVisible = true;
      myContentManager.addContent(myChangeListTodosContent);
    }

    Content content = myContentManager.getContent(mySelectedIndex);
    content = content == null ? allTodosContent : content;
    myContentManager.setSelectedContent(content);
  }
  private void initToolWindow() {
    toolWindowForm = new MxmlPreviewToolWindowForm();
    String toolWindowId = FlashUIDesignerBundle.message("mxml.preview.tool.window.title");
    toolWindow =
        ToolWindowManager.getInstance(project)
            .registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, project, false);
    toolWindow.setIcon(PlatformIcons.UI_FORM_ICON);

    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
    toolWindowVisible = propertiesComponent.getBoolean(SETTINGS_TOOL_WINDOW_VISIBLE);
    if (toolWindowVisible) {
      toolWindow.show(null);
    } else {
      toolWindow.hide(null);
    }

    ((ToolWindowManagerEx) ToolWindowManager.getInstance(project))
        .addToolWindowManagerListener(
            new ToolWindowManagerAdapter() {
              @Override
              public void stateChanged() {
                if (project.isDisposed() || toolWindow == null || !toolWindow.isAvailable()) {
                  return;
                }

                final boolean currentVisible = toolWindow.isVisible();
                if (currentVisible == toolWindowVisible) {
                  return;
                }

                toolWindowVisible = currentVisible;

                PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
                if (currentVisible) {
                  propertiesComponent.setValue(SETTINGS_TOOL_WINDOW_VISIBLE, true);

                  if (!lastPreviewChecked) {
                    lastPreviewChecked = true;
                    if (checkLastImage()) {
                      return;
                    }
                  }

                  render(true, false);
                } else {
                  propertiesComponent.unsetValue(SETTINGS_TOOL_WINDOW_VISIBLE);
                }
              }
            });

    JPanel contentPanel = toolWindowForm.getContentPanel();
    ContentManager contentManager = toolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(contentPanel, null, false);
    content.setCloseable(false);
    content.setPreferredFocusableComponent(contentPanel);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, true);

    MessageBusConnection connection =
        ApplicationManager.getApplication().getMessageBus().connect(project);
    connection.subscribe(
        DesignerApplicationManager.MESSAGE_TOPIC,
        new DocumentRenderedListener() {
          private boolean isApplicable(DocumentFactoryManager.DocumentInfo info) {
            return toolWindowVisible
                && toolWindowForm.getFile() != null
                && info.equals(
                    DocumentFactoryManager.getInstance().getNullableInfo(toolWindowForm.getFile()));
          }

          @Override
          public void documentRendered(DocumentFactoryManager.DocumentInfo info) {
            if (isApplicable(info) && !toolWindowForm.waitingForGetDocument) {
              UIUtil.invokeLaterIfNeeded(
                  new Runnable() {
                    @Override
                    public void run() {
                      render(false, false);
                    }
                  });
            }
          }

          @Override
          public void errorOccurred() {}
        });
  }