Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How do I add a preferences page programatically at run time?
How do I add a preferences page programatically at run time? [message #330517] Wed, 30 July 2008 21:17 Go to next message
Eclipse UserFriend
Originally posted by: dlacerte.counterpath.com

I have a preference page that is added the usual way with an entry in the
plugin.xml file as in all the examples. Unfortunately this preference page
should not be shown at all for some situations so at run time when the
plugin launches I want to decide whether it should be shown or not. Can I
add a preference page programatically instead of using the plugin.xml
mechanism?
Re: How do I add a preferences page programatically at run time? [message #330518 is a reply to message #330517] Wed, 30 July 2008 23:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dlacerte.counterpath.com

To replace this plugin.xml entry:

<extension
point = "org.eclipse.ui.preferencePages">
<page id="CounterPath.Preferences.Accounts.AccountsPage"
class="CounterPath.Preferences.Accounts.AccountsPage"
name="Telephony Accounts">
</page>
</extension>

I tried the following code:

org.eclipse.jface.preference.PreferenceNode node =
new org.eclipse.jface.preference.PreferenceNode(
"CounterPath.Preferences.Accounts.AccountsPage", "Telephony Accounts",
null, "CounterPath.Preferences.Accounts.AccountsPage");
org.eclipse.jface.preference.PreferenceManager mgr =
org.eclipse.ui.PlatformUI.getWorkbench().getPreferenceManage r();
mgr.addToRoot(node);


Which results in an entry for the page being created but when I click on
it I get the following:

SEVERE: Problems occurred when invoking code from plug-in:
"org.eclipse.jface".
java.lang.NullPointerException
at
org.eclipse.jface.preference.PreferenceNode.createPage(Prefe renceNode.java:161)
at
org.eclipse.jface.preference.PreferenceDialog.createPage(Pre ferenceDialog.java:1241)
at
org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.cre atePage(FilteredPreferenceDialog.java:315)
at
org.eclipse.jface.preference.PreferenceDialog.showPage(Prefe renceDialog.java:1134)
at
org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.sho wPage(FilteredPreferenceDialog.java:438)
at
org.eclipse.jface.preference.PreferenceDialog$8.selectionCha nged(PreferenceDialog.java:661)
at
org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredV iewer.java:839)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:843)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:14 9)
at
org.eclipse.jface.viewers.StructuredViewer.firePostSelection Changed(StructuredViewer.java:837)
at
org.eclipse.jface.viewers.StructuredViewer.setSelection(Stru cturedViewer.java:1578)
at
org.eclipse.jface.preference.PreferenceDialog.selectSavedIte m(PreferenceDialog.java:958)
at
org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.sel ectSavedItem(FilteredPreferenceDialog.java:481)
at
org.eclipse.jface.preference.PreferenceDialog$3.run(Preferen ceDialog.java:345)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.jface.preference.PreferenceDialog.createContents (PreferenceDialog.java:341)
at org.eclipse.jface.window.Window.create(Window.java:426)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1111)
at
org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog.cr eateDialogOn(WorkbenchPreferenceDialog.java:96)
at
org.eclipse.ui.dialogs.PreferencesUtil.createPreferenceDialo gOn(PreferencesUtil.java:85)
at
CounterPath.Preferences.Accounts.AccountsPage.Show(AccountsP age.java:91)
at
CounterPath.SidePanel.Toolbar.ActionsButtonAction$2.widgetSe lected(ActionsButtonAction.java:102)
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.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:1932)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1896)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:424)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
com.ibm.rcp.personality.framework.internal.RCPApplication.ru n(RCPApplication.java:72)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:79)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Re: How do I add a preferences page programatically at run time? [message #330519 is a reply to message #330518] Thu, 31 July 2008 01:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

Dominique wrote:
> To replace this plugin.xml entry:
> <extension
> point = "org.eclipse.ui.preferencePages">
> <page id="CounterPath.Preferences.Accounts.AccountsPage"
> class="CounterPath.Preferences.Accounts.AccountsPage"
> name="Telephony Accounts">
> </page>
> </extension>
>
> I tried the following code:
>
> org.eclipse.jface.preference.PreferenceNode node = new
> org.eclipse.jface.preference.PreferenceNode(
> "CounterPath.Preferences.Accounts.AccountsPage", "Telephony
> Accounts", null, "CounterPath.Preferences.Accounts.AccountsPage");
> org.eclipse.jface.preference.PreferenceManager mgr =
> org.eclipse.ui.PlatformUI.getWorkbench().getPreferenceManage r();
> mgr.addToRoot(node);
>
>
> Which results in an entry for the page being created but when I click on
> it I get the following:
>
> SEVERE: Problems occurred when invoking code from plug-in:
> "org.eclipse.jface".
> java.lang.NullPointerException
> at
> org.eclipse.jface.preference.PreferenceNode.createPage(Prefe renceNode.java:161)
>
> at
> org.eclipse.jface.preference.PreferenceDialog.createPage(Pre ferenceDialog.java:1241)
>
> at
> org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.cre atePage(FilteredPreferenceDialog.java:315)
>
> at
> org.eclipse.jface.preference.PreferenceDialog.showPage(Prefe renceDialog.java:1134)
>
> at
> org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.sho wPage(FilteredPreferenceDialog.java:438)
>
> at
> org.eclipse.jface.preference.PreferenceDialog$8.selectionCha nged(PreferenceDialog.java:661)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredV iewer.java:839)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
> at org.eclipse.core.runtime.Platform.run(Platform.java:843)
> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:14 9)
> at
> org.eclipse.jface.viewers.StructuredViewer.firePostSelection Changed(StructuredViewer.java:837)
>
> at
> org.eclipse.jface.viewers.StructuredViewer.setSelection(Stru cturedViewer.java:1578)
>
> at
> org.eclipse.jface.preference.PreferenceDialog.selectSavedIte m(PreferenceDialog.java:958)
>
> at
> org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.sel ectSavedItem(FilteredPreferenceDialog.java:481)
>
> at
> org.eclipse.jface.preference.PreferenceDialog$3.run(Preferen ceDialog.java:345)
>
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at
> org.eclipse.jface.preference.PreferenceDialog.createContents (PreferenceDialog.java:341)
>
> at org.eclipse.jface.window.Window.create(Window.java:426)
> at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1111)
> at
> org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog.cr eateDialogOn(WorkbenchPreferenceDialog.java:96)
>
> at
> org.eclipse.ui.dialogs.PreferencesUtil.createPreferenceDialo gOn(PreferencesUtil.java:85)
>
> at
> CounterPath.Preferences.Accounts.AccountsPage.Show(AccountsP age.java:91)
> at
> CounterPath.SidePanel.Toolbar.ActionsButtonAction$2.widgetSe lected(ActionsButtonAction.java:102)
>
> 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.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:1932)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1896)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:424)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> com.ibm.rcp.personality.framework.internal.RCPApplication.ru n(RCPApplication.java:72)
>
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:79)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:618)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
> at org.eclipse.core.launcher.Main.run(Main.java:977)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
>
>
You'd better use IExtensionRegistry to add contributions dynamically at
runtime, e.g:

