List of usage examples for com.intellij.openapi.wm ToolWindow isAvailable
boolean isAvailable();
From source file:com.android.tools.idea.editors.theme.AndroidThemePreviewToolWindowManager.java
License:Apache License
private void initToolWindow() { myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(TOOL_WINDOW_ID, false, ToolWindowAnchor.RIGHT, myProject, false); myToolWindow.setIcon(AndroidIcons.ThemesPreview); myToolWindow.setAvailable(false, null); myToolWindow.setAutoHide(false);/* www. j a va2s. co m*/ // Add a listener so we only update the preview when it's visible ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)) .addToolWindowManagerListener(new ToolWindowManagerAdapter() { @Override public void stateChanged() { if (myProject.isDisposed()) { return; } final ToolWindow window = ToolWindowManager.getInstance(myProject) .getToolWindow(TOOL_WINDOW_ID); if (window != null && window.isAvailable()) { final boolean visible = window.isVisible(); AndroidEditorSettings.getInstance().getGlobalState().setVisible(visible); if (visible && !myIsToolWindowVisible) { updatePreview(); } myIsToolWindowVisible = visible; } } }); }
From source file:com.android.tools.idea.uibuilder.editor.NlPreviewManager.java
License:Apache License
protected void initToolWindow() { myToolWindowForm = new NlPreviewForm(this); final String toolWindowId = getToolWindowId(); myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, myProject, true); myToolWindow.setIcon(AndroidIcons.AndroidPreview); ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)) .addToolWindowManagerListener(new ToolWindowManagerAdapter() { @Override/*from w ww . j a va2s . c o m*/ public void stateChanged() { if (myProject.isDisposed()) { return; } final ToolWindow window = ToolWindowManager.getInstance(myProject) .getToolWindow(toolWindowId); if (window != null && window.isAvailable()) { final boolean visible = window.isVisible(); AndroidEditorSettings.getInstance().getGlobalState().setVisible(visible); if (myToolWindowForm != null) { if (visible) { myToolWindowForm.activate(); } else { myToolWindowForm.deactivate(); } } } } }); final JComponent contentPanel = myToolWindowForm.getComponent(); final ContentManager contentManager = myToolWindow.getContentManager(); @SuppressWarnings("ConstantConditions") final Content content = contentManager.getFactory().createContent(contentPanel, null, false); content.setDisposer(myToolWindowForm); content.setCloseable(false); content.setPreferredFocusableComponent(contentPanel); contentManager.addContent(content); contentManager.setSelectedContent(content, true); myToolWindow.setAvailable(false, null); myToolWindowForm.setUseInteractiveSelector(isUseInteractiveSelector()); }
From source file:com.intellij.ide.actions.ActivateToolWindowAction.java
License:Apache License
public void update(AnActionEvent e) { Project project = getEventProject(e); Presentation presentation = e.getPresentation(); if (project == null || project.isDisposed()) { presentation.setEnabledAndVisible(false); return;//ww w . ja v a 2 s .c o m } ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(myToolWindowId); if (toolWindow == null) { presentation.setEnabledAndVisible(false); } else { presentation.setVisible(true); presentation.setEnabled(toolWindow.isAvailable()); updatePresentation(presentation, toolWindow); } }
From source file:com.intellij.ide.actions.ResizeToolWindowAction.java
License:Apache License
@Override public final void update(AnActionEvent e) { Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); if (project == null) { setDisabled(e);//from w w w.j av a2 s . c o m return; } if (!myListenerInstalled) { myListenerInstalled = true; ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() { @Override public void projectClosed(Project project) { setDisabled(null); } }); } Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (owner == null) { setDisabled(e); return; } final Window windowAncestor = SwingUtilities.getWindowAncestor(owner); if (!(windowAncestor instanceof IdeFrame) || windowAncestor instanceof IdeFrame.Child) { setDisabled(e); return; } ToolWindowManager mgr = ToolWindowManager.getInstance(project); ToolWindow window = myToolWindow; if (window != null || mgr.getActiveToolWindowId() != null) { if (window == null) { window = mgr.getToolWindow(mgr.getActiveToolWindowId()); } if (window == null || !window.isAvailable() || !window.isVisible() || window.getType() == ToolWindowType.FLOATING || !window.isActive()) { setDisabled(e); return; } update(e, window, mgr); if (e.getPresentation().isEnabled()) { myLastWindow = window; myLastManager = mgr; } else { setDisabled(e); } } else { setDisabled(e); } }
From source file:com.intellij.ide.actions.ToggleDockModeAction.java
License:Apache License
public void update(AnActionEvent event) { super.update(event); Presentation presentation = event.getPresentation(); Project project = CommonDataKeys.PROJECT.getData(event.getDataContext()); if (project == null) { presentation.setEnabled(false);/* www .ja va 2 s . co m*/ return; } ToolWindowManager mgr = ToolWindowManager.getInstance(project); String id = mgr.getActiveToolWindowId(); if (id == null) { presentation.setEnabled(false); return; } ToolWindow toolWindow = mgr.getToolWindow(id); presentation.setEnabled(toolWindow.isAvailable() && ToolWindowType.FLOATING != toolWindow.getType()); }
From source file:com.intellij.ide.actions.TogglePinnedModeAction.java
License:Apache License
@Override protected void update(ToolWindow window, Presentation presentation) { presentation.setEnabled(window.isAvailable() && ToolWindowType.SLIDING != window.getType()); }
From source file:com.intellij.ide.actions.ToggleSideModeAction.java
License:Apache License
@Override protected void update(ToolWindow window, Presentation presentation) { presentation.setEnabled(window.isAvailable()); }
From source file:org.cdv.intellij.ui.CDVToolWindowFactory.java
License:Open Source License
private boolean isVisible(@NotNull final Project project, @NotNull final ToolWindow toolWindow) { // We have to check if our tool window is still registered, as // otherwise it will raise an exception when project is closed. if (project.isDisposed() || ToolWindowManagerEx.getInstanceEx(project).getToolWindow("CDV") == null) { return false; }//from w ww . ja v a2 s.c o m return toolWindow.isAvailable() && toolWindow.isVisible(); }
From source file:org.cordovastudio.editors.designer.designSurface.preview.PreviewToolWindowManager.java
License:Apache License
private void initToolWindow() { myToolWindowForm = new PreviewToolWindowForm(myProject, this); final String toolWindowId = "cordovastudio.layout.preview.tool.window"; myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, myProject, true); myToolWindow.setIcon(CordovaIcons.Windows.Preview); ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)) .addToolWindowManagerListener(new ToolWindowManagerAdapter() { private boolean myVisible = false; @Override//from w w w. j a va 2 s. c o m public void stateChanged() { if (myProject.isDisposed()) { return; } final ToolWindow window = ToolWindowManager.getInstance(myProject) .getToolWindow(toolWindowId); if (window != null && window.isAvailable()) { final boolean visible = window.isVisible(); PreviewToolWindowSettings.getInstance(myProject).getGlobalState().setVisible(visible); if (visible && !myVisible) { render(); } myVisible = visible; } } }); final JPanel contentPanel = myToolWindowForm.getContentPanel(); final ContentManager contentManager = myToolWindow.getContentManager(); @SuppressWarnings("ConstantConditions") final Content content = contentManager.getFactory().createContent(contentPanel, null, false); content.setDisposer(myToolWindowForm); content.setCloseable(false); content.setPreferredFocusableComponent(contentPanel); contentManager.addContent(content); contentManager.setSelectedContent(content, true); myToolWindow.setAvailable(false, null); }
From source file:org.intellij.plugins.xpathView.eval.EvalExpressionDialog.java
License:Apache License
protected void init() { final ToolWindow findWindow = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND); final boolean available = findWindow != null && findWindow.isAvailable(); final boolean enabled = mySettings.OPEN_NEW_TAB && available; myForm.getNewTabCheckbox().setEnabled(available); myForm.getNewTabCheckbox().setSelected(enabled); myForm.getHighlightCheckbox().setSelected(mySettings.HIGHLIGHT_RESULTS); myForm.getHighlightCheckbox().addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { updateOkAction();/*from w w w. j av a2 s .com*/ } }); myForm.getUsageViewCheckbox().setSelected(mySettings.SHOW_USAGE_VIEW); myForm.getUsageViewCheckbox().addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { myForm.getNewTabCheckbox().setEnabled(available && myForm.getUsageViewCheckbox().isSelected()); updateOkAction(); } }); super.init(); }