Fragment by Brian Fitzpartick:
Create a new IObjectActionDelegate class and reference it in your plug-in
something like the following...
The class might look like:
package blah;
import ...;
public class MyAction implements IObjectActionDelegate {
private ISelection mStashedSelection = null;
/ Constructor for Action1. /
public MyAction() {
super();
}
/ @see IActionDelegate#run(IAction) /
public void run(IAction action) {
if (mStashedSelection != null && !mStashedSelection.isEmpty()) {
if (mStashedSelection instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) mStashedSelection;
if (ssel.getFirstElement() instanceof IConnectionProfile) {
//do something
}
}
}
}
public void selectionChanged(IAction action, ISelection selection) {
mStashedSelection = selection;
}
}
And then your extension point in your plugin.xml looks something like
this:
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.datatools.connectivity.IConnectionProfile"
id="my.action.contribution">
<action
label="My Action Label"
class="my.action.class"
menubarPath="slot3"
enablesFor="1"
id="my.action.id">
</action>
</objectContribution>
</extension>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Fragment by Brian Fitzpartick:
Create a new IObjectActionDelegate class and reference it in your plug-in
something like the following...
The class might look like:
package blah;
import ...;
public class MyAction implements IObjectActionDelegate {
private ISelection mStashedSelection = null;
/
Constructor for Action1.
/
public MyAction() {
super();
}
/
@see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
}
/
@see IActionDelegate#run(IAction)
/
public void run(IAction action) {
if (mStashedSelection != null && !mStashedSelection.isEmpty()) {
if (mStashedSelection instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) mStashedSelection;
if (ssel.getFirstElement() instanceof IConnectionProfile) {
//do something
}
}
}
}
public void selectionChanged(IAction action, ISelection selection) {
mStashedSelection = selection;
}
}
And then your extension point in your plugin.xml looks something like
this:
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.datatools.connectivity.IConnectionProfile"
id="my.action.contribution">
<action
label="My Action Label"
class="my.action.class"
menubarPath="slot3"
enablesFor="1"
id="my.action.id">
</action>
</objectContribution>
</extension>
With [2527] this feature is implemented
Related
Commit: [r2527]