Merge lp:~javierder/bzr-eclipse/send_command into lp:~verterok/bzr-eclipse/trunk
- send_command
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Guillermo Gonzalez |
Approved revision: | no longer in the revision history of the source branch. |
Merged at revision: | not available |
Proposed branch: | lp:~javierder/bzr-eclipse/send_command |
Merge into: | lp:~verterok/bzr-eclipse/trunk |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~javierder/bzr-eclipse/send_command |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guillermo Gonzalez | Approve | ||
Review via email: mp+5676@code.launchpad.net |
Commit message
Description of the change
Javier Derderyan (javierder) wrote : | # |
Martin Albisetti (beuno) wrote : | # |
Copyright headers look odd, no?
Javier Derderyan (javierder) wrote : | # |
> Copyright headers look odd, no?
yes they do. They're the same in lots of original BzrEclipse files, like LocationInputDi
what should be there?
Guillermo Gonzalez (verterok) wrote : | # |
Hi Javier!
On Fri, Apr 17, 2009 at 8:45 PM, Javier Derderian <email address hidden> wrote:
> Javier Derderian has proposed merging lp:~javierder/bzr-eclipse/send_command into lp:bzr-eclipse.
>
> Requested reviews:
> Guillermo Gonzalez (verterok)
>
> Send command implementation.
>
> The dialog, action and command are based on merge and uncommit.
>
Great!
> Hope it merges!
I'm sure it 'll merge :)
I'm reviewing the branch, but having some network outages.
I'll have the full review for tomorrow.
Cheers,
> --
> https:/
> You are requested to review the proposed merge of lp:~javierder/bzr-eclipse/send_command into lp:bzr-eclipse.
>
Guillermo Gonzalez (verterok) wrote : | # |
Hi Javier,
On Sat, Apr 18, 2009 at 9:29 PM, Javier Derderian <email address hidden> wrote:
>> Copyright headers look odd, no?
>
> yes they do. They're the same in lots of original BzrEclipse files, like LocationInputDi
I think Martin is talking about the copyright in SendAction.java, as
it might be a similar copyright in other files of bzr-eclipse, it's
wrong (my fault, sorry for the confusion). Looks like that a search &
replace didn't worked as expected.
Most of the files have a placeholder for the LICENSE/COPYRIGHT, that I
should complete.
>
>
> what should be there?
I think that as Canonical is the sponsor of this work, the copyright
belongs to them, but that depends on the arrangement/
signed.
About the license, I know it's not clear. I think that using EPL it's
ok. but don't know if a specific license should be used (as part of
your contract with them).
Cheers,
> --
> https:/
> You are requested to review the proposed merge of lp:~javierder/bzr-eclipse/send_command into lp:bzr-eclipse.
>
Guillermo Gonzalez (verterok) wrote : | # |
Hi Javier,
On Fri, Apr 17, 2009 at 8:45 PM, Javier Derderian <email address hidden> wrote:
> Javier Derderian has proposed merging lp:~javierder/bzr-eclipse/send_command into lp:bzr-eclipse.
>
> Send command implementation.
>
> The dialog, action and command are based on merge and uncommit.
The branch looks good, but I have some comments regarding minor issues
I'ld like to see solved before merging.
1) please revert the changes to
org.vcs.
configuration of the project, but not the current default in order to
be able build the update-site.
2) org.vcs.
+ public void run(IProgressMo
+ try {
+ monitor.
+ IBazaarClient client = getClient(
+
+ final BranchLocation branchLocation = new BranchLocation(
+
+ client.
+ //annotation =
client.
The remoteLocation variable is handled as a plain string, this is
really discouraged, as it's a value provided by the user, also the
overall idea is that the core don't know about locations as strings
but as instances of BranchLocation class.
The SendAction or the Dialog should do some work to validate the
user input and pass a BranchLocation to SendCommand (see below).
Also, please remove the commented code at line 48.
* org.vcs.
- Please fix the header of the file.
- in isEnabledForUnm
+ protected boolean isEnabledForUnm
+ if(getSelectedP
+ return true;
+ } else if(getSelectedP
+ return true;
+ }
+ return false;
+ }
here you'r checking for getSelectedProj
getSelectedProj
Ir order to make clear the intention of the code there should be only
one check: >= 1. Also take into account the side effects of this, as
the action 'll be enabled with multiple projects selected. This Might
be valid in the case that two projects are in the same branch, but are
two different projects in bzr-eclipse (This feature is supported by
bzr-eclipse but not directly available to the regular user due to
limitations in the Eclipse Team integration framework)
* in the execute method:
+ final IBzrLocalResource[] resourcesToRevert =
BzrWorkspaceRoo
+
(line 50): you'r naming a variable resourcesToRevert when it should
be resourcesToSend maybe, or just resources?
+ final SendCommand cmd = new SendCommand(
dialog.
(line 52) only the first resource is used, but as in
isEnabledForUnm
projects.
+ run(new WorkspaceModify
+ public void execute(
InvocationTarge
+ try {
+ cmd.run(monitor);
+ ...
Guillermo Gonzalez (verterok) wrote : | # |
Oops, I missed the vote command
Javier Derderyan (javierder) wrote : | # |
Ok, thanks!!!!!!!!
I'll work on this tomorrow.
Javier Derderyan (javierder) wrote : | # |
Ok,
Based on your input I fixed the issues you mentioned.
About the cancel, I just changed the variable to allow cancel, is that enough or I have to do something else?
About the browse button, I'll add it to my list of things for the next month, because I'm still trying to be friend with Java and Eclipse and I have no idea how to do it.
It's first in my to-do list.
I'll check with canonical about the Copyright headers.
Thanks again!
Guillermo Gonzalez (verterok) wrote : | # |
On Mon, Apr 20, 2009 at 4:00 PM, Javier Derderian <email address hidden> wrote:
> Ok,
> Based on your input I fixed the issues you mentioned.
>
Great!
> About the cancel, I just changed the variable to allow cancel, is that enough or I have to do something else?
>
regarding how to fire some work/command as a Job take a look to the
PushAction class (or do a search for Job class in bzr-eclipse) ;)
> About the browse button, I'll add it to my list of things for the next month, because I'm still trying to be friend with Java and Eclipse and I have no idea how to do it.
> It's first in my to-do list.
Ok, you could take a look to
/org.vcs.
lines: 90-101
that's an example of using the org.eclipse.
class bound to a button (in this case should be the
org.eclipse.
>
> I'll check with canonical about the Copyright headers
I just talked with Martin Pool about this, and the copyright should be
for Canonical.
>
> Thanks again!
Thanks,
Cheers,
> --
> https:/
> You are reviewing the proposed merge of lp:~javierder/bzr-eclipse/send_command into lp:bzr-eclipse.
>
Javier Derderyan (javierder) wrote : | # |
Hi!
I managed to get the copyright headers and added a SendOperation to make it work as a Job.
I'm working right now with the browse dialog, but if you think it's ok I'll love to get this merged ASAP and then help you make a new release tomorrow (maybe a intermedial version before 1.2.0? or some beta?)
Javier Derderyan (javierder) wrote : | # |
> Hi!
>
> I managed to get the copyright headers and added a SendOperation to make it
> work as a Job.
>
> I'm working right now with the browse dialog, but if you think it's ok I'll
> love to get this merged ASAP and then help you make a new release tomorrow
> (maybe a intermedial version before 1.2.0? or some beta?)
ok, browse button is there!!!!!!!!
Guillermo Gonzalez (verterok) wrote : | # |
Hi
On Mon, Apr 20, 2009 at 9:26 PM, Javier Derderian <email address hidden> wrote:
>> Hi!
>>
>> I managed to get the copyright headers and added a SendOperation to make it
>> work as a Job.
>>
Great!
maybe missed to bzr add it? ;)
btw, The code looks ok.
Just one more thing, please remove the commented block on SendAction:
/*final SendCommand cmd = new SendCommand(
dialog.
run(new WorkspaceModify
public void execute(
InvocationTarge
try {
cmd.
} catch (BazaarException e) {
// FIXME: exception handling
throw new InvocationTarge
} finally {
monitor.
}
}
}, true / * cancelable * /, PROGRESS_DIALOG);*/
Thanks!
>> I'm working right now with the browse dialog, but if you think it's ok I'll
>> love to get this merged ASAP and then help you make a new release tomorrow
>> (maybe a intermedial version before 1.2.0? or some beta?)
>
>
> ok, browse button is there!!!!!!!!
Cool!
Cheers,
--
Guillermo Gonzalez
<http://
Javier Derderyan (javierder) wrote : | # |
Ok,
done and done.
I ALWAYS miss bzr add......=(
Thanks!
Guillermo Gonzalez (verterok) wrote : | # |
Great!
I'll land this ASAP!
On Tue, Apr 21, 2009 at 1:38 AM, Javier Derderian <email address hidden> wrote:
> Ok,
>
> done and done.
>
> I ALWAYS miss bzr add......=(
>
> Thanks!
>
>
> --
> https:/
> You are reviewing the proposed merge of lp:~javierder/bzr-eclipse/send_command into lp:bzr-eclipse.
>
Guillermo Gonzalez (verterok) wrote : | # |
looks good now!
- 208. By Guillermo Gonzalez
-
merge with Javier's send_command branch
- 209. By Guillermo Gonzalez
-
minor fix & cleanup
Preview Diff
1 | === modified file 'org.vcs.bazaar.eclipse.client/.classpath' | |||
2 | --- org.vcs.bazaar.eclipse.client/.classpath 2009-02-21 23:16:34 +0000 | |||
3 | +++ org.vcs.bazaar.eclipse.client/.classpath 2009-04-16 21:40:23 +0000 | |||
4 | @@ -1,10 +1,10 @@ | |||
5 | 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
6 | 2 | <classpath> | 2 | <classpath> |
8 | 3 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> | 3 | <classpathentry exported="true" kind="lib" path="bzr-java-lib-0.5.1-SNAPSHOT.jar" sourcepath="/home/javier/java/bzr-java-lib"/> |
9 | 4 | <classpathentry exported="true" kind="lib" path="kxml2-min-2.3.0.jar"/> | ||
10 | 5 | <classpathentry exported="true" kind="lib" path="xmlrpc-1.1.jar"/> | ||
11 | 6 | <classpathentry exported="true" kind="lib" path="xmlrpc-client-1.1.jar"/> | ||
12 | 7 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
13 | 4 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | 8 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
14 | 5 | <classpathentry exported="true" kind="lib" path="bzr-java-lib-0.5.1-SNAPSHOT.jar" sourcepath="org.vcs.bazaar.eclipse.clientsrc.zip"/> | ||
15 | 6 | <classpathentry exported="true" kind="lib" path="kxml2-min-2.3.0.jar" sourcepath="org.vcs.bazaar.eclipse.clientsrc.zip"/> | ||
16 | 7 | <classpathentry exported="true" kind="lib" path="xmlrpc-1.1.jar" sourcepath="org.vcs.bazaar.eclipse.clientsrc.zip"/> | ||
17 | 8 | <classpathentry exported="true" kind="lib" path="xmlrpc-client-1.1.jar" sourcepath="org.vcs.bazaar.eclipse.clientsrc.zip"/> | ||
18 | 9 | <classpathentry kind="output" path="bin"/> | 9 | <classpathentry kind="output" path="bin"/> |
19 | 10 | </classpath> | 10 | </classpath> |
20 | 11 | 11 | ||
21 | === modified file 'org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/CoreTexts.java' | |||
22 | --- org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/CoreTexts.java 2008-07-17 02:36:37 +0000 | |||
23 | +++ org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/CoreTexts.java 2009-04-16 21:40:23 +0000 | |||
24 | @@ -20,6 +20,8 @@ | |||
25 | 20 | public static String AddCommand_adding; | 20 | public static String AddCommand_adding; |
26 | 21 | 21 | ||
27 | 22 | public static String AnnotateCommand_annotate; | 22 | public static String AnnotateCommand_annotate; |
28 | 23 | |||
29 | 24 | public static String SendCommand_send; | ||
30 | 23 | 25 | ||
31 | 24 | public static String CommitCommand_commit; | 26 | public static String CommitCommand_commit; |
32 | 25 | 27 | ||
33 | 26 | 28 | ||
34 | === added file 'org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/core/commands/SendCommand.java' | |||
35 | --- org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/core/commands/SendCommand.java 1970-01-01 00:00:00 +0000 | |||
36 | +++ org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/core/commands/SendCommand.java 2009-04-17 13:57:24 +0000 | |||
37 | @@ -0,0 +1,60 @@ | |||
38 | 1 | /** | ||
39 | 2 | * LICENSE + COPYRIGHT | ||
40 | 3 | */ | ||
41 | 4 | package org.vcs.bazaar.eclipse.core.commands; | ||
42 | 5 | |||
43 | 6 | import org.eclipse.core.runtime.IProgressMonitor; | ||
44 | 7 | import org.vcs.bazaar.client.IBazaarAnnotation; | ||
45 | 8 | import org.vcs.bazaar.client.IBazaarClient; | ||
46 | 9 | import org.vcs.bazaar.client.commandline.commands.options.Option; | ||
47 | 10 | import org.vcs.bazaar.client.core.BazaarClientException; | ||
48 | 11 | import org.vcs.bazaar.eclipse.CoreTexts; | ||
49 | 12 | import org.vcs.bazaar.eclipse.core.model.local.IBzrLocalResource; | ||
50 | 13 | import org.vcs.bazaar.eclipse.internal.core.BazaarException; | ||
51 | 14 | import org.vcs.bazaar.client.core.BranchLocation; | ||
52 | 15 | |||
53 | 16 | /** | ||
54 | 17 | * @author Javier Der Derian<javierder AT gmail DOT com> | ||
55 | 18 | * @BasedOn RevertCommand from BzrEclipse | ||
56 | 19 | * | ||
57 | 20 | */ | ||
58 | 21 | public class SendCommand extends BazaarCommand { | ||
59 | 22 | |||
60 | 23 | private final IBzrLocalResource resource; | ||
61 | 24 | private IBazaarAnnotation annotation; | ||
62 | 25 | private Option[] options; | ||
63 | 26 | private String remoteLocation; | ||
64 | 27 | |||
65 | 28 | |||
66 | 29 | public SendCommand(IBzrLocalResource bzrResource, Option[] options, String remoteLocation) { | ||
67 | 30 | this.resource = bzrResource; | ||
68 | 31 | this.options = options; | ||
69 | 32 | this.remoteLocation = remoteLocation; | ||
70 | 33 | } | ||
71 | 34 | |||
72 | 35 | /** | ||
73 | 36 | * when this finish you must call {@link #getAnnotation()} | ||
74 | 37 | * | ||
75 | 38 | * @see org.vcs.bazaar.eclipse.core.commands.IBazaarCommand#run(org.eclipse.core.runtime.IProgressMonitor) | ||
76 | 39 | */ | ||
77 | 40 | public void run(IProgressMonitor monitor) throws BazaarException { | ||
78 | 41 | try { | ||
79 | 42 | monitor.beginTask(CoreTexts.SendCommand_send, 1000); | ||
80 | 43 | IBazaarClient client = getClient(resource.getIResource().getProject()); | ||
81 | 44 | |||
82 | 45 | final BranchLocation branchLocation = new BranchLocation(remoteLocation); | ||
83 | 46 | |||
84 | 47 | client.send(branchLocation, options); | ||
85 | 48 | //annotation = client.annotate(resource.getIResource().getLocation().toFile()); | ||
86 | 49 | } catch (BazaarClientException e) { | ||
87 | 50 | throw BazaarException.wrapException(e, resource.getIResource()); | ||
88 | 51 | } finally { | ||
89 | 52 | monitor.done(); | ||
90 | 53 | } | ||
91 | 54 | } | ||
92 | 55 | |||
93 | 56 | public IBazaarAnnotation getAnnotation() { | ||
94 | 57 | return annotation; | ||
95 | 58 | } | ||
96 | 59 | |||
97 | 60 | } | ||
98 | 0 | 61 | ||
99 | === modified file 'org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/coretexts.properties' | |||
100 | --- org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/coretexts.properties 2009-01-01 04:46:34 +0000 | |||
101 | +++ org.vcs.bazaar.eclipse.core/src/org/vcs/bazaar/eclipse/coretexts.properties 2009-04-16 21:40:23 +0000 | |||
102 | @@ -1,6 +1,7 @@ | |||
103 | 1 | AddCommand_adding=Adding files | 1 | AddCommand_adding=Adding files |
104 | 2 | BranchCommand_branching=Executing 'bzr branch' | 2 | BranchCommand_branching=Executing 'bzr branch' |
105 | 3 | AnnotateCommand_annotate=Getting file annotation | 3 | AnnotateCommand_annotate=Getting file annotation |
106 | 4 | SendCommand_send=Sending | ||
107 | 4 | RemoveCommand_removing=Removing files | 5 | RemoveCommand_removing=Removing files |
108 | 5 | StatusCommand_status=Executing 'bzr status' | 6 | StatusCommand_status=Executing 'bzr status' |
109 | 6 | DiffCommand_diff=Generating diff | 7 | DiffCommand_diff=Generating diff |
110 | 7 | 8 | ||
111 | === modified file 'org.vcs.bazaar.eclipse.ui/plugin.properties' | |||
112 | --- org.vcs.bazaar.eclipse.ui/plugin.properties 2009-01-18 14:57:50 +0000 | |||
113 | +++ org.vcs.bazaar.eclipse.ui/plugin.properties 2009-04-15 16:36:58 +0000 | |||
114 | @@ -51,6 +51,8 @@ | |||
115 | 51 | ActionResolve_tooltip=Mark a conflict as resolved. | 51 | ActionResolve_tooltip=Mark a conflict as resolved. |
116 | 52 | ActionRevert_label=&Revert | 52 | ActionRevert_label=&Revert |
117 | 53 | ActionRevert_tooltip=Revert files to a previous revision | 53 | ActionRevert_tooltip=Revert files to a previous revision |
118 | 54 | ActionSend_label=&Send | ||
119 | 55 | ActionSend_tooltip=Mail or create a merge-directive for submitting changes | ||
120 | 54 | ActionStatus_label=&Status | 56 | ActionStatus_label=&Status |
121 | 55 | ActionStatus_tooltip=Display status summary (in the Console) | 57 | ActionStatus_tooltip=Display status summary (in the Console) |
122 | 56 | ActionUnCommit_label=UnC&ommit | 58 | ActionUnCommit_label=UnC&ommit |
123 | 57 | 59 | ||
124 | === modified file 'org.vcs.bazaar.eclipse.ui/plugin.xml' | |||
125 | --- org.vcs.bazaar.eclipse.ui/plugin.xml 2009-02-21 23:16:34 +0000 | |||
126 | +++ org.vcs.bazaar.eclipse.ui/plugin.xml 2009-04-15 16:41:07 +0000 | |||
127 | @@ -158,6 +158,14 @@ | |||
128 | 158 | label="%ActionRevert_label" menubarPath="team.main/group4" | 158 | label="%ActionRevert_label" menubarPath="team.main/group4" |
129 | 159 | tooltip="%ActionRevert_tooltip"> | 159 | tooltip="%ActionRevert_tooltip"> |
130 | 160 | </action> | 160 | </action> |
131 | 161 | <action | ||
132 | 162 | class="org.vcs.bazaar.eclipse.ui.actions.SendAction" | ||
133 | 163 | definitionId="org.vcs.bazaar.eclipse.ui.actions.ActionSend" | ||
134 | 164 | icon="icons/bzrlogo.png" | ||
135 | 165 | id="org.vcs.bazaar.eclipse.ui.actions.ActionSend" | ||
136 | 166 | label="%ActionSend_label" menubarPath="team.main/group4" | ||
137 | 167 | tooltip="%ActionSend_tooltip"> | ||
138 | 168 | </action> | ||
139 | 161 | <action | 169 | <action |
140 | 162 | class="org.vcs.bazaar.eclipse.ui.actions.AddAction" | 170 | class="org.vcs.bazaar.eclipse.ui.actions.AddAction" |
141 | 163 | definitionId="org.vcs.bazaar.eclipse.ui.actions.ActionAdd" | 171 | definitionId="org.vcs.bazaar.eclipse.ui.actions.ActionAdd" |
142 | @@ -748,3 +756,4 @@ | |||
143 | 748 | </extension --> | 756 | </extension --> |
144 | 749 | 757 | ||
145 | 750 | </plugin> | 758 | </plugin> |
146 | 759 | |||
147 | 751 | 760 | ||
148 | === added file 'org.vcs.bazaar.eclipse.ui/src/org/vcs/bazaar/eclipse/ui/actions/SendAction.java' | |||
149 | --- org.vcs.bazaar.eclipse.ui/src/org/vcs/bazaar/eclipse/ui/actions/SendAction.java 1970-01-01 00:00:00 +0000 | |||
150 | +++ org.vcs.bazaar.eclipse.ui/src/org/vcs/bazaar/eclipse/ui/actions/SendAction.java 2009-04-17 13:57:24 +0000 | |||
151 | @@ -0,0 +1,86 @@ | |||
152 | 1 | /** | ||
153 | 2 | * org.vcs.bazaar.eclipse (c) Vectrace Sep 12, 2006 | ||
154 | 3 | * Created by zingo | ||
155 | 4 | */ | ||
156 | 5 | package org.vcs.bazaar.eclipse.ui.actions; | ||
157 | 6 | |||
158 | 7 | import java.lang.reflect.InvocationTargetException; | ||
159 | 8 | import java.util.Collection; | ||
160 | 9 | |||
161 | 10 | import org.eclipse.core.resources.IProject; | ||
162 | 11 | import org.eclipse.core.runtime.IProgressMonitor; | ||
163 | 12 | import org.eclipse.jface.action.IAction; | ||
164 | 13 | import org.eclipse.ui.IWorkbenchWindowActionDelegate; | ||
165 | 14 | import org.eclipse.ui.actions.WorkspaceModifyOperation; | ||
166 | 15 | import org.vcs.bazaar.eclipse.BzrWorkspaceRoot; | ||
167 | 16 | import org.vcs.bazaar.eclipse.core.commands.SendCommand; | ||
168 | 17 | import org.vcs.bazaar.eclipse.core.model.IBzrBranch; | ||
169 | 18 | import org.vcs.bazaar.eclipse.core.model.local.IBzrLocalResource; | ||
170 | 19 | import org.vcs.bazaar.eclipse.internal.core.BazaarException; | ||
171 | 20 | import org.vcs.bazaar.eclipse.ui.dialogs.SendDialog; | ||
172 | 21 | import org.vcs.bazaar.eclipse.ui.dialogs.SendDialog.SendDialogInfo; | ||
173 | 22 | |||
174 | 23 | /** | ||
175 | 24 | * @author Javier Der Derian<javierder AT gmail DOT com> | ||
176 | 25 | * @BasedOn RevertAction from BzrEclipse | ||
177 | 26 | */ | ||
178 | 27 | public class SendAction extends WorkbenchAction { | ||
179 | 28 | |||
180 | 29 | /** | ||
181 | 30 | * <p> | ||
182 | 31 | * The action has been activated. The argument of the method represents the | ||
183 | 32 | * 'real' action sitting in the workbench UI. | ||
184 | 33 | * </p> | ||
185 | 34 | * | ||
186 | 35 | * @throws BazaarException | ||
187 | 36 | * @see IWorkbenchWindowActionDelegate#run | ||
188 | 37 | */ | ||
189 | 38 | @Override | ||
190 | 39 | protected void execute(IAction action) throws BazaarException, InvocationTargetException, InterruptedException { | ||
191 | 40 | IProject[] projects = getEnclosingProjectsForSelectedResources(); | ||
192 | 41 | |||
193 | 42 | Collection<IBzrBranch> locations = getAllBranchLocations(projects[0]); | ||
194 | 43 | |||
195 | 44 | SendDialog dialog = new SendDialog(this.getShell(), locations, new SendDialogInfo()); | ||
196 | 45 | |||
197 | 46 | if(dialog.open() != SendDialog.OK) { | ||
198 | 47 | return; | ||
199 | 48 | } | ||
200 | 49 | |||
201 | 50 | final IBzrLocalResource[] resourcesToRevert = BzrWorkspaceRoot.getBzrResourcesFor(projects); | ||
202 | 51 | |||
203 | 52 | final SendCommand cmd = new SendCommand(resourcesToRevert[0], dialog.getOptions(), dialog.getValue()); | ||
204 | 53 | run(new WorkspaceModifyOperation() { | ||
205 | 54 | public void execute(IProgressMonitor monitor) throws InvocationTargetException { | ||
206 | 55 | try { | ||
207 | 56 | cmd.run(monitor); | ||
208 | 57 | } catch (BazaarException e) { | ||
209 | 58 | // FIXME: exception handling | ||
210 | 59 | throw new InvocationTargetException(e); | ||
211 | 60 | } finally { | ||
212 | 61 | monitor.done(); | ||
213 | 62 | } | ||
214 | 63 | } | ||
215 | 64 | }, false /* no cancelable */, PROGRESS_DIALOG); | ||
216 | 65 | |||
217 | 66 | } | ||
218 | 67 | |||
219 | 68 | protected boolean isEnabledForUnmanagedResources() { | ||
220 | 69 | return false; | ||
221 | 70 | } | ||
222 | 71 | |||
223 | 72 | @Override | ||
224 | 73 | protected boolean isEnabledForUnmodifiedResources() { | ||
225 | 74 | if(getSelectedProjects().length > 1) { | ||
226 | 75 | return true; | ||
227 | 76 | } else if(getSelectedProjects().length == 1) { | ||
228 | 77 | return true; | ||
229 | 78 | } | ||
230 | 79 | return false; | ||
231 | 80 | } | ||
232 | 81 | |||
233 | 82 | @Override | ||
234 | 83 | protected boolean isEnabledForMultipleEclosingProjects() { | ||
235 | 84 | return isSameBranchInEnclosingProjects(); | ||
236 | 85 | } | ||
237 | 86 | } | ||
238 | 0 | 87 | ||
239 | === added file 'org.vcs.bazaar.eclipse.ui/src/org/vcs/bazaar/eclipse/ui/dialogs/SendDialog.java' | |||
240 | --- org.vcs.bazaar.eclipse.ui/src/org/vcs/bazaar/eclipse/ui/dialogs/SendDialog.java 1970-01-01 00:00:00 +0000 | |||
241 | +++ org.vcs.bazaar.eclipse.ui/src/org/vcs/bazaar/eclipse/ui/dialogs/SendDialog.java 2009-04-17 23:39:17 +0000 | |||
242 | @@ -0,0 +1,281 @@ | |||
243 | 1 | /** | ||
244 | 2 | * LICENSE + COPYRIGHT | ||
245 | 3 | */ | ||
246 | 4 | package org.vcs.bazaar.eclipse.ui.dialogs; | ||
247 | 5 | |||
248 | 6 | import java.util.ArrayList; | ||
249 | 7 | import java.util.Collection; | ||
250 | 8 | import java.util.Collections; | ||
251 | 9 | import java.util.List; | ||
252 | 10 | |||
253 | 11 | import org.eclipse.jface.dialogs.Dialog; | ||
254 | 12 | import org.eclipse.jface.dialogs.IDialogConstants; | ||
255 | 13 | import org.eclipse.swt.SWT; | ||
256 | 14 | import org.eclipse.swt.events.SelectionAdapter; | ||
257 | 15 | import org.eclipse.swt.events.SelectionEvent; | ||
258 | 16 | import org.eclipse.swt.graphics.Point; | ||
259 | 17 | import org.eclipse.swt.layout.GridData; | ||
260 | 18 | import org.eclipse.swt.layout.GridLayout; | ||
261 | 19 | import org.eclipse.swt.widgets.Button; | ||
262 | 20 | import org.eclipse.swt.widgets.Composite; | ||
263 | 21 | import org.eclipse.swt.widgets.Display; | ||
264 | 22 | import org.eclipse.swt.widgets.Group; | ||
265 | 23 | import org.eclipse.swt.widgets.Label; | ||
266 | 24 | import org.eclipse.swt.widgets.Shell; | ||
267 | 25 | import org.eclipse.swt.widgets.Text; | ||
268 | 26 | import org.vcs.bazaar.client.commandline.commands.options.Option; | ||
269 | 27 | import org.vcs.bazaar.client.commandline.syntax.ISendOptions; | ||
270 | 28 | import org.vcs.bazaar.eclipse.core.model.IBzrBranch; | ||
271 | 29 | import org.vcs.bazaar.eclipse.core.repository.BranchFactory; | ||
272 | 30 | import org.vcs.bazaar.eclipse.ui.widgets.RevisionNumber; | ||
273 | 31 | |||
274 | 32 | /** | ||
275 | 33 | * | ||
276 | 34 | * @author Javier Der Derian <javierder AT gmail.com> | ||
277 | 35 | * @BasedOn RevertDialog from BzrEclipse | ||
278 | 36 | */ | ||
279 | 37 | public class SendDialog extends LocationInputDialog { | ||
280 | 38 | |||
281 | 39 | private static final String TITLE = "Remote location Dialog"; | ||
282 | 40 | private static final String MESSAGE = "Please enter the URI of the submit location: "; | ||
283 | 41 | private RevisionNumber revision; | ||
284 | 42 | private ArrayList<Option> options; | ||
285 | 43 | private Button nobundle; | ||
286 | 44 | private Button nopatch; | ||
287 | 45 | private Button send; | ||
288 | 46 | private Button save; | ||
289 | 47 | |||
290 | 48 | private SendDialogInfo dialogInfo; | ||
291 | 49 | private Text submitLocationText; | ||
292 | 50 | private Text messageText; | ||
293 | 51 | private Text formatText; | ||
294 | 52 | |||
295 | 53 | |||
296 | 54 | /** | ||
297 | 55 | * Create the dialog | ||
298 | 56 | * | ||
299 | 57 | * @param parentShell | ||
300 | 58 | * @param selectedResources | ||
301 | 59 | * @param commiteableResources | ||
302 | 60 | */ | ||
303 | 61 | public SendDialog(Shell parentShell, Collection<IBzrBranch> locations, SendDialogInfo dialogInfo) { | ||
304 | 62 | super(parentShell, TITLE, MESSAGE, "", new BaseURIValidator(), locations, dialogInfo, true, false); | ||
305 | 63 | setShellStyle(SWT.RESIZE | SWT.MODELESS | SWT.CLOSE | SWT.BORDER | SWT.TITLE); | ||
306 | 64 | setBlockOnOpen(true); | ||
307 | 65 | this.dialogInfo = dialogInfo; | ||
308 | 66 | } | ||
309 | 67 | |||
310 | 68 | protected void createOptionsArea(Composite composite) { | ||
311 | 69 | |||
312 | 70 | final Label label = new Label(composite, SWT.NONE); | ||
313 | 71 | label.setText("Enter send location"); | ||
314 | 72 | |||
315 | 73 | Group typeBoxGroup = new Group(composite, SWT.NONE); | ||
316 | 74 | |||
317 | 75 | GridData typeBoxGrid = new GridData(); | ||
318 | 76 | |||
319 | 77 | typeBoxGrid.horizontalAlignment = SWT.FILL; | ||
320 | 78 | typeBoxGroup.setLayout(new GridLayout(2, true)); | ||
321 | 79 | typeBoxGroup.setLayoutData(typeBoxGrid); | ||
322 | 80 | |||
323 | 81 | send = new Button(typeBoxGroup, SWT.RADIO); | ||
324 | 82 | send.setText("Send to email"); | ||
325 | 83 | send.setSelection(true); // Start selected. | ||
326 | 84 | send.setToolTipText("Send the bundle to a specific email address."); | ||
327 | 85 | save = new Button(typeBoxGroup, SWT.RADIO); | ||
328 | 86 | save.setText("Save to location"); | ||
329 | 87 | save.setSelection(false); // Start unselected. | ||
330 | 88 | save.setToolTipText("Save bundle to a file in a specific location."); | ||
331 | 89 | |||
332 | 90 | GridData submitLocationGrid = new GridData(); | ||
333 | 91 | |||
334 | 92 | submitLocationGrid.horizontalAlignment = SWT.FILL; | ||
335 | 93 | submitLocationText = new Text(composite, SWT.BORDER | SWT.SINGLE); | ||
336 | 94 | submitLocationText.setLayoutData(submitLocationGrid); | ||
337 | 95 | |||
338 | 96 | final Label label2 = new Label(composite, SWT.NONE); | ||
339 | 97 | label2.setText("Message"); | ||
340 | 98 | |||
341 | 99 | GridData messageGrid = new GridData(); | ||
342 | 100 | |||
343 | 101 | messageGrid.horizontalAlignment = SWT.FILL; | ||
344 | 102 | messageText = new Text(composite, SWT.BORDER | SWT.SINGLE); | ||
345 | 103 | messageText.setLayoutData(messageGrid); | ||
346 | 104 | |||
347 | 105 | Composite container = new Composite(composite, SWT.NONE); | ||
348 | 106 | container.setLayout(new GridLayout(2, false)); | ||
349 | 107 | container.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false)); | ||
350 | 108 | |||
351 | 109 | Group checkBoxGroup = new Group(container, SWT.NONE); | ||
352 | 110 | checkBoxGroup.setLayout(new GridLayout(2, false)); | ||
353 | 111 | super.createOptionsArea(checkBoxGroup); | ||
354 | 112 | nobundle = new Button(checkBoxGroup, SWT.CHECK); | ||
355 | 113 | nobundle.setText("No bundle"); | ||
356 | 114 | nobundle.setSelection(false); // Start unselected. | ||
357 | 115 | nobundle.setToolTipText("Do not include a bundle in the merge directive."); | ||
358 | 116 | nopatch = new Button(checkBoxGroup, SWT.CHECK); | ||
359 | 117 | nopatch.setText("No patch"); | ||
360 | 118 | nopatch.setSelection(false); // Start unselected. | ||
361 | 119 | nopatch.setToolTipText("Do not include a preview patch in the merge directive."); | ||
362 | 120 | |||
363 | 121 | |||
364 | 122 | Composite formatBoxGroup = new Composite(checkBoxGroup, SWT.NONE); | ||
365 | 123 | |||
366 | 124 | GridData formatBoxGrid = new GridData(); | ||
367 | 125 | |||
368 | 126 | formatBoxGrid.horizontalAlignment = SWT.FILL; | ||
369 | 127 | formatBoxGroup.setLayout(new GridLayout(2, false)); | ||
370 | 128 | formatBoxGroup.setLayoutData(formatBoxGrid); | ||
371 | 129 | |||
372 | 130 | final Label label3 = new Label(formatBoxGroup, SWT.NONE); | ||
373 | 131 | label3.setText("Format"); | ||
374 | 132 | formatText = new Text(formatBoxGroup, SWT.BORDER | SWT.SINGLE); | ||
375 | 133 | |||
376 | 134 | Group revisionGroup = new Group(container, SWT.NONE); | ||
377 | 135 | revisionGroup.setLayout(new GridLayout()); | ||
378 | 136 | revision = new RevisionNumber(revisionGroup); | ||
379 | 137 | |||
380 | 138 | GridData data = new GridData(GridData.FILL, GridData.FILL, true, false); | ||
381 | 139 | revisionGroup.setLayoutData(data); | ||
382 | 140 | checkBoxGroup.setLayoutData(data); | ||
383 | 141 | data = new GridData(GridData.FILL_BOTH); | ||
384 | 142 | container.setLayoutData(data); | ||
385 | 143 | |||
386 | 144 | revision.addShowLogButtonSelectionListener(new SelectionAdapter() { | ||
387 | 145 | @Override | ||
388 | 146 | public void widgetSelected(SelectionEvent e) { | ||
389 | 147 | showLog(); | ||
390 | 148 | } | ||
391 | 149 | }); | ||
392 | 150 | |||
393 | 151 | } | ||
394 | 152 | |||
395 | 153 | protected void showLog() { | ||
396 | 154 | String url = super.getTextInput(); | ||
397 | 155 | if(url == null || "".equals(url.trim())) { | ||
398 | 156 | return; | ||
399 | 157 | } | ||
400 | 158 | IBzrBranch branch = BranchFactory.getInstance().findOrCreateFor(url); | ||
401 | 159 | if(branch != null) { | ||
402 | 160 | ShowLogDialog dialog = new ShowLogDialog(getShell(), branch); | ||
403 | 161 | if(dialog.open() == Dialog.OK && dialog.getSelectedRevision() != null) { | ||
404 | 162 | revision.setRevision(dialog.getSelectedRevision().getValue()); | ||
405 | 163 | } | ||
406 | 164 | } | ||
407 | 165 | } | ||
408 | 166 | |||
409 | 167 | public String getPath() { | ||
410 | 168 | return submitLocationText.getText(); | ||
411 | 169 | } | ||
412 | 170 | public String getMessage() { | ||
413 | 171 | return messageText.getText(); | ||
414 | 172 | } | ||
415 | 173 | |||
416 | 174 | public String getFormat() { | ||
417 | 175 | return formatText.getText(); | ||
418 | 176 | } | ||
419 | 177 | |||
420 | 178 | |||
421 | 179 | public Integer getType(){ | ||
422 | 180 | // 0 means send by email, 1 means save in file | ||
423 | 181 | if(send.getSelection()) | ||
424 | 182 | return 0; | ||
425 | 183 | else | ||
426 | 184 | return 1; | ||
427 | 185 | } | ||
428 | 186 | |||
429 | 187 | protected Boolean isNoBundle() { | ||
430 | 188 | return nobundle.getSelection(); | ||
431 | 189 | } | ||
432 | 190 | |||
433 | 191 | protected Boolean isNoPatch() { | ||
434 | 192 | return nopatch.getSelection(); | ||
435 | 193 | } | ||
436 | 194 | |||
437 | 195 | public Option[] getOptions() { | ||
438 | 196 | return options.toArray(new Option[options.size()]); | ||
439 | 197 | |||
440 | 198 | } | ||
441 | 199 | |||
442 | 200 | /** | ||
443 | 201 | * Create contents of the button bar | ||
444 | 202 | * | ||
445 | 203 | * @param parent | ||
446 | 204 | */ | ||
447 | 205 | @Override | ||
448 | 206 | protected void createButtonsForButtonBar(Composite parent) { | ||
449 | 207 | createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, | ||
450 | 208 | true); | ||
451 | 209 | createButton(parent, IDialogConstants.CANCEL_ID, | ||
452 | 210 | IDialogConstants.CANCEL_LABEL, false); | ||
453 | 211 | } | ||
454 | 212 | |||
455 | 213 | /** | ||
456 | 214 | * Return the initial size of the dialog | ||
457 | 215 | */ | ||
458 | 216 | @Override | ||
459 | 217 | protected Point getInitialSize() { | ||
460 | 218 | return new Point(540, 490); | ||
461 | 219 | } | ||
462 | 220 | |||
463 | 221 | @Override | ||
464 | 222 | protected void okPressed() { | ||
465 | 223 | this.options = new ArrayList<Option>(0); | ||
466 | 224 | |||
467 | 225 | if(getPath().length() > 0 && getValue().length() > 0 ) { | ||
468 | 226 | if(getType() == 0){ | ||
469 | 227 | options.add(ISendOptions.MAIL_TO.setArgument(getPath())); | ||
470 | 228 | } | ||
471 | 229 | else { | ||
472 | 230 | options.add(ISendOptions.OUTPUT.setArgument(getPath())); | ||
473 | 231 | } | ||
474 | 232 | } | ||
475 | 233 | else { | ||
476 | 234 | //FIXME: give some kind of message | ||
477 | 235 | return; | ||
478 | 236 | } | ||
479 | 237 | |||
480 | 238 | options.add(ISendOptions.MESSAGE.setArgument(getMessage())); | ||
481 | 239 | |||
482 | 240 | if(isRemember()) { | ||
483 | 241 | options.add(ISendOptions.REMEMBER); | ||
484 | 242 | } | ||
485 | 243 | |||
486 | 244 | if(isNoBundle()) { | ||
487 | 245 | options.add(ISendOptions.NO_BUNDLE); | ||
488 | 246 | } | ||
489 | 247 | |||
490 | 248 | if(isNoPatch()) { | ||
491 | 249 | options.add(ISendOptions.NO_PATCH); | ||
492 | 250 | } | ||
493 | 251 | if(revision.isRevisionSelected()) { | ||
494 | 252 | options.add(ISendOptions.REVISION.setArgument(revision.getRevision())); | ||
495 | 253 | } | ||
496 | 254 | |||
497 | 255 | if(getFormat().length() > 0) { | ||
498 | 256 | options.add(ISendOptions.FORMAT.setArgument(getFormat())); | ||
499 | 257 | } | ||
500 | 258 | |||
501 | 259 | this.dialogInfo.options = options; | ||
502 | 260 | super.okPressed(); | ||
503 | 261 | } | ||
504 | 262 | |||
505 | 263 | public static class SendDialogInfo extends LocationDialogInfo { | ||
506 | 264 | List<Option> options; | ||
507 | 265 | |||
508 | 266 | public List<Option> getOptions() { | ||
509 | 267 | return options; | ||
510 | 268 | } | ||
511 | 269 | } | ||
512 | 270 | |||
513 | 271 | // this main is for test the dialog during development | ||
514 | 272 | public static void main(String[] args) { | ||
515 | 273 | Display display = new Display(); | ||
516 | 274 | Shell shell = new Shell(display); | ||
517 | 275 | shell.setMinimumSize(280, 400); | ||
518 | 276 | SendDialog dialog = new SendDialog(shell, Collections.EMPTY_LIST, new SendDialogInfo()); | ||
519 | 277 | dialog.setBlockOnOpen(true); | ||
520 | 278 | int exit = dialog.open(); | ||
521 | 279 | System.out.println("exit: " + exit); | ||
522 | 280 | } | ||
523 | 281 | } |
Send command implementation.
The dialog, action and command are based on merge and uncommit.
Hope it merges!