| 
| Login functionality in RAP app [message #59808] | Wed, 14 November 2007 12:15  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: benjamin.wolff.web.de 
 hellas!
 
 i wanted to implement a login function in my rap app that works this way:
 - a login dialog pops up and the user has to login using his username and
 password
 - after the login, the perspective that is opened, depends on the role of
 the user (e.g. i differ between the roles 'administration' and
 'management')
 - if the user logs out he'll return to the login view
 
 until now, i realised it using different perspective for the user roles.
 at the beginning the 'login perspective' is shown with a standalone view
 containing the login widgets. the user logs in and the perspective id for
 his role is extracted from a database. the code looks like this:
 
 
 IPerspectiveDescriptor pers =
 PlatformUI.getWorkbench().getPerspectiveRegistry().findPersp ectiveWithId(DBConn.getResultString(1));
 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().setPerspective(pers);
 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().resetPerspective();
 
 
 getResultString returns the id of the appropiate perspective for the user
 from a database. when the user logs out, the perspective is changed to the
 login perspective. the code for the logout event looks like this:
 
 IPerspectiveDescriptor pers =
 PlatformUI.getWorkbench().getPerspectiveRegistry().findPersp ectiveWithId(PerspectiveLogin.ID);
 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().setPerspective(pers);
 
 the problem is, if the users logs out, the perspective just changes but
 isn't 'closed'. is there a possibility to close (delete) the perspective
 completely so that it will be re-created if he logs in again without
 closing the app?
 
 however i'm not really satisfied with this solution because it seems too
 cobbled :P.
 
 maybe someone has an advice on how to implement the login more elegant, or
 maybe there is a common scheme to do this.
 
 i'd appreciate your help.
 |  |  |  | 
| 
| Re: Login functionality in RAP app [message #62476 is a reply to message #59808] | Fri, 23 November 2007 06:32   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: fappel.innoopract.com 
 Hi,
 
 sorry for not responding to your question for so long, but somehow I
 overlooked it. To close a perspective I would try the
 IWorkbenchPage#closePerspective(IPerspectiveDescriptor,boole an,boolean)
 method.
 
 Unfortunately there is no common solution for user/role based management of
 UIs in RAP or RCP. There is a discussion going on at
 https://bugs.eclipse.org/bugs/show_bug.cgi?id=201052 to find a general
 solution in RCP which will be hopefully adaptable for RAP too.
 
 
 Ciao
 Frank
 
 
 
 "Ben W." <benjamin.wolff@web.de> schrieb im Newsbeitrag
 news:9c30599d1c933024caf6a7a598e1a275$1@www.eclipse.org...
 > hellas!
 >
 > i wanted to implement a login function in my rap app that works this way:
 > - a login dialog pops up and the user has to login using his username and
 > password
 > - after the login, the perspective that is opened, depends on the role of
 > the user (e.g. i differ between the roles 'administration' and
 > 'management')
 > - if the user logs out he'll return to the login view
 >
 > until now, i realised it using different perspective for the user roles.
 > at the beginning the 'login perspective' is shown with a standalone view
 > containing the login widgets. the user logs in and the perspective id for
 > his role is extracted from a database. the code looks like this:
 >
 >
 > IPerspectiveDescriptor pers =
 >  PlatformUI.getWorkbench().getPerspectiveRegistry().findPersp ectiveWithId(DBConn.getResultString(1));
 >  PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().setPerspective(pers);
 >  PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().resetPerspective();
 >
 >
 > getResultString returns the id of the appropiate perspective for the user
 > from a database. when the user logs out, the perspective is changed to the
 > login perspective. the code for the logout event looks like this:
 >
 > IPerspectiveDescriptor pers =
 >  PlatformUI.getWorkbench().getPerspectiveRegistry().findPersp ectiveWithId(PerspectiveLogin.ID);
 >  PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().setPerspective(pers);
 >
 > the problem is, if the users logs out, the perspective just changes but
 > isn't 'closed'. is there a possibility to close (delete) the perspective
 > completely so that it will be re-created if he logs in again without
 > closing the app?
 >
 > however i'm not really satisfied with this solution because it seems too
 > cobbled :P.
 >
 > maybe someone has an advice on how to implement the login more elegant, or
 > maybe there is a common scheme to do this.
 >
 > i'd appreciate your help.
 >
 >
 |  |  |  | 
| 
| Re: Login functionality in RAP app [message #62512 is a reply to message #62476] | Fri, 23 November 2007 06:48  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: benjamin.wolff.web.de 
 hi!
 
 yes, that's the effect i wanted to achive. the perspectives and view are
 re-created after a new login.
 
 thanks a million.
 
 for everyone who needs a "pseudo role login model" here are a few snippets
 :)
 
 login part:
 
 
 IPerspectiveDescriptor pers =
 PlatformUI.getWorkbench().getPerspectiveRegistry().findPersp ectiveWithId( "id
 of the role perspective");
 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().setPerspective(pers);
 
 
 
 logout part:
 
 
 IPerspectiveDescriptor pers =
 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getPerspective();
 
 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().closePerspective(pers,
 false, false);
 
 pers =
 PlatformUI.getWorkbench().getPerspectiveRegistry().findPersp ectiveWithId( "id
 of the login perspective");
 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().setPerspective(pers);
 
 
 
 regards
 -ben
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03565 seconds