use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalSystemApiUtil method isOneToOneMapping.
/**
* Allows to answer if given ide project has 1-1 mapping with the given external project, i.e. the ide project has been
* imported from external system and no other external projects have been added.
* <p/>
* This might be necessary in a situation when project-level setting is changed (e.g. project name). We don't want to rename
* ide project if it doesn't completely corresponds to the given ide project then.
*
* @param ideProject target ide project
* @param projectData target external project
* @return <code>true</code> if given ide project has 1-1 mapping to the given external project;
* <code>false</code> otherwise
*/
public static boolean isOneToOneMapping(@NotNull Project ideProject, @NotNull ProjectData projectData) {
String linkedExternalProjectPath = null;
for (ExternalSystemManager<?, ?, ?, ?, ?> manager : getAllManagers()) {
ProjectSystemId externalSystemId = manager.getSystemId();
AbstractExternalSystemSettings systemSettings = getSettings(ideProject, externalSystemId);
Collection projectsSettings = systemSettings.getLinkedProjectsSettings();
int linkedProjectsNumber = projectsSettings.size();
if (linkedProjectsNumber > 1) {
// More than one external project of the same external system type is linked to the given ide project.
return false;
} else if (linkedProjectsNumber == 1) {
if (linkedExternalProjectPath == null) {
// More than one external project of different external system types is linked to the current ide project.
linkedExternalProjectPath = ((ExternalProjectSettings) projectsSettings.iterator().next()).getExternalProjectPath();
} else {
return false;
}
}
}
if (linkedExternalProjectPath != null && !linkedExternalProjectPath.equals(projectData.getLinkedExternalProjectPath())) {
// New external project is being linked.
return false;
}
for (Module module : ModuleManager.getInstance(ideProject).getModules()) {
if (!isExternalSystemAwareModule(projectData.getOwner(), module)) {
return false;
}
}
return true;
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class AttachExternalProjectAction method update.
@Override
public void update(AnActionEvent e) {
ProjectSystemId externalSystemId = ExternalSystemDataKeys.EXTERNAL_SYSTEM_ID.getData(e.getDataContext());
if (externalSystemId != null) {
String name = externalSystemId.getReadableName();
e.getPresentation().setText(ExternalSystemBundle.message("action.attach.external.project.text", name));
e.getPresentation().setDescription(ExternalSystemBundle.message("action.attach.external.project.description", name));
}
e.getPresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add);
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class DetachExternalProjectAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
if (this.getClass() != DetachExternalProjectAction.class)
return;
ProjectSystemId systemId = getSystemId(e);
final String systemIdName = systemId != null ? systemId.getReadableName() : "external";
Presentation presentation = e.getPresentation();
presentation.setText(ExternalSystemBundle.message("action.detach.external.project.text", systemIdName));
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalSystemNotificationManager method processExternalProjectRefreshError.
public void processExternalProjectRefreshError(@NotNull Throwable error, @NotNull String externalProjectName, @NotNull ProjectSystemId externalSystemId) {
if (myProject.isDisposed() || !myProject.isOpen()) {
return;
}
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
if (!(manager instanceof ExternalSystemConfigurableAware)) {
return;
}
String title = ExternalSystemBundle.message("notification.project.refresh.fail.title", externalSystemId.getReadableName(), externalProjectName);
String message = ExternalSystemApiUtil.buildErrorMessage(error);
NotificationCategory notificationCategory = NotificationCategory.ERROR;
String filePath = null;
Integer line = null;
Integer column = null;
//noinspection ThrowableResultOfMethodCallIgnored
Throwable unwrapped = RemoteUtil.unwrap(error);
if (unwrapped instanceof LocationAwareExternalSystemException) {
LocationAwareExternalSystemException locationAwareExternalSystemException = (LocationAwareExternalSystemException) unwrapped;
filePath = locationAwareExternalSystemException.getFilePath();
line = locationAwareExternalSystemException.getLine();
column = locationAwareExternalSystemException.getColumn();
}
NotificationData notificationData = new NotificationData(title, message, notificationCategory, NotificationSource.PROJECT_SYNC, filePath, ObjectUtils.notNull(line, -1), ObjectUtils.notNull(column, -1), false);
for (ExternalSystemNotificationExtension extension : ExternalSystemNotificationExtension.EP_NAME.getExtensions()) {
final ProjectSystemId targetExternalSystemId = extension.getTargetExternalSystemId();
if (!externalSystemId.equals(targetExternalSystemId) && !targetExternalSystemId.equals(ProjectSystemId.IDE)) {
continue;
}
extension.customize(notificationData, myProject, error);
}
EditorNotifications.getInstance(myProject).updateAllNotifications();
showNotification(externalSystemId, notificationData);
}
use of com.intellij.openapi.externalSystem.model.ProjectSystemId in project intellij-community by JetBrains.
the class ExternalProjectSerializer method save.
public void save(@NotNull ExternalProject externalProject) {
Output output = null;
try {
final File externalProjectDir = externalProject.getProjectDir();
final File configurationFile = getProjectConfigurationFile(new ProjectSystemId(externalProject.getExternalSystemId()), externalProjectDir);
if (!FileUtil.createParentDirs(configurationFile))
return;
output = new Output(new FileOutputStream(configurationFile));
myKryo.writeObject(output, externalProject);
LOG.debug("Data saved for imported project from: " + externalProjectDir.getPath());
} catch (FileNotFoundException e) {
LOG.error(e);
} finally {
StreamUtil.closeStream(output);
}
}
Aggregations