Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Hideing an Editor
Hideing an Editor [message #518967] Fri, 05 March 2010 15:19 Go to next message
Andre Kullmann is currently offline Andre Kullmann
Messages: 33
Registered: September 2009
Member
Hi,

I want to hide Editors and restore the later.
Something like

editorOne.open();
[...]
editorOne.setVisible( false );
editorTwo.open()
[...]
editorTwo.setVisible( false );
editorOne.setVisible( true );


Is this possible ? Does anybody knows how ?

Regards,
André
Re: Hideing an Editor [message #519004 is a reply to message #518967] Fri, 05 March 2010 11:36 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

there is some API that can help ... it mostly works :-)

See org.eclipse.ui.IWorkbenchPage.hideEditor(IEditorReference)

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Hideing an Editor [message #519096 is a reply to message #519004] Sat, 06 March 2010 11:54 Go to previous messageGo to next message
Andre Kullmann is currently offline 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 Sad

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é
Re: Hideing an Editor [message #519409 is a reply to message #519096] Mon, 08 March 2010 17:58 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

:-)

I'll just offer a word of caution, certain other internals were shifted
around to make that work in 3.5. As long as it does what you want, of
course it's great, but I would try and run a few tests to make sure you
are not leaking editors anywhere.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:Adding login-type check to oe.ui.ide.workbench Product
Next Topic:Problem with Splash Browser
Goto Forum:
  


Current Time: Sun Sep 21 22:23:17 GMT 2014

Powered by FUDForum. Page generated in 0.01749 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software