Merge lp:~craighewetson-deactivatedaccount/qbzr-eclipse/menuActions into lp:qbzr-eclipse

Proposed by Craig Hewetson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~craighewetson-deactivatedaccount/qbzr-eclipse/menuActions
Merge into: lp:qbzr-eclipse
Diff against target: 159 lines
4 files modified
qbzr-eclipse/plugin.xml (+25/-5)
qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/BazaarCommandHandler.java (+15/-5)
qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/DiffMenuCommandHandler.java (+10/-0)
qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/LogMenuCommandHandler.java (+10/-0)
To merge this branch: bzr merge lp:~craighewetson-deactivatedaccount/qbzr-eclipse/menuActions
Reviewer Review Type Date Requested Status
Nicholas Allen Approve
Review via email: mp+13690@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Craig Hewetson (craighewetson-deactivatedaccount) wrote :

The log and the diff action from the Main Menu will now behave slightly differently:
If a file or project is selected it will not make use of the selected resource by rather the branch that it is found in.

So if the user wants to do a log <dir> or log <file>, he needs to right click on it and then execute the log action.

The same was done for Diff. The other actions are already branch based.

Revision history for this message
Nicholas Allen (nick-allen) wrote :

Hi Craig,

There was no need to introduce the ignoreSelectedFilesOverBranch() method so I have removed it. Instead the LogMenuCommandHandler and the DiffMenuCommandHandler can simply override useSelectedFilesAsArguments() to return false to make themselves work on the branch and not the selected files.

Also I renamed LogMenuCommandHandler to LogBranchCommandHandler and likewise for the diff one.

I have merged it onto trunk now. Thanks for the patch.

Cheers,

Nick

review: Approve
Revision history for this message
Craig Hewetson (craighewetson-deactivatedaccount) wrote :

