IDEA-76142: Gradle support - cannot update IDEA projects once one of build.gradle files changes

'Expand' project change tree nodes state is preserved during the single IDE launch session even if they are not persistent
This commit is contained in:
Denis.Zhdanov
2012-03-14 13:24:43 +04:00
parent aaf925e837
commit 30e298cd77
2 changed files with 28 additions and 7 deletions
@@ -45,6 +45,9 @@ public class GradleSettings implements PersistentStateComponent<GradleSettings>,
/** Holds changes confirmed by the end-user. */
private final AtomicReference<Map<String/*tree path*/, Boolean/*expanded*/>> myExpandStates
= new AtomicReference<Map<String, Boolean>>(new HashMap<String, Boolean>());
/** @see #getWorkingExpandStates() */
private final AtomicReference<Map<String/*tree path*/, Boolean/*expanded*/>> myWorkingExpandStates
= new AtomicReference<Map<String, Boolean>>(new HashMap<String, Boolean>());
/** Holds information about 'expand/collapse' status of the 'sync project structure tree' nodes. */
//private final AtomicReference<Set<GradleProjectStructureChange>> myAcceptedChanges
// = new AtomicReference<Set<GradleProjectStructureChange>>();
@@ -54,8 +57,9 @@ public class GradleSettings implements PersistentStateComponent<GradleSettings>,
@Override
public GradleSettings getState() {
if (!PRESERVE_EXPAND_STATE) {
myExpandStates.get().clear();
myExpandStates.get().clear();
if (PRESERVE_EXPAND_STATE) {
myExpandStates.get().putAll(myWorkingExpandStates.get());
}
return this;
}
@@ -104,15 +108,32 @@ public class GradleSettings implements PersistentStateComponent<GradleSettings>,
project.getMessageBus().syncPublisher(GradleConfigNotifier.TOPIC).onLinkedProjectPathChange(oldPath, path);
}
@SuppressWarnings("UnusedDeclaration")
@NotNull
public Map<String, Boolean> getExpandStates() {
public Map<String, Boolean> getExpandStates() { // Necessary for the serialization.
return myExpandStates.get();
}
/**
* It's possible to configure the gradle integration to not persist 'expand states' (see {@link #PRESERVE_EXPAND_STATE}).
* <p/>
* However, we want the state to be saved during the single IDE session even if we don't want to persist it between the
* different sessions.
* <p/>
* This method allows to retrieve that 'non-persistent state'.
*
* @return project structure changes tree nodes 'expand state' to use
*/
@NotNull
public Map<String, Boolean> getWorkingExpandStates() {
return myWorkingExpandStates.get();
}
@SuppressWarnings("UnusedDeclaration")
public void setExpandStates(@Nullable Map<String, Boolean> state) { // Necessary for the serialization.
if (state != null) {
myExpandStates.set(state);
myExpandStates.get().putAll(state);
myWorkingExpandStates.get().putAll(state);
}
}
@@ -99,14 +99,14 @@ public class GradleProjectStructureChangesPanel extends GradleToolWindowPanel {
@Override
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
if (!mySuppressCollapseTracking) {
mySettings.getExpandStates().put(getPath(event.getPath()), true);
mySettings.getWorkingExpandStates().put(getPath(event.getPath()), true);
}
}
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
if (!mySuppressCollapseTracking) {
mySettings.getExpandStates().put(getPath(event.getPath()), false);
mySettings.getWorkingExpandStates().put(getPath(event.getPath()), false);
}
}
});
@@ -361,7 +361,7 @@ public class GradleProjectStructureChangesPanel extends GradleToolWindowPanel {
*/
private void applyCollapseState(@NotNull TreePath path) {
final String key = getPath(path);
final Boolean expanded = mySettings.getExpandStates().get(key);
final Boolean expanded = mySettings.getWorkingExpandStates().get(key);
if (expanded == null) {
return;
}