Eclipse Common Navigator Framework
I have an Eclipse Common Navigator (specific to our project ) on our RAP application. So, generally, when user a resource in the left hand side navigator, it gets opened in the right hand side navigator.Now,suppose, if a click a file with some extension, I want to open a custom message opened and popped up in front of the user in the form of a Dialog Box. how can I achi开发者_StackOverflow社区eve this
Alternatively you can register a specific editor with an associated launcher:
<editor
id="com.foo.MyEditor"
launcher="com.foo.MyEditorLauncher"
default="true"
extensions="your_extension_here"
icon="any icon for your file"
name="Dialog editor">
</editor>
And implement the launcher to show the dialog you want:
public class MyEditorLauncher implements IEditorLauncher {
@Override
public void open(IPath path) {
Shell shell = Display.getDefault().getActiveShell();
MessageDialog.openInformation(shell, "Not Editable", "Can't open this element");
}
}
The user will be always be able to use alternative editors, but by default they'll get that message.
You will want to register an editor via the editors extension point against files of that extension. The body of that editor can be the message that you want.
Try registering an ActionProvider in the navigatorContent with the appropiated enablement (so that it is applied to the files you're interested in).
Within your custom action provider (extending CommonActionProvider) you can subscribe to the doubleclick events in the init method:
@Override
public void init(ICommonActionExtensionSite aSite) {
super.init(aSite);
IWorkbench workbench = MyPlugin.getDefault().getWorkbench();
doubleclick = new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
// show Your Popup Here !!!
}
};
aSite.getStructuredViewer().addDoubleClickListener(doubleclick);
}
精彩评论