Java Code Examples for com.intellij.ui.content.Content#isCloseable()

The following examples show how to use com.intellij.ui.content.Content#isCloseable() . 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: CloseActiveTabAction.java    From consulo with Apache License 2.0 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 = context.getData(PlatformDataKeys.TOOL_WINDOW);
    if (tw != null) {
      tw.hide(null);
    }
  }
}
 
Example 2
Source File: TabbedContentAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  Content[] contents = myManager.getContents();
  for (Content content : contents) {
    if (myContent != content && content.isCloseable()) {
      myManager.removeContent(content, true);
    }
  }
  myManager.setSelectedContent(myContent);
}
 
Example 3
Source File: TabbedContentAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean hasCloseableContents() {
  Content[] contents = myManager.getContents();
  for (Content content : contents) {
    if (myContent != content && content.isCloseable()) {
      return true;
    }
  }
  return false;
}
 
Example 4
Source File: TabbedContentAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  Content[] contents = myManager.getContents();
  for (Content content : contents) {
    if (content.isCloseable()) {
      myManager.removeContent(content, true);
    }
  }
}
 
Example 5
Source File: CloseOtherViewsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void actionPerformed(final AnActionEvent e, final ViewContext context, final Content[] content) {
  final ContentManager manager = context.getContentManager();
  for (Content c : manager.getContents()) {
    if (c != content[0] && c.isCloseable()) {
      manager.removeContent(c, context.isToDisposeRemovedContent());
    }
  }
}
 
Example 6
Source File: CloseOtherViewsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean isEnabled(ViewContext context, Content[] content, String place) {
  if (content.length != 1) return false;
  int closeable = 0;
  for (Content c : context.getContentManager().getContents()) {
    if (c == content[0]) continue;
    if (c.isCloseable()) closeable++;
  }
  return closeable > 0;
}
 
Example 7
Source File: CloseAllViewsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void actionPerformed(final AnActionEvent e, final ViewContext context, final Content[] content) {
  final ContentManager manager = context.getContentManager();
  for (Content c : manager.getContents()) {
    if (c.isCloseable()) {
      manager.removeContent(c, context.isToDisposeRemovedContent());
    }
  }
}
 
Example 8
Source File: CloseAllViewsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean isEnabled(ViewContext context, Content[] content, String place) {
  int closeable = 0;
  for (Content c : context.getContentManager().getContents()) {
    if (c.isCloseable()) closeable ++;
  }
  return closeable > 1;
}