use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalSystemNotificationManager method prepareMessagesView.
@NotNull
public NewErrorTreeViewPanel prepareMessagesView(@NotNull final ProjectSystemId externalSystemId, @NotNull final NotificationSource notificationSource, boolean activateView) {
ApplicationManager.getApplication().assertIsDispatchThread();
final NewErrorTreeViewPanel errorTreeView;
final String contentDisplayName = getContentDisplayName(notificationSource, externalSystemId);
final Pair<NotificationSource, ProjectSystemId> contentIdPair = Pair.create(notificationSource, externalSystemId);
Content targetContent = findContent(contentIdPair, contentDisplayName);
final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
if (targetContent == null || !contentIdPair.equals(targetContent.getUserData(CONTENT_ID_KEY))) {
errorTreeView = new NewEditableErrorTreeViewPanel(myProject, null, true, true, null);
targetContent = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, contentDisplayName, true);
targetContent.putUserData(CONTENT_ID_KEY, contentIdPair);
messageView.getContentManager().addContent(targetContent);
Disposer.register(targetContent, errorTreeView);
} else {
assert targetContent.getComponent() instanceof NewEditableErrorTreeViewPanel;
errorTreeView = (NewEditableErrorTreeViewPanel) targetContent.getComponent();
}
messageView.getContentManager().setSelectedContent(targetContent);
final ToolWindow tw = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
if (activateView && tw != null && !tw.isActive()) {
tw.activate(null, false);
}
return errorTreeView;
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalModuleStructureExtension method moduleRemoved.
@Override
public void moduleRemoved(Module module) {
String systemIdString = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
if (StringUtil.isEmpty(systemIdString))
return;
String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
if (StringUtil.isEmpty(rootProjectPath))
return;
Project project = module.getProject();
ModulesConfigurator modulesConfigurator = getModulesConfigurator(project);
if (modulesConfigurator == null)
return;
for (Module m : modulesConfigurator.getModules()) {
if (m != module && rootProjectPath.equals(ExternalSystemApiUtil.getExternalRootProjectPath(m))) {
return;
}
}
ProjectSystemId systemId = new ProjectSystemId(systemIdString);
ExternalSystemApiUtil.getSettings(project, systemId).unlinkExternalProject(rootProjectPath);
assert myOrphanProjectsCandidates != null;
myOrphanProjectsCandidates.put(rootProjectPath, systemId);
isExternalSystemsInvolved = true;
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalModuleStructureExtension method disposeUIResources.
@Override
public void disposeUIResources() {
try {
if (isExternalSystemsInvolved) {
assert myOrphanProjectsCandidates != null;
assert myProject != null;
if (myExternalProjectsToRestore != null) {
for (Pair<ProjectSystemId, ExternalProjectSettings> settingsPair : myExternalProjectsToRestore.values()) {
AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(myProject, settingsPair.first);
String rootProjectPath = settingsPair.second.getExternalProjectPath();
if (settings.getLinkedProjectSettings(rootProjectPath) == null) {
//noinspection unchecked
settings.linkProject(settingsPair.second);
}
myOrphanProjectsCandidates.remove(rootProjectPath);
}
}
ModulesConfigurator modulesConfigurator = getModulesConfigurator(myProject);
if (modulesConfigurator != null) {
for (Map.Entry<String, ProjectSystemId> entry : myOrphanProjectsCandidates.entrySet()) {
String rootProjectPath = entry.getKey();
if (StringUtil.isNotEmpty(rootProjectPath)) {
unlinkProject(myProject, entry.getValue(), rootProjectPath);
}
}
}
}
} catch (Throwable e) {
LOG.warn(e);
} finally {
myProject = null;
myExternalProjectsToRestore = null;
myOrphanProjectsCandidates = null;
}
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalModuleStructureExtension method addModuleNodeChildren.
@Override
public boolean addModuleNodeChildren(Module module, MasterDetailsComponent.MyNode moduleNode, Runnable treeNodeNameUpdater) {
String systemIdString = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
if (StringUtil.isNotEmpty(systemIdString)) {
isExternalSystemsInvolved = true;
String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
if (myOrphanProjectsCandidates != null && StringUtil.isNotEmpty(rootProjectPath)) {
myOrphanProjectsCandidates.put(rootProjectPath, new ProjectSystemId(systemIdString));
}
}
return false;
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalProjectsManager method getStateProvider.
@NotNull
public ExternalProjectsStateProvider getStateProvider() {
return new ExternalProjectsStateProvider() {
@Override
public List<TasksActivation> getAllTasksActivation() {
List<TasksActivation> result = new SmartList<>();
Map<String, ProjectSystemId> systemIds = ExternalSystemApiUtil.getAllManagers().stream().collect(Collectors.toMap(o -> o.getSystemId().getId(), o -> o.getSystemId()));
for (Map.Entry<String, ExternalProjectsState.State> systemState : myState.getExternalSystemsState().entrySet()) {
ProjectSystemId systemId = systemIds.get(systemState.getKey());
if (systemId == null)
continue;
for (Map.Entry<String, TaskActivationState> activationStateEntry : systemState.getValue().getExternalSystemsTaskActivation().entrySet()) {
result.add(new TasksActivation(systemId, activationStateEntry.getKey(), activationStateEntry.getValue()));
}
}
return result;
}
@Override
public List<TasksActivation> getTasksActivation(@NotNull final ProjectSystemId systemId) {
final Set<Map.Entry<String, TaskActivationState>> entries = myState.getExternalSystemsState().get(systemId.getId()).getExternalSystemsTaskActivation().entrySet();
return ContainerUtil.map(entries, entry -> new TasksActivation(systemId, entry.getKey(), entry.getValue()));
}
@Override
public TaskActivationState getTasksActivation(@NotNull ProjectSystemId systemId, @NotNull String projectPath) {
return myState.getExternalSystemsState().get(systemId.getId()).getExternalSystemsTaskActivation().get(projectPath);
}
@Override
public Map<String, TaskActivationState> getProjectsTasksActivationMap(@NotNull final ProjectSystemId systemId) {
return myState.getExternalSystemsState().get(systemId.getId()).getExternalSystemsTaskActivation();
}
};
}
Aggregations