Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-05-31 01:51:10 +0000
committerMichael Valenta2002-05-31 01:51:10 +0000
commit10625a156c95a41d56c76cc6251389c444aa9653 (patch)
tree1289265873c25d43907c6c94380e9f4bd2202f6e
parent7dcd3a4fb198867e3195fc1af06cbcef2bfa73b0 (diff)
downloadeclipse.platform.team-10625a156c95a41d56c76cc6251389c444aa9653.tar.gz
eclipse.platform.team-10625a156c95a41d56c76cc6251389c444aa9653.tar.xz
eclipse.platform.team-10625a156c95a41d56c76cc6251389c444aa9653.zip
18208: TM: Sync and Deploy actions
- added Upload action that only puts dirty resources
-rw-r--r--bundles/org.eclipse.team.ui/plugin.properties4
-rw-r--r--bundles/org.eclipse.team.ui/plugin.xml6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PromptingDialog.java44
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties12
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/UploadAction.java137
5 files changed, 178 insertions, 25 deletions
diff --git a/bundles/org.eclipse.team.ui/plugin.properties b/bundles/org.eclipse.team.ui/plugin.properties
index e5c9891f3..42b362d77 100644
--- a/bundles/org.eclipse.team.ui/plugin.properties
+++ b/bundles/org.eclipse.team.ui/plugin.properties
@@ -24,7 +24,7 @@ SiteExplorerView.name=Site Explorer
Deployment.viewCategory=Target Management
Deployment.group=Depl&oy
-Deployment.getAction=&Get
-Deployment.putAction=&Put
+Deployment.getAction=&Replace with Target
+Deployment.uploadAction=&Upload
Deployment.configSite=&Configure Site...
Deployment.synchronize=&Synchronize with Target... \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml
index cc2aeacaa..6bdb65030 100644
--- a/bundles/org.eclipse.team.ui/plugin.xml
+++ b/bundles/org.eclipse.team.ui/plugin.xml
@@ -105,9 +105,9 @@
</action>
<action
menubarPath="team.target/group1"
- class="org.eclipse.team.internal.ui.target.PutAction"
- id="org.eclipse.team.target.putAction"
- label="%Deployment.putAction">
+ class="org.eclipse.team.internal.ui.target.UploadAction"
+ id="org.eclipse.team.target.uploadAction"
+ label="%Deployment.uploadAction">
</action>
<action
menubarPath="team.target/group1"
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PromptingDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PromptingDialog.java
index d816860b1..e0e8d2375 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PromptingDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PromptingDialog.java
@@ -30,6 +30,7 @@ public class PromptingDialog {
private boolean confirmOverwrite = true;
private IPromptCondition condition;
private String title;
+ private boolean hasMultipeResources;
/**
* Prompt for the given resources using the specific condition. The prompt dialog will
@@ -40,15 +41,16 @@ public class PromptingDialog {
this.resources = resources;
this.title = title;
this.shell = shell;
- if(resources.length == 1) {
- buttons = new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL};
- } else {
+ this.hasMultipeResources = resources.length > 1;
+ if (hasMultipeResources) {
buttons = new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.YES_TO_ALL_LABEL,
- IDialogConstants.NO_LABEL,
- IDialogConstants.CANCEL_LABEL};
- }
+ IDialogConstants.YES_LABEL,
+ IDialogConstants.YES_TO_ALL_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.CANCEL_LABEL};
+ } else {
+ buttons = new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL};
+ }
}
/**
@@ -89,17 +91,21 @@ public class PromptingDialog {
dialog.open();
}
});
- switch (dialog.getReturnCode()) {
- case 0://Yes
- return true;
- case 1://No or Cancel
- return false;
- case 2://Yes to all
- confirmOverwrite = false;
- return true;
- case 3://Cancel
- default:
- throw new InterruptedException();
+ if (hasMultipeResources) {
+ switch (dialog.getReturnCode()) {
+ case 0://Yes
+ return true;
+ case 1://Yes to all
+ confirmOverwrite = false;
+ return true;
+ case 2://No
+ return false;
+ case 3://Cancel
+ default:
+ throw new InterruptedException();
+ }
+ } else {
+ return dialog.getReturnCode() == 0;
}
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index 40b462b5f..fae0c5cf2 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -213,4 +213,14 @@ TargetCatchupReleaseViewer.Get_1=&Get
TargetCatchupReleaseViewer.Put_2=&Put
SiteSelectionPage.siteLabelCurrentWithMapping={0} (currently as {1})
-SiteSelectionPage.siteLabelCurrent={0} (current) \ No newline at end of file
+SiteSelectionPage.siteLabelCurrent={0} (current)
+
+UploadAction.Exception_getting_provider=Exception getting provider
+UploadAction.working=Uploading to ''{0}''...
+UploadAction.noDirtyTitle=No Dirty Resources Found
+UploadAction.noDirtyMessage=There were no dirty resources found to upload.
+UploadAction.confirmDeletionTitle=Confirm Deletion
+UploadAction.confirmFileDeletionMessage=File ''{0}'' has been deleted locally. Do you want to delete it remotely?
+UploadAction.problemMessage=Problems occurred uploading.
+
+
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/UploadAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/UploadAction.java
new file mode 100644
index 000000000..643b80d2b
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/UploadAction.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * 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.ui.target;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.target.TargetManager;
+import org.eclipse.team.core.target.TargetProvider;
+import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
+import org.eclipse.team.internal.core.TeamPlugin;
+import org.eclipse.team.internal.ui.IPromptCondition;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.PromptingDialog;
+import org.eclipse.team.internal.ui.actions.TeamAction;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+public class UploadAction extends TeamAction {
+
+ /**
+ * @see TeamAction#isEnabled()
+ */
+ protected boolean isEnabled() throws TeamException {
+ IResource[] resources = getSelectedResources();
+ if (resources.length == 0) return false;
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ try {
+ TargetProvider provider = TargetManager.getProvider(resource.getProject());
+ if(provider == null)
+ return false;
+ if(! provider.canPut(resource))
+ return false; //if one can't don't allow for any
+ // Don't want to go though the resources deeply to see if there are dirty children
+ } catch (TeamException e) {
+ TeamPlugin.log(IStatus.ERROR, Policy.bind("UploadAction.Exception_getting_provider"), e); //$NON-NLS-1$
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ run(new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
+ try {
+ Hashtable table = getTargetProviderMapping();
+ Set keySet = table.keySet();
+ monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
+ Iterator iterator = keySet.iterator();
+ while (iterator.hasNext()) {
+ IProgressMonitor subMonitor = new InfiniteSubProgressMonitor(monitor, 1024);
+ final TargetProvider provider = (TargetProvider)iterator.next();
+ monitor.setTaskName(Policy.bind("UploadAction.working", provider.getURL().toExternalForm())); //$NON-NLS-1$
+
+ // Collect the dirty resource
+ List list = (List)table.get(provider);
+ final List dirtyResources = new ArrayList();
+ for (Iterator iter = list.iterator(); iter.hasNext();) {
+ IResource resource = (IResource) iter.next();
+ resource.accept(new IResourceVisitor() {
+ public boolean visit(IResource resource) throws CoreException {
+ if (resource.getType() == IResource.FILE) {
+ if (provider.isDirty(resource)) {
+ dirtyResources.add(resource);
+ }
+ } else {
+ // Check for outgoing folder deletions?
+ }
+ return true;
+ }
+ }, IResource.DEPTH_INFINITE, true /* include phantoms */);
+ }
+ if (dirtyResources.isEmpty()) {
+ getShell().getDisplay().syncExec(
+ new Runnable() {
+ public void run() {
+ MessageDialog.openInformation(getShell(),
+ Policy.bind("UploadAction.noDirtyTitle"),
+ Policy.bind("UploadAction.noDirtyMessage"));
+ }
+ });
+ return;
+ };
+
+ // Prompt for any outgoing deletions
+ PromptingDialog prompt = new PromptingDialog(
+ getShell(),
+ (IResource[])dirtyResources.toArray(new IResource[list.size()]),
+ new IPromptCondition() {
+ public boolean needsPrompt(IResource resource) {
+ return ! resource.exists();
+ }
+ public String promptMessage(IResource resource) {
+ return Policy.bind("UploadAction.confirmFileDeletionMessage", resource.getFullPath().toString());
+ }
+ },
+ Policy.bind("UploadAction.confirmDeletionTitle"));//$NON-NLS-1$
+
+ // Put the resources that were selected
+ provider.put(prompt.promptForMultiple(), subMonitor);
+ }
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } catch (TeamException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ }, Policy.bind("UploadAction.problemMessage"), this.PROGRESS_DIALOG); //$NON-NLS-1$
+ }
+
+}

Back to the top