@Override
    public void processTerminated(ProcessEvent event) {
      if (myProject.isDisposed()) return;
      if (!myTerminateNotified.compareAndSet(false, true)) return;

      ApplicationManager.getApplication()
          .invokeLater(
              () -> {
                RunnerLayoutUi ui = myDescriptor.getRunnerLayoutUi();
                if (ui != null && !ui.isDisposed()) {
                  ui.updateActionsNow();
                }
              },
              ModalityState.any());

      myProject
          .getMessageBus()
          .syncPublisher(EXECUTION_TOPIC)
          .processTerminated(myExecutorId, myEnvironment, myProcessHandler, event.getExitCode());

      SaveAndSyncHandler saveAndSyncHandler = SaveAndSyncHandler.getInstance();
      if (saveAndSyncHandler != null) {
        saveAndSyncHandler.scheduleRefresh();
      }
    }
  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);
  }
 public CompositeDiffPanel(
     Project project,
     final DiscloseMultiRequest request,
     final Window window,
     final Disposable parentDisposable) {
   myRequest = request;
   myWindow = window;
   myParentDisposable = parentDisposable;
   myUi =
       RunnerLayoutUi.Factory.getInstance(project)
           .create("Diff", "Diff", "Diff", parentDisposable);
   myUi.getComponent().setBorder(null);
   myUi.getOptions().setMinimizeActionEnabled(false);
   // myUi.getOptions().setTopToolbar()
   myMap = new HashMap<String, DiffViewer>();
 }
 private void removeTab(Content[] contents, String s) {
   myMap.remove(s);
   for (Content content : contents) {
     if (s.equals(content.getDisplayName())) {
       myUi.getContentManager().removeContent(content, false);
       break;
     }
   }
 }
Exemple #5
0
  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);
    }
  }
  @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);
    }
  }
 @Override
 public JComponent getPreferredFocusedComponent() {
   final Content[] contents = myUi.getContents();
   if (contents == null || contents.length == 0) return null;
   return contents[0].getPreferredFocusableComponent();
 }
 @Override
 public JComponent getComponent() {
   return myUi.getComponent();
 }