コード例 #1
0
  @Override
  public void setDiffRequest(DiffRequest request) {
    final Map<String, DiffRequest> requestMap = myRequest.discloseRequest(request);
    final HashMap<String, DiffViewer> copy = new HashMap<String, DiffViewer>(myMap);

    for (Map.Entry<String, DiffRequest> entry : requestMap.entrySet()) {
      final String key = entry.getKey();
      final DiffRequest diffRequest = entry.getValue();
      diffRequest.getGenericData().put(PlatformDataKeys.COMPOSITE_DIFF_VIEWER.getName(), this);
      final DiffViewer viewer = copy.remove(key);
      if (viewer != null && viewer.acceptsType(diffRequest.getType())) {
        viewer.setDiffRequest(diffRequest);
      } else {
        if (viewer != null) {
          removeTab(myUi.getContentManager().getContents(), key);
        }
        final DiffViewer newViewer =
            myRequest.viewerForRequest(myWindow, myParentDisposable, key, diffRequest);
        if (newViewer == null) continue;
        myMap.put(key, newViewer);
        final Content content =
            myUi.createContent(
                key, newViewer.getComponent(), key, null, newViewer.getPreferredFocusedComponent());
        content.setCloseable(false);
        content.setPinned(true);
        Disposer.register(
            myParentDisposable,
            new Disposable() {
              @Override
              public void dispose() {
                myMap.remove(key);
                myUi.removeContent(content, true);
              }
            });
        myUi.addContent(content);
      }
    }
    final Content[] contents = myUi.getContentManager().getContents();
    for (String s : copy.keySet()) {
      removeTab(contents, s);
    }

    if (myMap.isEmpty()) {
      final EmptyDiffViewer emptyDiffViewer = new EmptyDiffViewer();
      myMap.put(FICTIVE_KEY, emptyDiffViewer);
      final Content content =
          myUi.createContent(
              FICTIVE_KEY,
              emptyDiffViewer.getComponent(),
              FICTIVE_KEY,
              null,
              emptyDiffViewer.getPreferredFocusedComponent());
      content.setCloseable(false);
      content.setPinned(true);
      content.setDisposer(myParentDisposable);
      myUi.addContent(content);
    }
  }
コード例 #2
0
  private Content createTerminalInContentPanel(
      @NotNull AbstractTerminalRunner terminalRunner, final @NotNull ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
    content.setCloseable(true);

    myTerminalWidget = terminalRunner.createTerminalWidget(content);
    myTerminalWidget.addTabListener(
        new TabbedTerminalWidget.TabListener() {
          @Override
          public void tabClosed(JediTermWidget terminal) {
            UIUtil.invokeLaterIfNeeded(
                () -> {
                  if (myTerminalWidget != null) {
                    hideIfNoActiveSessions(toolWindow, myTerminalWidget);
                  }
                });
          }
        });

    panel.setContent(myTerminalWidget.getComponent());
    panel.addFocusListener(createFocusListener());

    ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow);
    toolbar.getComponent().addFocusListener(createFocusListener());
    toolbar.setTargetComponent(panel);
    panel.setToolbar(toolbar.getComponent());

    content.setPreferredFocusableComponent(myTerminalWidget.getComponent());

    return content;
  }
コード例 #3
0
 @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);
 }
コード例 #4
0
  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);
  }
コード例 #6
0
ファイル: DebuggerUtilsEx.java プロジェクト: jared2501/test
  public static void addThreadDump(
      Project project,
      List<ThreadState> threads,
      final RunnerLayoutUi ui,
      DebuggerSession session) {
    final TextConsoleBuilder consoleBuilder =
        TextConsoleBuilderFactory.getInstance().createBuilder(project);
    consoleBuilder.filters(ExceptionFilters.getFilters(session.getSearchScope()));
    final ConsoleView consoleView = consoleBuilder.getConsole();
    final DefaultActionGroup toolbarActions = new DefaultActionGroup();
    consoleView.allowHeavyFilters();
    final ThreadDumpPanel panel =
        new ThreadDumpPanel(project, consoleView, toolbarActions, threads);

    final String id = THREAD_DUMP_CONTENT_PREFIX + " #" + myCurrentThreadDumpId;
    final Content content = ui.createContent(id, panel, id, null, null);
    content.putUserData(RunnerContentUi.LIGHTWEIGHT_CONTENT_MARKER, Boolean.TRUE);
    content.setCloseable(true);
    content.setDescription("Thread Dump");
    ui.addContent(content);
    ui.selectAndFocus(content, true, true);
    myThreadDumpsCount++;
    myCurrentThreadDumpId++;
    Disposer.register(
        content,
        new Disposable() {
          @Override
          public void dispose() {
            myThreadDumpsCount--;
            if (myThreadDumpsCount == 0) {
              myCurrentThreadDumpId = 1;
            }
          }
        });
    Disposer.register(content, consoleView);
    ui.selectAndFocus(content, true, false);
    if (threads.size() > 0) {
      panel.selectStackFrame(0);
    }
  }
コード例 #7
0
  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() {}
        });
  }