Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-03-14 13:36:39 +0000
committerMichael Valenta2002-03-14 13:36:39 +0000
commit2ef4de26ae3239e658b35f2022b37efcc8b4f85d (patch)
treeeb1007aa028458a0f654846513e4287edeac420e
parent92f89a2cbea0a246e2deae74dfdff68e39055dea (diff)
downloadeclipse.platform.team-2ef4de26ae3239e658b35f2022b37efcc8b4f85d.tar.gz
eclipse.platform.team-2ef4de26ae3239e658b35f2022b37efcc8b4f85d.tar.xz
eclipse.platform.team-2ef4de26ae3239e658b35f2022b37efcc8b4f85d.zip
11214: Should show tag in a project's CVS properties
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java84
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java96
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizardPage.java135
4 files changed, 322 insertions, 1 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
index 5f9cdda1d..298df261f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
@@ -17,9 +17,11 @@ import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -28,13 +30,16 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.ccvs.core.IUserInfo;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.ui.wizards.UpdateWizard;
import org.eclipse.ui.dialogs.PropertyPage;
public class CVSPropertiesPage extends PropertyPage {
@@ -48,8 +53,10 @@ public class CVSPropertiesPage extends PropertyPage {
Label pathLabel;
Label moduleLabel;
Label portLabel;
+ Label tagLabel;
boolean passwordChanged;
+ boolean connectionInfoChanged;
IUserInfo info;
CVSTeamProvider provider;
@@ -63,35 +70,86 @@ public class CVSPropertiesPage extends PropertyPage {
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
- layout.numColumns = 2;
+ layout.numColumns = 3;
composite.setLayout(layout);
Label label = createLabel(composite, Policy.bind("CVSPropertiesPage.connectionType"));
methodType = createCombo(composite);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ methodType.setLayoutData(data);
label = createLabel(composite, Policy.bind("CVSPropertiesPage.user"));
userText = createTextField(composite);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ userText.setLayoutData(data);
label = createLabel(composite, Policy.bind("CVSPropertiesPage.password"));
passwordText = createTextField(composite);
passwordText.setEchoChar('*');
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ passwordText.setLayoutData(data);
label = createLabel(composite, Policy.bind("CVSPropertiesPage.host"));
hostLabel = createLabel(composite, "");
+ data = new GridData();
+ data.horizontalSpan = 2;
+ hostLabel.setLayoutData(data);
label = createLabel(composite, Policy.bind("CVSPropertiesPage.port"));
portLabel = createLabel(composite, "");
+ data = new GridData();
+ data.horizontalSpan = 2;
+ portLabel.setLayoutData(data);
label = createLabel(composite, Policy.bind("CVSPropertiesPage.path"));
pathLabel = createLabel(composite, "");
+ data = new GridData();
+ data.horizontalSpan = 2;
+ pathLabel.setLayoutData(data);
label = createLabel(composite, Policy.bind("CVSPropertiesPage.module"));
moduleLabel = createLabel(composite, "");
+ data = new GridData();
+ data.horizontalSpan = 2;
+ moduleLabel.setLayoutData(data);
+
+ label = createLabel(composite, Policy.bind("CVSPropertiesPage.tag"));
+ tagLabel = createLabel(composite, "");
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ tagLabel.setLayoutData(data);
+
+ Button changeTag = new Button(composite, SWT.PUSH);
+ data = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ changeTag.setLayoutData(data);
+ changeTag.setText(Policy.bind("CVSPropertiesPage.update"));
+ changeTag.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ UpdateWizard wizard = new UpdateWizard();
+ wizard.setProject(project);
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ dialog.open();
+ initializeTag();
+ }
+ });
initializeValues();
passwordText.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
passwordChanged = true;
+ connectionInfoChanged = true;
+ }
+ });
+ userText.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event event) {
+ connectionInfoChanged = true;
+ }
+ });
+ methodType.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event event) {
+ connectionInfoChanged = true;
}
});
return composite;
@@ -198,11 +256,35 @@ public class CVSPropertiesPage extends PropertyPage {
} catch (TeamException e) {
handle(e);
}
+
+ initializeTag();
+ }
+
+ private void initializeTag() {
+ provider = (CVSTeamProvider)TeamPlugin.getManager().getProvider(project);
+ if (provider == null) return;
+ CVSWorkspaceRoot cvsRoot = provider.getCVSWorkspaceRoot();
+ try {
+ ICVSFolder local = cvsRoot.getCVSFolderFor(project);
+ CVSTag tag = local.getFolderSyncInfo().getTag();
+ String tagName;
+ if (tag == null) {
+ tagName = "HEAD";
+ } else {
+ tagName = tag.getName();
+ }
+ tagLabel.setText(tagName);
+ } catch (TeamException e) {
+ handle(e);
+ }
}
/*
* @see PreferencesPage#performOk
*/
public boolean performOk() {
+ if ( ! connectionInfoChanged) {
+ return true;
+ }
info.setUsername(userText.getText());
if (passwordChanged) {
info.setPassword(passwordText.getText());
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 8e2c58741..e2050817b 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
@@ -113,6 +113,8 @@ CVSPropertiesPage.port=Port:
CVSPropertiesPage.path=Repository path:
CVSPropertiesPage.module=Module:
CVSPropertiesPage.defaultPort=Default
+CVSPropertiesPage.tag=Tag:
+CVSPropertiesPage.update=Change tag
CVSPreferencePage.pruneEmptyDirectories=&Prune empty directories
CVSPreferencePage.timeoutValue=&Communication timeout value (in seconds)
@@ -351,6 +353,12 @@ TagAction.enterTag=Please enter a version tag:
UpdateAction.update=Problems encountered performing update
UpdateAction.updating=Updating...
+UpdateWizard.title=Update
+UpdateWizard.updatePage=Update
+
+UpdateWizardPage.description=Select a tag to update the project sharing to
+UpdateWizardPage.overwrite=Overwrite any local changes
+
UserValidationDialog.required=Password Required
UserValidationDialog.labelUser=Enter a user name and password for the following repository:\n{0}
UserValidationDialog.labelPassword=Enter a password for {0} in the following repository:\n{1}
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
new file mode 100644
index 000000000..c5cbd6eb7
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java
@@ -0,0 +1,96 @@
+package org.eclipse.team.internal.ccvs.ui.wizards;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+
+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.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.TeamPlugin;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+
+public class UpdateWizard extends Wizard {
+
+ UpdateWizardPage updatePage;
+ IProject project;
+
+ public UpdateWizard() {
+ setNeedsProgressMonitor(true);
+ setWindowTitle(Policy.bind("UpdateWizard.title"));
+ }
+
+ 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));
+ updatePage.setProject(project);
+ addPage(updatePage);
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ CVSUIPlugin.log(new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, Policy.bind("internal"), e.getTargetException()));
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ }
+
+ /*
+ * @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 {
+ CVSTeamProvider provider = ((CVSTeamProvider)TeamPlugin.getManager().getProvider(project));
+ provider.update(new IResource[] {project}, updatePage.getLocalOptions(), updatePage.getTag(), null, monitor);
+ result[0] = true;
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ return true;
+ } catch (InvocationTargetException e) {
+ Throwable target = e.getTargetException();
+ if (target instanceof CVSException) {
+ ErrorDialog.openError(getShell(), null, null, ((CVSException)target).getStatus());
+ return false;
+ }
+ if (target instanceof RuntimeException) {
+ throw (RuntimeException)target;
+ }
+ if (target instanceof Error) {
+ throw (Error)target;
+ }
+ }
+ return result[0];
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+}
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
new file mode 100644
index 000000000..a96b3e915
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizardPage.java
@@ -0,0 +1,135 @@
+package org.eclipse.team.internal.ccvs.ui.wizards;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.resources.IProject;
+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.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSRemoteFolder;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.client.Command;
+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.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;
+
+ public UpdateWizardPage(String pageName, String title, ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ /*
+ * @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"));
+
+ 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, "");
+ createLabel(composite, "");
+
+ 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"));
+ overwrite.setSelection(doOverwrite);
+ overwrite.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ doOverwrite = overwrite.getSelection();
+ }
+ });
+
+ setControl(composite);
+ tree.setInput(new ProjectElement(remote, getShell()));
+ setPageComplete(false);
+ }
+
+ 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);
+ }
+
+ 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;
+ }
+
+ public LocalOption[] getLocalOptions() {
+ if (doOverwrite) {
+ return new LocalOption[] { Update.IGNORE_LOCAL_CHANGES };
+ }
+ return Command.NO_LOCAL_OPTIONS;
+ }
+}

Back to the top