mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-109519 Gradle: Don't ignore user-defined settings on initial project import
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface ExternalSystemManager<
|
||||
ProjectSettings extends ExternalProjectSettings,
|
||||
SettingsListener extends ExternalSystemSettingsListener<ProjectSettings>,
|
||||
Settings extends AbstractExternalSystemSettings<ProjectSettings, SettingsListener>,
|
||||
Settings extends AbstractExternalSystemSettings<Settings, ProjectSettings, SettingsListener>,
|
||||
LocalSettings extends AbstractExternalSystemLocalSettings,
|
||||
ExecutionSettings extends ExternalSystemExecutionSettings>
|
||||
extends ParametersEnhancer
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ public abstract class AbstractExternalSystemLocalSettings {
|
||||
toForget.add(taskInfo.getSettings().getExternalProjectPath());
|
||||
}
|
||||
|
||||
AbstractExternalSystemSettings<?, ?> settings = manager.getSettingsProvider().fun(myProject);
|
||||
AbstractExternalSystemSettings<?, ?, ?> settings = manager.getSettingsProvider().fun(myProject);
|
||||
for (ExternalProjectSettings projectSettings : settings.getLinkedProjectsSettings()) {
|
||||
toForget.remove(projectSettings.getExternalProjectPath());
|
||||
}
|
||||
|
||||
+36
-22
@@ -32,12 +32,16 @@ import java.util.*;
|
||||
* @author Denis Zhdanov
|
||||
* @since 4/3/13 4:04 PM
|
||||
*/
|
||||
public abstract class AbstractExternalSystemSettings<S extends ExternalProjectSettings, L extends ExternalSystemSettingsListener<S>> {
|
||||
|
||||
public abstract class AbstractExternalSystemSettings<
|
||||
SS extends AbstractExternalSystemSettings<SS, PS, L>,
|
||||
PS extends ExternalProjectSettings,
|
||||
L extends ExternalSystemSettingsListener<PS>>
|
||||
{
|
||||
|
||||
@NotNull private final Topic<L> myChangesTopic;
|
||||
@NotNull private final Project myProject;
|
||||
|
||||
@NotNull private final Map<String/* project path */, S> myLinkedProjectsSettings = ContainerUtilRt.newHashMap();
|
||||
@NotNull private final Map<String/* project path */, PS> myLinkedProjectsSettings = ContainerUtilRt.newHashMap();
|
||||
|
||||
protected AbstractExternalSystemSettings(@NotNull Topic<L> topic, @NotNull Project project) {
|
||||
myChangesTopic = topic;
|
||||
@@ -59,24 +63,34 @@ public abstract class AbstractExternalSystemSettings<S extends ExternalProjectSe
|
||||
* implementation then.
|
||||
* <p/>
|
||||
* That's why this method allows to wrap given 'generic listener' into external system-specific one.
|
||||
*
|
||||
*
|
||||
* @param listener target generic listener to wrap to external system-specific implementation
|
||||
*/
|
||||
public abstract void subscribe(@NotNull ExternalSystemSettingsListener<S> listener);
|
||||
public abstract void subscribe(@NotNull ExternalSystemSettingsListener<PS> listener);
|
||||
|
||||
public void copyFrom(@NotNull SS settings) {
|
||||
myLinkedProjectsSettings.clear();
|
||||
for (PS projectSettings : settings.getLinkedProjectsSettings()) {
|
||||
myLinkedProjectsSettings.put(projectSettings.getExternalProjectPath(), projectSettings);
|
||||
}
|
||||
copyExtraSettingsFrom(settings);
|
||||
}
|
||||
|
||||
protected abstract void copyExtraSettingsFrom(@NotNull SS settings);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@NotNull
|
||||
public Collection<S> getLinkedProjectsSettings() {
|
||||
public Collection<PS> getLinkedProjectsSettings() {
|
||||
return myLinkedProjectsSettings.values();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public S getLinkedProjectSettings(@NotNull String linkedProjectPath) {
|
||||
public PS getLinkedProjectSettings(@NotNull String linkedProjectPath) {
|
||||
return myLinkedProjectsSettings.get(linkedProjectPath);
|
||||
}
|
||||
|
||||
public void linkProject(@NotNull S settings) throws IllegalArgumentException {
|
||||
S existing = getLinkedProjectSettings(settings.getExternalProjectPath());
|
||||
public void linkProject(@NotNull PS settings) throws IllegalArgumentException {
|
||||
PS existing = getLinkedProjectSettings(settings.getExternalProjectPath());
|
||||
if (existing != null) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Can't link external project '%s'. Reason: it's already registered at the current ide project",
|
||||
@@ -96,7 +110,7 @@ public abstract class AbstractExternalSystemSettings<S extends ExternalProjectSe
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public boolean unlinkExternalProject(@NotNull String linkedProjectPath) {
|
||||
S removed = myLinkedProjectsSettings.remove(linkedProjectPath);
|
||||
PS removed = myLinkedProjectsSettings.remove(linkedProjectPath);
|
||||
if (removed == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -105,16 +119,16 @@ public abstract class AbstractExternalSystemSettings<S extends ExternalProjectSe
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setLinkedProjectsSettings(@NotNull Collection<S> settings) {
|
||||
List<S> added = ContainerUtilRt.newArrayList();
|
||||
Map<String, S> removed = ContainerUtilRt.newHashMap(myLinkedProjectsSettings);
|
||||
public void setLinkedProjectsSettings(@NotNull Collection<PS> settings) {
|
||||
List<PS> added = ContainerUtilRt.newArrayList();
|
||||
Map<String, PS> removed = ContainerUtilRt.newHashMap(myLinkedProjectsSettings);
|
||||
myLinkedProjectsSettings.clear();
|
||||
for (S current : settings) {
|
||||
for (PS current : settings) {
|
||||
myLinkedProjectsSettings.put(current.getExternalProjectPath(), current);
|
||||
}
|
||||
|
||||
for (S current : settings) {
|
||||
S old = removed.remove(current.getExternalProjectPath());
|
||||
for (PS current : settings) {
|
||||
PS old = removed.remove(current.getExternalProjectPath());
|
||||
if (old == null) {
|
||||
added.add(current);
|
||||
}
|
||||
@@ -140,7 +154,7 @@ public abstract class AbstractExternalSystemSettings<S extends ExternalProjectSe
|
||||
* @param old old settings state
|
||||
* @param current current settings state
|
||||
*/
|
||||
protected abstract void checkSettings(@NotNull S old, @NotNull S current);
|
||||
protected abstract void checkSettings(@NotNull PS old, @NotNull PS current);
|
||||
|
||||
@NotNull
|
||||
public Topic<L> getChangesTopic() {
|
||||
@@ -152,17 +166,17 @@ public abstract class AbstractExternalSystemSettings<S extends ExternalProjectSe
|
||||
return myProject.getMessageBus().syncPublisher(myChangesTopic);
|
||||
}
|
||||
|
||||
protected void fillState(@NotNull State<S> state) {
|
||||
protected void fillState(@NotNull State<PS> state) {
|
||||
state.setLinkedExternalProjectsSettings(ContainerUtilRt.newTreeSet(myLinkedProjectsSettings.values()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void loadState(@NotNull State<S> state) {
|
||||
Set<S> settings = state.getLinkedExternalProjectsSettings();
|
||||
protected void loadState(@NotNull State<PS> state) {
|
||||
Set<PS> settings = state.getLinkedExternalProjectsSettings();
|
||||
if (settings != null) {
|
||||
myLinkedProjectsSettings.clear();
|
||||
for (S s : settings) {
|
||||
myLinkedProjectsSettings.put(s.getExternalProjectPath(), s);
|
||||
for (PS projectSettings : settings) {
|
||||
myLinkedProjectsSettings.put(projectSettings.getExternalProjectPath(), projectSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-8
@@ -21,7 +21,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo;
|
||||
@@ -31,7 +30,7 @@ import com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemTasksTr
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
@@ -129,11 +128,10 @@ public class DetachExternalProjectAction extends AnAction implements DumbAware {
|
||||
return MyInfo.EMPTY;
|
||||
}
|
||||
|
||||
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
|
||||
assert manager != null;
|
||||
AbstractExternalSystemSettings<?, ?> settings = manager.getSettingsProvider().fun(ideProject);
|
||||
ExternalSystemSettingsManager settingsManager = ServiceManager.getService(ExternalSystemSettingsManager.class);
|
||||
AbstractExternalSystemSettings<?, ?, ?> settings = settingsManager.getSettings(ideProject, externalSystemId);
|
||||
ExternalProjectSettings externalProjectSettings = settings.getLinkedProjectSettings(externalProject.getPath());
|
||||
AbstractExternalSystemLocalSettings localSettings = manager.getLocalSettingsProvider().fun(ideProject);
|
||||
AbstractExternalSystemLocalSettings localSettings = settingsManager.getLocalSettings(ideProject, externalSystemId);
|
||||
|
||||
return new MyInfo(externalProjectSettings == null ? null : settings,
|
||||
localSettings == null ? null : localSettings,
|
||||
@@ -146,13 +144,13 @@ public class DetachExternalProjectAction extends AnAction implements DumbAware {
|
||||
|
||||
public static final MyInfo EMPTY = new MyInfo(null, null, null, null, null);
|
||||
|
||||
@Nullable public final AbstractExternalSystemSettings<?, ?> settings;
|
||||
@Nullable public final AbstractExternalSystemSettings<?, ?, ?> settings;
|
||||
@Nullable public final AbstractExternalSystemLocalSettings localSettings;
|
||||
@Nullable public final ExternalProjectPojo externalProject;
|
||||
@Nullable public final Project ideProject;
|
||||
@Nullable public final ProjectSystemId externalSystemId;
|
||||
|
||||
MyInfo(@Nullable AbstractExternalSystemSettings<?, ?> settings,
|
||||
MyInfo(@Nullable AbstractExternalSystemSettings<?, ?, ?> settings,
|
||||
@Nullable AbstractExternalSystemLocalSettings localSettings,
|
||||
@Nullable ExternalProjectPojo externalProject,
|
||||
@Nullable Project ideProject,
|
||||
|
||||
+2
-1
@@ -71,6 +71,7 @@ public abstract class AbstractExternalSystemTaskConfigurationType implements Con
|
||||
return myFactories[0];
|
||||
}
|
||||
|
||||
@SuppressWarnings("MethodMayBeStatic")
|
||||
@NotNull
|
||||
protected ExternalSystemRunConfiguration doCreateConfiguration(@NotNull ProjectSystemId externalSystemId,
|
||||
@NotNull Project project,
|
||||
@@ -124,7 +125,7 @@ public abstract class AbstractExternalSystemTaskConfigurationType implements Con
|
||||
{
|
||||
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
|
||||
assert manager != null;
|
||||
AbstractExternalSystemSettings<?,?> s = manager.getSettingsProvider().fun(project);
|
||||
AbstractExternalSystemSettings<?, ?,?> s = manager.getSettingsProvider().fun(project);
|
||||
Map<String/* project dir path */, String/* project file path */> rootProjectPaths = ContainerUtilRt.newHashMap();
|
||||
for (ExternalProjectSettings projectSettings : s.getLinkedProjectsSettings()) {
|
||||
String path = projectSettings.getExternalProjectPath();
|
||||
|
||||
+7
-7
@@ -114,7 +114,7 @@ public class ExternalSystemAutoImporter implements BulkFileListener, DocumentLis
|
||||
List<MyEntry> autoImportAware = ContainerUtilRt.newArrayList();
|
||||
Collection<ExternalSystemManager<?, ?, ?, ?, ?>> managers = ExternalSystemApiUtil.getAllManagers();
|
||||
for (ExternalSystemManager<?, ?, ?, ?, ?> manager : managers) {
|
||||
AbstractExternalSystemSettings<?, ?> systemSettings = manager.getSettingsProvider().fun(project);
|
||||
AbstractExternalSystemSettings<?, ?, ?> systemSettings = manager.getSettingsProvider().fun(project);
|
||||
ExternalSystemAutoImportAware defaultImportAware = createDefault(systemSettings);
|
||||
final ExternalSystemAutoImportAware aware;
|
||||
if (manager instanceof ExternalSystemAutoImportAware) {
|
||||
@@ -153,7 +153,7 @@ public class ExternalSystemAutoImporter implements BulkFileListener, DocumentLis
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static ExternalSystemAutoImportAware createDefault(@NotNull final AbstractExternalSystemSettings<?, ?> systemSettings) {
|
||||
private static ExternalSystemAutoImportAware createDefault(@NotNull final AbstractExternalSystemSettings<?, ?, ?> systemSettings) {
|
||||
return new ExternalSystemAutoImportAware() {
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -327,13 +327,13 @@ public class ExternalSystemAutoImporter implements BulkFileListener, DocumentLis
|
||||
}
|
||||
|
||||
private static class MyEntry {
|
||||
|
||||
@NotNull public final ProjectSystemId externalSystemId;
|
||||
@NotNull public final AbstractExternalSystemSettings<?, ?> systemSettings;
|
||||
@NotNull public final ExternalSystemAutoImportAware aware;
|
||||
|
||||
@NotNull public final ProjectSystemId externalSystemId;
|
||||
@NotNull public final AbstractExternalSystemSettings<?, ?, ?> systemSettings;
|
||||
@NotNull public final ExternalSystemAutoImportAware aware;
|
||||
|
||||
MyEntry(@NotNull ProjectSystemId externalSystemId,
|
||||
@NotNull AbstractExternalSystemSettings<?, ?> systemSettings,
|
||||
@NotNull AbstractExternalSystemSettings<?, ?, ?> systemSettings,
|
||||
@NotNull ExternalSystemAutoImportAware aware)
|
||||
{
|
||||
this.externalSystemId = externalSystemId;
|
||||
|
||||
+65
-26
@@ -1,6 +1,7 @@
|
||||
package com.intellij.openapi.externalSystem.service.project.wizard;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
|
||||
@@ -41,10 +42,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* GoF builder for gradle-backed projects.
|
||||
@@ -58,13 +56,13 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractImp
|
||||
{
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + AbstractExternalProjectImportBuilder.class.getName());
|
||||
|
||||
|
||||
@NotNull private final ExternalSystemSettingsManager mySettingsManager;
|
||||
@NotNull private final ProjectDataManager myProjectDataManager;
|
||||
@NotNull private final C myControl;
|
||||
@NotNull private final ProjectSystemId myExternalSystemId;
|
||||
|
||||
private DataNode<ProjectData> myExternalProjectNode;
|
||||
private DataNode<ProjectData> myExternalProjectNode;
|
||||
|
||||
public AbstractExternalProjectImportBuilder(@NotNull ExternalSystemSettingsManager settingsManager,
|
||||
@NotNull ProjectDataManager projectDataManager,
|
||||
@@ -126,11 +124,8 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractImp
|
||||
@Override
|
||||
public void run() {
|
||||
AbstractExternalSystemSettings systemSettings = mySettingsManager.getSettings(project, myExternalSystemId);
|
||||
ExternalProjectSettings projectSettings = myControl.getProjectSettings().clone();
|
||||
File externalProjectConfigFile = getExternalProjectConfigToUse(new File(projectSettings.getExternalProjectPath()));
|
||||
final String linkedProjectPath = FileUtil.toCanonicalPath(externalProjectConfigFile.getPath());
|
||||
assert linkedProjectPath != null;
|
||||
projectSettings.setExternalProjectPath(linkedProjectPath);
|
||||
systemSettings.copyFrom(myControl.getSystemSettings());
|
||||
final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
|
||||
Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
|
||||
projects.add(projectSettings);
|
||||
systemSettings.setLinkedProjectsSettings(projects);
|
||||
@@ -157,7 +152,7 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractImp
|
||||
@Override
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
ExternalSystemResolveProjectTask task
|
||||
= new ExternalSystemResolveProjectTask(myExternalSystemId, project, linkedProjectPath, true);
|
||||
= new ExternalSystemResolveProjectTask(myExternalSystemId, project, projectSettings.getExternalProjectPath(), true);
|
||||
task.execute(indicator);
|
||||
DataNode<ProjectData> projectWithResolvedLibraries = task.getExternalProject();
|
||||
if (projectWithResolvedLibraries == null) {
|
||||
@@ -176,6 +171,16 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractImp
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ExternalProjectSettings getCurrentExternalProjectSettings() {
|
||||
ExternalProjectSettings result = myControl.getProjectSettings().clone();
|
||||
File externalProjectConfigFile = getExternalProjectConfigToUse(new File(result.getExternalProjectPath()));
|
||||
final String linkedProjectPath = FileUtil.toCanonicalPath(externalProjectConfigFile.getPath());
|
||||
assert linkedProjectPath != null;
|
||||
result.setExternalProjectPath(linkedProjectPath);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected abstract void beforeCommit(@NotNull DataNode<ProjectData> dataNode, @NotNull Project project);
|
||||
|
||||
/**
|
||||
@@ -250,14 +255,14 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractImp
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void ensureProjectIsDefined(@NotNull WizardContext wizardContext) throws ConfigurationException {
|
||||
String externalSystemName = myExternalSystemId.getReadableName();
|
||||
final String externalSystemName = myExternalSystemId.getReadableName();
|
||||
File projectFile = getProjectFile();
|
||||
if (projectFile == null) {
|
||||
throw new ConfigurationException(ExternalSystemBundle.message("error.project.undefined"));
|
||||
}
|
||||
projectFile = getExternalProjectConfigToUse(projectFile);
|
||||
final Ref<ConfigurationException> error = new Ref<ConfigurationException>();
|
||||
ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
|
||||
final ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
|
||||
myExternalProjectNode = externalProject;
|
||||
@@ -275,18 +280,29 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractImp
|
||||
};
|
||||
|
||||
final Project project = getProject(wizardContext);
|
||||
try {
|
||||
ExternalSystemUtil.refreshProject(
|
||||
project,
|
||||
myExternalSystemId,
|
||||
projectFile.getAbsolutePath(),
|
||||
callback,
|
||||
false,
|
||||
true
|
||||
);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
throw new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName));
|
||||
final File finalProjectFile = projectFile;
|
||||
final Ref<ConfigurationException> exRef = new Ref<ConfigurationException>();
|
||||
executeAndRestoreSettings(project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ExternalSystemUtil.refreshProject(
|
||||
project,
|
||||
myExternalSystemId,
|
||||
finalProjectFile.getAbsolutePath(),
|
||||
callback,
|
||||
false,
|
||||
true
|
||||
);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
exRef.set(new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName)));
|
||||
}
|
||||
}
|
||||
});
|
||||
ConfigurationException ex = exRef.get();
|
||||
if (ex != null) {
|
||||
throw ex;
|
||||
}
|
||||
if (myExternalProjectNode == null) {
|
||||
ConfigurationException exception = error.get();
|
||||
@@ -299,6 +315,29 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractImp
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void executeAndRestoreSettings(@NotNull Project project, @NotNull Runnable task) {
|
||||
AbstractExternalSystemSettings systemSettings = mySettingsManager.getSettings(project, myExternalSystemId);
|
||||
Object systemStateToRestore = null;
|
||||
if (systemSettings instanceof PersistentStateComponent) {
|
||||
systemStateToRestore = ((PersistentStateComponent)systemSettings).getState();
|
||||
}
|
||||
systemSettings.copyFrom(myControl.getSystemSettings());
|
||||
Collection projectSettingsToRestore = systemSettings.getLinkedProjectsSettings();
|
||||
systemSettings.setLinkedProjectsSettings(Collections.singleton(getCurrentExternalProjectSettings()));
|
||||
try {
|
||||
task.run();
|
||||
}
|
||||
finally {
|
||||
if (systemStateToRestore != null) {
|
||||
((PersistentStateComponent)systemSettings).loadState(systemStateToRestore);
|
||||
}
|
||||
else {
|
||||
systemSettings.setLinkedProjectsSettings(projectSettingsToRestore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to adjust external project config file to use on the basis of the given value.
|
||||
* <p/>
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ import java.util.List;
|
||||
public abstract class AbstractExternalSystemConfigurable<
|
||||
ProjectSettings extends ExternalProjectSettings,
|
||||
L extends ExternalSystemSettingsListener<ProjectSettings>,
|
||||
SystemSettings extends AbstractExternalSystemSettings<ProjectSettings, L>
|
||||
SystemSettings extends AbstractExternalSystemSettings<SystemSettings, ProjectSettings, L>
|
||||
> implements SearchableConfigurable, Configurable.NoScroll
|
||||
{
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public abstract class AbstractExternalSystemToolWindowCondition implements Condi
|
||||
if (manager == null) {
|
||||
return false;
|
||||
}
|
||||
AbstractExternalSystemSettings<?,?> settings = manager.getSettingsProvider().fun(project);
|
||||
AbstractExternalSystemSettings<?, ?,?> settings = manager.getSettingsProvider().fun(project);
|
||||
return settings != null && !settings.getLinkedProjectsSettings().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -44,7 +44,7 @@ import java.awt.*;
|
||||
public abstract class AbstractImportFromExternalSystemControl<
|
||||
ProjectSettings extends ExternalProjectSettings,
|
||||
L extends ExternalSystemSettingsListener<ProjectSettings>,
|
||||
SystemSettings extends AbstractExternalSystemSettings<ProjectSettings, L>>
|
||||
SystemSettings extends AbstractExternalSystemSettings<SystemSettings, ProjectSettings, L>>
|
||||
{
|
||||
@NotNull private final SystemSettings mySystemSettings;
|
||||
@NotNull private final ProjectSettings myProjectSettings;
|
||||
@@ -165,6 +165,11 @@ public abstract class AbstractImportFromExternalSystemControl<
|
||||
myLinkedProjectPathField.setText(path);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SystemSettings getSystemSettings() {
|
||||
return mySystemSettings;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProjectSettings getProjectSettings() {
|
||||
return myProjectSettings;
|
||||
@@ -186,7 +191,7 @@ public abstract class AbstractImportFromExternalSystemControl<
|
||||
else if (myCurrentProject != null) {
|
||||
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(myExternalSystemId);
|
||||
assert manager != null;
|
||||
AbstractExternalSystemSettings<?,?> settings = manager.getSettingsProvider().fun(myCurrentProject);
|
||||
AbstractExternalSystemSettings<?, ?,?> settings = manager.getSettingsProvider().fun(myCurrentProject);
|
||||
if (settings.getLinkedProjectSettings(linkedProjectPath) != null) {
|
||||
throw new ConfigurationException(ExternalSystemBundle.message("error.project.already.registered"));
|
||||
}
|
||||
|
||||
+8
-2
@@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.impl.ToolWindowImpl;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -47,9 +48,14 @@ public class ExternalToolWindowManager {
|
||||
if (!settings.getLinkedProjectsSettings().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ToolWindow toolWindow = getToolWindow(project, manager.getSystemId());
|
||||
final ToolWindow toolWindow = getToolWindow(project, manager.getSystemId());
|
||||
if (toolWindow != null) {
|
||||
toolWindow.setAvailable(false, null);
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toolWindow.setAvailable(false, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class ExternalSystemSettingsManager implements DisposableExternalSystemSe
|
||||
@NotNull ProjectSystemId externalSystemId) throws IllegalArgumentException
|
||||
{
|
||||
Holder holder = myHolder.getValue();
|
||||
Function<Project, ? extends AbstractExternalSystemSettings<?, ?>> provider = holder.settingsProviders.get(externalSystemId);
|
||||
Function<Project, ? extends AbstractExternalSystemSettings<?, ?, ?>> provider = holder.settingsProviders.get(externalSystemId);
|
||||
if (provider == null) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Can't retrieve settings for external system with id '%s'. Reason: no such system is registered. Known systems: %s",
|
||||
@@ -105,7 +105,7 @@ public class ExternalSystemSettingsManager implements DisposableExternalSystemSe
|
||||
|
||||
private static class Holder {
|
||||
@NotNull
|
||||
public final ConcurrentMap<ProjectSystemId, Function<Project, ? extends AbstractExternalSystemSettings<?, ?>>> settingsProviders
|
||||
public final ConcurrentMap<ProjectSystemId, Function<Project, ? extends AbstractExternalSystemSettings<?, ?, ?>>> settingsProviders
|
||||
= ContainerUtil.newConcurrentMap();
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ public class ExternalSystemUtil {
|
||||
if (manager == null) {
|
||||
return;
|
||||
}
|
||||
AbstractExternalSystemSettings<?, ?> settings = manager.getSettingsProvider().fun(project);
|
||||
AbstractExternalSystemSettings<?, ?, ?> settings = manager.getSettingsProvider().fun(project);
|
||||
final Collection<? extends ExternalProjectSettings> projectsSettings = settings.getLinkedProjectsSettings();
|
||||
if (projectsSettings.isEmpty()) {
|
||||
return;
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class GradleAutoImportAware implements ExternalSystemAutoImportAware {
|
||||
|
||||
ExternalSystemManager<?,?,?,?,?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
|
||||
assert manager != null;
|
||||
AbstractExternalSystemSettings<?,?> systemSettings = manager.getSettingsProvider().fun(project);
|
||||
AbstractExternalSystemSettings<?, ?,?> systemSettings = manager.getSettingsProvider().fun(project);
|
||||
Collection<? extends ExternalProjectSettings> projectsSettings = systemSettings.getLinkedProjectsSettings();
|
||||
if (projectsSettings.isEmpty()) {
|
||||
return null;
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.util.Set;
|
||||
@Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/gradle.xml", scheme = StorageScheme.DIRECTORY_BASED)
|
||||
}
|
||||
)
|
||||
public class GradleSettings extends AbstractExternalSystemSettings<GradleProjectSettings, GradleSettingsListener>
|
||||
public class GradleSettings extends AbstractExternalSystemSettings<GradleSettings, GradleProjectSettings, GradleSettingsListener>
|
||||
implements PersistentStateComponent<GradleSettings.MyState>
|
||||
{
|
||||
|
||||
@@ -62,6 +62,11 @@ public class GradleSettings extends AbstractExternalSystemSettings<GradleProject
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void copyExtraSettingsFrom(@NotNull GradleSettings settings) {
|
||||
myServiceDirectoryPath = settings.getServiceDirectoryPath();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user