Lines 7-12
Link Here
|
7 |
* |
7 |
* |
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* Chris Aniszczyk <zx@us.ibm.com> - initial API and implementation |
9 |
* Chris Aniszczyk <zx@us.ibm.com> - initial API and implementation |
|
|
10 |
* Remy Suen <remy.suen@gmail.com> - bug 203451 |
10 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
11 |
package org.eclipse.pde.internal.runtime.spy.sections; |
12 |
package org.eclipse.pde.internal.runtime.spy.sections; |
12 |
|
13 |
|
Lines 14-23
Link Here
|
14 |
import org.eclipse.jface.dialogs.Dialog; |
15 |
import org.eclipse.jface.dialogs.Dialog; |
15 |
import org.eclipse.jface.preference.IPreferencePage; |
16 |
import org.eclipse.jface.preference.IPreferencePage; |
16 |
import org.eclipse.jface.preference.PreferenceDialog; |
17 |
import org.eclipse.jface.preference.PreferenceDialog; |
|
|
18 |
import org.eclipse.pde.internal.runtime.PDERuntimeMessages; |
19 |
import org.eclipse.pde.internal.runtime.PDERuntimePluginImages; |
17 |
import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; |
20 |
import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; |
|
|
21 |
import org.eclipse.swt.graphics.Image; |
18 |
import org.eclipse.swt.widgets.Composite; |
22 |
import org.eclipse.swt.widgets.Composite; |
19 |
import org.eclipse.swt.widgets.Control; |
23 |
import org.eclipse.swt.widgets.Control; |
20 |
import org.eclipse.swt.widgets.Shell; |
24 |
import org.eclipse.swt.widgets.Shell; |
|
|
25 |
import org.eclipse.swt.widgets.Widget; |
21 |
import org.eclipse.ui.IEditorPart; |
26 |
import org.eclipse.ui.IEditorPart; |
22 |
import org.eclipse.ui.IEditorReference; |
27 |
import org.eclipse.ui.IEditorReference; |
23 |
import org.eclipse.ui.IViewReference; |
28 |
import org.eclipse.ui.IViewReference; |
Lines 34-43
Link Here
|
34 |
|
39 |
|
35 |
public class ActiveHelpSection implements ISpySection { |
40 |
public class ActiveHelpSection implements ISpySection { |
36 |
|
41 |
|
37 |
private static String HELP_KEY = "org.eclipse.ui.help"; //$NON-NLS-1$ |
42 |
private SpyFormToolkit toolkit; |
38 |
|
43 |
|
39 |
public void build(ScrolledForm form, SpyFormToolkit toolkit, |
44 |
public void build(ScrolledForm form, SpyFormToolkit toolkit, |
40 |
ExecutionEvent event) { |
45 |
ExecutionEvent event) { |
|
|
46 |
this.toolkit = toolkit; |
41 |
final Shell shell = HandlerUtil.getActiveShell(event); |
47 |
final Shell shell = HandlerUtil.getActiveShell(event); |
42 |
Object object = shell.getData(); |
48 |
Object object = shell.getData(); |
43 |
if(object == null) |
49 |
if(object == null) |
Lines 45-67
Link Here
|
45 |
|
51 |
|
46 |
StringBuffer helpBuffer = new StringBuffer(); |
52 |
StringBuffer helpBuffer = new StringBuffer(); |
47 |
// process help |
53 |
// process help |
|
|
54 |
// TODO we need to make this cleaner... help processing is complicated atm |
48 |
if(object instanceof PreferenceDialog) { |
55 |
if(object instanceof PreferenceDialog) { |
49 |
PreferenceDialog dialog = (PreferenceDialog) object; |
56 |
PreferenceDialog dialog = (PreferenceDialog) object; |
50 |
IPreferencePage page = (IPreferencePage) dialog.getSelectedPage(); |
57 |
IPreferencePage page = (IPreferencePage) dialog.getSelectedPage(); |
51 |
processChildren(page.getControl().getShell(), toolkit, helpBuffer); |
58 |
processHelp(page.getControl().getShell(), helpBuffer); |
|
|
59 |
processChildren(page.getControl(), helpBuffer); |
52 |
} else if(object instanceof Dialog) { |
60 |
} else if(object instanceof Dialog) { |
53 |
Dialog dialog = (Dialog) object; |
61 |
Dialog dialog = (Dialog) object; |
54 |
processChildren(dialog.getShell(), toolkit, helpBuffer); |
62 |
processChildren(dialog.getShell(), helpBuffer); |
55 |
} else { |
63 |
} else { |
56 |
helpBuffer.append(processControlHelp(event, toolkit)); |
64 |
helpBuffer.append(processControlHelp(event, toolkit)); |
57 |
} |
65 |
} |
58 |
|
66 |
|
59 |
// ensure we actually have help |
|
|
60 |
// TODO we need to make this cleaner... help processing is complicated atm |
61 |
if(helpBuffer != null && helpBuffer.length() > 0) { |
67 |
if(helpBuffer != null && helpBuffer.length() > 0) { |
62 |
Section section = toolkit.createSection(form.getBody(), |
68 |
Section section = toolkit.createSection(form.getBody(), |
63 |
ExpandableComposite.TITLE_BAR); |
69 |
ExpandableComposite.TITLE_BAR); |
64 |
section.setText("Active Help"); //$NON-NLS-1$ |
70 |
section.setText(PDERuntimeMessages.SpyDialog_activeHelpSection_title); |
65 |
|
71 |
|
66 |
FormText text = toolkit.createFormText(section, true); |
72 |
FormText text = toolkit.createFormText(section, true); |
67 |
section.setClient(text); |
73 |
section.setClient(text); |
Lines 70-93
Link Here
|
70 |
td.grabHorizontal = true; |
76 |
td.grabHorizontal = true; |
71 |
section.setLayoutData(td); |
77 |
section.setLayoutData(td); |
72 |
|
78 |
|
|
|
79 |
Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_CONTEXTID_OBJ); |
80 |
text.setImage("contextid", image); //$NON-NLS-1$ |
81 |
|
73 |
StringBuffer buffer = new StringBuffer(); |
82 |
StringBuffer buffer = new StringBuffer(); |
74 |
buffer.append("<form>"); //$NON-NLS-1$ |
83 |
buffer.append("<form>"); //$NON-NLS-1$ |
75 |
buffer.append(helpBuffer.toString()); |
84 |
buffer.append(helpBuffer.toString()); |
76 |
buffer.append("</form>"); //$NON-NLS-1$ |
85 |
buffer.append("</form>"); //$NON-NLS-1$ |
77 |
text.setText(buffer.toString(), true, false); |
86 |
String content = buffer.toString().replaceAll("&", "&"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
87 |
text.setText(content, true, false); |
78 |
} |
88 |
} |
79 |
|
89 |
|
80 |
} |
90 |
} |
|
|
91 |
|
92 |
private void processHelp(Widget widget, StringBuffer buffer) { |
93 |
buffer.append(toolkit.createHelpIdentifierSection(widget)); |
94 |
} |
81 |
|
95 |
|
82 |
private void processChildren(Control control, SpyFormToolkit toolkit, StringBuffer buffer) { |
96 |
private void processChildren(Control control, StringBuffer buffer) { |
83 |
if(control.getData(HELP_KEY) != null) { |
97 |
processHelp(control, buffer); |
84 |
buffer.append("<li bindent=\"20\">" + control.toString() + " - " + control.getData(HELP_KEY) + "</li>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
|
85 |
} |
86 |
if(control instanceof Composite) { |
98 |
if(control instanceof Composite) { |
87 |
Composite composite = (Composite) control; |
99 |
Composite composite = (Composite) control; |
88 |
Control[] controls = composite.getChildren(); |
100 |
Control[] controls = composite.getChildren(); |
89 |
for (int i = 0; i < controls.length; i++) { |
101 |
for (int i = 0; i < controls.length; i++) { |
90 |
processChildren(controls[i], toolkit, buffer); |
102 |
processChildren(controls[i], buffer); |
91 |
} |
103 |
} |
92 |
} |
104 |
} |
93 |
} |
105 |
} |
Lines 137-157
Link Here
|
137 |
|
149 |
|
138 |
} |
150 |
} |
139 |
if (shell != null) { |
151 |
if (shell != null) { |
140 |
if (shell.getData(HELP_KEY) != null) { |
152 |
buffer.append(toolkit.createHelpIdentifierSection(shell)); |
141 |
buffer.append("<li bindent=\"20\">" + shell.toString() + " - " + shell.getData(HELP_KEY) + "</li>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
|
142 |
} |
143 |
for (int i = 0; i < shell.getChildren().length; i++) { |
153 |
for (int i = 0; i < shell.getChildren().length; i++) { |
144 |
processChildren(shell.getChildren()[i], toolkit, buffer); |
154 |
processChildren(shell.getChildren()[i], buffer); |
145 |
} |
155 |
} |
146 |
} |
156 |
} |
147 |
else if(control != null) { |
157 |
else if(control != null) { |
148 |
if(control.getData(HELP_KEY) != null) { |
158 |
buffer.append(toolkit.createHelpIdentifierSection(control)); |
149 |
buffer.append("<li bindent=\"20\">" + control.toString() + " - " + control.getData(HELP_KEY) + "</li>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
|
150 |
} |
151 |
if(control instanceof Composite) { |
159 |
if(control instanceof Composite) { |
152 |
Composite parent = (Composite) control; |
160 |
Composite parent = (Composite) control; |
153 |
for(int i = 0; i < parent.getChildren().length; i++) { |
161 |
for(int i = 0; i < parent.getChildren().length; i++) { |
154 |
processChildren(parent.getChildren()[i], toolkit, buffer); |
162 |
processChildren(parent.getChildren()[i], buffer); |
155 |
} |
163 |
} |
156 |
} |
164 |
} |
157 |
} |
165 |
} |