Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Display view in Eclipse menu Window-> Show View
Display view in Eclipse menu Window-> Show View [message #495493] Thu, 05 November 2009 00:40 Go to next message
Abhinav Mishra is currently offline Abhinav Mishra
Messages: 10
Registered: November 2009
Junior Member
I have created an Eclipse plugin which creates a view in Eclipse. Currently it is displayed in the Eclipse menu as :
'Window->Show View->Others'.

I want to show it in 'Window -> Show View' and not under the submenu 'Others'.

I have tried it giving the 'Category' of the view in the plugin.xml file as 'org.eclipse.ui' but it is still showing the view in 'Others' submenu.

Is there any other way to do so? Any suggestions are helpful in this regard.

Thanks in advance,
Abhinav

[Updated on: Sat, 07 November 2009 13:06]

Report message to a moderator

Re: Display view in Eclipse menu Window-> Show View [message #495599 is a reply to message #495493] Thu, 05 November 2009 08:17 Go to previous messageGo to next message
David Largeteau is currently offline David Largeteau
Messages: 35
Registered: July 2009
Location: Bordeaux - France
Member
Abhinav Mishra a écrit :
> I have created an Eclipse plugin which creates a view in Eclipse.
> Currently it is displayed in the Eclipse menu as :
> 'Window->Show View->Others'.
>
> I want to show it in 'Window -> Show View' and not under the submenu
> 'Others'.
>
> I have tried it giving the 'Category' of the view in the plugin.xml file
> as 'org.eclipse.ui' but it is still showing the view in 'Others' submenu.
>
> Is there any other way to do so? Any suggestions are helpful in this
> regard.
>
> Thanks in advance,
> Abhinav

Hi,

In your Perspective class that implements IPerspectiveFactory, you have
to add a view shortcut, like this :

public void createInitialLayout(IPageLayout layout)
{
// ....
layout.addShowViewShortcut(your_view_ID);
// ....
}

Don't forget to reset your perspective (Windows / Reset Perspective ...)
to make this work.

Hope this help !

David
Re: Display view in Eclipse menu Window-> Show View [message #496142 is a reply to message #495599] Sun, 08 November 2009 23:28 Go to previous messageGo to next message
Abhinav Mishra is currently offline Abhinav Mishra
Messages: 10
Registered: November 2009
Junior Member
Dear David,

The piece of code you sent seems working as it brings the view shortcut into Window->Show View->Other..->General category. Earlier it was coming into Other...->Others category. But I want it to directly display under Window->Show View and not under Other..->General submenu. Do I need to change some Eclipse preferences to do so? I am not able to locate where I need to make change for that.


Also is it possible to completely hide/remove any view entry/shortcut to appear from Window->Show View menu? As I want to embed them in a separate menu.

Thanks a lot for your reply..

[Updated on: Sun, 08 November 2009 23:30]

Report message to a moderator

Re: Display view in Eclipse menu Window-> Show View [message #496157 is a reply to message #496142] Mon, 09 November 2009 03:38 Go to previous messageGo to next message
David Largeteau is currently offline David Largeteau
Messages: 35
Registered: July 2009
Location: Bordeaux - France
Member
Abhinav Mishra a écrit :
> Dear David,
>
> This is working as it brings the view shortcut into Window->Show
> View->Other..->General category. Earlier it was coming into
> Other...->Others category. But I want it to directly display under
> Window->Show View and not under Other..->General submenu. Do I need to
> change some Eclipse preferences to do so? I am not able to locate where
> I need to make change for that.
>
>
> Also is it possible to completely hide/remove any view entry/shortcut to
> appear from Window->Show View menu? As I want to embed them in a
> separate menu.
>
> Thanks a lot for your reply..

Hi Abhinav,

It works great for me.

I have set the org.eclipse.ui.perspectives Entensions Point. My
perspective class implements IPerspectiveFactory. If i let the class
empty, with only createInitialLayout method does nothing, the Windows /
Show views menu contains only Others. If I add a view shortcut in this
method, Windows / Show views menu contains my view (not in Others /
General). I do not understand where your problem comes from ...

David

PS : as i said it before, you have to reset your perspective to make it
works
Re: Display view in Eclipse menu Window-> Show View [message #506041 is a reply to message #496157] Tue, 05 January 2010 15:12 Go to previous messageGo to next message
Kitesurfer () is currently offline Kitesurfer ()
Messages: 84
Registered: December 2009
Member
How can I show the Problems view programmatically in a plugin ? (by hand it would be via menu Window, ShowView, Problems).

So when it isn't already there it should be added ... and when it's already there the Problems tab should be selected (as if you did a mouseclick on it).
Re: Display view in Eclipse menu Window-> Show View [message #506110 is a reply to message #506041] Wed, 06 January 2010 03:34 Go to previous messageGo to next message
Abhinav Mishra is currently offline Abhinav Mishra
Messages: 10
Registered: November 2009
Junior Member
Hi Kitesurfer,

You can try the following:

String problemViewID = "org.eclipse.ui.views.problems";
IViewPart problemView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().showView(problemViewID);
Re: Display view in Eclipse menu Window-> Show View [message #506252 is a reply to message #506110] Wed, 06 January 2010 12:11 Go to previous messageGo to next message
Kitesurfer () is currently offline Kitesurfer ()
Messages: 84
Registered: December 2009
Member
Abhinav Mishra wrote on Wed, 06 January 2010 03:34
You can try the following:

String problemViewID = "org.eclipse.ui.views.problems";
IViewPart problemView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().showView(problemViewID);



Thanks ... I get an exception on the "IViewPart problemView" line. Any ideas ?

String problemViewID = "org.eclipse.ui.views.problems";
try {
IViewPart problemView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().showView(problemViewID);
problemView.setFocus();
} catch (Exception e) {
e.printStackTrace();
}




java.lang.NullPointerException
at article.editor.markers.MarkingErrorHandler.removeExistingMar kers(MarkingErrorHandler.java:110)
at article.editor.XMLEditor.validateAndMark(XMLEditor.java:77)
at article.editor.XMLEditor.doSetInput(XMLEditor.java:53)
at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(Abstract TextEditor.java:3115)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:464)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:372)
at org.eclipse.jface.window.ApplicationWindow$1.run(Application Window.java:759)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWi ndow.java:756)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow. java:2579)
at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(Ab stractTextEditor.java:3133)
at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTe xtEditor.java:3160)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManag er.java:798)
at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:644)
at org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:462)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:595)
at org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(Ed itorAreaHelper.java:271)
at org.eclipse.ui.internal.EditorManager.setVisibleEditor(Edito rManager.java:1417)
at org.eclipse.ui.internal.EditorManager$5.runWithException(Edi torManager.java:942)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3476)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$28.runWithException(Workbe nch.java:1384)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3476)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 21)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Re: Display view in Eclipse menu Window-> Show View [message #506271 is a reply to message #506041] Wed, 06 January 2010 13:00 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Kitesurfer wrote:
> How can I show the Problems view programmatically in a plugin ? (by hand
> it would be via menu Window, ShowView, Problems).
>

What you need to do is call
IWorkbenchPage#showView(org.eclipse.ui.IPageLayout.ID_PROBLE M_VIEW)

What are you doing or where are you when you want to do this? An
action? An existing view? for example, from within a view simply:

getSite().getPage().showView(IPageLayout.ID_PROBLEM_VIEW);

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: Display view in Eclipse menu Window-> Show View [message #506272 is a reply to message #506252] Wed, 06 January 2010 13:05 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Kitesurfer wrote:

> String problemViewID = "org.eclipse.ui.views.problems";

This constant is already defined in IPageLayout

> try {
> IViewPart problemView =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi
> vePage().showView(problemViewID);
> problemView.setFocus();

never call part.setFocus() ... the javadoc forbids it.

>
> java.lang.NullPointerException
> at article.editor.markers.MarkingErrorHandler.removeExistingMar
> kers(MarkingErrorHandler.java:110)

Are you sure? The NPE would have come from "problemView.setFocus();"
since that ID looks invalid.

If that's not it, they you would have to break up the long line to find
out which get*() call return null.

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: Display view in Eclipse menu Window-> Show View [message #506294 is a reply to message #506271] Wed, 06 January 2010 15:11 Go to previous messageGo to next message
Kitesurfer () is currently offline Kitesurfer ()
Messages: 84
Registered: December 2009
Member
Paul Webster wrote on Wed, 06 January 2010 13:00
What are you doing or where are you when you want to do this?


In this case its done within a self-written class instanced out of "doSetInput" of:
public class XMLEditor extends TextEditor

At the end of the day I'm going to do it behind a menu-item that uploads the file to a hostsystem, compiles on the host and sets ProblemMarkers for the compile-errors/warnings (that are returned in a downloaded textfile).

Paul Webster wrote on Wed, 06 January 2010 13:00
What you need to do is call
IWorkbenchPage#showView(org.eclipse.ui.IPageLayout.ID_PROBLE M_VIEW)



It dumps on the last line of this code :
try {
IWorkbench Workbench = PlatformUI.getWorkbench();
IWorkbenchWindow WorkbenchWindow = Workbench.getActiveWorkbenchWindow();
IWorkbenchPage WorkbenchPage = WorkbenchWindow.getActivePage();
WorkbenchPage.showView(IPageLayout.ID_PROBLEM_VIEW);
Re: Display view in Eclipse menu Window-> Show View [message #506704 is a reply to message #506294] Fri, 08 January 2010 16:04 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Kitesurfer wrote:
>
> In this case its done within a self-written class instanced out of
> "doSetInput" of:
> public class XMLEditor extends TextEditor
>

If you are in the text editor, use getSite().getPage() to get your page.
Try that for now to confirm you can open the correct view.

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: Display view in Eclipse menu Window-> Show View [message #896678 is a reply to message #506704] Thu, 19 July 2012 07:08 Go to previous messageGo to next message
Latha Shankara is currently offline Latha Shankara
Messages: 30
Registered: June 2012
Member
Hi Paul,

I get the same exception when I use PlatformUI. The exception is thrown at

IWorkbenchWindow WorkbenchWindow = Workbench.getActiveWorkbenchWindow();

since I am using it a non ui thread.

Is there a way to open the Problems view without using PlatformUI? I want to open the problems view in a non ui thread also

Thanks,
Latha
Re: Display view in Eclipse menu Window-> Show View [message #896719 is a reply to message #896678] Thu, 19 July 2012 09:40 Go to previous messageGo to next message
Joseph Carroll is currently offline Joseph Carroll
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

If all your only problem is that you are not on a UI thread use this code:
// If you are only the UI thread get the currently associated display
Display display = Display.getCurrent();
if (display == null)
    // Otherwise get the display associated with the UI thread
    display = Display.getDefault();

display.asyncExec(new Runnable() {

    @Override
    public void run() {
        // Insert your code here:
        // getSite().getPAge() ...				
    }
});
Re: Display view in Eclipse menu Window-> Show View [message #896721 is a reply to message #896719] Thu, 19 July 2012 09:48 Go to previous message
Joseph Carroll is currently offline Joseph Carroll
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

use
display.syncExec(...
if you want synchronous behavior.
Previous Topic:Eclipse configurations
Next Topic:Linux text annotations (Juno)
Goto Forum:
  


Current Time: Fri Aug 29 22:30:42 EDT 2014

Powered by FUDForum. Page generated in 0.02953 seconds