MultiPage Editor - Problem with delete action across tabs [message #225496] |
Tue, 31 October 2006 10:26 |
Eclipse User |
|
|
|
Originally posted by: prashanto.chatterjee.softwareag.com
Hi,
I have a multi-page editor with three tabs - graphical layout, tree layout
and source.
I have a model selected in the graphical layout. Using the delete-key from
the keyboard, the object can be deleted from the model. I switch to tree
layout and selection-synchronizer ensures that the same is selected in the
tree. I switch next to source (xml) tab. Next I switch back to graphical
layout tab. The model remains selected and using the delete key (on the
keyboard) works fine and the object is deleted from the internal model and
reflected in the view.
Now, if I am in the tree-layout tab(And if I have not yet switched to the
source tab), pressing delete key works fine. I switch now to the source tab
and back to the tree-layout tab. Now pressing the delete key actually
deletes from the source-editor and not from the current tree-editor. A
careful look at the events, reveal that the selection is not a
structured-selection but a text-selection. This is quite strange because at
the time of the switch from source to tree, the selected item is a
structured selection.
Please note that I have the same GraphicalEditor for both graphical-layout
and tree-layout with one exception. For the tree-editor I do the following:
------------------------------------------------------------ ------------------------------------------------------------ ----------------------------
protected void createGraphicalViewer(Composite parent) {
GraphicalViewer viewer =
new SequenceTreeViewer(getSite().getWorkbenchWindow().getShell() );
viewer.createControl(parent);
setGraphicalViewer(viewer);
configureGraphicalViewer();
hookGraphicalViewer();
initializeGraphicalViewer();
}
------------------------------------------------------------ ------------------------------------------------------------ ----------------------------
Also for both the graphical and tree editors I have the following method
overriden as:
------------------------------------------------------------ ------------------------------------------------------------ ----------------------------
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// If not the active editor, ignore selection changed.
if (getSite().getPage().getActiveEditor() == getWorkflowEditor()
&& getWorkflowEditor().getActiveEditor() == this) {
updateActions(getSelectionActions());
}
}
------------------------------------------------------------ ------------------------------------------------------------ ----------------------------
I fail to understand as to why it works for one and not for the other. Also,
please note that I use a common edit-domain for both the tree and the
graphical editors.
Please guide me as to how I proceed with this.
Any help would be deeply appreciated.
Kind Regards,
Prashanto
|
|
|
|
Re: MultiPage Editor - Problem with delete action across tabs [message #225561 is a reply to message #225559] |
Tue, 31 October 2006 15:29 |
Eclipse User |
|
|
|
Originally posted by: prashanto.chatterjee.softwareag.com
Hi,
Yes I did that. In fact inside my EditorActionBarContributor I have the
following code:
------------------------------------------------------------ --------------------------------------------------
public void setActivePage(IEditorPart part) {
IActionBars actionBars = getActionBars();
if (actionBars != null) {
actionBars.clearGlobalActionHandlers();
if(part instanceof GraphicalEditor){
ActionRegistry registry = (ActionRegistry)
part.getAdapter(ActionRegistry.class);
for (int i = 0; i < globalActionKeys.size(); i++) {
String id = (String) globalActionKeys.get(i);
actionBars.setGlobalActionHandler(id, registry.getAction(id));
}
}else if(part instanceof ITextEditor){
ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part
: null;
actionBars.setGlobalActionHandler(
ActionFactory.DELETE.getId(),
getTextAction(editor, ITextEditorActionConstants.DELETE));
actionBars.setGlobalActionHandler(
ActionFactory.UNDO.getId(),
getTextAction(editor, ITextEditorActionConstants.UNDO));
actionBars.setGlobalActionHandler(
ActionFactory.REDO.getId(),
getTextAction(editor, ITextEditorActionConstants.REDO));
actionBars.setGlobalActionHandler(
ActionFactory.CUT.getId(),
getTextAction(editor, ITextEditorActionConstants.CUT));
actionBars.setGlobalActionHandler(
ActionFactory.COPY.getId(),
getTextAction(editor, ITextEditorActionConstants.COPY));
actionBars.setGlobalActionHandler(
ActionFactory.PASTE.getId(),
getTextAction(editor, ITextEditorActionConstants.PASTE));
actionBars.setGlobalActionHandler(
ActionFactory.SELECT_ALL.getId(),
getTextAction(editor, ITextEditorActionConstants.SELECT_ALL));
actionBars.setGlobalActionHandler(
ActionFactory.FIND.getId(),
getTextAction(editor, ITextEditorActionConstants.FIND));
actionBars.setGlobalActionHandler(
IDEActionFactory.BOOKMARK.getId(),
getTextAction(editor, IDEActionFactory.BOOKMARK.getId()));
}
//update the action bars
actionBars.updateActionBars();
}
}
------------------------------------------------------------ ----------------------------------------------------------
What is wierd is the fact that it works perfectly fine for the
graphical-editor but doesn't work for tree-editor.
Regards,
Prashanto
"Xiang Qinxian" <fyaoxy@gmail.com> wrote in message
news:ei7pis$2c4$1@utils.eclipse.org...
> Hi,
> Did you do setGlobalActionHandler?
>
> Regards,
>
> Qinxian
>
> Prashanto Chatterjee д
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02902 seconds