Home » Eclipse Projects » Eclipse Platform » using keybindings, menus, and context in a fragment
using keybindings, menus, and context in a fragment [message #326960] |
Thu, 03 April 2008 13:08  |
Eclipse User |
|
|
|
I have a fragment, which defines a context, menu, commands, handlers and
keybindings. This works when I run the project through eclipse to debug,
but when I do a build and run the program, I no longer see my toolbar and
menu. I get a NotDefinedException for the context. Can I define the menus
in the fragment? The fragment is to contribute a page and menus to several
of our editors. In the page, I have the code:
IContextService contextService = (IContextService)
getSite().getService(IContextService.class);
contextService.activateContext("com.mycompany.context");
And have that context defined in fragment.xml for my fragment. Is there
anything I need to do to set any dependencies?
|
|
|
Re: using keybindings, menus, and context in a fragment [message #326966 is a reply to message #326960] |
Thu, 03 April 2008 14:10   |
Eclipse User |
|
|
|
Jay Simpson wrote:
> I have a fragment, which defines a context, menu, commands, handlers and
> keybindings. This works when I run the project through eclipse to debug,
> but when I do a build and run the program, I no longer see my toolbar and
> menu. I get a NotDefinedException for the context. Can I define the menus
> in the fragment? The fragment is to contribute a page and menus to several
> of our editors. In the page, I have the code:
When a fragment is available, its classpath and XML appear just as if
they were in the host plugin. Start your deployed app with -console and
do an 'ss'
What is the state of your plugin? What is the state of your fragment?
> IContextService contextService = (IContextService)
> getSite().getService(IContextService.class);
>
> contextService.activateContext("com.mycompany.context");
BTW: it doesn't really make sense to reference something concrete like a
context or command from a plugin that's defined in a fragment ... since
if the fragment is not there, you'll get killed.
Although it is acceptable to check a command or context to see if
they're defined first.
Later,
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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
|
|
|
Re: using keybindings, menus, and context in a fragment [message #326970 is a reply to message #326966] |
Thu, 03 April 2008 14:32   |
Eclipse User |
|
|
|
what do you mean by state?
The page that holds that context code is all in the fragment.
Sorry I'm a newbie.
"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:ft368k$dad$1@build.eclipse.org...
> Jay Simpson wrote:
>> I have a fragment, which defines a context, menu, commands, handlers and
>> keybindings. This works when I run the project through eclipse to debug,
>> but when I do a build and run the program, I no longer see my toolbar and
>> menu. I get a NotDefinedException for the context. Can I define the
>> menus in the fragment? The fragment is to contribute a page and menus to
>> several of our editors. In the page, I have the code:
>
> When a fragment is available, its classpath and XML appear just as if they
> were in the host plugin. Start your deployed app with -console and do an
> 'ss'
>
> What is the state of your plugin? What is the state of your fragment?
>
>> IContextService contextService = (IContextService)
>> getSite().getService(IContextService.class);
>>
>> contextService.activateContext("com.mycompany.context");
>
> BTW: it doesn't really make sense to reference something concrete like a
> context or command from a plugin that's defined in a fragment ... since if
> the fragment is not there, you'll get killed.
>
> Although it is acceptable to check a command or context to see if they're
> defined first.
>
> Later,
> 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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
|
|
|
Re: using keybindings, menus, and context in a fragment [message #326971 is a reply to message #326966] |
Thu, 03 April 2008 14:39   |
Eclipse User |
|
|
|
Its like it doesnt understand org.eclipse.ui.menus. I am using 3.3.1.1.
The toolbar should appear based on which editor is open, and that is not
being shown. When I go to the page that sets the context, it gets this
error":
org.eclipse.core.commands.common.NotDefinedException: Cannot get the parent
identifier from an undefined context. com.mycompany.context
at org.eclipse.core.commands.contexts.Context.getParentId(Conte xt.java:201)
at
org.eclipse.jface.bindings.BindingManager.createFilteredCont extTreeFor(BindingManager.java:825)
at
org.eclipse.jface.bindings.BindingManager.recomputeBindings( BindingManager.java:1720)
at
org.eclipse.jface.bindings.BindingManager.contextManagerChan ged(BindingManager.java:689)
at
org.eclipse.core.commands.contexts.ContextManager.fireContex tManagerChanged(ContextManager.java:152)
at
org.eclipse.core.commands.contexts.ContextManager.addActiveC ontext(ContextManager.java:96)
at
org.eclipse.ui.internal.contexts.ContextAuthority.updateCont ext(ContextAuthority.java:765)
at
org.eclipse.ui.internal.contexts.ContextAuthority.activateCo ntext(ContextAuthority.java:179)
at
org.eclipse.ui.internal.contexts.ContextService.activateCont ext(ContextService.java:88)
at
org.eclipse.ui.internal.contexts.SlaveContextService.doActiv ateContext(SlaveContextService.java:279)
at
org.eclipse.ui.internal.contexts.SlaveContextService.activat eContext(SlaveContextService.java:164)
at
org.eclipse.ui.internal.contexts.SlaveContextService.activat eContext(SlaveContextService.java:133)
at
org.eclipse.ui.internal.contexts.SlaveContextService.doActiv ateContext(SlaveContextService.java:279)
at
org.eclipse.ui.internal.contexts.SlaveContextService.activat eContext(SlaveContextService.java:122)
at
com.mycompany.ToolhelpEditorPage.addLongHelpTextEditorTab(To olhelpEditorPage.java:114)
at com.mycompany.ToolhelpEditorPage.createTabs(ToolhelpEditorPa ge.java:92)
at
com.mycompany.AbstractTabbedFormPage.createFormContent(Abstr actTabbedFormPage.java:80)
at org.eclipse.ui.forms.editor.FormPage$1.run(FormPage.java:151 )
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at org.eclipse.ui.forms.editor.FormPage.createPartControl(FormP age.java:149)
at org.eclipse.ui.forms.editor.FormEditor.pageChange(FormEditor .java:488)
at
com.mycompany.AbstractMetadataEditor.pageChange(AbstractMeta dataEditor.java:998)
at
org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(Mul tiPageEditorPart.java:239)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:7 06)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.ja va:3227)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:20 05)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.j ava:316)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:363)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:176)
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: 508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:ft368k$dad$1@build.eclipse.org...
> Jay Simpson wrote:
>> I have a fragment, which defines a context, menu, commands, handlers and
>> keybindings. This works when I run the project through eclipse to debug,
>> but when I do a build and run the program, I no longer see my toolbar and
>> menu. I get a NotDefinedException for the context. Can I define the
>> menus in the fragment? The fragment is to contribute a page and menus to
>> several of our editors. In the page, I have the code:
>
> When a fragment is available, its classpath and XML appear just as if they
> were in the host plugin. Start your deployed app with -console and do an
> 'ss'
>
> What is the state of your plugin? What is the state of your fragment?
>
>> IContextService contextService = (IContextService)
>> getSite().getService(IContextService.class);
>>
>> contextService.activateContext("com.mycompany.context");
>
> BTW: it doesn't really make sense to reference something concrete like a
> context or command from a plugin that's defined in a fragment ... since if
> the fragment is not there, you'll get killed.
>
> Although it is acceptable to check a command or context to see if they're
> defined first.
>
> Later,
> 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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
|
|
| |
Re: using keybindings, menus, and context in a fragment [message #326975 is a reply to message #326972] |
Thu, 03 April 2008 15:28   |
Eclipse User |
|
|
|
Before opening editor:
12 RESOLVED com.mycompany.eclipse.toolhelp_0.1.4
Master=13
13 <<LAZY>> com.mycompany.eclipse.ui_0.1.4
Fragments=11, 12
13 changes to ACTIVE once I open the editor.
ToolhelpEditorPage is defined in the fragment as well
I created a second toolbar in the fragment.xml to remove some of the
complexity of my original one. This shows up when I'm testing using eclipse
to launch, but not after I do a build and run it that way.
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar">
<toolbar id="com.mycompany.eclipse.toolbar2">
<command
commandId="org.eclipse.ui.file.print"
name="print"
categoryId="org.eclipse.ui.category.file"
tooltip="myprint"
>
</command>
</toolbar>
</menuContribution>
</extension>
"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:ft39r5$5ip$1@build.eclipse.org...
> Jay Simpson wrote:
>> what do you mean by state?
>
> the state output by -console followed by ss (installed, resolved, active,
> etc).
>
>
>>
>> The page that holds that context code is all in the fragment.
>
> So ToolhelpEditorPage is defined in the fragment as well? BTW the below
> error indicates that the org.eclipse.ui.contexts definition for
> com.mycompany.context is not available to ToolhelpEditorPage. I'm
> surprised the system was able to load the class from your fragment but not
> the extension.
>
> Jay Simpson wrote:
> > Its like it doesnt understand org.eclipse.ui.menus. I am using 3.3.1.1.
> > The toolbar should appear based on which editor is open, and that is not
> > being shown. When I go to the page that sets the context, it gets this
> > error":
> >
> > org.eclipse.core.commands.common.NotDefinedException: Cannot get the
> parent
> > identifier from an undefined context. com.mycompany.context
> >
> org.eclipse.ui.internal.contexts.SlaveContextService.activat eContext(SlaveContextService.java:122)
> > at
> >
> com.mycompany.ToolhelpEditorPage.addLongHelpTextEditorTab(To olhelpEditorPage.java:114)
> > at
> com.mycompany.ToolhelpEditorPage.createTabs(ToolhelpEditorPa ge.java:92)
> > at
> >
> com.mycompany.AbstractTabbedFormPage.createFormContent(Abstr actTabbedFormPage.java:80)
> > at org.eclipse.ui.forms.editor.FormPage$1.run(FormPage.java:151 )
>
>
> Are there any errors in your error log before this one? What are the
> first 2 or 3 errors after the !SESSION marker?
>
> 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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
|
|
| |
Goto Forum:
Current Time: Wed Mar 26 08:20:28 EDT 2025
Powered by FUDForum. Page generated in 0.09637 seconds
|