eclipsefileeditorcnf

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 achieve this


Solution

  • 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.