Search in sources :

Example 6 with InternalExternalProjectInfo

use of com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo in project intellij-community by JetBrains.

the class ExternalProjectsDataStorage method load.

public synchronized void load() {
    myExternalRootProjects.clear();
    try {
        final Collection<InternalExternalProjectInfo> projectInfos = load(myProject);
        for (InternalExternalProjectInfo projectInfo : projectInfos) {
            if (validate(projectInfo)) {
                myExternalRootProjects.put(Pair.create(projectInfo.getProjectSystemId(), new File(projectInfo.getExternalProjectPath())), projectInfo);
            }
        }
    } catch (IOException e) {
        LOG.debug(e);
    }
    mergeLocalSettings();
}
Also used : InternalExternalProjectInfo(com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo)

Example 7 with InternalExternalProjectInfo

use of com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo in project intellij-community by JetBrains.

the class ExternalProjectsDataStorage method load.

@NotNull
private static Collection<InternalExternalProjectInfo> load(@NotNull Project project) throws IOException {
    SmartList<InternalExternalProjectInfo> projects = new SmartList<>();
    @SuppressWarnings("unchecked") final File configurationFile = getProjectConfigurationFile(project);
    if (!configurationFile.isFile())
        return projects;
    DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(configurationFile)));
    try {
        final String storage_version = in.readUTF();
        if (!STORAGE_VERSION.equals(storage_version))
            return projects;
        final int size = in.readInt();
        ObjectInputStream os = new ObjectInputStream(in);
        try {
            for (int i = 0; i < size; i++) {
                //noinspection unchecked
                InternalExternalProjectInfo projectDataDataNode = (InternalExternalProjectInfo) os.readObject();
                projects.add(projectDataDataNode);
            }
        } catch (Exception e) {
            throw new IOException(e);
        } finally {
            os.close();
        }
    } finally {
        in.close();
    }
    return projects;
}
Also used : InternalExternalProjectInfo(com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with InternalExternalProjectInfo

use of com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo in project intellij-community by JetBrains.

the class GradleProjectImportBuilder method createFinalImportCallback.

@Override
protected ExternalProjectRefreshCallback createFinalImportCallback(@NotNull final Project project, @NotNull ExternalProjectSettings projectSettings) {
    return new ExternalProjectRefreshCallback() {

        @Override
        public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
            if (externalProject == null)
                return;
            Runnable selectDataTask = () -> {
                ExternalProjectDataSelectorDialog dialog = new ExternalProjectDataSelectorDialog(project, new InternalExternalProjectInfo(GradleConstants.SYSTEM_ID, projectSettings.getExternalProjectPath(), externalProject));
                if (dialog.hasMultipleDataToSelect()) {
                    dialog.showAndGet();
                } else {
                    Disposer.dispose(dialog.getDisposable());
                }
            };
            Runnable importTask = () -> ServiceManager.getService(ProjectDataManager.class).importData(externalProject, project, false);
            if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
                ApplicationManager.getApplication().invokeLater(() -> {
                    selectDataTask.run();
                    ApplicationManager.getApplication().executeOnPooledThread(importTask);
                });
            } else {
                importTask.run();
            }
        }

        @Override
        public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
        }
    };
}
Also used : ProjectDataManager(com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ExternalProjectDataSelectorDialog(com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog) ExternalProjectRefreshCallback(com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback) InternalExternalProjectInfo(com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

InternalExternalProjectInfo (com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo)8 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)3 NotNull (org.jetbrains.annotations.NotNull)3 ExternalProjectDataSelectorDialog (com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog)2 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)2 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 ExternalProjectPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)1 ExternalProjectRefreshCallback (com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback)1 IdeModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)1 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)1 IdeUIModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeUIModifiableModelsProvider)1 ProjectDataManager (com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager)1 AbstractExternalSystemLocalSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings)1 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)1 Module (com.intellij.openapi.module.Module)1 ModulesConfigurator (com.intellij.openapi.roots.ui.configuration.ModulesConfigurator)1 MultiMap (com.intellij.util.containers.MultiMap)1 AbstractCollection (com.intellij.util.xmlb.annotations.AbstractCollection)1 Collection (java.util.Collection)1 Map (java.util.Map)1