mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-76142: Gradle support - cannot update IDEA projects once one of build.gradle files changes
Don't refresh gradle project on intellij project structure change while modal dialog is open (assuming that that modal dialog is 'project settings' dialog)
This commit is contained in:
+18
-1
@@ -1,11 +1,13 @@
|
||||
package org.jetbrains.plugins.gradle.sync;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootListener;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.util.GradleUtil;
|
||||
|
||||
@@ -59,10 +61,25 @@ public class GradleProjectStructureChangesDetector extends AbstractProjectCompon
|
||||
myAlarm.cancelAllRequests();
|
||||
final long diff = System.currentTimeMillis() - myStartRefreshTime.get();
|
||||
if (diff < 0) {
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(this, (int)-diff);
|
||||
return;
|
||||
}
|
||||
GradleUtil.refreshProject(myProject);
|
||||
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (ModalityState.current() != ModalityState.NON_MODAL) {
|
||||
// There is a possible case that user performs intellij project structure modification and 'project settings' dialog
|
||||
// is open. We want to perform the refresh when the editing is completely finished then.
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(RefreshRequest.this, REFRESH_DELAY_MILLIS);
|
||||
return;
|
||||
}
|
||||
|
||||
GradleUtil.refreshProject(myProject);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,10 +157,10 @@ public class GradleUtil {
|
||||
*/
|
||||
@Nullable
|
||||
public static GradleProject refreshProject(@NotNull final Project project,
|
||||
@NotNull final String gradleProjectPath,
|
||||
@NotNull final Ref<String> errorHolder,
|
||||
final boolean resolveLibraries,
|
||||
final boolean modal)
|
||||
@NotNull final String gradleProjectPath,
|
||||
@NotNull final Ref<String> errorHolder,
|
||||
final boolean resolveLibraries,
|
||||
final boolean modal)
|
||||
{
|
||||
final Ref<GradleProject> gradleProject = new Ref<GradleProject>();
|
||||
final TaskUnderProgress task = new TaskUnderProgress() {
|
||||
@@ -196,7 +196,7 @@ public class GradleUtil {
|
||||
task.execute(indicator);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return gradleProject.get();
|
||||
|
||||
Reference in New Issue
Block a user