use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class RunDashboardManagerImpl method getRunConfigurations.
@Override
public List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> getRunConfigurations() {
List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> result = new ArrayList<>();
List<RunnerAndConfigurationSettings> configurations = RunManager.getInstance(myProject).getAllSettings().stream().filter(runConfiguration -> RunDashboardContributor.isShowInDashboard(runConfiguration.getType())).collect(Collectors.toList());
//noinspection ConstantConditions ???
ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(myProject);
configurations.forEach(configurationSettings -> {
List<RunContentDescriptor> descriptors = executionManager.getDescriptors(settings -> Comparing.equal(settings.getConfiguration(), configurationSettings.getConfiguration()));
if (descriptors.isEmpty()) {
result.add(Pair.create(configurationSettings, null));
} else {
descriptors.forEach(descriptor -> result.add(Pair.create(configurationSettings, descriptor)));
}
});
// It is possible that run configuration was deleted, but there is running content descriptor for such run configuration.
// It should be shown in he dashboard tree.
List<RunConfiguration> storedConfigurations = configurations.stream().map(RunnerAndConfigurationSettings::getConfiguration).collect(Collectors.toList());
List<RunContentDescriptor> notStoredDescriptors = executionManager.getRunningDescriptors(settings -> {
RunConfiguration configuration = settings.getConfiguration();
return RunDashboardContributor.isShowInDashboard(settings.getType()) && !storedConfigurations.contains(configuration);
});
notStoredDescriptors.forEach(descriptor -> {
Set<RunnerAndConfigurationSettings> settings = executionManager.getConfigurations(descriptor);
settings.forEach(setting -> result.add(Pair.create(setting, descriptor)));
});
return result;
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class RunDashboardManagerImpl method createToolWindowContent.
@Override
public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
myDashboardContent = new RunDashboardContent(myProject, myContentManager, myGroupers);
ContentManager contentManager = toolWindow.getContentManager();
Content content = contentManager.getFactory().createContent(myDashboardContent, null, false);
Disposer.register(content, myDashboardContent);
Disposer.register(content, () -> myDashboardContent = null);
toolWindow.getContentManager().addContent(content);
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class ReplaceInProjectManager method replaceInProject.
public void replaceInProject(@NotNull DataContext dataContext) {
final boolean isOpenInNewTabEnabled;
final boolean toOpenInNewTab;
final Content selectedContent = com.intellij.usageView.UsageViewManager.getInstance(myProject).getSelectedContent(true);
if (selectedContent != null && selectedContent.isPinned()) {
toOpenInNewTab = true;
isOpenInNewTabEnabled = false;
} else {
toOpenInNewTab = FindSettings.getInstance().isShowResultsInSeparateView();
isOpenInNewTabEnabled = com.intellij.usageView.UsageViewManager.getInstance(myProject).getReusableContentsCount() > 0;
}
final FindManager findManager = FindManager.getInstance(myProject);
final FindModel findModel = findManager.getFindInProjectModel().clone();
findModel.setReplaceState(true);
findModel.setOpenInNewTabVisible(true);
findModel.setOpenInNewTabEnabled(isOpenInNewTabEnabled);
findModel.setOpenInNewTab(toOpenInNewTab);
FindInProjectUtil.setDirectoryName(findModel, dataContext);
FindInProjectUtil.initStringToFindFromDataContext(findModel, dataContext);
findManager.showFindDialog(findModel, () -> {
if (!findModel.isProjectScope() && FindInProjectUtil.getDirectory(findModel) == null && findModel.getModuleName() == null && findModel.getCustomScope() == null) {
return;
}
UsageViewManager manager = UsageViewManager.getInstance(myProject);
if (manager == null)
return;
findManager.getFindInProjectModel().copyFrom(findModel);
final FindModel findModelCopy = findModel.clone();
final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(findModel.isOpenInNewTab(), findModelCopy);
final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, true, presentation);
UsageSearcherFactory factory = new UsageSearcherFactory(findModelCopy, processPresentation);
searchAndShowUsages(manager, factory, findModelCopy, presentation, processPresentation, findManager);
});
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class BrowseHierarchyActionBase method createAndAddToPanel.
@NotNull
public static HierarchyBrowser createAndAddToPanel(@NotNull Project project, @NotNull final HierarchyProvider provider, @NotNull PsiElement target) {
HierarchyBrowser hierarchyBrowser = provider.createHierarchyBrowser(target);
final Content content;
HierarchyBrowserManager hierarchyBrowserManager = HierarchyBrowserManager.getInstance(project);
final ContentManager contentManager = hierarchyBrowserManager.getContentManager();
final Content selectedContent = contentManager.getSelectedContent();
if (selectedContent != null && !selectedContent.isPinned()) {
content = selectedContent;
final Component component = content.getComponent();
if (component instanceof Disposable) {
Disposer.dispose((Disposable) component);
}
content.setComponent(hierarchyBrowser.getComponent());
} else {
content = ContentFactory.SERVICE.getInstance().createContent(hierarchyBrowser.getComponent(), null, true);
contentManager.addContent(content);
}
contentManager.setSelectedContent(content);
hierarchyBrowser.setContent(content);
final Runnable runnable = () -> {
if (hierarchyBrowser instanceof HierarchyBrowserBase && ((HierarchyBrowserBase) hierarchyBrowser).isDisposed()) {
return;
}
provider.browserActivated(hierarchyBrowser);
};
ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY).activate(runnable);
return hierarchyBrowser;
}
use of com.intellij.ui.content.Content in project intellij-community by JetBrains.
the class DependenciesHandlerBase method onSuccess.
private void onSuccess(final List<DependenciesBuilder> builders) {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> {
if (shouldShowDependenciesPanel(builders)) {
final String displayName = getPanelDisplayName(builders);
DependenciesPanel panel = new DependenciesPanel(myProject, builders, myExcluded);
Content content = ContentFactory.SERVICE.getInstance().createContent(panel, displayName, false);
content.setDisposer(panel);
panel.setContent(content);
DependenciesToolWindow.getInstance(myProject).addContent(content);
}
});
}
Aggregations