How to tell RAP to switch perspective from external servlet ? [message #77621] |
Mon, 10 March 2008 05:29  |
Eclipse User |
|
|
|
Hi,
On startup our app is opening a default perspective containing a maximized
viewpart that serves as a login page.
This login page is implemented using browser widget backed by a plain
servlet. Now if the user is successfully logged in the servlet must tell
RAP to switch to the main perspective containing the core business
application.
But in the login servlet I'm kind of lost since I don't know how to
contact the RAP.
Is this scenario possible at all ?
Thanks in advance for any advice.
Regards,
Setya
|
|
|
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #78103 is a reply to message #77995] |
Wed, 12 March 2008 05:30   |
Eclipse User |
|
|
|
Hi Frank,
I'm sorry for being too slow on this.
> In order to switch perspective I need to at least have reference to
> IWorkbench and IWorkbenchPage, how can I obtain the reference from the
> servlet ?
> To ease this you can program the runnable inside your entry point
> implementation and pass the runnable also via the session.
So from your suggestion I should have the following code in my
IEntryPoint#createUI():
public int createUI()
{
Display display = PlatformUI.createDisplay();
HttpSession httpSession = RWT.getSessionStore().getHttpSession();
Runnable runnable = new Runnable()
{
public void run()
{
//How to obtain the reference to IWorkbenchWindow at this stage ?
IWorkbenchPage page = window.getActivePage();
IPerspectiveDescriptor perspective = page.getPerspective();
perspective = window.getWorkbench().getPerspectiveRegistry()
.findPerspectiveWithId("main.perspective.id");
page.setPerspective(perspective);
UICallBack.deactivate("my.entrypoint.classname");
}
};
httpSession.setAttribute("key.display",display);
httpSession.setAttribute("key.runnable",runnable);
UICallBack.activate("my.entrypoint.classname");
return PlatformUI.createAndRunWorkbench(display,new CoreWorkbench());
}
I still can't see how I can obtain reference to IWorkbenchWindow at this
stage.
Or maybe I should create and store the runnable in
WorkbenchWindowAdvisor#postWindowOpen ?
public void postWindowOpen()
{
Runnable runnable = new Runnable()
{
public void run()
{
//Obtaining the reference to IWorkbenchWindow
IWorkbenchWindow window = getWindowConfigurer().getWindow();
IWorkbenchPage page = window.getActivePage();
IPerspectiveDescriptor perspective = page.getPerspective();
perspective = window.getWorkbench().getPerspectiveRegistry()
.findPerspectiveWithId("main.perspective.id");
page.setPerspective(perspective);
UICallBack.deactivate("my.entrypoint.classname");
}
};
RWT.getSessionStore().getHttpSession().setAttribute("key.runnable ",runnable);
super.postWindowOpen();
}
And finally in my login servlet :
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
//Perform login authentication here
boolean success = validateLogin(request.getParameter("user"),
request.getParameter("password"));
if (!success)
{
getServletContext().getRequestDispatcher(IPluginXmlConstants .WEB_CONTEXT +
"/login.html").forward(request,response);
return;
}
Display display = (Display)request.getAttribute("key.display");
Runnable runnable = (Runnable)request.getAttribute("key.runnable");
display.asyncExec(runnable);
}
Or am I missing something here ?
Regards,
Setya
|
|
|
|
|
|
RE: How to tell RAP to switch perspective from external servlet ? [message #78205 is a reply to message #78192] |
Thu, 13 March 2008 11:24   |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
from my understanding of what you want to do, it makes no difference,
whether you create the runnable in WorkbenchWindowAdvisor#postWindowOpen
or directly in IEntryPoint#createUI(), since the code of the Runnable
gets executed in one of the subsequent requests from the servlet. At
that point of time the workbench is already up an running. So feel free
to create the runnable in WorkbenchWindowAdvisor#postWindowOpen(), if
this is for any reasons your prefered place.
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Setya [mailto:jsetya@gmail.com]
Bereitgestellt: Donnerstag, 13. März 2008 10:50
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: How to tell RAP to switch perspective from external
servlet ?
Betreff: Re: How to tell RAP to switch perspective from external servlet
?
Frank,
> the code don't get executed at that point, you create the runnable. If
> I got you right your login screen is inside a view of the workbench
> (browser widget I suggest). So the workbench exists at that point in
> time when you execute the runnable and that's all that matters.
OK.
So I should create the runnable inside
WorkbenchWindowAdvisor#postWindowOpen ?
Regards,
Setya
|
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #78351 is a reply to message #78235] |
Fri, 14 March 2008 10:16   |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
why don't you use the following?
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
Ciao
Frank
"Setya" <jsetya@gmail.com> schrieb im Newsbeitrag
news:504362e97f4f3264bd72f1ce3df1c666$1@www.eclipse.org...
> Frank,
>
>> from my understanding of what you want to do, it makes no difference,
>> whether you create the runnable in WorkbenchWindowAdvisor#postWindowOpen
>> or directly in IEntryPoint#createUI(), since the code of the Runnable
>> gets executed in one of the subsequent requests from the servlet. At
>> that point of time the workbench is already up an running. So feel free
>> to create the runnable in WorkbenchWindowAdvisor#postWindowOpen(), if
>> this is for any reasons your prefered place.
>
> If you take a look at the runnable code I created earlier, it's impossible
> to create the runnable in IEntryPoint#createUI() since I don't know how to
> obtain the reference to IWorkbenchWindow in this method, or am I missing
> something here ?
>
> Regards,
>
> Setya
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04457 seconds