Search in sources :

Example 6 with ProjectSystemId

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;
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Module(com.intellij.openapi.module.Module) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 7 with ProjectSystemId

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);
}
Also used : ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId)

Example 8 with ProjectSystemId

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));
}
Also used : ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 9 with ProjectSystemId

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);
}
Also used : ExternalSystemConfigurableAware(com.intellij.openapi.externalSystem.ExternalSystemConfigurableAware) LocationAwareExternalSystemException(com.intellij.openapi.externalSystem.model.LocationAwareExternalSystemException) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId)

Example 10 with ProjectSystemId

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);
    }
}
Also used : Output(com.esotericsoftware.kryo.io.Output) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) File(java.io.File)

Aggregations

ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)36 Project (com.intellij.openapi.project.Project)10 Map (java.util.Map)5 ExternalConfigPathAware (com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware)4 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)4 File (java.io.File)4 NotNull (org.jetbrains.annotations.NotNull)4 ExternalSystemManager (com.intellij.openapi.externalSystem.ExternalSystemManager)3 DataNode (com.intellij.openapi.externalSystem.model.DataNode)3 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)3 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)3 TaskData (com.intellij.openapi.externalSystem.model.task.TaskData)3 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)3 Collection (java.util.Collection)3 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Logger (com.intellij.openapi.diagnostic.Logger)2 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)2 ExternalSystemProcessingManager (com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager)2 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)2