Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-10-31 20:11:45 +0000
committerMichael Valenta2002-10-31 20:11:45 +0000
commitc301cd55853fabd0d5584e6a0151de18527c7297 (patch)
tree9ae19506094ceeeb54e556f510625bb0aa602c5f
parent038021a7abbc85f747d4a249aec31c62f072767c (diff)
downloadeclipse.platform.team-c301cd55853fabd0d5584e6a0151de18527c7297.tar.gz
eclipse.platform.team-c301cd55853fabd0d5584e6a0151de18527c7297.tar.xz
eclipse.platform.team-c301cd55853fabd0d5584e6a0151de18527c7297.zip
Added working set management
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.properties13
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml36
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java20
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties32
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSet.java37
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetFolderSelectionPage.java99
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetWizard.java30
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java (renamed from bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AutoRefreshMembership.java)59
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java7
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java35
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java113
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/WorkingSetSelectionDialog.java433
18 files changed, 795 insertions, 144 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties
index bca225bca..340377767 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.properties
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.properties
@@ -53,11 +53,8 @@ CopyRepositoryNameAction.tooltip=Copy Repository Names to Clipboard
IgnoreAction.label=A&dd to .cvsignore
IgnoreAction.tooltip=Ignore the Selected Resources when Synchronizing
-RemoveBranchTagAction.label=Discard &Branch
-RemoveBranchTagAction.tooltip=Discard Branch
-
-RemoveModuleVersionAction.label=Discard &Version
-RemoveModuleVersionAction.tooltip=Discard Version
+RefreshTagsAction.label=Refresh Branches and &Versions
+RefreshTagsAction.tooltip=Refresh the branch and version tags and their members using the auto-refresh files associated with each remote folder
RemoveRootAction.label=Discard &Location
RemoveRootAction.tooltip=Discard Location
@@ -80,9 +77,6 @@ MoveTagAction.tooltip=Tag the selected resources with an existing tag
SetKeywordSubstitutionAction.label=C&hange ASCII/Binary Property...
SetKeywordSubstitutionAction.tooltip=Change whether the selected resources should be treated as ASCII or binary on the CVS Server
-DefineBranchAction.label=&Define Branch Tag...
-DefineBranchAction.tooltip=Define a Branch Tag that Exists on CVS Server
-
UpdateAction.label=&Update
UpdateAction.tooltip=Update
@@ -151,6 +145,3 @@ CVSActionSet.syncTooltip=Synchronize all CVS projects with their repositories
RestoreFromRepositoryAction.label=&Restore from Repository...
RestoreFromRepositoryAction.tooltip=Restore resources that have been deleted from the remote folder.
-RefreshTagMembership.label=Refresh from Repository
-RefreshTagMembership.tooltip=Refresh the contents of the tag by querying the server.
-
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index d9b0ad57d..cd03da50d 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -439,13 +439,13 @@
id="org.eclipse.team.ccvs.ui.removeRoot">
</action>
<action
- label="%DefineBranchAction.label"
+ label="%RefreshTagsAction.label"
icon="icons/full/clcl16/newstream_wiz.gif"
- tooltip="%DefineBranchAction.tooltip"
+ tooltip="%RefreshTagsAction.tooltip"
menubarPath="tagGroup"
- class="org.eclipse.team.internal.ccvs.ui.repo.DefineBranchAction"
- helpContextId="org.eclipse.team.cvs.ui.define_branch_action_context"
- id="org.eclipse.team.ccvs.ui.defineBranch">
+ class="org.eclipse.team.internal.ccvs.ui.repo.RefreshTagsAction"
+ helpContextId="org.eclipse.team.cvs.ui.refresh_tags_action_context"
+ id="org.eclipse.team.ccvs.ui.refreshTags">
</action>
<action
id="org.eclipse.team.ccvs.ui.configureTagsOnBranchCategory"
@@ -459,14 +459,6 @@
<objectContribution
objectClass="org.eclipse.team.internal.ccvs.ui.model.BranchCategory"
id="org.eclipse.team.ccvs.ui.BranchCategoryContributions">
- <action
- label="%DefineBranchAction.label"
- icon="icons/full/clcl16/newstream_wiz.gif"
- tooltip="%DefineBranchAction.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.repo.DefineBranchAction"
- helpContextId="org.eclipse.team.cvs.ui.define_branch_action_context"
- id="org.eclipse.team.ccvs.ui.defineBranch">
- </action>
<action
id="org.eclipse.team.ccvs.ui.configureTagsOnBranchCategory"
label="%ConfigureTags.label"
@@ -476,24 +468,6 @@
class="org.eclipse.team.internal.ccvs.ui.actions.ConfigureTagsFromRepoView"/>
</objectContribution>
<objectContribution
- objectClass="org.eclipse.team.internal.ccvs.ui.model.CVSTagElement"
- id="org.eclipse.team.ccvs.ui.CVSTagContributions">
- <action
- label="%RemoveBranchTagAction.label"
- tooltip="%RemoveBranchTagAction.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.repo.RemoveBranchTagAction"
- helpContextId="org.eclipse.team.cvs.ui.remove_branch_action_context"
- id="org.eclipse.team.ccvs.ui.removeBranchTag">
- </action>
- <action
- label="%RefreshTagMembership.label"
- tooltip="%RefreshTagMembership.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.repo.AutoRefreshMembership"
- helpContextId="org.eclipse.team.cvs.ui.refresh_tag_membership_action_context"
- id="org.eclipse.team.ccvs.ui.refreshTagMembership">
- </action>
- </objectContribution>
- <objectContribution
objectClass="org.eclipse.team.internal.ccvs.core.ICVSRemoteResource"
id="org.eclipse.team.ccvs.ui.RemoteResourceContributions">
<action
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java
index 530cb1b4b..84075e0af 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IRepositoryListener.java
@@ -11,7 +11,7 @@ import org.eclipse.team.internal.ccvs.ui.repo.CVSWorkingSet;
public interface IRepositoryListener {
public void repositoryAdded(ICVSRepositoryLocation root);
public void repositoryRemoved(ICVSRepositoryLocation root);
- public void repositoryChanged(ICVSRepositoryLocation root);
+ public void repositoriesChanged(ICVSRepositoryLocation[] roots);
public void workingSetChanged(CVSWorkingSet set);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
index 2b8878e0a..546e1fda5 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
@@ -349,7 +349,25 @@ abstract public class CVSAction extends TeamAction {
}
return null;
}
-
+
+ protected Object[] getSelectedResources(Class c) {
+ ArrayList result = null;
+ if (!selection.isEmpty()) {
+ result = new ArrayList();
+ Iterator elements = ((IStructuredSelection) selection).iterator();
+ while (elements.hasNext()) {
+ Object adapter = getAdapter(elements.next(), c);
+ if (c.isInstance(adapter)) {
+ result.add(adapter);
+ }
+ }
+ }
+ if (result != null && !result.isEmpty()) {
+ return (Object[])result.toArray(new Object[result.size()]);
+ }
+ return new Object[0];
+ }
+
/**
* Returns the selected CVS resources
*/
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 8c0c46ef1..7ec78b862 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -418,7 +418,6 @@ ReplaceWithAction.localChanges={0} has local changes which you are about to over
RepositoryDialog.getRepository=Select a repository
RepositoryDialog.description=Select a repository to connect your project to
-RepositoryManager.getting=Getting
RepositoryManager.committing=Committing
RepositoryManager.updating=Updating
RepositoryManager.deleting=Deleting
@@ -426,14 +425,17 @@ RepositoryManager.adding=Adding
RepositoryManager.rename=An IO Exception occurred while renaming the state file
RepositoryManager.save=An IO Exception occurred while saving the state file
RepositoryManager.ioException=An IO Exception occurred while reading the state file
+RepositoryManager.parsingProblem=An error occured parsing file ''{0}''.
RepositoriesView.refresh=&Refresh View
RepositoriesView.refreshTooltip=Refresh View
RepositoriesView.new=&Repository Location...
RepositoriesView.newSubmenu=&New
-RepositoriesView.Show_Folders_6=Show Folders
-RepositoriesView.Show_Modules_7=Show Modules
RepositoriesView.newAnonCVS=&Anonymous Repository Location to dev.eclipse.org...
+RepositoriesView.newWorkingSet=Select Working Set...
+RepositoriesView.deselectWorkingSet=Deselect Working Set
+RepositoriesView.editWorkingSet=Edit Active Working Set...
+RepositoriesView.workingSetMenuItem={0} {1}
ResourcePropertiesPage.status=Status
ResourcePropertiesPage.notManaged=Not managed by CVS
@@ -713,8 +715,6 @@ GroupedByVersionCategory.Versions_1=Versions
VersionCategory.Versions_1=Versions
HistoryView.[...]_4=[...]
-RepositoryManager.refreshDefinedTags=Refreshing defined tags
-
CVSProjectPropertiesPage.Select_a_Repository_1=Select a Repository
CVSProjectPropertiesPage.Select_a_CVS_repository_location_to_share_the_project_with__2=Select a compatible CVS repository location to share the project with:
CVSProjectPropertiesPage.Change_Sharing_5=&Change Sharing...
@@ -793,3 +793,25 @@ RestoreFromRepositoryFileSelectionPage.fileExists=File ''{0}'' already exists lo
RestoreFromRepositoryAction.noFilesTitle=No Deleted Files Found
RestoreFromRepositoryAction.noFilesMessage=There were no deleted files found on the repository in folder ''{0}''.
+RepositoryRoot.folderInfoMissing=Local folder ''{0}'' is not properly mapped to a remote folder.
+
+RepositoriesViewContentHandler.unmatchedTag=No matching end tag found for tag ''{0}'' while reading repositories View configuration file.
+RepositoriesViewContentHandler.missingAttribute=Required attribute ''{1}'' missing from tag ''{0}'' while reading repositories View configuration file.
+RepositoriesViewContentHandler.errorCreatingRoot=An error occured trying to create repository ''{0}''.
+
+CVSWorkingSetFolderSelectionPage.projectSelectionPageTitle=CVS Working Set
+CVSWorkingSetFolderSelectionPage.projectSelectionPageDescription=Enter a working set name and select the working set folders.
+CVSWorkingSetFolderSelectionPage.name=&Working set name:
+CVSWorkingSetFolderSelectionPage.treeLabel=Working &set contents:
+CVSWorkingSetFolderSelectionPage.refresh=&Refresh Contents
+CVSWorkingSetFolderSelectionPage.invalidWorkingSetName=The name must contain only letters and digits.
+CVSWorkingSetFolderSelectionPage.duplicateWorkingSetName=A working set of the specific name already exists.
+CVSWorkingSetFolderSelectionPage.mustSelectFolder=At least one folder must be checked.
+
+WorkingSetSelectionDialog.title= Select CVS Working Set
+WorkingSetSelectionDialog.title.multiSelect= Select CVS Working Sets
+WorkingSetSelectionDialog.message= &Select a CVS working set:
+WorkingSetSelectionDialog.message.multiSelect= &Select CVS working sets:
+WorkingSetSelectionDialog.detailsButton.label= &Edit...
+WorkingSetSelectionDialog.newButton.label= &New...
+WorkingSetSelectionDialog.removeButton.label= &Remove \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java
index 4eb6b2cc6..05a05e6b6 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java
@@ -11,9 +11,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.ui.model.IWorkbenchAdapter;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
index 03e4c83d5..589db2fb3 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java
@@ -39,6 +39,8 @@ public class RemoteContentProvider extends WorkbenchContentProvider {
}
} else if(element instanceof VersionCategory) {
return true;
+ } else if(element instanceof BranchCategory) {
+ return true;
} else if(element instanceof CVSTagElement) {
return true;
} else if(element instanceof RemoteModule) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java
index 312cbea95..1942ea3d4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java
@@ -314,7 +314,7 @@ public class CVSRepositoryPropertiesPage extends PropertyPage {
true,
DetailsDialogWithProjects.DLG_IMG_WARNING);
int r = dialog.open();
- if (r != dialog.OK) {
+ if (r != DetailsDialogWithProjects.OK) {
result[0] = false;
return;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSet.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSet.java
index fe3a25027..be36c1ebf 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSet.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSet.java
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -27,7 +28,7 @@ import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.XMLWriter;
-public class CVSWorkingSet {
+public class CVSWorkingSet implements Cloneable {
private String name;
// Map of ICVSRepositoryLocation -> Set (String folder paths that are repository relative)
Map remotePaths = new HashMap();
@@ -168,4 +169,38 @@ public class CVSWorkingSet {
set.add(currentRemotePath);
}
+ protected Object clone() {
+ CVSWorkingSet copy = new CVSWorkingSet(getName());
+ for (Iterator iter = remotePaths.keySet().iterator(); iter.hasNext();) {
+ ICVSRepositoryLocation key = (ICVSRepositoryLocation) iter.next();
+ Set value = (Set)remotePaths.get(key);
+ for (Iterator iterator = value.iterator(); iterator.hasNext();) {
+ String element = (String) iterator.next();
+ copy.addRemotePath(key, element);
+ }
+ }
+ return copy;
+ }
+
+ protected void mutate(CVSWorkingSet set) {
+ name = set.getName();
+ remotePaths = new HashMap();
+ ICVSRepositoryLocation[] locations = set.getRepositoryLocations();
+ for (int i = 0; i < locations.length; i++) {
+ ICVSRepositoryLocation key = locations[i];
+ String[] paths = set.getRemotePaths(key);
+ for (int j = 0; j < paths.length; j++) {
+ String path = paths[j];
+ addRemotePath(key, path);
+ }
+ }
+ }
+
+ public boolean equals(CVSWorkingSet set) {
+ if (!set.getName().equals(getName())) return false;
+ // XXX Not sure if the below works
+ if (!set.remotePaths.equals(remotePaths)) return false;
+ return true;
+ }
+
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetFolderSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetFolderSelectionPage.java
index a9a8f94db..7096f0df0 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetFolderSelectionPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetFolderSelectionPage.java
@@ -21,6 +21,7 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
@@ -62,8 +63,10 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
private String workingSetName;
+ private String originalWorkingSetName;
private Set checkedFolders;
private Map modulesCategoryCache = new HashMap();
+ private boolean editing = false;
private Text nameField;
private CheckboxTreeViewer tree;
@@ -73,6 +76,7 @@ public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
public CVSWorkingSetFolderSelectionPage(String pageName, String title, ImageDescriptor titleImage, String description) {
super(pageName, title, titleImage, description);
checkedFolders = new HashSet();
+ workingSetName = "";
}
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
@@ -106,11 +110,7 @@ public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
// Ignore
}
public void treeExpanded(TreeExpansionEvent event) {
- Object element = event.getElement();
- if (element instanceof ICVSRepositoryLocation) {
- ICVSRepositoryLocation location = (ICVSRepositoryLocation) element;
- tree.setGrayed(CVSWorkingSetFolderSelectionPage.this.getModuleCategory(location), true);
- }
+ CVSWorkingSetFolderSelectionPage.this.handleExpansion(event.getElement());
}
});
@@ -131,6 +131,17 @@ public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
updateWidgetEnablements();
nameField.setFocus();
}
+ /**
+ * Method handleExpansion.
+ * @param object
+ */
+ public void handleExpansion(Object element) {
+ if (element instanceof ICVSRepositoryLocation) {
+ ICVSRepositoryLocation location = (ICVSRepositoryLocation) element;
+ tree.setGrayed(CVSWorkingSetFolderSelectionPage.this.getModuleCategory(location), true);
+ }
+ updateCheckState(element);
+ }
/**
* Method handleChecked.
@@ -248,7 +259,7 @@ public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
* Method initializeValues.
*/
private void initializeValues() {
- workingSetName = "";
+ nameField.setText(workingSetName);
tree.setGrayedElements(getRepositoryManager().getKnownRepositoryLocations());
}
@@ -259,33 +270,48 @@ public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
// update the check state of repository locations and modules categories
tree.removeCheckStateListener(checkStateListener);
try {
- updateCheckState();
+ updateCheckState(null);
// Make sure the name is valid
- if (!isValidName(workingSetName)) {
+ if (workingSetName.length() == 0) {
+ setPageComplete(false);
+ setErrorMessage(null);
+ } else if (!isValidName(workingSetName)) {
setPageComplete(false);
setErrorMessage(Policy.bind("CVSWorkingSetFolderSelectionPage.invalidWorkingSetName", workingSetName)); //$NON-NLS-1$
+ } else if (isDuplicateName(workingSetName)) {
+ setPageComplete(false);
+ setErrorMessage(Policy.bind("CVSWorkingSetFolderSelectionPage.duplicateWorkingSetName", workingSetName)); //$NON-NLS-1$
+ } else if (checkedFolders.isEmpty()) {
+ setErrorMessage(Policy.bind("CVSWorkingSetFolderSelectionPage.mustSelectFolder")); //$NON-NLS-1$
+ setPageComplete(false);
} else {
+ setPageComplete(true);
setErrorMessage(null);
}
- // The page is complete when a least one folder is checked
- boolean complete = ! checkedFolders.isEmpty();
- setPageComplete(complete);
} finally {
tree.addCheckStateListener(checkStateListener);
}
}
- private void updateCheckState() {
+ private void updateCheckState(Object expanded) {
ICVSRepositoryLocation[] locations = getRepositoryManager().getKnownRepositoryLocations();
Set checkedLocations = new HashSet();
Set checkedCategories = new HashSet();
+ List expandedParents = new ArrayList();
+ expandedParents.addAll(Arrays.asList(tree.getExpandedElements()));
+ if (expanded != null)
+ expandedParents.add(expanded);
for (Iterator iter = checkedFolders.iterator(); iter.hasNext();) {
ICVSRemoteFolder folder = (ICVSRemoteFolder) iter.next();
checkedLocations.add(folder.getRepository());
if (folder.isDefinedModule()) {
+ ModulesCategory category = getModuleCategory(folder.getRepository());
checkedCategories.add(getModuleCategory(folder.getRepository()));
+ if (expandedParents.contains(category))
+ tree.setChecked(folder, true);
+ } else if (expandedParents.contains(folder.getRepository())) {
+ tree.setChecked(folder, true);
}
- tree.setChecked(folder, true);
}
for (int i = 0; i < locations.length; i++) {
ICVSRepositoryLocation location = locations[i];
@@ -293,7 +319,8 @@ public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
}
for (Iterator iter = modulesCategoryCache.values().iterator(); iter.hasNext();) {
ModulesCategory element = (ModulesCategory) iter.next();
- tree.setChecked(element, checkedCategories.contains(element));
+ if (expandedParents.contains(element.getRepository()))
+ tree.setChecked(element, checkedCategories.contains(element));
}
}
@@ -313,6 +340,25 @@ public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
return true;
}
+ /**
+ * Method isDuplicateName.
+ * @param workingSetName
+ * @return boolean
+ */
+ private boolean isDuplicateName(String workingSetName) {
+ if (originalWorkingSetName != null && workingSetName.equals(originalWorkingSetName)) {
+ return false;
+ }
+ String names[] = CVSUIPlugin.getPlugin().getRepositoryManager().getWorkingSetNames();
+ for (int i = 0; i < names.length; i++) {
+ String string = names[i];
+ if (workingSetName.equals(string)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
protected CheckboxTreeViewer createFolderSelectionTree(Composite composite, int span) {
CheckboxTreeViewer tree = new CheckboxTreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
tree.setUseHashlookup(true);
@@ -399,5 +445,30 @@ public class CVSWorkingSetFolderSelectionPage extends CVSWizardPage {
public ICVSRemoteFolder[] getSelectedFolders() {
return (ICVSRemoteFolder[]) checkedFolders.toArray(new ICVSRemoteFolder[checkedFolders.size()]);
}
+
+ /**
+ * Method setOriginalWorkingSet.
+ * @param editedSet
+ */
+ public void setOriginalWorkingSet(final CVSWorkingSet editedSet) {
+ if (editedSet == null) return;
+ originalWorkingSetName = editedSet.getName();
+ workingSetName = editedSet.getName();
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ ICVSRemoteFolder[] folders = editedSet.getFolders(monitor);
+ checkedFolders.addAll(Arrays.asList(folders));
+ } catch (CVSException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ CVSUIPlugin.openError(null, null, null , e, CVSUIPlugin.PERFORM_SYNC_EXEC);
+ } catch (InterruptedException e) {
+ }
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetWizard.java
index 4c94be3bd..f32b9c1ae 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSWorkingSetWizard.java
@@ -28,8 +28,23 @@ import org.eclipse.team.internal.ccvs.ui.Policy;
public class CVSWorkingSetWizard extends Wizard {
private CVSWorkingSetFolderSelectionPage folderSelectionPage;
+
+ private CVSWorkingSet selection;
+ private CVSWorkingSet editedSet;
/**
+ * Constructor for CVSWorkingSetWizard.
+ */
+ public CVSWorkingSetWizard() {
+ super();
+ }
+
+ public CVSWorkingSetWizard(CVSWorkingSet editedSet) {
+ super();
+ this.editedSet = editedSet;
+ }
+
+ /**
* @see org.eclipse.jface.wizard.IWizard#addPages()
*/
public void addPages() {
@@ -40,6 +55,7 @@ public class CVSWorkingSetWizard extends Wizard {
Policy.bind("CVSWorkingSetFolderSelectionPage.projectSelectionPageTitle"), //$NON-NLS-1$
substImage,
Policy.bind("CVSWorkingSetFolderSelectionPage.projectSelectionPageDescription")); //$NON-NLS-1$
+ folderSelectionPage.setOriginalWorkingSet(editedSet);
addPage(folderSelectionPage);
}
@@ -51,7 +67,11 @@ public class CVSWorkingSetWizard extends Wizard {
RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
CVSWorkingSet set = new CVSWorkingSet(folderSelectionPage.getWorkingSetName());
set.setFolders(folderSelectionPage.getSelectedFolders());
- manager.addWorkingSet(set);
+ selection = set;
+ if (editedSet != null) {
+ editedSet.mutate(set);
+ selection = editedSet;
+ }
return true;
} catch (CVSException e) {
CVSUIPlugin.openError(getShell(), null, null, e, CVSUIPlugin.PERFORM_SYNC_EXEC);
@@ -59,4 +79,12 @@ public class CVSWorkingSetWizard extends Wizard {
return false;
}
+ /**
+ * Method getSelection.
+ * @return CVSWorkingSet
+ */
+ public CVSWorkingSet getSelection() {
+ return selection;
+ }
+
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AutoRefreshMembership.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java
index 9f1b0a2b0..bb9a10efd 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/AutoRefreshMembership.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshTagsAction.java
@@ -1,13 +1,3 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM - Initial implementation
- ******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.repo;
import java.lang.reflect.InvocationTargetException;
@@ -22,34 +12,46 @@ import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.actions.CVSAction;
-import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
/**
- * For each child of the selected tag, refresh the known tags using the auto-refresh files
+ * @author Administrator
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
*/
-public class AutoRefreshMembership extends CVSAction {
+public class RefreshTagsAction extends CVSAction {
/**
* @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
*/
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
- // XXX this method only removes. It never adds
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- CVSTagElement[] tags = getSelectedTags();
+ ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations();
RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
try {
- ICVSRemoteResource[] resources = manager.getFoldersForTag(tags[0].getRoot(), tags[0].getTag(), Policy.monitorFor(null));
- monitor.beginTask(null, 100 * resources.length);
- for (int i = 0; i < resources.length; i++) {
- ICVSRemoteResource resource = resources[i];
- if (resource instanceof ICVSFolder) {
- manager.refreshDefinedTags((ICVSFolder)resource, true /* replace */, true, Policy.subMonitorFor(monitor, 100));
+ monitor.beginTask(null, 100 * locations.length);
+ for (int j = 0; j < locations.length; j++) {
+ ICVSRepositoryLocation location = locations[j];
+ // todo: This omits defined modules when there is no current working set
+ ICVSRemoteResource[] resources = manager.getWorkingFoldersForTag(location, CVSTag.DEFAULT, Policy.subMonitorFor(monitor, 10));
+ IProgressMonitor subMonitor = Policy.subMonitorFor(monitor, 90);
+ subMonitor.beginTask(null, 100 * resources.length);
+ for (int i = 0; i < resources.length; i++) {
+ ICVSRemoteResource resource = resources[i];
+ if (resource instanceof ICVSFolder) {
+ manager.refreshDefinedTags((ICVSFolder)resource, true /* replace */, true, Policy.subMonitorFor(subMonitor, 100));
+ }
}
+ subMonitor.done();
}
+ monitor.done();
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
@@ -61,25 +63,26 @@ public class AutoRefreshMembership extends CVSAction {
* @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
*/
protected boolean isEnabled() throws TeamException {
- CVSTagElement[] tags = getSelectedTags();
- if (tags.length != 1) return false;
- return (tags[0].getTag().getType() == CVSTag.VERSION || tags[0].getTag().getType() == CVSTag.BRANCH);
+ ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations();
+ if (locations.length == 0) return false;
+ return true;
}
/**
* Returns the selected CVS tags
*/
- protected CVSTagElement[] getSelectedTags() {
+ protected ICVSRepositoryLocation[] getSelectedRepositoryLocations() {
ArrayList tags = new ArrayList();
if (!selection.isEmpty()) {
Iterator elements = ((IStructuredSelection) selection).iterator();
while (elements.hasNext()) {
- Object adapter = getAdapter(elements.next(), CVSTagElement.class);
- if (adapter instanceof CVSTagElement) {
+ Object adapter = getAdapter(elements.next(), ICVSRepositoryLocation.class);
+ if (adapter instanceof ICVSRepositoryLocation) {
tags.add(adapter);
}
}
}
- return (CVSTagElement[])tags.toArray(new CVSTagElement[tags.size()]);
+ return (ICVSRepositoryLocation[])tags.toArray(new ICVSRepositoryLocation[tags.size()]);
}
+
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java
index f26371204..7c50b0a92 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java
@@ -16,10 +16,8 @@ import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
@@ -28,8 +26,8 @@ import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.actions.CVSAction;
import org.eclipse.team.internal.ui.DetailsDialogWithProjects;
@@ -110,13 +108,14 @@ public class RemoveRootAction extends CVSAction {
}
}
}
- }, false /* cancelable */, this.PROGRESS_BUSYCURSOR);
+ }, false /* cancelable */, PROGRESS_BUSYCURSOR);
}
/*
* @see TeamAction#isEnabled()
*/
protected boolean isEnabled() throws TeamException {
+ if (CVSUIPlugin.getPlugin().getRepositoryManager().getCurrentWorkingSet() != null) return false;
ICVSRepositoryLocation[] roots = getSelectedRemoteRoots();
return roots.length > 0;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java
index 99e6a1778..8e0a8119f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
@@ -88,7 +89,7 @@ public class RepositoriesView extends ViewPart {
public void repositoryRemoved(ICVSRepositoryLocation root) {
refresh();
}
- public void repositoryChanged(ICVSRepositoryLocation root) {
+ public void repositoriesChanged(ICVSRepositoryLocation[] roots) {
refresh();
}
public void workingSetChanged(CVSWorkingSet set) {
@@ -106,17 +107,15 @@ public class RepositoriesView extends ViewPart {
private Action newWorkingSetAction;
private Action deselectWorkingSetAction;
private Action editWorkingSetAction;
- private Action deleteWorkingSetAction;
public class ChangeWorkingSetAction extends Action {
String name;
public ChangeWorkingSetAction(String name, int index) {
- super(index + " " + name);
+ super(Policy.bind("RepositoriesView.workingSetMenuItem", new Integer(index).toString(), name));
this.name = name;
}
public void run() {
CVSUIPlugin.getPlugin().getRepositoryManager().setCurrentWorkingSet(name);
- RepositoriesView.this.refreshAll();
}
}
@@ -175,9 +174,12 @@ public class RepositoriesView extends ViewPart {
// New Working Set (popup)
newWorkingSetAction = new Action(Policy.bind("RepositoriesView.newWorkingSet")) { //$NON-NLS-1$
public void run() {
- CVSWorkingSetWizard wizard = new CVSWorkingSetWizard();
- WizardDialog dialog = new WizardDialog(shell, wizard);
+ WorkingSetSelectionDialog dialog = new WorkingSetSelectionDialog(shell, false);
dialog.open();
+ CVSWorkingSet[] sets = dialog.getSelection();
+ if (sets != null && sets.length > 0) {
+ CVSUIPlugin.getPlugin().getRepositoryManager().setCurrentWorkingSet(sets[0]);
+ }
}
};
//WorkbenchHelp.setHelp(newAction, IHelpContextIds.NEW_CVS_WORKING_SET_ACTION);
@@ -197,19 +199,14 @@ public class RepositoriesView extends ViewPart {
public void run() {
String name = null;
CVSWorkingSet set = CVSUIPlugin.getPlugin().getRepositoryManager().getCurrentWorkingSet();
- }
- };
- //WorkbenchHelp.setHelp(newAction, IHelpContextIds.NEW_CVS_WORKING_SET_ACTION);
-
- // Delete Working Set (popup)
- deleteWorkingSetAction = new Action(Policy.bind("RepositoriesView.deleteWorkingSet")) { //$NON-NLS-1$
- public void run() {
- // XXX should prompt
- CVSWorkingSet set = CVSUIPlugin.getPlugin().getRepositoryManager().getCurrentWorkingSet();
- if (set != null) {
- CVSUIPlugin.getPlugin().getRepositoryManager().removeWorkingSet(set);
+ RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
+ CVSWorkingSetWizard wizard = new CVSWorkingSetWizard(set);
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ if (dialog.open() == Window.OK) {
+ CVSWorkingSet newSet = wizard.getSelection();
+ manager.addWorkingSet(newSet);
+ manager.setCurrentWorkingSet(newSet);
}
- refreshViewer();
}
};
//WorkbenchHelp.setHelp(newAction, IHelpContextIds.NEW_CVS_WORKING_SET_ACTION);
@@ -295,8 +292,6 @@ public class RepositoriesView extends ViewPart {
deselectWorkingSetAction.setEnabled(CVSUIPlugin.getPlugin().getRepositoryManager().getCurrentWorkingSet() != null);
mgr.add(editWorkingSetAction);
editWorkingSetAction.setEnabled(CVSUIPlugin.getPlugin().getRepositoryManager().getCurrentWorkingSet() != null);
- mgr.add(deleteWorkingSetAction);
- deleteWorkingSetAction.setEnabled(CVSUIPlugin.getPlugin().getRepositoryManager().getCurrentWorkingSet() != null);
mgr.add(new Separator());
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java
index 5ea9b4544..feb88cd61 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java
@@ -18,6 +18,7 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -29,6 +30,7 @@ public class RepositoriesViewContentHandler extends DefaultHandler {
public static final String REPOSITORY_TAG = "repository"; //$NON-NLS-1$
public static final String WORKING_SET_TAG = "working-set"; //$NON-NLS-1$
+ public static final String CURRENT_WORKING_SET_TAG = "current-working-set"; //$NON-NLS-1$
public static final String MODULE_TAG = "module"; //$NON-NLS-1$
public static final String TAG_TAG = "tag"; //$NON-NLS-1$
public static final String AUTO_REFRESH_FILE_TAG = "auto-refresh-file"; //$NON-NLS-1$
@@ -155,6 +157,12 @@ public class RepositoriesViewContentHandler extends DefaultHandler {
throw new SAXException(Policy.bind("RepositoriesViewContentHandler.missingAttribute", AUTO_REFRESH_FILE_TAG, PATH_ATTRIBUTE));
}
autoRefreshFiles.add(path);
+ } else if (localName.equals(CURRENT_WORKING_SET_TAG)) {
+ String name = atts.getValue(NAME_ATTRIBUTE);
+ if (name == null) {
+ throw new SAXException(Policy.bind("RepositoriesViewContentHandler.missingAttribute", CURRENT_WORKING_SET_TAG, NAME_ATTRIBUTE));
+ }
+ CVSUIPlugin.getPlugin().getRepositoryManager().setCurrentWorkingSet(name);
}
// empty buffer
buffer = new StringBuffer();
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java
index bfbf9934b..b98f8f362 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java
@@ -72,8 +72,8 @@ public class RepositoryManager {
private static final String REPOSITORIES_VIEW_FILE = "repositoriesView.xml"; //$NON-NLS-1$
private Map repositoryRoots = new HashMap();
- private Map workingSets = new HashMap();
- private CVSWorkingSet currentWorkingSet;
+ private List workingSets = new ArrayList();
+ private String currentWorkingSet;
List listeners = new ArrayList();
@@ -82,6 +82,10 @@ public class RepositoryManager {
public static boolean notifyRepoView = true;
+ // Cache of changed repository roots
+ private int notificationLevel = 0;
+ private Map changedRepositories = new HashMap();
+
/**
* Answer an array of all known remote roots.
*/
@@ -377,11 +381,17 @@ public class RepositoryManager {
RepositoryRoot root = getRepositoryRootFor(location);
root.writeState(writer);
}
- it = workingSets.values().iterator();
+ it = workingSets.iterator();
while (it.hasNext()) {
CVSWorkingSet workingSet = (CVSWorkingSet)it.next();
workingSet.writeState(writer);
}
+ if (getCurrentWorkingSet() != null) {
+ HashMap attributes = new HashMap();
+ attributes.clear();
+ attributes.put(RepositoriesViewContentHandler.NAME_ATTRIBUTE, getCurrentWorkingSet().getName());
+ writer.startAndEndTag(RepositoriesViewContentHandler.CURRENT_WORKING_SET_TAG, attributes, true);
+ }
writer.endTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG);
}
@@ -391,7 +401,7 @@ public class RepositoryManager {
try {
parser.parse(new InputSource(stream));
} catch (SAXException ex) {
- throw new CVSException(Policy.bind("RepositoryManager.parsingProblem"), ex); //$NON-NLS-1$
+ throw new CVSException(Policy.bind("RepositoryManager.parsingProblem", REPOSITORIES_VIEW_FILE), ex); //$NON-NLS-1$
}
}
@@ -661,10 +671,18 @@ public class RepositoryManager {
}
private void broadcastRepositoryChange(RepositoryRoot root) {
+ if (notificationLevel == 0) {
+ broadcastRepositoriesChanged(new ICVSRepositoryLocation[] {root.getRoot()});
+ } else {
+ changedRepositories.put(root.getRoot().getLocation(), root.getRoot());
+ }
+ }
+
+ private void broadcastRepositoriesChanged(ICVSRepositoryLocation[] roots) {
Iterator it = listeners.iterator();
while (it.hasNext()) {
IRepositoryListener listener = (IRepositoryListener)it.next();
- listener.repositoryChanged(root.getRoot());
+ listener.repositoriesChanged(roots);
}
}
@@ -680,7 +698,20 @@ public class RepositoryManager {
* Run the given runnable, waiting until the end to perform a refresh
* * @param runnable * @param monitor */
public void run(IRunnableWithProgress runnable, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- runnable.run(monitor);
+ try {
+ notificationLevel++;
+ runnable.run(monitor);
+ } finally {
+ notificationLevel = Math.max(0, notificationLevel - 1);
+ if (notificationLevel == 0) {
+ try {
+ Collection roots = changedRepositories.values();
+ broadcastRepositoriesChanged((ICVSRepositoryLocation[]) roots.toArray(new ICVSRepositoryLocation[roots.size()]));
+ } finally {
+ changedRepositories.clear();
+ }
+ }
+ }
}
/**
@@ -697,8 +728,13 @@ public class RepositoryManager {
* @param set
*/
public void addWorkingSet(CVSWorkingSet set) {
- workingSets.put(set.getName(), set);
- setCurrentWorkingSet(set.getName());
+ CVSWorkingSet oldSet = getWorkingSet(set.getName());
+ if (oldSet != null) {
+ removeWorkingSet(oldSet);
+ }
+ if (!workingSets.contains(set)) {
+ workingSets.add(set);
+ }
broadcastWorkingSetChange(set);
}
@@ -707,8 +743,8 @@ public class RepositoryManager {
* @param set
*/
public void removeWorkingSet(CVSWorkingSet set) {
- workingSets.remove(set.getName());
- if (currentWorkingSet == set)
+ workingSets.remove(set);
+ if (currentWorkingSet.equals(set.getName()))
currentWorkingSet = null;
broadcastWorkingSetChange(set);
}
@@ -718,14 +754,32 @@ public class RepositoryManager {
* @param string
*/
public void setCurrentWorkingSet(String string) {
- setCurrentWorkingSet((CVSWorkingSet)workingSets.get(string));
+ this.currentWorkingSet = string;
+ CVSWorkingSet current = getCurrentWorkingSet();
+ if (current != null)
+ broadcastWorkingSetChange(current);
+ }
+
+ /**
+ * Method getWorkingSet.
+ * @param string
+ * @return String
+ */
+ public CVSWorkingSet getWorkingSet(String string) {
+ if (string == null) return null;
+ for (Iterator iter = workingSets.iterator(); iter.hasNext();) {
+ CVSWorkingSet workingSet = (CVSWorkingSet) iter.next();
+ if (workingSet.getName().equals(string))
+ return workingSet;
+ }
+ return null;
}
/**
* Returns the currentWorkingSet.
* @return CVSWorkingSet
*/
public CVSWorkingSet getCurrentWorkingSet() {
- return currentWorkingSet;
+ return getWorkingSet(currentWorkingSet);
}
/**
@@ -733,8 +787,7 @@ public class RepositoryManager {
* @param currentWorkingSet The currentWorkingSet to set
*/
public void setCurrentWorkingSet(CVSWorkingSet currentWorkingSet) {
- this.currentWorkingSet = currentWorkingSet;
- broadcastWorkingSetChange(currentWorkingSet);
+ setCurrentWorkingSet(currentWorkingSet.getName());
}
/**
@@ -742,10 +795,11 @@ public class RepositoryManager {
* @return Object[]
*/
public RepositoryRoot[] getWorkingRepositoryRoots() {
- if (currentWorkingSet == null) {
+ CVSWorkingSet current = getWorkingSet(currentWorkingSet);
+ if (current == null) {
return getKnownRepositoryRoots();
} else {
- return getRepositoryRoots(currentWorkingSet.getRepositoryLocations());
+ return getRepositoryRoots(current.getRepositoryLocations());
}
}
@@ -757,13 +811,14 @@ public class RepositoryManager {
* @return Object[]
*/
public ICVSRemoteResource[] getWorkingFoldersForTag(ICVSRepositoryLocation root, CVSTag tag, IProgressMonitor monitor) throws CVSException {
- if (currentWorkingSet == null) {
+ CVSWorkingSet current = getCurrentWorkingSet();
+ if (current == null) {
return getFoldersForTag(root, tag, monitor);
} else {
if (CVSTag.DEFAULT.equals(tag) || tag == null) {
- return currentWorkingSet.getFoldersForTag(root, tag, monitor);
+ return current.getFoldersForTag(root, tag, monitor);
} else {
- return getRepositoryRootFor(root).filterResources(currentWorkingSet.getFoldersForTag(root, tag, monitor));
+ return getRepositoryRootFor(root).filterResources(current.getFoldersForTag(root, tag, monitor));
}
}
}
@@ -775,11 +830,12 @@ public class RepositoryManager {
* @return CVSTag[]
*/
public CVSTag[] getWorkingTags(ICVSRepositoryLocation repository, int tagType, IProgressMonitor monitor) throws CVSException {
- if (currentWorkingSet == null) {
+ CVSWorkingSet current = getCurrentWorkingSet();
+ if (current == null) {
return getKnownTags(repository, tagType);
} else {
Set tags = new HashSet();
- ICVSRemoteFolder[] folders = currentWorkingSet.getFoldersForTag(repository, CVSTag.DEFAULT, monitor);
+ ICVSRemoteFolder[] folders = current.getFoldersForTag(repository, CVSTag.DEFAULT, monitor);
for (int i = 0; i < folders.length; i++) {
ICVSRemoteFolder folder = folders[i];
tags.addAll(Arrays.asList(getKnownTags(folder, tagType)));
@@ -789,11 +845,23 @@ public class RepositoryManager {
}
public String[] getWorkingSetNames() {
- Set names = workingSets.keySet();
+ Set names = new HashSet();
+ for (Iterator iter = workingSets.iterator(); iter.hasNext();) {
+ CVSWorkingSet workingSet = (CVSWorkingSet) iter.next();
+ names.add(workingSet.getName());
+ }
return (String[]) names.toArray(new String[names.size()]);
}
/**
+ * Method getWorkingSets.
+ * @return Object[]
+ */
+ CVSWorkingSet[] getWorkingSets() {
+ return (CVSWorkingSet[]) workingSets.toArray(new CVSWorkingSet[workingSets.size()]);
+ }
+
+ /**
* This method is invoked whenever the refresh button in the
* RepositoriesView is pressed.
*/
@@ -803,5 +871,4 @@ public class RepositoryManager {
root.clearCache();
}
}
-
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java
index 7efb00949..0f1d2ce1b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositorySorter.java
@@ -11,7 +11,9 @@ import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
+import org.eclipse.team.internal.ccvs.ui.model.VersionCategory;
public class RepositorySorter extends ViewerSorter {
public int category(Object element) {
@@ -33,6 +35,12 @@ public class RepositorySorter extends ViewerSorter {
return 6;
}
}
+ if (element instanceof BranchCategory) {
+ return 4;
+ }
+ if (element instanceof VersionCategory) {
+ return 5;
+ }
return 0;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/WorkingSetSelectionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/WorkingSetSelectionDialog.java
new file mode 100644
index 000000000..b1de4556d
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/WorkingSetSelectionDialog.java
@@ -0,0 +1,433 @@
+package org.eclipse.team.internal.ccvs.ui.repo;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.model.WorkbenchViewerSorter;
+
+/**
+ * @author Administrator
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class WorkingSetSelectionDialog extends SelectionDialog {
+ private final static int SIZING_SELECTION_WIDGET_HEIGHT = 200;
+ private final static int SIZING_SELECTION_WIDGET_WIDTH = 50;
+
+ private static class WorkingSetLabelProvider extends LabelProvider {
+ private Map icons;
+
+ public WorkingSetLabelProvider() {
+ icons = new Hashtable();
+ }
+ public void dispose() {
+ Iterator iterator = icons.values().iterator();
+
+ while (iterator.hasNext()) {
+ Image icon = (Image) iterator.next();
+ icon.dispose();
+ }
+ super.dispose();
+ }
+ public Image getImage(Object workingSet) {
+ return null;
+ }
+ public String getText(Object workingSet) {
+ return ((CVSWorkingSet) workingSet).getName();
+ }
+ }
+
+ public class ListContentProvider implements IStructuredContentProvider {
+ List fContents;
+
+ public ListContentProvider() {
+ }
+
+ public Object[] getElements(Object input) {
+ if (fContents != null && fContents == input)
+ return fContents.toArray();
+ return new Object[0];
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (newInput instanceof List)
+ fContents= (List)newInput;
+ else
+ fContents= null;
+ // we use a fixed set.
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isDeleted(Object o) {
+ return fContents != null && !fContents.contains(o);
+ }
+ }
+
+ private ILabelProvider labelProvider;
+ private IStructuredContentProvider contentProvider;
+ private TableViewer listViewer;
+ private Button newButton;
+ private Button detailsButton;
+ private Button removeButton;
+ private CVSWorkingSet[] result;
+ private boolean multiSelect;
+ private List addedWorkingSets;
+ private List removedWorkingSets;
+ private Map editedWorkingSets;
+
+ /**
+ * Creates a working set selection dialog.
+ *
+ * @param parentShell the parent shell
+ * @param multi true=more than one working set can be chosen
+ * in the dialog. false=only one working set can be chosen. Multiple
+ * working sets can still be selected and removed from the list but
+ * the dialog can only be closed when a single working set is selected.
+ */
+ public WorkingSetSelectionDialog(Shell parentShell, boolean multi) {
+ super(parentShell);
+ contentProvider = new ListContentProvider();
+ labelProvider = new WorkingSetLabelProvider();
+ multiSelect = multi;
+ if (multiSelect) {
+ setTitle(Policy.bind("WorkingSetSelectionDialog.title.multiSelect")); //$NON-NLS-1$;
+ setMessage(Policy.bind("WorkingSetSelectionDialog.message.multiSelect")); //$NON-NLS-1$
+ }
+ else {
+ setTitle(Policy.bind("WorkingSetSelectionDialog.title")); //$NON-NLS-1$;
+ setMessage(Policy.bind("WorkingSetSelectionDialog.message")); //$NON-NLS-1$
+ }
+ }
+ /**
+ * Adds the modify buttons to the dialog.
+ *
+ * @param composite Composite to add the buttons to
+ */
+ private void addModifyButtons(Composite composite) {
+ Composite buttonComposite = new Composite(composite, SWT.RIGHT);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ buttonComposite.setLayout(layout);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
+ data.grabExcessHorizontalSpace = true;
+ composite.setData(data);
+
+ int id = IDialogConstants.CLIENT_ID + 1;
+ newButton = createButton(buttonComposite, id++, Policy.bind("WorkingSetSelectionDialog.newButton.label"), false); //$NON-NLS-1$
+ newButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ createWorkingSet();
+ }
+ });
+
+ detailsButton = createButton(buttonComposite, id++, Policy.bind("WorkingSetSelectionDialog.detailsButton.label"), false); //$NON-NLS-1$
+ detailsButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ editSelectedWorkingSet();
+ }
+ });
+
+ removeButton = createButton(buttonComposite, id++, Policy.bind("WorkingSetSelectionDialog.removeButton.label"), false); //$NON-NLS-1$
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ removeSelectedWorkingSets();
+ }
+ });
+ }
+ /**
+ * Overrides method from Dialog.
+ *
+ * @see Dialog#cancelPressed()
+ */
+ protected void cancelPressed() {
+ restoreAddedWorkingSets();
+ restoreChangedWorkingSets();
+ restoreRemovedWorkingSets();
+ super.cancelPressed();
+ }
+ /**
+ * Overrides method from Window.
+ *
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+// todo
+// WorkbenchHelp.setHelp(shell, IHelpContextIds.WORKING_SET_SELECTION_DIALOG);
+ }
+ /**
+ * Overrides method from Dialog.
+ * Create the dialog widgets.
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ createMessageArea(composite);
+ listViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+ data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
+ listViewer.getTable().setLayoutData(data);
+
+ listViewer.setLabelProvider(labelProvider);
+ listViewer.setContentProvider(contentProvider);
+ listViewer.setSorter(new WorkbenchViewerSorter());
+ listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleSelectionChanged();
+ }
+ });
+ listViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+ });
+ addModifyButtons(composite);
+ listViewer.setInput(Arrays.asList(CVSUIPlugin.getPlugin().getRepositoryManager().getWorkingSets()));
+
+ return composite;
+ }
+ /**
+ * Overrides method from Dialog.
+ * Sets the initial selection, if any.
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+ Control control = super.createContents(parent);
+ List selections = getInitialElementSelections();
+ if (!selections.isEmpty()) {
+ listViewer.setSelection(new StructuredSelection(selections), true);
+ }
+ updateButtonAvailability();
+
+ return control;
+ }
+ /**
+ * Opens a working set wizard for creating a new working set.
+ */
+ private void createWorkingSet() {
+ CVSWorkingSetWizard wizard = new CVSWorkingSetWizard();
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ dialog.create();
+// WorkbenchHelp.setHelp(dialog.getShell(), IHelpContextIds.WORKING_SET_NEW_WIZARD);
+ if (dialog.open() == Window.OK) {
+ RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
+ CVSWorkingSet workingSet = wizard.getSelection();
+
+ listViewer.add(workingSet);
+ listViewer.setSelection(new StructuredSelection(workingSet), true);
+ manager.addWorkingSet(workingSet);
+ addedWorkingSets.add(workingSet);
+ }
+ }
+ /**
+ * Opens a working set wizard for editing the currently selected
+ * working set.
+ *
+ * @see org.eclipse.ui.IWorkingSetPage
+ */
+ private void editSelectedWorkingSet() {
+ RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
+ CVSWorkingSet editWorkingSet = (CVSWorkingSet) getSelectedWorkingSets().get(0);
+ CVSWorkingSetWizard wizard = new CVSWorkingSetWizard(editWorkingSet);
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ CVSWorkingSet originalWorkingSet = (CVSWorkingSet) editedWorkingSets.get(editWorkingSet);
+ boolean firstEdit = originalWorkingSet == null;
+
+ // save the original working set values for restoration when selection
+ // dialog is cancelled.
+ if (firstEdit) {
+ originalWorkingSet = (CVSWorkingSet)editWorkingSet.clone();
+ }
+ else {
+ editedWorkingSets.remove(editWorkingSet);
+ }
+ dialog.create();
+// WorkbenchHelp.setHelp(dialog.getShell(), IHelpContextIds.WORKING_SET_EDIT_WIZARD);
+ if (dialog.open() == Window.OK) {
+ editWorkingSet = (CVSWorkingSet) wizard.getSelection();
+ listViewer.update(editWorkingSet, null);
+ }
+ editedWorkingSets.put(editWorkingSet, originalWorkingSet);
+ }
+ /**
+ * Implements IWorkingSetSelectionDialog.
+ *
+ * @see org.eclipse.ui.dialogs.IWorkingSetSelectionDialog#getSelection()
+ */
+ public CVSWorkingSet[] getSelection() {
+ return result;
+ }
+ /**
+ * Returns the selected working sets.
+ *
+ * @return the selected working sets
+ */
+ private List getSelectedWorkingSets() {
+ ISelection selection = listViewer.getSelection();
+ if (selection instanceof IStructuredSelection)
+ return ((IStructuredSelection) selection).toList();
+ return null;
+ }
+ /**
+ * Called when the selection has changed.
+ */
+ private void handleSelectionChanged() {
+ updateButtonAvailability();
+ }
+ /**
+ * Sets the selected working sets as the dialog result.
+ * Overrides method from Dialog
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+ List newResult = getSelectedWorkingSets();
+
+ result = (CVSWorkingSet[]) newResult.toArray(new CVSWorkingSet[newResult.size()]);
+ setResult(newResult);
+ super.okPressed();
+ }
+ /**
+ * Overrides method in Dialog
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#open()
+ */
+ public int open() {
+ addedWorkingSets = new ArrayList();
+ removedWorkingSets = new ArrayList();
+ editedWorkingSets = new HashMap();
+ return super.open();
+ }
+ /**
+ * Removes the selected working sets from the workbench.
+ */
+ private void removeSelectedWorkingSets() {
+ ISelection selection = listViewer.getSelection();
+
+ if (selection instanceof IStructuredSelection) {
+ RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
+ Iterator iter = ((IStructuredSelection) selection).iterator();
+ while (iter.hasNext()) {
+ CVSWorkingSet workingSet = (CVSWorkingSet) iter.next();
+ manager.removeWorkingSet(workingSet);
+ if (addedWorkingSets.contains(workingSet)) {
+ addedWorkingSets.remove(workingSet);
+ }
+ else {
+ removedWorkingSets.add(workingSet);
+ }
+ }
+ listViewer.remove(((IStructuredSelection) selection).toArray());
+ }
+ }
+ /**
+ * Removes newly created working sets from the working set manager.
+ */
+ private void restoreAddedWorkingSets() {
+ RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
+ Iterator iterator = addedWorkingSets.iterator();
+
+ while (iterator.hasNext()) {
+ manager.removeWorkingSet(((CVSWorkingSet) iterator.next()));
+ }
+ }
+ /**
+ * Rolls back changes to working sets.
+ */
+ private void restoreChangedWorkingSets() {
+ Iterator iterator = editedWorkingSets.keySet().iterator();
+
+ while (iterator.hasNext()) {
+ CVSWorkingSet editedWorkingSet = (CVSWorkingSet) iterator.next();
+ CVSWorkingSet originalWorkingSet = (CVSWorkingSet) editedWorkingSets.get(editedWorkingSet);
+
+ if (editedWorkingSet.getName().equals(originalWorkingSet.getName()) == false) {
+ editedWorkingSet.setName(originalWorkingSet.getName());
+ }
+ if (!editedWorkingSet.equals(originalWorkingSet)) {
+ editedWorkingSet.mutate(originalWorkingSet);
+ }
+ }
+ }
+
+ /**
+ * Adds back removed working sets to the working set manager.
+ */
+ private void restoreRemovedWorkingSets() {
+ RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
+ Iterator iterator = removedWorkingSets.iterator();
+
+ while (iterator.hasNext()) {
+ manager.addWorkingSet(((CVSWorkingSet) iterator.next()));
+ }
+ }
+ /**
+ * Implements IWorkingSetSelectionDialog.
+ *
+ * @see org.eclipse.ui.dialogs.IWorkingSetSelectionDialog#setSelection(IWorkingSet[])
+ */
+ public void setSelection(CVSWorkingSet[] workingSets) {
+ result = workingSets;
+ setInitialSelections(workingSets);
+ }
+ /**
+ * Updates the modify buttons' enabled state based on the
+ * current seleciton.
+ */
+ private void updateButtonAvailability() {
+ ISelection selection = listViewer.getSelection();
+ boolean hasSelection = selection != null && !selection.isEmpty();
+ boolean hasSingleSelection = hasSelection;
+
+ removeButton.setEnabled(hasSelection);
+ if (hasSelection && selection instanceof IStructuredSelection) {
+ hasSingleSelection = ((IStructuredSelection) selection).size() == 1;
+ }
+ detailsButton.setEnabled(hasSingleSelection);
+ if (multiSelect == false) {
+ getOkButton().setEnabled(hasSelection == false || hasSingleSelection);
+ }
+ }
+}

Back to the top