use of com.intellij.ui.content.ContentManager in project android by JetBrains.
the class FloatingToolWindow method setToolWindowContent.
private void setToolWindowContent(@NotNull ToolWindowEx toolWindow) {
ContentManager contentManager = toolWindow.getContentManager();
Content content = contentManager.getSelectedContent();
if (content == null) {
content = contentManager.getFactory().createContent(myContent.getComponent(), null, false);
content.setCloseable(false);
content.setComponent(myContent.getComponent());
content.setPreferredFocusableComponent(myContent.getFocusedComponent());
content.setShouldDisposeContent(true);
contentManager.addContent(content);
contentManager.setSelectedContent(content, true);
}
}
use of com.intellij.ui.content.ContentManager in project android by JetBrains.
the class NlAbstractWindowManager method createWindowContent.
protected void createWindowContent(@NotNull JComponent contentPane, @NotNull JComponent focusedComponent, @Nullable AnAction[] actions) {
ContentManager contentManager = myToolWindow.getContentManager();
Content content = contentManager.getFactory().createContent(contentPane, null, false);
content.setCloseable(false);
content.setPreferredFocusableComponent(focusedComponent);
if (actions != null) {
ToolWindowEx toolWindow = (ToolWindowEx) myToolWindow;
toolWindow.setTitleActions(actions);
}
contentManager.addContent(content);
contentManager.setSelectedContent(content, true);
}
use of com.intellij.ui.content.ContentManager in project intellij-plugins by JetBrains.
the class MxmlPreviewToolWindowManager method initToolWindow.
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(() -> render(false, false));
}
}
@Override
public void errorOccurred() {
}
});
}
use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class CvsTabbedWindow method addTab.
public void addTab(String title, JComponent component, boolean selectTab, boolean replaceContent, boolean lockable, boolean addDefaultToolbar, @Nullable final ActionGroup toolbarActions, @NonNls String helpId) {
final ContentManager contentManager = getToolWindow().getContentManager();
final Content existingContent = contentManager.findContent(title);
if (existingContent != null) {
final JComponent existingComponent = existingContent.getComponent();
if (existingComponent instanceof DeactivateListener) {
((DeactivateListener) existingComponent).deactivated();
}
if (!replaceContent) {
contentManager.setSelectedContent(existingContent);
return;
} else if (!existingContent.isPinned()) {
contentManager.removeContent(existingContent, true);
existingContent.release();
}
}
final CvsTabbedWindowComponent newComponent = new CvsTabbedWindowComponent(component, addDefaultToolbar, toolbarActions, contentManager, helpId);
final Content content = contentManager.getFactory().createContent(newComponent.getShownComponent(), title, lockable);
newComponent.setContent(content);
contentManager.addContent(content);
if (selectTab) {
getToolWindow().activate(null, false);
}
}
use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.
the class CloseActiveTabAction method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(event.getDataContext(), true);
presentation.setEnabled(contentManager != null && contentManager.canCloseContents());
if (!presentation.isEnabled() && contentManager != null) {
final DataContext context = DataManager.getInstance().getDataContext(contentManager.getComponent());
presentation.setEnabled(PlatformDataKeys.TOOL_WINDOW.getData(context) != null);
}
}
Aggregations