Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-10-05 16:16:35 +0000
committerMichael Valenta2004-10-05 16:16:35 +0000
commit4f35f42ef0f447e35fb0e8df2f9e2ec4e0662aaa (patch)
tree35d1c704d7cd5941abbe7b0d122bda43976def9e
parent042834e6eed37d2c6a145c6745a45ed010e6d241 (diff)
downloadeclipse.platform.team-4f35f42ef0f447e35fb0e8df2f9e2ec4e0662aaa.tar.gz
eclipse.platform.team-4f35f42ef0f447e35fb0e8df2f9e2ec4e0662aaa.tar.xz
eclipse.platform.team-4f35f42ef0f447e35fb0e8df2f9e2ec4e0662aaa.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java186
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java13
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java10
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java4
9 files changed, 155 insertions, 77 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java
index bd0f5d920..892fc09e7 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.subscriber;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.ui.synchronize.*;
@@ -42,4 +44,11 @@ public class CVSChangeSetCapability extends ChangeSetCapability {
public SynchronizePageActionGroup getActionGroup() {
return new CVSChangeSetActionGroup();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.ChangeSetCapability#enableChangeSetsByDefault()
+ */
+ public boolean enableChangeSetsByDefault() {
+ return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT);
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java
index 7ae06c720..7fd4ca34b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java
@@ -264,7 +264,7 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector {
public void run() {
addLogEntries(infos, logs, Policy.subMonitorFor(monitor, 10));
}
- });
+ }, true /* preserver expansion */);
}
/**
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
index 6271b11e8..57f988b1f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
@@ -318,6 +318,95 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo
*/
protected abstract boolean hasViewerState();
+ /*
+ * Return all the resources that are expanded in the page.
+ * This method should only be called in the UI thread
+ * after validating that the viewer is still valid.
+ */
+ protected IResource[] getExpandedResources() {
+ final StructuredViewer viewer = getViewer();
+ Object[] objects = ((AbstractTreeViewer) viewer).getVisibleExpandedElements();
+ return getResources(objects);
+ }
+
+ /*
+ * Expand the resources if they appear in the page.
+ * This method should only be called in the UI thread
+ * after validating that the viewer is still valid.
+ */
+ protected void expandResources(IResource[] resources) {
+ Set expandedElements = new HashSet();
+ StructuredViewer viewer = getViewer();
+ for (int j = 0; j < resources.length; j++) {
+ IResource resource = resources[j];
+ ISynchronizeModelElement[] elements = getModelObjects(resource);
+ for (int i = 0; i < elements.length; i++) {
+ ISynchronizeModelElement element = elements[i];
+ // Add all parents of the element to the expansion set
+ while (element != null) {
+ expandedElements.add(element);
+ element = (ISynchronizeModelElement)element.getParent();
+ }
+ }
+ }
+ ((AbstractTreeViewer) viewer).setExpandedElements(expandedElements.toArray());
+ }
+
+ private ISynchronizeModelElement[] getModelElements(IResource[] resources) {
+ Set result = new HashSet();
+ for (int j = 0; j < resources.length; j++) {
+ IResource resource = resources[j];
+ ISynchronizeModelElement[] elements = getModelObjects(resource);
+ for (int i = 0; i < elements.length; i++) {
+ ISynchronizeModelElement element = elements[i];
+ result.add(element);
+ }
+ }
+ return (ISynchronizeModelElement[]) result.toArray(new ISynchronizeModelElement[result.size()]);
+ }
+
+ protected IResource[] getResources(Object[] objects) {
+ Set result = new HashSet();
+ if (objects.length > 0) {
+ for (int i = 0; i < objects.length; i++) {
+ if (objects[i] instanceof ISynchronizeModelElement) {
+ IResource resource = ((ISynchronizeModelElement)objects[i]).getResource();
+ if(resource != null)
+ result.add(resource);
+ }
+ }
+ }
+ return (IResource[]) result.toArray(new IResource[result.size()]);
+ }
+
+ private void cacheResources(IResource[] resources, String configProperty) {
+ if (resources.length > 0) {
+ ISynchronizePageConfiguration config = getConfiguration();
+ ArrayList paths = new ArrayList();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ paths.add(resource.getFullPath().toString());
+ }
+ config.setProperty(configProperty, paths);
+ }
+ }
+
+ private IResource[] getCachedResources(String configProperty) {
+ List paths = (List)getConfiguration().getProperty(configProperty);
+ IContainer container = ResourcesPlugin.getWorkspace().getRoot();
+ ArrayList resources = new ArrayList();
+ if (paths != null) {
+ for (Iterator it = paths.iterator(); it.hasNext();) {
+ String path = (String) it.next();
+ IResource resource = getResourceForPath(container, path);
+ if (resource != null) {
+ resources.add(resource);
+ }
+ }
+ }
+ return (IResource[]) resources.toArray(new IResource[resources.size()]);
+ }
+
/**
* Save the viewer state (expansion and selection)
*/
@@ -325,46 +414,20 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo
// save visible expanded elements and selection
final StructuredViewer viewer = getViewer();
if (viewer != null && !viewer.getControl().isDisposed() && viewer instanceof AbstractTreeViewer) {
- final Object[][] expandedElements = new Object[1][1];
- final Object[][] selectedElements = new Object[1][1];
+ final IResource[][] expandedResources = new IResource[1][1];
+ final IResource[][] selectedResources = new IResource[1][1];
viewer.getControl().getDisplay().syncExec(new Runnable() {
public void run() {
if (viewer != null && !viewer.getControl().isDisposed()) {
- expandedElements[0] = ((AbstractTreeViewer) viewer).getVisibleExpandedElements();
- selectedElements[0] = ((IStructuredSelection) viewer.getSelection()).toArray();
+ expandedResources[0] = getExpandedResources();
+ selectedResources[0] = getResources(((IStructuredSelection) viewer.getSelection()).toArray());
}
}
});
- //
- // Save expansion
- //
- if (expandedElements[0].length > 0) {
- ISynchronizePageConfiguration config = getConfiguration();
- ArrayList savedExpansionState = new ArrayList();
- for (int i = 0; i < expandedElements[0].length; i++) {
- if (expandedElements[0][i] instanceof ISynchronizeModelElement) {
- IResource resource = ((ISynchronizeModelElement) expandedElements[0][i]).getResource();
- if(resource != null)
- savedExpansionState.add(resource.getFullPath().toString());
- }
- }
- config.setProperty(P_VIEWER_EXPANSION_STATE, savedExpansionState);
- }
- //
- // Save selection
- //
- if (selectedElements[0].length > 0) {
- ISynchronizePageConfiguration config = getConfiguration();
- ArrayList savedSelectedState = new ArrayList();
- for (int i = 0; i < selectedElements[0].length; i++) {
- if (selectedElements[0][i] instanceof ISynchronizeModelElement) {
- IResource resource = ((ISynchronizeModelElement) selectedElements[0][i]).getResource();
- if(resource != null)
- savedSelectedState.add(resource.getFullPath().toString());
- }
- }
- config.setProperty(P_VIEWER_SELECTION_STATE, savedSelectedState);
- }
+
+ // Save expansion and selection
+ cacheResources(expandedResources[0], P_VIEWER_EXPANSION_STATE);
+ cacheResources(selectedResources[0], P_VIEWER_SELECTION_STATE);
}
}
@@ -376,43 +439,30 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo
// restore expansion state and selection state
final StructuredViewer viewer = getViewer();
if (viewer != null && !viewer.getControl().isDisposed() && viewer instanceof AbstractTreeViewer) {
- List savedExpansionState = (List)getConfiguration().getProperty(P_VIEWER_EXPANSION_STATE);
- List savedSelectionState = (List)getConfiguration().getProperty(P_VIEWER_SELECTION_STATE);
- IContainer container = ResourcesPlugin.getWorkspace().getRoot();
- final ArrayList expandedElements = new ArrayList();
- if (savedExpansionState != null) {
- for (Iterator it = savedExpansionState.iterator(); it.hasNext();) {
- String path = (String) it.next();
- IResource resource = getResourceForPath(container, path);
- ISynchronizeModelElement[] elements = getModelObjects(resource);
- for (int i = 0; i < elements.length; i++) {
- ISynchronizeModelElement element = elements[i];
- // Add all parents of the element to the expansion set
- while (element != null) {
- expandedElements.add(element);
- element = (ISynchronizeModelElement)element.getParent();
- }
- }
- }
- }
- final ArrayList selectedElements = new ArrayList();
- if (savedSelectionState != null) {
- for (Iterator it = savedSelectionState.iterator(); it.hasNext();) {
- String path = (String) it.next();
- IResource resource = getResourceForPath(container, path);
- ISynchronizeModelElement[] elements = getModelObjects(resource);
- // Only preserve the selection if there is one element for the resource
- if (elements.length == 1) {
- selectedElements.add(elements[0]);
- }
- }
- }
- ((AbstractTreeViewer) viewer).setExpandedElements(expandedElements.toArray());
- viewer.setSelection(new StructuredSelection(selectedElements));
+ IResource[] resourcesToExpand = getCachedResources(P_VIEWER_EXPANSION_STATE);
+ IResource[] resourcesToSelect = getCachedResources(P_VIEWER_SELECTION_STATE);
+ expandResources(resourcesToExpand);
+ selectResources(resourcesToSelect);
}
}
- /*
+ private void selectResources(IResource[] resourcesToSelect) {
+ StructuredViewer viewer = getViewer();
+ final ArrayList selectedElements = new ArrayList();
+ if (resourcesToSelect != null) {
+ for (int i = 0; i < resourcesToSelect.length; i++) {
+ IResource resource = resourcesToSelect[i];
+ ISynchronizeModelElement[] elements = getModelObjects(resource);
+ // Only preserve the selection if there is one element for the resource
+ if (elements.length == 1) {
+ selectedElements.add(elements[0]);
+ }
+ }
+ }
+ viewer.setSelection(new StructuredSelection(selectedElements));
+ }
+
+ /*
* Convert a path to a resource by first looking in the resource
* tree and, if that fails, by using the path format to create
* a handle.
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java
index 776554889..e8e8964ee 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java
@@ -204,7 +204,7 @@ public class ActiveChangeSetCollector implements ISyncInfoSetChangeListener {
}
}
}
- });
+ }, true /* preserver expansion */);
}
/* (non-Javadoc)
@@ -224,7 +224,7 @@ public class ActiveChangeSetCollector implements ISyncInfoSetChangeListener {
}
}
}
- });
+ }, true /* preserver expansion */);
}
private ChangeSet getChangeSet(SyncInfoSet set) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java
index 2f1340c22..61b1de084 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelManager.java
@@ -147,7 +147,7 @@ public class ChangeSetModelManager extends HierarchicalModelManager implements I
// Load our setting before invoking super since the inherited
// initialize will create the provider
IDialogSettings pageSettings = getConfiguration().getSite().getPageSettings();
- // TODO enabled = TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT);
+ enabled = getConfiguration().getParticipant().getChangeSetCapability().enableChangeSetsByDefault();
if(pageSettings != null && pageSettings.get(P_COMMIT_SET_ENABLED) != null) {
enabled = pageSettings.getBoolean(P_COMMIT_SET_ENABLED);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
index 67c73be27..bbcf139ba 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java
@@ -281,8 +281,17 @@ public class ChangeSetModelProvider extends CompositeModelProvider {
/* (non-Javadoc)
* @see org.eclipse.team.internal.ui.synchronize.AbstractSynchronizeModelProvider#runViewUpdate(java.lang.Runnable)
*/
- public void runViewUpdate(Runnable runnable) {
- super.runViewUpdate(runnable);
+ public void runViewUpdate(final Runnable runnable, final boolean preserveExpansion) {
+ runViewUpdate(new Runnable() {
+ public void run() {
+ IResource[] resources = null;
+ if (preserveExpansion)
+ resources = getExpandedResources();
+ runnable.run();
+ if (resources != null)
+ expandResources(resources);
+ }
+ });
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java
index d14c0fc70..58d605170 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java
@@ -34,7 +34,7 @@ import org.eclipse.ui.actions.BaseSelectionListenerAction;
* This action group contributes actions that support the management
* of Change sets to a synchronize page.
*/
-public final class ChangeSetActionGroup extends SynchronizePageActionGroup {
+public class ChangeSetActionGroup extends SynchronizePageActionGroup {
/**
* Menu group that can be added to the context menu
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java
index 69697b92d..932393d6d 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ChangeSetCapability.java
@@ -140,5 +140,15 @@ public abstract class ChangeSetCapability {
return supportsActiveChangeSets() &&
configuration.getMode() == ISynchronizePageConfiguration.OUTGOING_MODE;
}
+
+ /**
+ * Return whether change sets should be enabled by default on pages
+ * that display the participant.
+ * @return whether change sets should be enabled by default on pages
+ * that display the participant
+ */
+ public boolean enableChangeSetsByDefault() {
+ return false;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java
index ce7e0b7c1..f9bc5ec9d 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoSetChangeSetCollector.java
@@ -157,8 +157,8 @@ public abstract class SyncInfoSetChangeSetCollector extends ChangeSetCollector {
return configuration;
}
- protected void runViewUpdate(Runnable runnable) {
- provider.runViewUpdate(runnable);
+ protected void runViewUpdate(Runnable runnable, boolean preserveExpansion) {
+ provider.runViewUpdate(runnable, preserveExpansion);
}
/* (non-javadoc)

Back to the top