|
Re: Context help in a wizard [message #39094 is a reply to message #38972] |
Sun, 04 January 2009 09:45 |
hotzst Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Andi Hotz wrote:
> Hi
>
> I programed a wizard that creates Java classes. The wizard has several
> pages. The first is an extension of
> org.eclipse.jdt.ui.wizards.NewTypeWizardPage.
> It would be neat to have some context sensitive help that can show the
> user specific help to the current page or even the focused field. For
> the first page this works. All further pages are extended from WizardPage.
> To get the help working I followed the steps described here:
> http://www.macrobug.com/blog/2007/09/27/displaying-help-in-w izards-in-eclipse/
>
> This did not work for me so made a simple example that is attached.
> Drilling down to the IContext instance I found that the objects are
> there though the elements/attributes are null. I figure the problem lies
> somewhere in the setup of my help.
> If someone could point me in the right direction that would be great.
>
> Andy
There are some things I figured out so far. The ContextManager provides
the actual IContext. This context manager is passed twice first with the
context data from my plugin and then with new_wizard_context from
org.eclipse.ui. The second masks the my context. The reason for this
seams that the displayHelp is called twice:
- directly from the performHelp with the appropriate context-ID
- from the event queue with a 'generic' context-ID
The obvious way should be not to call from perform help and instead pass
the context-ID to the event queue. But I have no idea on how to do that.
Therefore I choose to unhook the events so that only the direct call is
left. The following code will do just that:
public void performHelp() {
IWizardContainer container = getContainer();
Composite comp = (Composite) container.getShell().getChildren()[0];
ToolItem item = ((ToolBar) ((Composite)
((Composite)comp.getChildren()[0]).getChildren()[1]).getChil dren()[0]).getItems()[0];
// This is the help button
Class widget = Widget.class;
try {
Field eventTable = widget.getDeclaredField("eventTable");
eventTable.setAccessible(true);
Object eTable = eventTable.get(item);
Class eventTabelClass = eTable.getClass();
Method m = eventTabelClass.getMethod("getListeners", new
Class[]{int.class});
m.setAccessible(true);
Listener[] listeners = (Listener[]) m.invoke(eTable, new
Object[]{SWT.DefaultSelection});
Vector v = new Vector();
for (int i = 0; i < listeners.length; i++) {
v.add(listeners[i]);
}
listeners = (Listener[]) m.invoke(eTable, new Object[]{SWT.Selection});
for (int i = 0; i < listeners.length; i++) {
v.add(listeners[i]);
}
m = eventTabelClass.getMethod("unhook", new
Class[]{int.class,Listener.class});
m.setAccessible(true);
for (Iterator iterator = v.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
m.invoke(eTable, new Object[]{SWT.DefaultSelection,listeners[0]});
m.invoke(eTable, new Object[]{SWT.Selection,listeners[0]});
}
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
PlatformUI.getWorkbench().getHelpSystem()
..displayHelp("ch.sahits.tutorial.help.firsthelp");
}
Has anybody an idea on how to pass the contex-ID
"ch.sahits.tutorial.help.firsthelp" to the event queue?
Andy
|
|
|
Re: Context help in a wizard [message #39125 is a reply to message #39094] |
Mon, 05 January 2009 13:40 |
Eclipse User |
|
|
|
Originally posted by: nospam_kowalskilee.gmail.com
Hi Andi,
Because this concerns the Eclipse help system, I recommend that you
repost your situation and question to the eclipse.platform.ua newsgroup.
That newsgroup is focused on the Eclipse "UA" system (= wizards, help
system, etc.), and you might get more of a response from followers of
that newsgroup.
Hope this helps,
Lee Anne
Andi Hotz wrote:
> Andi Hotz wrote:
>> Hi
>>
>> I programed a wizard that creates Java classes. The wizard has several
>> pages. The first is an extension of
>> org.eclipse.jdt.ui.wizards.NewTypeWizardPage.
>> It would be neat to have some context sensitive help that can show the
>> user specific help to the current page or even the focused field. For
>> the first page this works. All further pages are extended from
>> WizardPage.
>> To get the help working I followed the steps described here:
>> http://www.macrobug.com/blog/2007/09/27/displaying-help-in-w izards-in-eclipse/
>>
>> This did not work for me so made a simple example that is attached.
>> Drilling down to the IContext instance I found that the objects are
>> there though the elements/attributes are null. I figure the problem
>> lies somewhere in the setup of my help.
>> If someone could point me in the right direction that would be great.
>>
>> Andy
> There are some things I figured out so far. The ContextManager provides
> the actual IContext. This context manager is passed twice first with the
> context data from my plugin and then with new_wizard_context from
> org.eclipse.ui. The second masks the my context. The reason for this
> seams that the displayHelp is called twice:
> - directly from the performHelp with the appropriate context-ID
> - from the event queue with a 'generic' context-ID
>
> The obvious way should be not to call from perform help and instead pass
> the context-ID to the event queue. But I have no idea on how to do that.
>
> Therefore I choose to unhook the events so that only the direct call is
> left. The following code will do just that:
>
> public void performHelp() {
> IWizardContainer container = getContainer();
> Composite comp = (Composite) container.getShell().getChildren()[0];
> ToolItem item = ((ToolBar) ((Composite)
> ((Composite)comp.getChildren()[0]).getChildren()[1]).getChil dren()[0]).getItems()[0];
> // This is the help button
> Class widget = Widget.class;
> try {
> Field eventTable = widget.getDeclaredField("eventTable");
> eventTable.setAccessible(true);
> Object eTable = eventTable.get(item);
> Class eventTabelClass = eTable.getClass();
> Method m = eventTabelClass.getMethod("getListeners", new
> Class[]{int.class});
> m.setAccessible(true);
> Listener[] listeners = (Listener[]) m.invoke(eTable, new
> Object[]{SWT.DefaultSelection});
> Vector v = new Vector();
> for (int i = 0; i < listeners.length; i++) {
> v.add(listeners[i]);
> }
> listeners = (Listener[]) m.invoke(eTable, new Object[]{SWT.Selection});
> for (int i = 0; i < listeners.length; i++) {
> v.add(listeners[i]);
> }
> m = eventTabelClass.getMethod("unhook", new
> Class[]{int.class,Listener.class});
> m.setAccessible(true);
> for (Iterator iterator = v.iterator(); iterator.hasNext();) {
> Object object = (Object) iterator.next();
> m.invoke(eTable, new Object[]{SWT.DefaultSelection,listeners[0]});
> m.invoke(eTable, new Object[]{SWT.Selection,listeners[0]});
> }
> } catch (SecurityException e) {
> e.printStackTrace();
> } catch (IllegalArgumentException e) {
> e.printStackTrace();
> } catch (NoSuchFieldException e) {
> e.printStackTrace();
> } catch (IllegalAccessException e) {
> e.printStackTrace();
> } catch (NoSuchMethodException e) {
> e.printStackTrace();
> } catch (InvocationTargetException e) {
> e.printStackTrace();
> }
> PlatformUI.getWorkbench().getHelpSystem()
> .displayHelp("ch.sahits.tutorial.help.firsthelp");
> }
>
> Has anybody an idea on how to pass the contex-ID
> "ch.sahits.tutorial.help.firsthelp" to the event queue?
>
> Andy
|
|
|
|
Re: Context help in a wizard [message #587789 is a reply to message #38972] |
Sun, 04 January 2009 09:45 |
hotzst Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Andi Hotz wrote:
> Hi
>
> I programed a wizard that creates Java classes. The wizard has several
> pages. The first is an extension of
> org.eclipse.jdt.ui.wizards.NewTypeWizardPage.
> It would be neat to have some context sensitive help that can show the
> user specific help to the current page or even the focused field. For
> the first page this works. All further pages are extended from WizardPage.
> To get the help working I followed the steps described here:
> http://www.macrobug.com/blog/2007/09/27/displaying-help-in-w izards-in-eclipse/
>
> This did not work for me so made a simple example that is attached.
> Drilling down to the IContext instance I found that the objects are
> there though the elements/attributes are null. I figure the problem lies
> somewhere in the setup of my help.
> If someone could point me in the right direction that would be great.
>
> Andy
There are some things I figured out so far. The ContextManager provides
the actual IContext. This context manager is passed twice first with the
context data from my plugin and then with new_wizard_context from
org.eclipse.ui. The second masks the my context. The reason for this
seams that the displayHelp is called twice:
- directly from the performHelp with the appropriate context-ID
- from the event queue with a 'generic' context-ID
The obvious way should be not to call from perform help and instead pass
the context-ID to the event queue. But I have no idea on how to do that.
Therefore I choose to unhook the events so that only the direct call is
left. The following code will do just that:
public void performHelp() {
IWizardContainer container = getContainer();
Composite comp = (Composite) container.getShell().getChildren()[0];
ToolItem item = ((ToolBar) ((Composite)
((Composite)comp.getChildren()[0]).getChildren()[1]).getChil dren()[0]).getItems()[0];
// This is the help button
Class widget = Widget.class;
try {
Field eventTable = widget.getDeclaredField("eventTable");
eventTable.setAccessible(true);
Object eTable = eventTable.get(item);
Class eventTabelClass = eTable.getClass();
Method m = eventTabelClass.getMethod("getListeners", new
Class[]{int.class});
m.setAccessible(true);
Listener[] listeners = (Listener[]) m.invoke(eTable, new
Object[]{SWT.DefaultSelection});
Vector v = new Vector();
for (int i = 0; i < listeners.length; i++) {
v.add(listeners[i]);
}
listeners = (Listener[]) m.invoke(eTable, new Object[]{SWT.Selection});
for (int i = 0; i < listeners.length; i++) {
v.add(listeners[i]);
}
m = eventTabelClass.getMethod("unhook", new
Class[]{int.class,Listener.class});
m.setAccessible(true);
for (Iterator iterator = v.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
m.invoke(eTable, new Object[]{SWT.DefaultSelection,listeners[0]});
m.invoke(eTable, new Object[]{SWT.Selection,listeners[0]});
}
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
PlatformUI.getWorkbench().getHelpSystem()
..displayHelp("ch.sahits.tutorial.help.firsthelp");
}
Has anybody an idea on how to pass the contex-ID
"ch.sahits.tutorial.help.firsthelp" to the event queue?
Andy
|
|
|
Re: Context help in a wizard [message #587802 is a reply to message #39094] |
Mon, 05 January 2009 13:40 |
Lee Anne Kowalski Messages: 54 Registered: July 2009 |
Member |
|
|
Hi Andi,
Because this concerns the Eclipse help system, I recommend that you
repost your situation and question to the eclipse.platform.ua newsgroup.
That newsgroup is focused on the Eclipse "UA" system (= wizards, help
system, etc.), and you might get more of a response from followers of
that newsgroup.
Hope this helps,
Lee Anne
Andi Hotz wrote:
> Andi Hotz wrote:
>> Hi
>>
>> I programed a wizard that creates Java classes. The wizard has several
>> pages. The first is an extension of
>> org.eclipse.jdt.ui.wizards.NewTypeWizardPage.
>> It would be neat to have some context sensitive help that can show the
>> user specific help to the current page or even the focused field. For
>> the first page this works. All further pages are extended from
>> WizardPage.
>> To get the help working I followed the steps described here:
>> http://www.macrobug.com/blog/2007/09/27/displaying-help-in-w izards-in-eclipse/
>>
>> This did not work for me so made a simple example that is attached.
>> Drilling down to the IContext instance I found that the objects are
>> there though the elements/attributes are null. I figure the problem
>> lies somewhere in the setup of my help.
>> If someone could point me in the right direction that would be great.
>>
>> Andy
> There are some things I figured out so far. The ContextManager provides
> the actual IContext. This context manager is passed twice first with the
> context data from my plugin and then with new_wizard_context from
> org.eclipse.ui. The second masks the my context. The reason for this
> seams that the displayHelp is called twice:
> - directly from the performHelp with the appropriate context-ID
> - from the event queue with a 'generic' context-ID
>
> The obvious way should be not to call from perform help and instead pass
> the context-ID to the event queue. But I have no idea on how to do that.
>
> Therefore I choose to unhook the events so that only the direct call is
> left. The following code will do just that:
>
> public void performHelp() {
> IWizardContainer container = getContainer();
> Composite comp = (Composite) container.getShell().getChildren()[0];
> ToolItem item = ((ToolBar) ((Composite)
> ((Composite)comp.getChildren()[0]).getChildren()[1]).getChil dren()[0]).getItems()[0];
> // This is the help button
> Class widget = Widget.class;
> try {
> Field eventTable = widget.getDeclaredField("eventTable");
> eventTable.setAccessible(true);
> Object eTable = eventTable.get(item);
> Class eventTabelClass = eTable.getClass();
> Method m = eventTabelClass.getMethod("getListeners", new
> Class[]{int.class});
> m.setAccessible(true);
> Listener[] listeners = (Listener[]) m.invoke(eTable, new
> Object[]{SWT.DefaultSelection});
> Vector v = new Vector();
> for (int i = 0; i < listeners.length; i++) {
> v.add(listeners[i]);
> }
> listeners = (Listener[]) m.invoke(eTable, new Object[]{SWT.Selection});
> for (int i = 0; i < listeners.length; i++) {
> v.add(listeners[i]);
> }
> m = eventTabelClass.getMethod("unhook", new
> Class[]{int.class,Listener.class});
> m.setAccessible(true);
> for (Iterator iterator = v.iterator(); iterator.hasNext();) {
> Object object = (Object) iterator.next();
> m.invoke(eTable, new Object[]{SWT.DefaultSelection,listeners[0]});
> m.invoke(eTable, new Object[]{SWT.Selection,listeners[0]});
> }
> } catch (SecurityException e) {
> e.printStackTrace();
> } catch (IllegalArgumentException e) {
> e.printStackTrace();
> } catch (NoSuchFieldException e) {
> e.printStackTrace();
> } catch (IllegalAccessException e) {
> e.printStackTrace();
> } catch (NoSuchMethodException e) {
> e.printStackTrace();
> } catch (InvocationTargetException e) {
> e.printStackTrace();
> }
> PlatformUI.getWorkbench().getHelpSystem()
> .displayHelp("ch.sahits.tutorial.help.firsthelp");
> }
>
> Has anybody an idea on how to pass the contex-ID
> "ch.sahits.tutorial.help.firsthelp" to the event queue?
>
> Andy
|
|
|
|
Powered by
FUDForum. Page generated in 0.02582 seconds