IExtensionRegistryTracker tracker = .....
IExtensionRegistry reg = tracer.getService(IExtensionRegistry.class...)
reg.addContribution(xxx,xxx)
Re: How do I add a preferences page programatically at run time? [message #330523 is a reply to message #330517] Thu, 31 July 2008 05:47 Go to previous messageGo to next message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
Dominique wrote:
> I have a preference page that is added the usual way with an entry in
> the plugin.xml file as in all the examples. Unfortunately this
> preference page should not be shown at all for some situations

I question whether that is really the right UI choice.

Will your users understand why the preferences are available sometimes
and not others?
Re: How do I add a preferences page programatically at run time? [message #330531 is a reply to message #330518] Thu, 31 July 2008 14:40 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Dominique wrote:
> To replace this plugin.xml entry:
> <extension
> point = "org.eclipse.ui.preferencePages">
> <page id="CounterPath.Preferences.Accounts.AccountsPage"
> class="CounterPath.Preferences.Accounts.AccountsPage"
> name="Telephony Accounts">
> </page>
> </extension>
>
> I tried the following code:
>
> org.eclipse.jface.preference.PreferenceNode node = new
> org.eclipse.jface.preference.PreferenceNode(
> "CounterPath.Preferences.Accounts.AccountsPage", "Telephony
> Accounts", null, "CounterPath.Preferences.Accounts.AccountsPage");
> org.eclipse.jface.preference.PreferenceManager mgr =
> org.eclipse.ui.PlatformUI.getWorkbench().getPreferenceManage r();
> mgr.addToRoot(node);

Is CounterPath.Preferences.Accounts.AccountsPage really the FQCN? Put a
breakpoint in PreferenceDialog.createPage(*) and step through the
PreferenceNode code when creating your page. I suspect that jface
Class.forName(*) can't find the class. You might have to override
PreferenceNode.createPage(*) if supplying your own node.

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: How do I add a preferences page programatically at run time? [message #330539 is a reply to message #330518] Thu, 31 July 2008 19:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dlacerte.counterpath.com

I also tried the following:

org.eclipse.core.runtime.IExtensionRegistry registry =
org.eclipse.core.runtime.Platform.getExtensionRegistry();
org.eclipse.core.runtime.IExtensionPoint point =
registry.getExtensionPoint("org.eclipse.ui.preferencePages");
boolean success = false;
if (point != null)
{
InputStream is = new StringBufferInputStream(
" <plugin><extension" +
" point = 'org.eclipse.ui.preferencePages'>" +
" <page id='CounterPath.Preferences.Accounts.AccountsPage'" +
" class='CounterPath.Preferences.Accounts.AccountsPage'" +
" name='Telephony Accounts'>" +
" </page>" +
" </extension></plugin>");
success = registry.addContribution(is, point.getContributor(), false,
"Telephony Accounts", null, null);
}

Which executed fine but when I try to show the preferences page I get an
error saying "Plugin org.eclipse.ui was unable to load class
CounterPath.Preferences.Accounts.AccountsPage." This class is there and
this works fine when I put the XML in the plugin.xml file. Do I need to
somehow register the class so it is found?
Re: How do I add a preferences page programatically at run time? [message #330540 is a reply to message #330531] Thu, 31 July 2008 19:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dlacerte.counterpath.com

I believe it is the FQCN as the class is declared as such in the code and
when I load it using this same string via plugin.xml it works fine.

I am not able to step through this code you mentioned. Where do I get the
sources for this?
Re: How do I add a preferences page programatically at run time? [message #330541 is a reply to message #330523] Thu, 31 July 2008 19:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dlacerte.counterpath.com

Yes, because if they don't see it they never will and if they do see it
they always will. The decision is constant for a given user.
Re: How do I add a preferences page programatically at run time? [message #330543 is a reply to message #330541] Thu, 31 July 2008 21:42 Go to previous messageGo to next message
Gordon Hirsch is currently offline Gordon HirschFriend
Messages: 100
Registered: July 2009
Senior Member
Maybe it would be easier to define the preference page as usual and use
activities to enable/disable its availability to users.

http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench_advext_activities.htm

Dominique wrote:
> Yes, because if they don't see it they never will and if they do see it
> they always will. The decision is constant for a given user.
>
Re: How do I add a preferences page programatically at run time? [message #330546 is a reply to message #330541] Fri, 01 August 2008 04:20 Go to previous messageGo to next message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
Dominique wrote:
> Yes, because if they don't see it they never will and if they do see it
> they always will. The decision is constant for a given user.

Hm. Well, you certainly know your application and userbase better than
I do, but I will point out that the Eclipse newsgroups are full of posts
by people confused because they see something different than what
someone else sees.
Re: How do I add a preferences page programatically at run time? [message #330563 is a reply to message #330543] Fri, 01 August 2008 20:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dlacerte.counterpath.com

Thanks for the pointer, this gets me most of the way there! The only
problem I have is when I disable the preference page I get two copies of
the buttons on my toolbar. Seems like the toolbar is being parsed a second
time when I disable the page. Weird since the toolbar is in a different
plugin. Even more weird is that if I repeatedly enable/disable the page I
still only get two copies of my toolbar buttons.

Here is my preference page XML:

<!-- Preferences "Telephony Accounts" page -->
<extension
point = "org.eclipse.ui.preferencePages">
<page id="CounterPath.Preferences.Accounts.AccountsPage"
class="CounterPath.Preferences.Accounts.AccountsPage"
name="Telephony Accounts">
</page>
</extension>
<!-- An activity to allow us to show/hide the "Telephony Accounts" page
-->
<extension
point="org.eclipse.ui.activities">
<activity
name="Telephony Accounts"
description="Telephony Accounts Preferences"
id="CounterPath.Preferences.AccountsPageActivity">
</activity>
<activityPatternBinding
activityId="CounterPath.Preferences.AccountsPageActivity"
pattern="PALS/CounterPath\.Preferences\.Accounts\.AccountsPage ">
</activityPatternBinding>
<!-- <defaultEnablement id="CounterPath.Preferences.AccountsPageActivity"
/> -->
</extension>


And the toolabr XML in the other plugin:

<!-- Notes toolbar -->
<extension
point="com.ibm.rcp.ui.controlSets">
<controlSet
align="left"
id="CounterPath.NotesToolbar.ToolbarContribution.set"
label="SMC Plug-in Toolbar"
visible="true">
<toolBar
id="CounterPath.NotesToolbar.ToolbarContribution.bar"
path="BEGIN_GROUP"/>
<control
class="CounterPath.NotesToolbar.ToolbarContribution"
id="CounterPath.NotesToolbar.ToolbarContribution"

toolbarPath="CounterPath.NotesToolbar.ToolbarContribution.bar "/>
</controlSet>
</extension>

And my code to disable the preference page:

org.eclipse.ui.activities.IWorkbenchActivitySupport
workbenchActivitySupport =
org.eclipse.ui.PlatformUI.getWorkbench().getActivitySupport( );
org.eclipse.ui.activities.IActivityManager activityManager =
workbenchActivitySupport.getActivityManager();
HashSet enabledIds = new HashSet(activityManager.getEnabledActivityIds());
if (enabledIds.remove("CounterPath.Preferences.AccountsPageActivity "))
workbenchActivitySupport.setEnabledActivityIds(enabledIds);
Re: How do I add a preferences page programatically at run time? [message #330588 is a reply to message #330563] Mon, 04 August 2008 15:47 Go to previous messageGo to next message
Gordon Hirsch is currently offline Gordon HirschFriend
Messages: 100
Registered: July 2009
Senior Member
We do much the same thing, and have not seen this problem. It sounds
like a bug. Where is the code that disables the page running? We run it
in our override of ActionBarAdvisor.makeActions() and it works fine.

Dominique wrote:
> Thanks for the pointer, this gets me most of the way there! The only
> problem I have is when I disable the preference page I get two copies of
> the buttons on my toolbar. Seems like the toolbar is being parsed a
> second time when I disable the page. Weird since the toolbar is in a
> different plugin. Even more weird is that if I repeatedly enable/disable
> the page I still only get two copies of my toolbar buttons.
>
> Here is my preference page XML:
>
> <!-- Preferences "Telephony Accounts" page -->
> <extension
> point = "org.eclipse.ui.preferencePages">
> <page id="CounterPath.Preferences.Accounts.AccountsPage"
> class="CounterPath.Preferences.Accounts.AccountsPage"
> name="Telephony Accounts">
> </page>
> </extension>
> <!-- An activity to allow us to show/hide the "Telephony Accounts"
> page -->
> <extension
> point="org.eclipse.ui.activities">
> <activity
> name="Telephony Accounts"
> description="Telephony Accounts Preferences"
> id="CounterPath.Preferences.AccountsPageActivity">
> </activity>
> <activityPatternBinding
> activityId="CounterPath.Preferences.AccountsPageActivity"
>
> pattern="PALS/CounterPath\.Preferences\.Accounts\.AccountsPage ">
> </activityPatternBinding>
> <!-- <defaultEnablement
> id="CounterPath.Preferences.AccountsPageActivity" /> -->
> </extension>
>
>
> And the toolabr XML in the other plugin:
>
> <!-- Notes toolbar -->
> <extension
> point="com.ibm.rcp.ui.controlSets">
> <controlSet
> align="left"
> id="CounterPath.NotesToolbar.ToolbarContribution.set"
> label="SMC Plug-in Toolbar"
> visible="true">
> <toolBar
> id="CounterPath.NotesToolbar.ToolbarContribution.bar"
> path="BEGIN_GROUP"/>
> <control
> class="CounterPath.NotesToolbar.ToolbarContribution"
> id="CounterPath.NotesToolbar.ToolbarContribution"
>
> toolbarPath="CounterPath.NotesToolbar.ToolbarContribution.bar "/>
> </controlSet>
> </extension>
>
> And my code to disable the preference page:
>
> org.eclipse.ui.activities.IWorkbenchActivitySupport
> workbenchActivitySupport =
> org.eclipse.ui.PlatformUI.getWorkbench().getActivitySupport( );
> org.eclipse.ui.activities.IActivityManager activityManager =
> workbenchActivitySupport.getActivityManager();
> HashSet enabledIds = new HashSet(activityManager.getEnabledActivityIds());
> if (enabledIds.remove("CounterPath.Preferences.AccountsPageActivity "))
> workbenchActivitySupport.setEnabledActivityIds(enabledIds);
>
>
Re: How do I add a preferences page programatically at run time? [message #330829 is a reply to message #330540] Thu, 14 August 2008 12:56 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Dominique wrote:
> I believe it is the FQCN as the class is declared as such in the code
> and when I load it using this same string via plugin.xml it works fine.

Right, but the plugin.xml uses the OSGi classloaders ... the JFace
classloader won't be able to find your class. You might have to
override org.eclipse.jface.preference.PreferenceNode.createPage()

>
> I am not able to step through this code you mentioned. Where do I get
> the sources for this?

My target is an SDK target, and so it has the source included. You can
always use the update manager to download the source features from the
Europa (3.3) or Ganymede (3.4) discovery sites.

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: How do I add a preferences page programatically at run time? [message #330831 is a reply to message #330539] Thu, 14 August 2008 12:57 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Dominique wrote:
> I also tried the following:
>
> org.eclipse.core.runtime.IExtensionRegistry registry =
> org.eclipse.core.runtime.Platform.getExtensionRegistry();
> org.eclipse.core.runtime.IExtensionPoint point =
> registry.getExtensionPoint("org.eclipse.ui.preferencePages");
> boolean success = false;
> if (point != null)
> {
> InputStream is = new StringBufferInputStream(
> " <plugin><extension" +
> " point = 'org.eclipse.ui.preferencePages'>" + " <page
> id='CounterPath.Preferences.Accounts.AccountsPage'" +
> " class='CounterPath.Preferences.Accounts.AccountsPage'" +
> " name='Telephony Accounts'>" +
> " </page>" +
> " </extension></plugin>");
> success = registry.addContribution(is, point.getContributor(),
> false, "Telephony Accounts", null, null);
> }
>
> Which executed fine but when I try to show the preferences page I get an
> error saying "Plugin org.eclipse.ui was unable to load class
> CounterPath.Preferences.Accounts.AccountsPage." This class is there and
> this works fine when I put the XML in the plugin.xml file. Do I need to
> somehow register the class so it is found?

Your contributor has to identify your plugin ... point.getContributor()
returns "org.eclipse.ui" which cannot load your class, you need to
create a contributor that returns your plugin.id.

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


Previous Topic:sorting table
Next Topic:Defining help contexts
Goto Forum:
  


Current Time: Sat Jul 27 20:12:47 GMT 2024

Powered by FUDForum. Page generated in 0.04811 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top