本文整理汇总了Java中com.intellij.ui.content.ContentManager类的典型用法代码示例。如果您正苦于以下问题:Java ContentManager类的具体用法?Java ContentManager怎么用?Java ContentManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentManager类属于com.intellij.ui.content包,在下文中一共展示了ContentManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createToolWindowContent
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
toolWindow.setIcon(EducationalCoreIcons.TaskDescription);
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course != null) {
final StudyToolWindow studyToolWindow;
if (StudyUtils.hasJavaFx() && StudySettings.getInstance().shouldUseJavaFx()) {
studyToolWindow = new StudyJavaFxToolWindow();
}
else {
studyToolWindow = new StudySwingToolWindow();
}
studyToolWindow.init(project, true);
final ContentManager contentManager = toolWindow.getContentManager();
final Content content = contentManager.getFactory().createContent(studyToolWindow, null, false);
contentManager.addContent(content);
Disposer.register(project, studyToolWindow);
}
}
示例2: addOrReplaceContent
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
public static void addOrReplaceContent(ContentManager manager, Content content, boolean select) {
final String contentName = content.getDisplayName();
Content[] contents = manager.getContents();
Content oldContentFound = null;
for(Content oldContent: contents) {
if (!oldContent.isPinned() && oldContent.getDisplayName().equals(contentName)) {
oldContentFound = oldContent;
break;
}
}
manager.addContent(content);
if (oldContentFound != null) {
manager.removeContent(oldContentFound, true);
}
if (select) {
manager.setSelectedContent(content);
}
}
示例3: ContentTabLabel
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
public ContentTabLabel(final Content content, TabContentLayout layout) {
super(layout.myUi, true);
myLayout = layout;
myContent = content;
update();
myBehavior = new BaseButtonBehavior(this) {
protected void execute(final MouseEvent e) {
final ContentManager mgr = contentManager();
if (mgr.getIndexOfContent(myContent) >= 0) {
mgr.setSelectedContent(myContent, true);
}
}
};
myBehavior.setActionTrigger(MouseEvent.MOUSE_PRESSED);
myBehavior.setMouseDeadzone(TimedDeadzone.NULL);
}
示例4: selectContent
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
/**
* Searches through all {@link Content simple} and {@link TabbedContent tabbed} contents of the given ContentManager,
* and selects the one which holds the specified {@code contentComponent}.
*
* @return true if the necessary content was found (and thus selected) among content components of the given ContentManager.
*/
public static boolean selectContent(@NotNull ContentManager manager, @NotNull final JComponent contentComponent, boolean requestFocus) {
for (Content content : manager.getContents()) {
if (content instanceof TabbedContentImpl) {
boolean found = ((TabbedContentImpl)content).findAndSelectContent(contentComponent);
if (found) {
manager.setSelectedContent(content, requestFocus);
return true;
}
}
else if (Comparing.equal(content.getComponent(), contentComponent)) {
manager.setSelectedContent(content, requestFocus);
return true;
}
}
return false;
}
示例5: findContentComponent
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
/**
* Searches through all {@link Content simple} and {@link TabbedContent tabbed} contents of the given ContentManager,
* trying to find the first one which matches the given condition.
*/
@Nullable
public static JComponent findContentComponent(@NotNull ContentManager manager, @NotNull Condition<JComponent> condition) {
for (Content content : manager.getContents()) {
if (content instanceof TabbedContentImpl) {
List<Pair<String, JComponent>> tabs = ((TabbedContentImpl)content).getTabs();
for (Pair<String, JComponent> tab : tabs) {
if (condition.value(tab.second)) {
return tab.second;
}
}
}
else if (condition.value(content.getComponent())) {
return content.getComponent();
}
}
return null;
}
示例6: actionPerformed
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
if (windowManager.isEditorComponentActive()) {
doNavigate(dataContext, project);
return;
}
ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
if (contentManager == null) return;
doNavigate(contentManager);
}
示例7: update
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
DataContext dataContext = event.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
presentation.setEnabled(false);
if (project == null) {
return;
}
final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
if (windowManager.isEditorComponentActive()) {
final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
if (currentWindow == null){
editorManager.getCurrentWindow ();
}
if (currentWindow != null) {
final VirtualFile[] files = currentWindow.getFiles();
presentation.setEnabled(files.length > 1);
}
return;
}
ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
示例8: actionPerformed
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
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 = PlatformDataKeys.TOOL_WINDOW.getData(context);
if (tw != null) {
tw.hide(null);
}
}
}
示例9: ToggleToolbarAction
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
private ToggleToolbarAction(@NotNull ToolWindow toolWindow, @NotNull PropertiesComponent propertiesComponent) {
super("Show Toolbar");
myPropertiesComponent = propertiesComponent;
myToolWindow = toolWindow;
myToolWindow.getContentManager().addContentManagerListener(new ContentManagerAdapter() {
@Override
public void contentAdded(ContentManagerEvent event) {
JComponent component = event.getContent().getComponent();
setContentToolbarVisible(component, getVisibilityValue());
// support nested content managers, e.g. RunnerLayoutUi as content component
ContentManager contentManager =
component instanceof DataProvider ? PlatformDataKeys.CONTENT_MANAGER.getData((DataProvider)component) : null;
if (contentManager != null) contentManager.addContentManagerListener(this);
}
});
}
示例10: select
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
public void select() {
if (ApplicationManager.getApplication().isUnitTestMode()) return;
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (myRunContentDescriptor != null) {
ToolWindow toolWindow = ExecutionManager.getInstance(myProject).getContentManager()
.getToolWindowByDescriptor(myRunContentDescriptor);
Content content = myRunContentDescriptor.getAttachedContent();
if (toolWindow == null || content == null) return;
ContentManager manager = toolWindow.getContentManager();
if (ArrayUtil.contains(content, manager.getContents()) && !manager.isSelected(content)) {
manager.setSelectedContent(content);
}
}
}
});
}
示例11: addMessageToConsoleWindow
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
@Override
public void addMessageToConsoleWindow(final String message, final TextAttributes attributes) {
if (!Registry.is("vcs.showConsole")) {
return;
}
if (StringUtil.isEmptyOrSpaces(message)) {
return;
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
// for default and disposed projects the ContentManager is not available.
if (myProject.isDisposed() || myProject.isDefault()) return;
final ContentManager contentManager = getContentManager();
if (contentManager == null) {
myPendingOutput.add(Pair.create(message, attributes));
}
else {
getOrCreateConsoleContent(contentManager);
myEditorAdapter.appendString(message, attributes);
}
}
}, ModalityState.defaultModalityState());
}
示例12: getContentManager
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
private ContentManager getContentManager(boolean dataFlowToThis) {
if (dataFlowToThis) {
if (myBackContentManager == null) {
ToolWindow backToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(BACK_TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, myProject);
myBackContentManager = backToolWindow.getContentManager();
new ContentManagerWatcher(backToolWindow, myBackContentManager);
}
return myBackContentManager;
}
if (myForthContentManager == null) {
ToolWindow forthToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(FORTH_TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, myProject);
myForthContentManager = forthToolWindow.getContentManager();
new ContentManagerWatcher(forthToolWindow, myForthContentManager);
}
return myForthContentManager;
}
示例13: initSession
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
@Override
protected void initSession(XDebugSession session, RunProfileState state, Executor executor) {
XDebugSessionTab tab = ((XDebugSessionImpl)session).getSessionTab();
if (tab != null) {
RunnerLayoutUi ui = tab.getUi();
ContentManager contentManager = ui.getContentManager();
Content content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.watches.title"));
if (content != null) {
contentManager.removeContent(content, true);
}
content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.console.content.name"));
if (content != null) {
contentManager.removeContent(content, true);
}
initEduConsole(session, ui);
}
}
示例14: initToolWindow
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
@Override
protected void initToolWindow() {
myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(UIDesignerBundle.message("toolwindow.ui.designer.name"),
false, getAnchor(), myProject, true);
myToolWindow.setIcon(UIDesignerIcons.ToolWindowUIDesigner);
if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
myToolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
}
initGearActions();
ContentManager contentManager = myToolWindow.getContentManager();
Content content =
contentManager.getFactory()
.createContent(myToolWindowPanel.getToolWindowPanel(), UIDesignerBundle.message("toolwindow.ui.designer.title"), false);
content.setCloseable(false);
content.setPreferredFocusableComponent(myToolWindowPanel.getComponentTree());
contentManager.addContent(content);
contentManager.setSelectedContent(content, true);
myToolWindow.setAvailable(false, null);
}
示例15: showSkipped
import com.intellij.ui.content.ContentManager; //导入依赖的package包/类
/**
* Show skipped commits
*
* @param project the context project
* @param skippedCommits the skipped commits
*/
public static void showSkipped(final Project project, final SortedMap<VirtualFile, List<GitRebaseUtils.CommitInfo>> skippedCommits) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
ContentManager contentManager = ProjectLevelVcsManagerEx.getInstanceEx(project).getContentManager();
if (contentManager == null) {
return;
}
GitSkippedCommits skipped = new GitSkippedCommits(contentManager, project, skippedCommits);
Content content = ContentFactory.SERVICE.getInstance().createContent(skipped, "Skipped Commits", true);
ContentsUtil.addContent(contentManager, content, true);
ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS).activate(null);
}
});
}