Hi Awanthika

I hope workbenchWindow.getActivePage() is null, this may be because at the
startup, it might not have initiated by that time? is there
a possibility to delay this call a bit and try?

/Susinda

On Tue, Jun 28, 2016 at 9:11 AM, Awanthika Senarath <awanth...@wso2.com>
wrote:

> Hi,
>
> I want to start eclipse in a custom perspective, but when I try to do that
> in the startup method, it throws a null pointer exception at the point I
> try to access the Display thread.
>
> code used to invoke the perspective :
>
> final IWorkbenchWindow workbenchWindow =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow();
> IPerspectiveDescriptor activePerspective =
> workbenchWindow.getActivePage().getPerspective();// null pointer here
> if (activePerspective == null ||
> !activePerspective.getId().equals(PERSPECTIVE_ID)) {
> Display.getCurrent().asyncExec(new Runnable() {// if I remove the get
> active page since it is not mandatory, I get null pointer here.
> public void run() {
> // switch perspective
> try {
> workbenchWindow.getWorkbench().showPerspective(PERSPECTIVE_ID,
> workbenchWindow);
> } catch (WorkbenchException e) {
> log.error("Can not switch to perspective: " + PERSPECTIVE_ID, e);
> }
> }
> });
> }
>
>
> Can someone help me to open eclipse in my custom perspective? I tried
> using this in an early startup as well as in the activator class, both gave
> same results.
>
>
> Regards
> Awanthika Senarath
> Senior Software Engineer, WSO2 Inc.
> Mobile: +94717681791
>
>
>


-- 
*Susinda Perera*
Software Engineer
B.Sc.(Eng), M.Sc(Computer Science), AMIE(SL)
Mobile:(+94)716049075
Blog: susinda.blogspot.com
WSO2 Inc. http://wso2.com/
Tel : 94 11 214 5345 Fax :94 11 2145300
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to