Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-05-04 12:07:24 -0400
committerMichael Valenta2004-05-04 12:07:24 -0400
commitb3aabf402b809ca18459b46f0e3d642ad492b86e (patch)
tree9eb5d52100accf837437ed01da87bade313d97f1
parente36d3cddf2c821e0ec9573e7740c802674d46504 (diff)
downloadeclipse.platform.team-b3aabf402b809ca18459b46f0e3d642ad492b86e.tar.gz
eclipse.platform.team-b3aabf402b809ca18459b46f0e3d642ad492b86e.tar.xz
eclipse.platform.team-b3aabf402b809ca18459b46f0e3d642ad492b86e.zip
49014: Need ability to do a CVS "update -r" WITHOUT -C option
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/TagSelectionWizardPage.java51
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java97
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizardPage.java143
5 files changed, 122 insertions, 184 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java
index e144fa250..5554100c9 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateAction.java
@@ -13,8 +13,8 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.jface.action.IAction;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.team.internal.ccvs.ui.wizards.UpdateWizard;
/**
* UpdateAction performs a 'cvs update' command on the selected resources.
@@ -28,8 +28,9 @@ public class UpdateAction extends WorkspaceAction {
* @see IActionDelegate#run(IAction)
*/
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
- new UpdateOperation(getTargetPart(), getSelectedResources(), Command.NO_LOCAL_OPTIONS, null /* use the tag of the resources */)
- .run();
+ UpdateWizard wizard = new UpdateWizard(getTargetPart(), getSelectedResources());
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ dialog.open();
}
/**
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 ed596fba6..0d4cd58a0 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
@@ -627,10 +627,8 @@ UpdateAction.promptForUpdateOne=Are you sure you want to update {0} resource?
UpdateAction.promptForUpdateTitle=Confirm Update
UpdateWizard.title=Update
-UpdateWizard.updatePage=Update
-
-UpdateWizardPage.description=&Select a tag to update the project sharing to:
-UpdateWizardPage.overwrite=&Overwrite local changes
+UpdateWizard.updatePage=Update Options
+UpdateWizardPage.description=Select other options for the update
UserValidationDialog.required=Password Required
UserValidationDialog.labelUser={0}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/TagSelectionWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/TagSelectionWizardPage.java
index c6a87fedf..e5a5f6a1b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/TagSelectionWizardPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/TagSelectionWizardPage.java
@@ -13,16 +13,28 @@ package org.eclipse.team.internal.ccvs.ui.wizards;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+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.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.ui.*;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.IHelpContextIds;
+import org.eclipse.team.internal.ccvs.ui.TagConfigurationDialog;
import org.eclipse.team.internal.ccvs.ui.merge.ProjectElement;
import org.eclipse.team.internal.ccvs.ui.merge.TagElement;
import org.eclipse.team.internal.ccvs.ui.merge.ProjectElement.ProjectElementSorter;
@@ -48,6 +60,12 @@ public class TagSelectionWizardPage extends CVSWizardPage {
private String label;
private int includeFlags;
+ // Fields for allowing the use of the tag from the local workspace
+ boolean allowNoTag = false;
+ private Button useResourceTagButton;
+ private Button selectTagButton;
+ private boolean useResourceTag = false;
+
public TagSelectionWizardPage(String pageName, String title, ImageDescriptor titleImage, String description, String label, int includeFlags) {
super(pageName, title, titleImage, description);
this.label = label;
@@ -64,7 +82,21 @@ public class TagSelectionWizardPage extends CVSWizardPage {
// set F1 help
WorkbenchHelp.setHelp(composite, IHelpContextIds.SHARE_WITH_EXISTING_TAG_SELETION_DIALOG);
- if (label != null) {
+ if (allowNoTag) {
+ SelectionListener listener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ useResourceTag = useResourceTagButton.getSelection();
+ updateEnablement();
+ }
+ };
+ useResourceTag = true;
+ useResourceTagButton = createRadioButton(composite, "&Use the tag currently associated with the workspace resources", 1);
+ selectTagButton = createRadioButton(composite, "&Select the tag from the following list", 1);
+ useResourceTagButton.setSelection(useResourceTag);
+ selectTagButton.setSelection(!useResourceTag);
+ useResourceTagButton.addSelectionListener(listener);
+ selectTagButton.addSelectionListener(listener);
+ } else if (label != null) {
createWrappingLabel(composite, label, 0);
}
@@ -147,7 +179,8 @@ public class TagSelectionWizardPage extends CVSWizardPage {
}
private void updateEnablement() {
- setPageComplete(selectedTag != null);
+ tagTree.getControl().setEnabled(!useResourceTag);
+ setPageComplete(useResourceTag || selectedTag != null);
}
public ICVSFolder getFolder() {
@@ -159,6 +192,8 @@ public class TagSelectionWizardPage extends CVSWizardPage {
}
public CVSTag getSelectedTag() {
+ if (useResourceTag)
+ return null;
return selectedTag;
}
@@ -170,4 +205,8 @@ public class TagSelectionWizardPage extends CVSWizardPage {
this.remoteFolders = remoteFolders;
setInput();
}
+
+ public void setAllowNoTag(boolean b) {
+ allowNoTag = b;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java
index f7b4501fa..a2a916a8b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java
@@ -12,78 +12,75 @@ package org.eclipse.team.internal.ccvs.ui.wizards;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.team.internal.ccvs.ui.*;
+import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.merge.ProjectElement;
import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation;
+import org.eclipse.ui.IWorkbenchPart;
public class UpdateWizard extends Wizard {
- UpdateWizardPage updatePage;
- IProject project;
+ private IResource[] resources;
+ private final IWorkbenchPart part;
+ private UpdateWizardPage optionsPage;
+ private TagSelectionWizardPage tagSelectionPage;
- public UpdateWizard() {
- setNeedsProgressMonitor(true);
+ public UpdateWizard(IWorkbenchPart part, IResource[] resources) {
+ this.part = part;
+ this.resources = resources;
setWindowTitle(Policy.bind("UpdateWizard.title")); //$NON-NLS-1$
}
public void addPages() {
- // Provide a progress monitor to indicate what is going on
- try {
- new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- monitor.beginTask(null, 100);
- updatePage = new UpdateWizardPage("updatePage", Policy.bind("UpdateWizard.updatePage"), CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_SHARE)); //$NON-NLS-1$ //$NON-NLS-2$
- updatePage.setProject(project);
- addPage(updatePage);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- CVSUIPlugin.log(IStatus.ERROR, Policy.bind("internal"), e.getTargetException()); //$NON-NLS-1$
- } catch (InterruptedException e) {
- // Ignore
- }
+ ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_CHECKOUT);
+
+ tagSelectionPage = new TagSelectionWizardPage("tagPage", "Select Tag", substImage, "Select the tag for the update", null /* no laqbel */, ProjectElement.INCLUDE_ALL_TAGS); //$NON-NLS-1$
+ tagSelectionPage.setAllowNoTag(true);
+ tagSelectionPage.setFolders(getCVSFolders());
+ addPage(tagSelectionPage);
+
+ optionsPage = new UpdateWizardPage("updatePage", Policy.bind("UpdateWizard.updatePage"), substImage); //$NON-NLS-1$ //$NON-NLS-2$
+ addPage(optionsPage);
}
+ private ICVSFolder[] getCVSFolders() {
+ Set projects = new HashSet();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ projects.add(resource.getProject());
+ }
+ ICVSFolder[] folders = new ICVSFolder[projects.size()];
+ int i = 0;
+ for (Iterator iter = projects.iterator(); iter.hasNext();) {
+ IProject project = (IProject) iter.next();
+ folders[i++] = CVSWorkspaceRoot.getCVSFolderFor(project);
+ }
+ return folders;
+ }
+
/*
* @see IWizard#performFinish()
*/
public boolean performFinish() {
- final boolean[] result = new boolean[] {false};
try {
- getContainer().run(false, false, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- new UpdateOperation(
- null, /* workbench part */ // TODO: Shoild have a part
- new IResource[] { project },
- updatePage.getLocalOptions(),
- updatePage.getTag())
- .run(monitor);
- result[0] = true;
- } catch (InterruptedException e) {
- // User cancelled
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InterruptedException e) {
- return true;
+ new UpdateOperation(part, resources, optionsPage.getLocalOptions(), tagSelectionPage.getSelectedTag()).run();
} catch (InvocationTargetException e) {
CVSUIPlugin.openError(getShell(), null, null, e);
+ return false;
+ } catch (InterruptedException e) {
+ return false;
}
- return result[0];
- }
-
- public void setProject(IProject project) {
- this.project = project;
+ return true;
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizardPage.java
index e5cc80c6c..97a733a26 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizardPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizardPage.java
@@ -11,151 +11,54 @@
package org.eclipse.team.internal.ccvs.ui.wizards;
-import org.eclipse.core.resources.IProject;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Tree;
-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.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.client.Update;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.TagConfigurationDialog;
-import org.eclipse.team.internal.ccvs.ui.merge.ProjectElement;
-import org.eclipse.team.internal.ccvs.ui.merge.TagElement;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
public class UpdateWizardPage extends CVSWizardPage {
-
- IProject project;
- TreeViewer tree;
- CVSTag result;
- ICVSRemoteFolder remote;
- boolean doOverwrite;
+ private Button fetchAbsentDirectories;
+ private Button pruneEmptyFolders;
+
public UpdateWizardPage(String pageName, String title, ImageDescriptor titleImage) {
super(pageName, title, titleImage);
+ setDescription(Policy.bind("UpdateWizardPage.description"));
}
/*
* @see IDialogPage#createControl(Composite)
*/
public void createControl(Composite parent) {
- Composite composite = createComposite(parent, 2);
- // set F1 help
- // WorkbenchHelp.setHelp(composite, new DialogPageContextComputer (this, ITeamHelpContextIds.REPO_CONNECTION_MAIN_PAGE));
-
- Label description = new Label(composite, SWT.WRAP);
- GridData data = new GridData();
- data.horizontalSpan = 2;
- data.widthHint = 350;
- description.setLayoutData(data);
- description.setText(Policy.bind("UpdateWizardPage.description")); //$NON-NLS-1$
-
- tree = createTree(composite);
- tree.setContentProvider(new WorkbenchContentProvider());
- tree.setLabelProvider(new WorkbenchLabelProvider());
- tree.setSorter(new ViewerSorter() {
- public int compare(Viewer v, Object o1, Object o2) {
- int result = super.compare(v, o1, o2);
- if (o1 instanceof TagElement && o2 instanceof TagElement) {
- return -result;
- }
- return result;
- }
- });
- tree.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- Object selected = ((IStructuredSelection)tree.getSelection()).getFirstElement();
- if (selected instanceof TagElement) {
- result = ((TagElement)selected).getTag();
- setPageComplete(true);
- } else {
- result = null;
- setPageComplete(false);
- }
- }
- });
-
- createLabel(composite, ""); //$NON-NLS-1$
- createLabel(composite, ""); //$NON-NLS-1$
-
- doOverwrite = false;
- final Button overwrite = new Button(composite, SWT.CHECK);
- data = new GridData();
- data.horizontalSpan = 2;
- overwrite.setLayoutData(data);
- overwrite.setText(Policy.bind("UpdateWizardPage.overwrite")); //$NON-NLS-1$
- overwrite.setSelection(doOverwrite);
- overwrite.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- doOverwrite = overwrite.getSelection();
- }
- });
-
- setControl(composite);
- tree.setInput(new ProjectElement(CVSWorkspaceRoot.getCVSFolderFor(project), ProjectElement.INCLUDE_ALL_TAGS));
+ Composite composite = createComposite(parent, 2);
+ fetchAbsentDirectories = createCheckBox(composite, "&Fetch absent directories");
+ pruneEmptyFolders = createCheckBox(composite, "&Prune empty directories");
+ initializeValues();
- Runnable refresh = new Runnable() {
- public void run() {
- tree.refresh();
- }
- };
- TagConfigurationDialog.createTagDefinitionButtons(getShell(), composite, new ICVSFolder[] {CVSWorkspaceRoot.getCVSFolderFor(project)},
- convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT),
- convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH), refresh, refresh);
-
- Label seperator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- data = new GridData (GridData.FILL_BOTH);
- data.horizontalSpan = 2;
- seperator.setLayoutData(data);
-
- setPageComplete(false);
Dialog.applyDialogFont(parent);
- }
-
- protected TreeViewer createTree(Composite parent) {
- Tree tree = new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE);
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
- return new TreeViewer(tree);
+ setControl(composite);
}
- public void setProject(IProject project) {
- this.project = project;
- try {
- this.remote = (ICVSRemoteFolder) CVSWorkspaceRoot.getRemoteResourceFor(project);
- } catch (TeamException e) {
- // To do
- }
- }
-
- public CVSTag getTag() {
- return result;
+ private void initializeValues() {
+ fetchAbsentDirectories.setSelection(true);
+ pruneEmptyFolders.setSelection(CVSProviderPlugin.getPlugin().getPruneEmptyDirectories());
}
public LocalOption[] getLocalOptions() {
- if (doOverwrite) {
- return new LocalOption[] { Update.IGNORE_LOCAL_CHANGES };
+ List localOptions = new ArrayList();
+ if (fetchAbsentDirectories.getSelection()) {
+ localOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
+ }
+ if (pruneEmptyFolders.getSelection()) {
+ localOptions.add(Update.PRUNE_EMPTY_DIRECTORIES);
}
- return Command.NO_LOCAL_OPTIONS;
+ return (LocalOption[]) localOptions.toArray(new LocalOption[localOptions.size()]);
}
}

Back to the top