Java Code Examples for com.intellij.openapi.wm.ToolWindow#isAvailable()

The following examples show how to use com.intellij.openapi.wm.ToolWindow#isAvailable() . 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: ServersToolWindowManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateWindowAvailable(boolean showIfAvailable) {
  ToolWindow toolWindow = myToolWindowManager.getToolWindow(ID);

  boolean available = isAvailable();
  boolean doShow = !toolWindow.isAvailable() && available;
  if (toolWindow.isAvailable() && !available) {
    toolWindow.hide(null);
  }
  toolWindow.setAvailable(available, null);
  if (showIfAvailable && doShow) {
    toolWindow.show(null);
  }
}
 
Example 2
Source File: ToolWindowLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public List<String> getVisibleIdsOn(@Nonnull ToolWindowAnchor anchor, @Nonnull ToolWindowManager manager) {
  List<String> ids = new ArrayList<>();
  for (WindowInfoImpl each : getAllInfos(anchor)) {
    final ToolWindow window = manager.getToolWindow(each.getId());
    if (window == null) continue;
    if (window.isAvailable() || UISettings.getInstance().ALWAYS_SHOW_WINDOW_BUTTONS) {
      ids.add(each.getId());
    }
  }
  return ids;
}
 
Example 3
Source File: ShTerminalRunner.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean isAvailable(@NotNull Project project) {
  ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
  return window != null && window.isAvailable();
}
 
Example 4
Source File: FlutterPerformanceView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
void debugActive(@NotNull FlutterViewMessages.FlutterDebugEvent event) {
  final FlutterApp app = event.app;
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
  if (!(toolWindowManager instanceof ToolWindowManagerEx)) {
    return;
  }

  final ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOL_WINDOW_ID);
  if (toolWindow == null) {
    return;
  }

  if (!toolWindow.isAvailable()) {
    toolWindow.setAvailable(true, null);
  }

  addPerformanceViewContent(app, toolWindow);

  app.getVmService().addVmServiceListener(new VmServiceListenerAdapter() {
    @Override
    public void connectionOpened() {
      onAppChanged(app);
    }

    @Override
    public void connectionClosed() {
      ApplicationManager.getApplication().invokeLater(() -> {
        if (toolWindow.isDisposed()) return;
        final ContentManager contentManager = toolWindow.getContentManager();
        onAppChanged(app);
        final PerfViewAppState state = perAppViewState.remove(app);
        if (state != null) {
          if (state.content != null) {
            contentManager.removeContent(state.content, true);
          }
          if (state.disposable != null) {
            Disposer.dispose(state.disposable);
          }
        }
        if (perAppViewState.isEmpty()) {
          // No more applications are running.
          updateForEmptyContent(toolWindow);
        }
      });
    }
  });
  onAppChanged(app);
}
 
Example 5
Source File: FlutterPerformanceView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
void debugActive(@NotNull FlutterViewMessages.FlutterDebugEvent event) {
  final FlutterApp app = event.app;
  final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
  if (!(toolWindowManager instanceof ToolWindowManagerEx)) {
    return;
  }

  final ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOL_WINDOW_ID);
  if (toolWindow == null) {
    return;
  }

  if (!toolWindow.isAvailable()) {
    toolWindow.setAvailable(true, null);
  }

  addPerformanceViewContent(app, toolWindow);

  app.getVmService().addVmServiceListener(new VmServiceListenerAdapter() {
    @Override
    public void connectionOpened() {
      onAppChanged(app);
    }

    @Override
    public void connectionClosed() {
      ApplicationManager.getApplication().invokeLater(() -> {
        if (toolWindow.isDisposed()) return;
        final ContentManager contentManager = toolWindow.getContentManager();
        onAppChanged(app);
        final PerfViewAppState state = perAppViewState.remove(app);
        if (state != null) {
          if (state.content != null) {
            contentManager.removeContent(state.content, true);
          }
          if (state.disposable != null) {
            Disposer.dispose(state.disposable);
          }
        }
        if (perAppViewState.isEmpty()) {
          // No more applications are running.
          updateForEmptyContent(toolWindow);
        }
      });
    }
  });
  onAppChanged(app);
}