Skip to content

Commit 9b309dc

Browse files
committed
Started on Update, might need to port current add reference to new API due to 'popupMenu' being deprecated..
1 parent f903956 commit 9b309dc

File tree

3 files changed

+153
-1
lines changed

3 files changed

+153
-1
lines changed

src/ServiceStackEclipse/plugin.xml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<objectContribution
88
adaptable="true"
99
objectClass="org.eclipse.core.resources.IFolder"
10-
id="net.servicestack.eclipse.contribution1">
10+
id="net.servicestack.eclipse.addReference">
1111
<action
1212
label="Add ServiceStack Reference..."
1313
class="net.servicestack.eclipse.popup.actions.AddReferenceAction"
@@ -17,6 +17,53 @@
1717
id="net.servicestack.eclipse.newAction">
1818
</action>
1919
</objectContribution>
20+
<objectContribution
21+
adaptable="true"
22+
objectClass="org.eclipse.core.resources.IFile"
23+
id="net.servicestack.eclipse.updateReference">
24+
<action
25+
label="Update ServiceStack Reference"
26+
class="net.servicestack.eclipse.popup.actions.UpdateReference"
27+
menubarPath="additions"
28+
enablesFor="1"
29+
icon="icons/logo-16.png"
30+
id="net.servicestack.eclipse.updateAction">
31+
</action>
32+
</objectContribution>
33+
</extension>
34+
<!--<extension
35+
point="org.eclipse.ui.commands">
36+
<command
37+
id="net.servicestack.eclipse.commands.sampleCommand"
38+
name="Add ServiceStack Reference...">
39+
</command>
40+
</extension>
41+
<extension
42+
point="org.eclipse.ui.handlers">
43+
<handler
44+
class="net.servicestack.eclipse.handlers.SampleHandler"
45+
commandId="net.servicestack.eclipse.commands.sampleCommand">
46+
</handler>
2047
</extension>
48+
<extension
49+
point="org.eclipse.ui.bindings">
50+
<key
51+
commandId="net.servicestack.eclipse.commands.sampleCommand"
52+
contextId="org.eclipse.ui.contexts.window"
53+
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
54+
sequence="M1+6">
55+
</key>
56+
</extension>
57+
<extension
58+
point="org.eclipse.ui.menus">
59+
<menuContribution
60+
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
61+
<command
62+
commandId="net.servicestack.eclipse.commands.sampleCommand"
63+
id="net.servicestack.eclipse.menus.sampleCommand"
64+
mnemonic="S">
65+
</command>
66+
</menuContribution>
67+
</extension>-->
2168

2269
</plugin>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package net.servicestack.eclipse.handlers;
2+
3+
import org.eclipse.core.commands.AbstractHandler;
4+
import org.eclipse.core.commands.ExecutionEvent;
5+
import org.eclipse.core.commands.ExecutionException;
6+
import org.eclipse.ui.IWorkbenchWindow;
7+
import org.eclipse.ui.handlers.HandlerUtil;
8+
import org.eclipse.jface.dialogs.MessageDialog;
9+
10+
/**
11+
* Our sample handler extends AbstractHandler, an IHandler base class.
12+
* @see org.eclipse.core.commands.IHandler
13+
* @see org.eclipse.core.commands.AbstractHandler
14+
*/
15+
public class SampleHandler extends AbstractHandler {
16+
/**
17+
* The constructor.
18+
*/
19+
public SampleHandler() {
20+
}
21+
22+
/**
23+
* the command has been executed, so extract extract the needed information
24+
* from the application context.
25+
*/
26+
public Object execute(ExecutionEvent event) throws ExecutionException {
27+
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
28+
MessageDialog.openInformation(
29+
window.getShell(),
30+
"Eclipse",
31+
"Hello, Eclipse world");
32+
return null;
33+
}
34+
35+
36+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package net.servicestack.eclipse.popup.actions;
2+
3+
import net.servicestack.eclipse.wizard.AddReferenceWizard;
4+
5+
import org.eclipse.core.resources.IFolder;
6+
import org.eclipse.jdt.core.IPackageFragment;
7+
import org.eclipse.jface.action.IAction;
8+
import org.eclipse.jface.viewers.ISelection;
9+
import org.eclipse.jface.viewers.IStructuredSelection;
10+
import org.eclipse.jface.wizard.WizardDialog;
11+
import org.eclipse.swt.widgets.Shell;
12+
import org.eclipse.ui.IObjectActionDelegate;
13+
import org.eclipse.ui.ISelectionService;
14+
import org.eclipse.ui.IWorkbenchPart;
15+
16+
public class UpdateReference implements IObjectActionDelegate {
17+
18+
private Shell shell;
19+
private IFolder _selection;
20+
private IPackageFragment _packageFragment;
21+
private ISelectionService selectionService;
22+
/**
23+
* Constructor for Action1.
24+
*/
25+
public UpdateReference() {
26+
super();
27+
}
28+
29+
/**
30+
* @see IObjectActionDelegate
31+
*/
32+
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
33+
shell = targetPart.getSite().getShell();
34+
targetPart.getSite().getWorkbenchWindow().getSelectionService();
35+
selectionService = targetPart.getSite().getWorkbenchWindow().getSelectionService();
36+
}
37+
38+
/**
39+
* @see IActionDelegate#run(IAction)
40+
*/
41+
public void run(IAction action) {
42+
if (_selection != null) {
43+
IStructuredSelection packageSelection = (IStructuredSelection) selectionService
44+
.getSelection("org.eclipse.jdt.ui.PackageExplorer");
45+
46+
AddReferenceWizard generationWizard = new AddReferenceWizard(_selection, packageSelection);
47+
WizardDialog dialog = new WizardDialog(shell, generationWizard);
48+
49+
if (dialog.open() == WizardDialog.OK){
50+
// MessageDialog.openInformation(shell, "CTE tree generation", "CTE trees are being generated, checking the process view for details!");
51+
}
52+
}
53+
}
54+
55+
/**
56+
* @see IActionDelegate#selectionChanged(IAction, ISelection)
57+
*/
58+
@Override
59+
public void selectionChanged(IAction action, ISelection selection) {
60+
if(selection instanceof IStructuredSelection) {
61+
IStructuredSelection structured = (IStructuredSelection)selection;
62+
Object firstElement = structured.getFirstElement();
63+
if(firstElement instanceof IFolder) {
64+
_selection = (IFolder) firstElement;
65+
}
66+
}
67+
}
68+
69+
}

0 commit comments

Comments
 (0)