java - Eclipse RCP: Command handler for view and editor -
i have command have added context menu of view (which has treeviewer) , context menu of custom editor.
in handler there way me differentiate context menu command has been called from? because in case of view, use data need,
iselection selection = handlerutil.getactiveworkbenchwindow(event) .getactivepage().getselection(); if (selection != null & selection instanceof istructuredselection) { istructuredselection strucselection = (istructuredselection) selection; ..... in case of editor, selection null, of course. added following handle editor part,
ieditorpart editor = handlerutil.getactiveeditor(event); ieditorinput input = editor.geteditorinput(); ipath path = ((fileeditorinput)input).getpath(); but happens if execute command view, returns active editor. mean have write separate handlers active based on whether view or editor in focus?
thank you!
does mean have write separate handlers active based on whether view or editor in focus?
yes does. however, separate handlers can small classes call common class of work of command. don't know data command needs function, separate handlers can prepare data , pass common class through 1 or more constructors.
Comments
Post a Comment