Skip to content

Commit d4dc6d3

Browse files
committed
Update actionset example to contribute to the search menu
1 parent 25a8587 commit d4dc6d3

File tree

3 files changed

+55
-75
lines changed

3 files changed

+55
-75
lines changed

com.vogella.rcp.example.actionset/plugin.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@
6262
point="org.eclipse.ui.actionSets">
6363
<actionSet
6464
id="testing.actionSet"
65-
label="Sample Action Set"
65+
label="Quick Access search"
6666
visible="true">
67-
<menu
68-
id="sampleMenu"
69-
label="Sample &amp;Menu">
70-
<separator
71-
name="sampleGroup">
72-
</separator>
73-
</menu>
7467
<action
75-
class="testing.actions.SampleAction"
76-
icon="icons/sample.gif"
68+
class="testing.actions.TriggerQuickAccessAction"
7769
id="testing.actions.SampleAction"
7870
label="&amp;Sample Action"
79-
menubarPath="sampleMenu/sampleGroup"
71+
menubarPath="org.eclipse.search.menu/extraSearchGroup"
72+
toolbarPath="sampleGroup"
73+
tooltip="Hello, Eclipse world">
74+
</action>
75+
<action
76+
class="testing.actions.TriggerQuickAccessAction"
77+
id="testing.actions.SampleAction2"
78+
label="Find Commands..."
79+
menubarPath="org.eclipse.search.menu/extraSearchGroup"
8080
toolbarPath="sampleGroup"
8181
tooltip="Hello, Eclipse world">
8282
</action>

com.vogella.rcp.example.actionset/src/testing/actions/SampleAction.java

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package testing.actions;
2+
3+
import org.eclipse.core.commands.ExecutionException;
4+
import org.eclipse.core.commands.NotEnabledException;
5+
import org.eclipse.core.commands.NotHandledException;
6+
import org.eclipse.core.commands.common.NotDefinedException;
7+
import org.eclipse.jface.action.IAction;
8+
import org.eclipse.jface.viewers.ISelection;
9+
import org.eclipse.ui.IWorkbenchWindow;
10+
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
11+
import org.eclipse.ui.handlers.IHandlerService;
12+
/**
13+
* Contributed via ActionSet as workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213385
14+
* Extension be converted to a menu contribution and this class be removed once the above bug is solved
15+
*
16+
*/
17+
public class TriggerQuickAccessAction implements IWorkbenchWindowActionDelegate {
18+
private IWorkbenchWindow window;
19+
20+
@Override
21+
public void run(IAction action) {
22+
IHandlerService handlerService = window.getService(IHandlerService.class);
23+
try {
24+
handlerService.executeCommand("org.eclipse.ui.window.quickAccess", null); // //$NON-NLS-1$
25+
} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) {
26+
e.printStackTrace();
27+
}
28+
}
29+
30+
@Override
31+
public void selectionChanged(IAction action, ISelection selection) {
32+
// intentially left emtpy
33+
}
34+
35+
@Override
36+
public void dispose() {
37+
// intentially left emtpy
38+
}
39+
40+
@Override
41+
public void init(IWorkbenchWindow window) {
42+
this.window = window;
43+
}
44+
}

0 commit comments

Comments
 (0)