>
> There was no need to introduce the ignoreSelectedFilesOverBranch() method
> so I have removed it. Instead the LogMenuCommandHandler and the
> DiffMenuCommandHandler can simply override useSelectedFilesAsArguments() to
> return false to make themselves work on the branch and not the selected
> files.
>
>
Oh yes that make sense. Thanks alot.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qbzr-eclipse/plugin.xml'
2--- qbzr-eclipse/plugin.xml 2009-10-01 07:02:04 +0000
3+++ qbzr-eclipse/plugin.xml 2009-10-21 06:35:19 +0000
4@@ -126,12 +126,24 @@
5 </command>
6 <command
7 categoryId="qbzr_eclipse.commands.category"
8+ description="Show differences that will be committed"
9+ id="qbzr_eclipse.commands.diffMenuCommand"
10+ name="Show Differences...">
11+ </command>
12+ <command
13+ categoryId="qbzr_eclipse.commands.category"
14 description="Browse revisions in the history log"
15 id="qbzr_eclipse.commands.logCommand"
16 name="Log History...">
17 </command>
18 <command
19 categoryId="qbzr_eclipse.commands.category"
20+ description="Browse revisions in the history log"
21+ id="qbzr_eclipse.commands.logMenuCommand"
22+ name="Log History...">
23+ </command>
24+ <command
25+ categoryId="qbzr_eclipse.commands.category"
26 description="Browse files, directory etc in a branch"
27 id="qbzr_eclipse.commands.browseCommand"
28 name="Browse Items...">
29@@ -248,10 +260,18 @@
30 commandId="qbzr_eclipse.commands.diffCommand">
31 </handler>
32 <handler
33+ class="org.bazaar_vcs.qbzr_eclipse.handlers.DiffMenuCommandHandler"
34+ commandId="qbzr_eclipse.commands.diffMenuCommand">
35+ </handler>
36+ <handler
37 class="org.bazaar_vcs.qbzr_eclipse.handlers.LogCommandHandler"
38 commandId="qbzr_eclipse.commands.logCommand">
39 </handler>
40 <handler
41+ class="org.bazaar_vcs.qbzr_eclipse.handlers.LogMenuCommandHandler"
42+ commandId="qbzr_eclipse.commands.logMenuCommand">
43+ </handler>
44+ <handler
45 class="org.bazaar_vcs.qbzr_eclipse.handlers.BrowseCommandHandler"
46 commandId="qbzr_eclipse.commands.browseCommand">
47 </handler>
48@@ -337,11 +357,11 @@
49 mnemonic="A">
50 </command>
51 <command
52- commandId="qbzr_eclipse.commands.diffCommand"
53+ commandId="qbzr_eclipse.commands.diffMenuCommand"
54 icon="icons/diff.png"
55- id="qbzr_eclipse.menus.diffCommand"
56+ id="qbzr_eclipse.menus.diffMenuCommand"
57 mnemonic="D">
58- </command>
59+ </command>
60 <command
61 commandId="qbzr_eclipse.commands.commitCommand"
62 icon="icons/commit.png"
63@@ -411,9 +431,9 @@
64 mnemonic="x"
65 icon="icons/explore.png">
66 <command
67- commandId="qbzr_eclipse.commands.logCommand"
68+ commandId="qbzr_eclipse.commands.logMenuCommand"
69 icon="icons/log.png"
70- id="qbzr_eclipse.menus.logCommand"
71+ id="qbzr_eclipse.menus.logMenuCommand"
72 mnemonic="L">
73 </command>
74 <command
75
76=== modified file 'qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/BazaarCommandHandler.java'
77--- qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/BazaarCommandHandler.java 2009-10-11 16:45:03 +0000
78+++ qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/BazaarCommandHandler.java 2009-10-21 06:35:19 +0000
79@@ -72,7 +72,7 @@
80 File branchDirectory = null;
81 File fileBeingEdited = null;
82
83- if (selection != null && selection instanceof ITreeSelection)
84+ if (selection != null && !selection.isEmpty() && selection instanceof ITreeSelection)
85 {
86 selectedFiles = EclipseUtilities
87 .getSelectedFiles((ITreeSelection) selection);
88@@ -88,10 +88,10 @@
89 }
90
91 // Check that the command can run on the selection.
92-
93+ final boolean ignoreSelectedFiles=ignoreSelectedFilesOverBranch();
94 try
95 {
96- checkCommandCanRunOnSelection(selectedFiles, fileBeingEdited,
97+ checkCommandCanRunOnSelection(ignoreSelectedFiles?Collections.EMPTY_LIST:selectedFiles, fileBeingEdited,
98 branchDirectory);
99 }
100 catch (CannotRunCommandOnSelectionException e)
101@@ -106,9 +106,9 @@
102 .getLocation();
103
104 final File directoryToRunIn = getDirectoryToRunIn(workspaceRoot
105- .toFile(), branchDirectory, selectedFiles, fileBeingEdited);
106+ .toFile(), branchDirectory, ignoreSelectedFiles?Collections.EMPTY_LIST:selectedFiles, fileBeingEdited);
107
108- List<String> commandElements = getCommand(selectedFiles,
109+ List<String> commandElements = getCommand(ignoreSelectedFiles?Collections.EMPTY_LIST:selectedFiles,
110 fileBeingEdited, branchDirectory, directoryToRunIn);
111 final String[] command = commandElements
112 .toArray(new String[commandElements.size()]);
113@@ -229,6 +229,16 @@
114 }
115
116 /**
117+ * This is one way of indicating that the action occurred from menu item,
118+ * and therefore it should be run on the entire branch and not the last selected
119+ * files.
120+ * The popup action will always try to work on the last selected resource.
121+ * @return
122+ */
123+ protected boolean ignoreSelectedFilesOverBranch(){
124+ return false;
125+ }
126+ /**
127 * Checks if the list of selected files should be passed on to the Bazaar
128 * command.
129 */
130
131=== added file 'qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/DiffMenuCommandHandler.java'
132--- qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/DiffMenuCommandHandler.java 1970-01-01 00:00:00 +0000
133+++ qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/DiffMenuCommandHandler.java 2009-10-21 06:35:19 +0000
134@@ -0,0 +1,10 @@
135+package org.bazaar_vcs.qbzr_eclipse.handlers;
136+
137+public class DiffMenuCommandHandler extends DiffCommandHandler
138+{
139+
140+ @Override
141+ protected boolean ignoreSelectedFilesOverBranch() {
142+ return true;
143+ }
144+}
145
146=== added file 'qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/LogMenuCommandHandler.java'
147--- qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/LogMenuCommandHandler.java 1970-01-01 00:00:00 +0000
148+++ qbzr-eclipse/src/org/bazaar_vcs/qbzr_eclipse/handlers/LogMenuCommandHandler.java 2009-10-21 06:35:19 +0000
149@@ -0,0 +1,10 @@
150+package org.bazaar_vcs.qbzr_eclipse.handlers;
151+
152+public class LogMenuCommandHandler extends LogCommandHandler {
153+
154+ @Override
155+ protected boolean ignoreSelectedFilesOverBranch() {
156+ return true;
157+ }
158+
159+}

Subscribers

People subscribed via source and target branches

to all changes: