use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project intellij-leiningen-plugin by derkork.
the class LeiningenProjectNavigator method addPanel.
private void addPanel() {
initTree();
myStructure = new LeiningenProjectStructure(myProject, myProjectsManager, myTree);
JPanel panel = new LeiningenProjectNavigatorPanel(myProject, myTree);
final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
myToolWindow = manager.registerToolWindow(TOOL_WINDOW_ID, panel, ToolWindowAnchor.RIGHT, myProject, true);
myToolWindow.setIcon(LeiningenIcons.PROJECT_ICON);
final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {
boolean wasVisible = false;
@Override
public void stateChanged() {
if (myToolWindow.isDisposed())
return;
boolean visible = myToolWindow.isVisible();
if (!visible || visible == wasVisible)
return;
scheduleStructureUpdate();
wasVisible = visible;
}
};
manager.addToolWindowManagerListener(listener);
Disposer.register(myProject, new Disposable() {
public void dispose() {
manager.removeToolWindowManagerListener(listener);
}
});
scheduleStructureUpdate();
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project intellij-community by JetBrains.
the class ExternalProjectsViewImpl method init.
public void init() {
Disposer.register(myProject, this);
initTree();
final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {
boolean wasVisible = false;
@Override
public void stateChanged() {
if (myToolWindow.isDisposed())
return;
boolean visible = myToolWindow.isVisible();
if (!visible || wasVisible) {
wasVisible = visible;
return;
}
scheduleStructureUpdate();
wasVisible = true;
}
};
manager.addToolWindowManagerListener(listener, myProject);
getShortcutsManager().addListener(new ExternalSystemShortcutsManager.Listener() {
@Override
public void shortcutsUpdated() {
scheduleTasksUpdate();
scheduleStructureRequest(() -> {
assert myStructure != null;
myStructure.updateNodes(RunConfigurationNode.class);
});
}
});
getTaskActivator().addListener(new ExternalSystemTaskActivator.Listener() {
@Override
public void tasksActivationChanged() {
scheduleTasksUpdate();
scheduleStructureRequest(() -> {
assert myStructure != null;
myStructure.updateNodes(RunConfigurationNode.class);
});
}
});
((RunManagerEx) RunManager.getInstance(myProject)).addRunManagerListener(new RunManagerListener() {
private void changed() {
scheduleStructureRequest(() -> {
assert myStructure != null;
myStructure.visitNodes(ModuleNode.class, node -> node.updateRunConfigurations());
});
}
@Override
public void runConfigurationAdded(@NotNull RunnerAndConfigurationSettings settings) {
changed();
}
@Override
public void runConfigurationRemoved(@NotNull RunnerAndConfigurationSettings settings) {
changed();
}
@Override
public void runConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
changed();
}
});
ExternalSystemApiUtil.subscribe(myProject, myExternalSystemId, new ExternalSystemSettingsListenerAdapter() {
@Override
public void onUseAutoImportChange(boolean currentValue, @NotNull final String linkedProjectPath) {
scheduleStructureRequest(() -> {
assert myStructure != null;
final List<ProjectNode> projectNodes = myStructure.getNodes(ProjectNode.class);
for (ProjectNode projectNode : projectNodes) {
final ProjectData projectData = projectNode.getData();
if (projectData != null && projectData.getLinkedExternalProjectPath().equals(linkedProjectPath)) {
projectNode.updateProject();
break;
}
}
});
}
});
myToolWindow.setAdditionalGearActions(createAdditionalGearActionsGroup());
scheduleStructureUpdate();
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project android by JetBrains.
the class AndroidThemePreviewToolWindowManager method initToolWindow.
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);
// 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;
}
}
});
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project android by JetBrains.
the class NlPreviewManager method initToolWindow.
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
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());
}
use of com.intellij.openapi.wm.ex.ToolWindowManagerAdapter in project intellij-community by JetBrains.
the class RunContentManagerImpl method init.
// must be called on EDT
private void init() {
ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(myProject);
if (toolWindowManager == null) {
return;
}
for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
registerToolWindow(executor, toolWindowManager);
}
RunDashboardManager dashboardManager = RunDashboardManager.getInstance(myProject);
initToolWindow(null, dashboardManager.getToolWindowId(), dashboardManager.getToolWindowIcon(), dashboardManager.getDashboardContentManager());
toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter() {
@Override
public void stateChanged() {
if (myProject.isDisposed()) {
return;
}
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
Set<String> currentWindows = new THashSet<>();
ContainerUtil.addAll(currentWindows, toolWindowManager.getToolWindowIds());
myToolwindowIdZBuffer.retainAll(currentWindows);
final String activeToolWindowId = toolWindowManager.getActiveToolWindowId();
if (activeToolWindowId != null) {
if (myToolwindowIdZBuffer.remove(activeToolWindowId)) {
myToolwindowIdZBuffer.addFirst(activeToolWindowId);
}
}
}
});
}
Aggregations