Home » Eclipse Projects » Rich Client Platform (RCP) » Hideing an Editor
| |
Re: Hideing an Editor [message #519096 is a reply to message #519004] |
Sat, 06 March 2010 11:54 |
Andre Kullmann Messages: 33 Registered: September 2009 |
Member |
|
|
Thanks !!
Currently I work with Eclipse 3.4 as target platform, the method hideEditor is not available in this release
So I build this workaround
public static void hideEditor( IWorkbenchPage page, IEditorReference ref) {
// if (!(this.editorPresentation.containsEditor((EditorReference)ref))) {
// return;
// }
// this.editorPresentation.closeEditor(ref);
Field field = FieldUtils.findField( page.getClass(), "editorPresentation");
Object obj = FieldUtils.get( page, field );
Method method = MethodUtils.findMethod( obj.getClass(), "closeEditor", new Class[] { IEditorReference.class } );
MethodUtils.invoke( obj, method, ref );
// this.activationList.remove(ref);
field = FieldUtils.findField( page.getClass(), "activationList");
obj = FieldUtils.get( page, field );
method = MethodUtils.findMethod( obj.getClass(), "remove", new Class[] { IEditorReference.class } );
MethodUtils.invoke( obj, method, ref );
//updateActivePart();
method = MethodUtils.findMethod( page.getClass(), "updateActivePart", new Class[0] );
MethodUtils.invoke( page, method );
IEditorPart editor = ref.getEditor(false);
if( editor != null ) {
SaveablesList modelManager = (SaveablesList) editor.getSite().getService(ISaveablesLifecycleListener.class);
Object result = modelManager.preCloseParts( Arrays.asList(editor), true, editor.getEditorSite().getWorkbenchWindow() );
modelManager.postClose( result );
}
}
public static void showEditor( IWorkbenchPage page, IEditorReference ref) {
// if (!(this.editorPresentation.containsEditor((EditorReference)ref))) {
// return;
// }
// this.editorPresentation.addEditor((EditorReference)ref, "", false);
Field field = FieldUtils.findField( page.getClass(), "editorPresentation");
Object obj = FieldUtils.get( page, field );
Method method = MethodUtils.findMethod( obj.getClass(), "addEditor", new Class[] { EditorReference.class, String.class } );
MethodUtils.invoke( obj, method, ref, "" );
// this.activationList.add(ref);
field = FieldUtils.findField( page.getClass(), "activationList");
obj = FieldUtils.get( page, field );
method = MethodUtils.findMethod( obj.getClass(), "add", new Class[] { IEditorReference.class } );
MethodUtils.invoke( obj, method, ref );
//this.removedEditors.add(ref); TODO
//updateActivePart();
method = MethodUtils.findMethod( page.getClass(), "updateActivePart", new Class[0] );
MethodUtils.invoke( page, method );
}
Regards,
André
|
|
| |
Goto Forum:
Current Time: Thu Sep 26 18:27:04 GMT 2024
Powered by FUDForum. Page generated in 0.03876 seconds
|