Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » programatically detach a view in 4.2
programatically detach a view in 4.2 [message #895411] Thu, 12 July 2012 18:44 Go to next message
Mark Fishman is currently offline Mark FishmanFriend
Messages: 27
Registered: March 2011
Junior Member
So I want to switch my RCP application from 3.7.2 to 4.2 to take advantage of some of the nice new features that it has but one of my hacks is coming back to haunt me.

In the 3.7.2 implementation of my application, I needed an ability to allow a user to, upon request, launch a view either attached as a tab in my main window or else detached in its own window. Further, if the user launched the view detached, I wanted them to be able to grab the tab for it and drag it back into the main window to attach it there.

In 3.7, I was able to meet this goal by using the internal APIs to make a call like:

((WorkbenchPage)getSite().getPage()).getActivePerspective().getPresentation( )
detachPart(ref);


to launch the view detached. Since it was still associated with the main window, I could then drag it back in and attach it like I wanted.

Those APIs are now gone in 4.2. I can't complain too much because I know that I was using internal APIs but my question is, is there a similar way to get the same sort of functionality in 4.2?

Thanks.
Re: programatically detach a view in 4.2 [message #895441 is a reply to message #895411] Thu, 12 July 2012 22:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I can't tell you which API but a good start is EModelService#detach
which allows to detach a complete stack.

Tom

Am 12.07.12 20:44, schrieb Mark Fishman:
> So I want to switch my RCP application from 3.7.2 to 4.2 to take
> advantage of some of the nice new features that it has but one of my
> hacks is coming back to haunt me.
>
> In the 3.7.2 implementation of my application, I needed an ability to
> allow a user to, upon request, launch a view either attached as a tab in
> my main window or else detached in its own window. Further, if the user
> launched the view detached, I wanted them to be able to grab the tab for
> it and drag it back into the main window to attach it there.
>
> In 3.7, I was able to meet this goal by using the internal APIs to make
> a call like:
>
> ((WorkbenchPage)getSite().getPage()).getActivePerspective().getPresentation(
> )
> detachPart(ref);
>
>
> to launch the view detached. Since it was still associated with the
> main window, I could then drag it back in and attach it like I wanted.
>
> Those APIs are now gone in 4.2. I can't complain too much because I
> know that I was using internal APIs but my question is, is there a
> similar way to get the same sort of functionality in 4.2?
> Thanks.
Re: programatically detach a view in 4.2 [message #895442 is a reply to message #895441] Thu, 12 July 2012 22:25 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
It is used by DetachedDropAgent and my initial comment was wrong one can
detach any MPartSashContainerElement which is a part or a complete stack.

Tom

Am 13.07.12 00:22, schrieb Tom Schindl:
> I can't tell you which API but a good start is EModelService#detach
> which allows to detach a complete stack.
>
> Tom
>
> Am 12.07.12 20:44, schrieb Mark Fishman:
>> So I want to switch my RCP application from 3.7.2 to 4.2 to take
>> advantage of some of the nice new features that it has but one of my
>> hacks is coming back to haunt me.
>>
>> In the 3.7.2 implementation of my application, I needed an ability to
>> allow a user to, upon request, launch a view either attached as a tab in
>> my main window or else detached in its own window. Further, if the user
>> launched the view detached, I wanted them to be able to grab the tab for
>> it and drag it back into the main window to attach it there.
>>
>> In 3.7, I was able to meet this goal by using the internal APIs to make
>> a call like:
>>
>> ((WorkbenchPage)getSite().getPage()).getActivePerspective().getPresentation(
>> )
>> detachPart(ref);
>>
>>
>> to launch the view detached. Since it was still associated with the
>> main window, I could then drag it back in and attach it like I wanted.
>>
>> Those APIs are now gone in 4.2. I can't complain too much because I
>> know that I was using internal APIs but my question is, is there a
>> similar way to get the same sort of functionality in 4.2?
>> Thanks.
>
>
Re: programatically detach a view in 4.2 [message #895515 is a reply to message #895442] Fri, 13 July 2012 11:12 Go to previous messageGo to next message
Mark Fishman is currently offline Mark FishmanFriend
Messages: 27
Registered: March 2011
Junior Member
Hi Tom,

Thanks for the response. This gives me a place to start.

-- Mark
Re: programatically detach a view in 4.2 [message #895616 is a reply to message #895515] Fri, 13 July 2012 19:56 Go to previous messageGo to next message
Mario Marinato is currently offline Mario MarinatoFriend
Messages: 38
Registered: March 2011
Location: Brazil
Member
Hi, Mark,

I am looking for this same solution. Please share any discoveries.

Best regards,


Mário Marinato
From Brazil
Re: programatically detach a view in 4.2 [message #895625 is a reply to message #895616] Fri, 13 July 2012 20:41 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
http://tomsondev.bestsolution.at/2012/07/13/so-you-used-internal-api/

Tom

Am 13.07.12 21:56, schrieb Mario Marinato:
> Hi, Mark,
>
> I am looking for this same solution. Please share any discoveries.
>
> Best regards,
Re: programatically detach a view in 4.2 [message #895631 is a reply to message #895616] Fri, 13 July 2012 21:04 Go to previous messageGo to next message
Mario Marinato is currently offline Mario MarinatoFriend
Messages: 38
Registered: March 2011
Location: Brazil
Member
I manage to detach my view. My code isn't 100% ok, but it's a start. I placed a button on my view, and on its widgedSelected listener method, I did this:

EPartService ePartService = (EPartService)PlatformUI.getWorkbench().getService( EPartService.class );
MPart mPart = ePartService.findPart( VIEW_ID ); // This is a const of mine.
EModelService eModelService = (EModelService)PlatformUI.getWorkbench().getService( EModelService.class );
MPlaceholder placeHolder = mPart.getCurSharedRef();
eModelService.detach( placeHolder, 50, 50, 100, 100 ); // Gotta compute correct bounds.


Mário Marinato
From Brazil
icon3.gif  Re: programatically detach a view in 4.2 [message #1696423 is a reply to message #895631] Tue, 26 May 2015 12:20 Go to previous message
bluetlck Mising name is currently offline bluetlck Mising nameFriend
Messages: 4
Registered: July 2009
Junior Member
public class DetachedAction extends Action {

public DetachedAction() {
super("Detached", IAction.AS_CHECK_BOX);
setHoverImageDescriptor(ImagesDescUtil.getImageDescriptor("detached.png",
Activator.PLUGIN_ID));

this.setChecked(false);
}
List<MUIElement> list;
@Override
public void run() {



// EPartService ePartService = (EPartService)PlatformUI.getWorkbench().getService( EPartService.class );


EModelService s = page.getSite().getService(EModelService.class);
MPartSashContainerElement p = page.getSite().getService(MPart.class);


if (p.getCurSharedRef() != null)
p = p.getCurSharedRef();

if (!this.isChecked()&&list!=null)
{
list.add(0,p);
}
else
{
list=p.getParent().getChildren();
s.detach(p, 100, 100, 300, 300);
}



}
}
Previous Topic:Make it possible to drag a viewpart to a place with no window, create and put it into a new window?
Next Topic:Applying MVC with the DI framework
Goto Forum:
  


Current Time: Thu Apr 25 23:08:24 GMT 2024

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

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

Back to the top