Lines 17-25
Link Here
|
17 |
import org.eclipse.core.resources.IFile; |
17 |
import org.eclipse.core.resources.IFile; |
18 |
import org.eclipse.core.resources.IResource; |
18 |
import org.eclipse.core.resources.IResource; |
19 |
import org.eclipse.core.runtime.IPath; |
19 |
import org.eclipse.core.runtime.IPath; |
|
|
20 |
import org.eclipse.core.runtime.Path; |
20 |
import org.eclipse.jface.action.*; |
21 |
import org.eclipse.jface.action.*; |
21 |
import org.eclipse.jface.dialogs.MessageDialog; |
22 |
import org.eclipse.jface.dialogs.MessageDialog; |
22 |
import org.eclipse.jface.viewers.*; |
23 |
import org.eclipse.jface.viewers.*; |
|
|
24 |
import org.eclipse.jface.window.Window; |
23 |
import org.eclipse.pde.core.IModelChangedEvent; |
25 |
import org.eclipse.pde.core.IModelChangedEvent; |
24 |
import org.eclipse.pde.internal.core.text.IDocumentElementNode; |
26 |
import org.eclipse.pde.internal.core.text.IDocumentElementNode; |
25 |
import org.eclipse.pde.internal.ua.core.ctxhelp.ICtxHelpConstants; |
27 |
import org.eclipse.pde.internal.ua.core.ctxhelp.ICtxHelpConstants; |
Lines 46-51
Link Here
|
46 |
import org.eclipse.ui.PlatformUI; |
48 |
import org.eclipse.ui.PlatformUI; |
47 |
import org.eclipse.ui.actions.ActionFactory; |
49 |
import org.eclipse.ui.actions.ActionFactory; |
48 |
import org.eclipse.ui.actions.ContributionItemFactory; |
50 |
import org.eclipse.ui.actions.ContributionItemFactory; |
|
|
51 |
import org.eclipse.ui.dialogs.ListDialog; |
49 |
import org.eclipse.ui.dialogs.PatternFilter; |
52 |
import org.eclipse.ui.dialogs.PatternFilter; |
50 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
53 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
51 |
import org.eclipse.ui.forms.widgets.Section; |
54 |
import org.eclipse.ui.forms.widgets.Section; |
Lines 53-60
Link Here
|
53 |
import org.eclipse.ui.keys.IBindingService; |
56 |
import org.eclipse.ui.keys.IBindingService; |
54 |
|
57 |
|
55 |
/** |
58 |
/** |
56 |
* Tree section for the context help editor. Displays the structure |
59 |
* Tree section for the context help editor. Displays the structure of the xml |
57 |
* of the xml file and adds actions allowing manipulation of the structure. |
60 |
* file and adds actions allowing manipulation of the structure. |
|
|
61 |
* |
58 |
* @since 3.4 |
62 |
* @since 3.4 |
59 |
* @see CtxHelpEditor |
63 |
* @see CtxHelpEditor |
60 |
*/ |
64 |
*/ |
Lines 63-72
Link Here
|
63 |
private TreeViewer fTree; |
67 |
private TreeViewer fTree; |
64 |
private FormFilteredTree fFilteredTree; |
68 |
private FormFilteredTree fFilteredTree; |
65 |
|
69 |
|
66 |
/* The indices for each button attached to the Tree Viewer. |
70 |
/* |
67 |
* This type of UI form does not permit direct access to each particular |
71 |
* The indices for each button attached to the Tree Viewer. This type of UI |
68 |
* button. However, using these indices, one can perform any typical SWT |
72 |
* form does not permit direct access to each particular button. However, |
69 |
* operation on any button. |
73 |
* using these indices, one can perform any typical SWT operation on any |
|
|
74 |
* button. |
70 |
*/ |
75 |
*/ |
71 |
private static final int F_BUTTON_ADD_CONTEXT = 0; |
76 |
private static final int F_BUTTON_ADD_CONTEXT = 0; |
72 |
private static final int F_BUTTON_ADD_TOPIC = 2; |
77 |
private static final int F_BUTTON_ADD_TOPIC = 2; |
Lines 74-81
Link Here
|
74 |
private static final int F_BUTTON_REMOVE = 5; |
79 |
private static final int F_BUTTON_REMOVE = 5; |
75 |
private static final int F_BUTTON_UP = 6; |
80 |
private static final int F_BUTTON_UP = 6; |
76 |
private static final int F_BUTTON_DOWN = 7; |
81 |
private static final int F_BUTTON_DOWN = 7; |
|
|
82 |
private static final int F_BUTTON_BROKENLINK = 8; |
77 |
|
83 |
|
78 |
// When one of the move buttons is pressed, a flag is used to determine the direction |
84 |
// When one of the move buttons is pressed, a flag is used to determine the |
|
|
85 |
// direction |
79 |
private static final int F_UP_FLAG = -1; |
86 |
private static final int F_UP_FLAG = -1; |
80 |
private static final int F_DOWN_FLAG = 1; |
87 |
private static final int F_DOWN_FLAG = 1; |
81 |
|
88 |
|
Lines 90-109
Link Here
|
90 |
// The action for opening a link from the context menu |
97 |
// The action for opening a link from the context menu |
91 |
private OpenLinkAction fOpenLinkAction; |
98 |
private OpenLinkAction fOpenLinkAction; |
92 |
|
99 |
|
93 |
// Used to temporarily store the target of a drop operation |
100 |
// Used to temporarily store the target of a drop operation |
94 |
// so that it does not have be be recalculated |
101 |
// so that it does not have be be recalculated |
95 |
private CtxHelpObject fDropTargetParent; |
102 |
private CtxHelpObject fDropTargetParent; |
96 |
private CtxHelpObject fDropTargetSibling; |
103 |
private CtxHelpObject fDropTargetSibling; |
97 |
|
104 |
|
98 |
/** If items are dragged and dropped within this tree, then |
105 |
/** |
99 |
* this flag inhibits reselection on the removal (drag) action, |
106 |
* If items are dragged and dropped within this tree, then this flag |
100 |
* thus ensuring that the selected objects are the ones that were |
107 |
* inhibits reselection on the removal (drag) action, thus ensuring that the |
101 |
* dropped. |
108 |
* selected objects are the ones that were dropped. |
102 |
*/ |
109 |
*/ |
103 |
private boolean fDragFromHere; |
110 |
private boolean fDragFromHere; |
104 |
|
111 |
|
105 |
/** |
112 |
/** |
106 |
* Action that allows a linked file to be opened in the editor |
113 |
* Action that allows a linked file to be opened in the editor |
|
|
114 |
* |
107 |
* @since 3.4 |
115 |
* @since 3.4 |
108 |
*/ |
116 |
*/ |
109 |
class OpenLinkAction extends Action { |
117 |
class OpenLinkAction extends Action { |
Lines 125-135
Link Here
|
125 |
} |
133 |
} |
126 |
|
134 |
|
127 |
public CtxHelpTreeSection(PDEFormPage formPage, Composite parent) { |
135 |
public CtxHelpTreeSection(PDEFormPage formPage, Composite parent) { |
128 |
super(formPage, parent, Section.DESCRIPTION, new String[] {CtxHelpMessages.CtxHelpTreeSection_1, null, CtxHelpMessages.CtxHelpTreeSection_2, CtxHelpMessages.CtxHelpTreeSection_3, null, CtxHelpMessages.CtxHelpTreeSection_4, CtxHelpMessages.CtxHelpTreeSection_5, CtxHelpMessages.CtxHelpTreeSection_6}); |
136 |
super(formPage, parent, Section.DESCRIPTION, new String[] { |
|
|
137 |
CtxHelpMessages.CtxHelpTreeSection_1, null, |
138 |
CtxHelpMessages.CtxHelpTreeSection_2, |
139 |
CtxHelpMessages.CtxHelpTreeSection_3, null, |
140 |
CtxHelpMessages.CtxHelpTreeSection_4, |
141 |
CtxHelpMessages.CtxHelpTreeSection_5, |
142 |
CtxHelpMessages.CtxHelpTreeSection_6, |
143 |
CtxHelpMessages.CtxHelpTreeSection_24 }); |
129 |
} |
144 |
} |
130 |
|
145 |
|
131 |
/* (non-Javadoc) |
146 |
/* |
132 |
* @see org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) |
147 |
* (non-Javadoc) |
|
|
148 |
* |
149 |
* @see |
150 |
* org.eclipse.pde.internal.ui.editor.PDESection#createClient(org.eclipse |
151 |
* .ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) |
133 |
*/ |
152 |
*/ |
134 |
protected void createClient(Section section, FormToolkit toolkit) { |
153 |
protected void createClient(Section section, FormToolkit toolkit) { |
135 |
fModel = (CtxHelpModel) getPage().getModel(); |
154 |
fModel = (CtxHelpModel) getPage().getModel(); |
Lines 158-165
Link Here
|
158 |
fAddContextAction = new CtxHelpAbstractAddAction() { |
177 |
fAddContextAction = new CtxHelpAbstractAddAction() { |
159 |
public void run() { |
178 |
public void run() { |
160 |
if (fParentObject != null) { |
179 |
if (fParentObject != null) { |
161 |
CtxHelpContext context = fParentObject.getModel().getFactory().createContext(); |
180 |
CtxHelpContext context = fParentObject.getModel() |
162 |
String id = PDELabelUtility.generateName(getChildNames(), CtxHelpMessages.CtxHelpTreeSection_9); |
181 |
.getFactory().createContext(); |
|
|
182 |
String id = PDELabelUtility.generateName(getChildNames(), |
183 |
CtxHelpMessages.CtxHelpTreeSection_9); |
163 |
context.setID(id); |
184 |
context.setID(id); |
164 |
addChild(context); |
185 |
addChild(context); |
165 |
} |
186 |
} |
Lines 169-176
Link Here
|
169 |
fAddTopicAction = new CtxHelpAbstractAddAction() { |
190 |
fAddTopicAction = new CtxHelpAbstractAddAction() { |
170 |
public void run() { |
191 |
public void run() { |
171 |
if (fParentObject != null) { |
192 |
if (fParentObject != null) { |
172 |
CtxHelpTopic topic = fParentObject.getModel().getFactory().createTopic(); |
193 |
CtxHelpTopic topic = fParentObject.getModel().getFactory() |
173 |
String label = PDELabelUtility.generateName(getChildNames(), CtxHelpMessages.CtxHelpTreeSection_11); |
194 |
.createTopic(); |
|
|
195 |
String label = PDELabelUtility.generateName( |
196 |
getChildNames(), |
197 |
CtxHelpMessages.CtxHelpTreeSection_11); |
174 |
topic.setLabel(label); |
198 |
topic.setLabel(label); |
175 |
addChild(topic); |
199 |
addChild(topic); |
176 |
} |
200 |
} |
Lines 180-187
Link Here
|
180 |
fAddCommandAction = new CtxHelpAbstractAddAction() { |
204 |
fAddCommandAction = new CtxHelpAbstractAddAction() { |
181 |
public void run() { |
205 |
public void run() { |
182 |
if (fParentObject != null) { |
206 |
if (fParentObject != null) { |
183 |
CtxHelpCommand command = fParentObject.getModel().getFactory().createCommand(); |
207 |
CtxHelpCommand command = fParentObject.getModel() |
184 |
String label = PDELabelUtility.generateName(getChildNames(), CtxHelpMessages.CtxHelpTreeSection_13); |
208 |
.getFactory().createCommand(); |
|
|
209 |
String label = PDELabelUtility.generateName( |
210 |
getChildNames(), |
211 |
CtxHelpMessages.CtxHelpTreeSection_13); |
185 |
command.setLabel(label); |
212 |
command.setLabel(label); |
186 |
addChild(command); |
213 |
addChild(command); |
187 |
} |
214 |
} |
Lines 194-210
Link Here
|
194 |
} |
221 |
} |
195 |
|
222 |
|
196 |
/** |
223 |
/** |
197 |
* Adds a link (with hand cursor) for tree 'Collapse All' action, |
224 |
* Adds a link (with hand cursor) for tree 'Collapse All' action, which |
198 |
* which collapses the tree down to the second level |
225 |
* collapses the tree down to the second level |
199 |
* |
226 |
* |
200 |
* @param section The section that the toolbar will belong to |
227 |
* @param section |
201 |
* @param toolkit The toolkit that will be used to make the toolbar |
228 |
* The section that the toolbar will belong to |
|
|
229 |
* @param toolkit |
230 |
* The toolkit that will be used to make the toolbar |
202 |
*/ |
231 |
*/ |
203 |
private void createSectionToolbar(Section section, FormToolkit toolkit) { |
232 |
private void createSectionToolbar(Section section, FormToolkit toolkit) { |
204 |
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); |
233 |
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); |
205 |
ToolBar toolbar = toolBarManager.createControl(section); |
234 |
ToolBar toolbar = toolBarManager.createControl(section); |
206 |
|
235 |
|
207 |
final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); |
236 |
final Cursor handCursor = new Cursor(Display.getCurrent(), |
|
|
237 |
SWT.CURSOR_HAND); |
208 |
toolbar.setCursor(handCursor); |
238 |
toolbar.setCursor(handCursor); |
209 |
// Cursor needs to be explicitly disposed |
239 |
// Cursor needs to be explicitly disposed |
210 |
toolbar.addDisposeListener(new DisposeListener() { |
240 |
toolbar.addDisposeListener(new DisposeListener() { |
Lines 216-222
Link Here
|
216 |
}); |
246 |
}); |
217 |
|
247 |
|
218 |
// Add collapse action to the tool bar |
248 |
// Add collapse action to the tool bar |
219 |
toolBarManager.add(new CollapseAction(fTree, CtxHelpMessages.CtxHelpTreeSection_15, 1, fModel.getCtxHelpRoot())); |
249 |
toolBarManager.add(new CollapseAction(fTree, |
|
|
250 |
CtxHelpMessages.CtxHelpTreeSection_15, 1, fModel |
251 |
.getCtxHelpRoot())); |
220 |
toolBarManager.update(true); |
252 |
toolBarManager.update(true); |
221 |
section.setTextClient(toolbar); |
253 |
section.setTextClient(toolbar); |
222 |
} |
254 |
} |
Lines 224-231
Link Here
|
224 |
/** |
256 |
/** |
225 |
* Create the tree widget that will contain the structure |
257 |
* Create the tree widget that will contain the structure |
226 |
* |
258 |
* |
227 |
* @param container The container of the tree widget |
259 |
* @param container |
228 |
* @param toolkit The toolkit used to create the tree |
260 |
* The container of the tree widget |
|
|
261 |
* @param toolkit |
262 |
* The toolkit used to create the tree |
229 |
*/ |
263 |
*/ |
230 |
private void createTree(Composite container, FormToolkit toolkit) { |
264 |
private void createTree(Composite container, FormToolkit toolkit) { |
231 |
TreePart treePart = getTreePart(); |
265 |
TreePart treePart = getTreePart(); |
Lines 233-248
Link Here
|
233 |
|
267 |
|
234 |
fTree = treePart.getTreeViewer(); |
268 |
fTree = treePart.getTreeViewer(); |
235 |
fTree.setContentProvider(new CtxHelpContentProvider()); |
269 |
fTree.setContentProvider(new CtxHelpContentProvider()); |
236 |
fTree.setLabelProvider(PDEUserAssistanceUIPlugin.getDefault().getLabelProvider()); |
270 |
fTree.setLabelProvider(PDEUserAssistanceUIPlugin.getDefault() |
|
|
271 |
.getLabelProvider()); |
237 |
|
272 |
|
238 |
PDEUserAssistanceUIPlugin.getDefault().getLabelProvider().connect(this); |
273 |
PDEUserAssistanceUIPlugin.getDefault().getLabelProvider().connect(this); |
239 |
|
274 |
|
240 |
// Create listener for the outline view 'link with editor' toggle button |
275 |
// Create listener for the outline view 'link with editor' toggle button |
241 |
fTree.addPostSelectionChangedListener(getPage().getPDEEditor().new PDEFormEditorChangeListener()); |
276 |
fTree |
|
|
277 |
.addPostSelectionChangedListener(getPage().getPDEEditor().new PDEFormEditorChangeListener()); |
242 |
} |
278 |
} |
243 |
|
279 |
|
244 |
/* (non-Javadoc) |
280 |
/* |
245 |
* @see org.eclipse.pde.internal.ui.editor.TreeSection#createTreeViewer(org.eclipse.swt.widgets.Composite, int) |
281 |
* (non-Javadoc) |
|
|
282 |
* |
283 |
* @see |
284 |
* org.eclipse.pde.internal.ui.editor.TreeSection#createTreeViewer(org.eclipse |
285 |
* .swt.widgets.Composite, int) |
246 |
*/ |
286 |
*/ |
247 |
protected TreeViewer createTreeViewer(Composite parent, int style) { |
287 |
protected TreeViewer createTreeViewer(Composite parent, int style) { |
248 |
fFilteredTree = new FormFilteredTree(parent, style, new PatternFilter()); |
288 |
fFilteredTree = new FormFilteredTree(parent, style, new PatternFilter()); |
Lines 269-282
Link Here
|
269 |
getTreePart().setButtonEnabled(F_BUTTON_REMOVE, false); |
309 |
getTreePart().setButtonEnabled(F_BUTTON_REMOVE, false); |
270 |
getTreePart().setButtonEnabled(F_BUTTON_UP, false); |
310 |
getTreePart().setButtonEnabled(F_BUTTON_UP, false); |
271 |
getTreePart().setButtonEnabled(F_BUTTON_DOWN, false); |
311 |
getTreePart().setButtonEnabled(F_BUTTON_DOWN, false); |
|
|
312 |
getTreePart().setButtonEnabled(F_BUTTON_BROKENLINK, true); |
272 |
} |
313 |
} |
273 |
|
314 |
|
274 |
/* (non-Javadoc) |
315 |
/* |
|
|
316 |
* (non-Javadoc) |
317 |
* |
275 |
* @see org.eclipse.ui.forms.AbstractFormPart#setFormInput(java.lang.Object) |
318 |
* @see org.eclipse.ui.forms.AbstractFormPart#setFormInput(java.lang.Object) |
276 |
*/ |
319 |
*/ |
277 |
public boolean setFormInput(Object object) { |
320 |
public boolean setFormInput(Object object) { |
278 |
// This method allows the outline view to select items in the tree |
321 |
// This method allows the outline view to select items in the tree |
279 |
// (Invoked by org.eclipse.ui.forms.editor.IFormPage.selectReveal(Object object)) |
322 |
// (Invoked by org.eclipse.ui.forms.editor.IFormPage.selectReveal(Object |
|
|
323 |
// object)) |
280 |
if (object instanceof CtxHelpObject) { |
324 |
if (object instanceof CtxHelpObject) { |
281 |
fTree.setSelection(new StructuredSelection(object), true); |
325 |
fTree.setSelection(new StructuredSelection(object), true); |
282 |
|
326 |
|
Lines 297-303
Link Here
|
297 |
} |
341 |
} |
298 |
|
342 |
|
299 |
/** |
343 |
/** |
300 |
* @param selection the new selection for the tree section |
344 |
* @param selection |
|
|
345 |
* the new selection for the tree section |
301 |
*/ |
346 |
*/ |
302 |
public void setSelection(ISelection selection) { |
347 |
public void setSelection(ISelection selection) { |
303 |
fTree.setSelection(selection); |
348 |
fTree.setSelection(selection); |
Lines 310-317
Link Here
|
310 |
fTree.setSelection(fTree.getSelection()); |
355 |
fTree.setSelection(fTree.getSelection()); |
311 |
} |
356 |
} |
312 |
|
357 |
|
313 |
/* (non-Javadoc) |
358 |
/* |
314 |
* @see org.eclipse.pde.internal.ui.editor.TreeSection#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection) |
359 |
* (non-Javadoc) |
|
|
360 |
* |
361 |
* @see |
362 |
* org.eclipse.pde.internal.ui.editor.TreeSection#selectionChanged(org.eclipse |
363 |
* .jface.viewers.IStructuredSelection) |
315 |
*/ |
364 |
*/ |
316 |
protected void selectionChanged(IStructuredSelection selection) { |
365 |
protected void selectionChanged(IStructuredSelection selection) { |
317 |
getPage().getPDEEditor().setSelection(selection); |
366 |
getPage().getPDEEditor().setSelection(selection); |
Lines 326-333
Link Here
|
326 |
return; |
375 |
return; |
327 |
} |
376 |
} |
328 |
|
377 |
|
329 |
IStructuredSelection selection = (IStructuredSelection) fTree.getSelection(); |
378 |
IStructuredSelection selection = (IStructuredSelection) fTree |
330 |
CtxHelpObject firstSelectedObject = (CtxHelpObject) selection.getFirstElement(); |
379 |
.getSelection(); |
|
|
380 |
CtxHelpObject firstSelectedObject = (CtxHelpObject) selection |
381 |
.getFirstElement(); |
331 |
|
382 |
|
332 |
// Add Context |
383 |
// Add Context |
333 |
getTreePart().setButtonEnabled(F_BUTTON_ADD_CONTEXT, true); |
384 |
getTreePart().setButtonEnabled(F_BUTTON_ADD_CONTEXT, true); |
Lines 337-343
Link Here
|
337 |
if (firstSelectedObject != null) { |
388 |
if (firstSelectedObject != null) { |
338 |
if (firstSelectedObject.canAddSibling(ICtxHelpConstants.TYPE_TOPIC)) { |
389 |
if (firstSelectedObject.canAddSibling(ICtxHelpConstants.TYPE_TOPIC)) { |
339 |
enableAdd = true; |
390 |
enableAdd = true; |
340 |
} else if (firstSelectedObject.canAddChild(ICtxHelpConstants.TYPE_TOPIC)) { |
391 |
} else if (firstSelectedObject |
|
|
392 |
.canAddChild(ICtxHelpConstants.TYPE_TOPIC)) { |
341 |
enableAdd = true; |
393 |
enableAdd = true; |
342 |
} |
394 |
} |
343 |
} |
395 |
} |
Lines 346-366
Link Here
|
346 |
// Add Command |
398 |
// Add Command |
347 |
enableAdd = false; |
399 |
enableAdd = false; |
348 |
if (firstSelectedObject != null) { |
400 |
if (firstSelectedObject != null) { |
349 |
if (firstSelectedObject.canAddSibling(ICtxHelpConstants.TYPE_COMMAND)) { |
401 |
if (firstSelectedObject |
|
|
402 |
.canAddSibling(ICtxHelpConstants.TYPE_COMMAND)) { |
350 |
enableAdd = true; |
403 |
enableAdd = true; |
351 |
} else if (firstSelectedObject.canAddChild(ICtxHelpConstants.TYPE_COMMAND)) { |
404 |
} else if (firstSelectedObject |
|
|
405 |
.canAddChild(ICtxHelpConstants.TYPE_COMMAND)) { |
352 |
enableAdd = true; |
406 |
enableAdd = true; |
353 |
} |
407 |
} |
354 |
} |
408 |
} |
355 |
getTreePart().setButtonEnabled(F_BUTTON_ADD_COMMAND, enableAdd); |
409 |
getTreePart().setButtonEnabled(F_BUTTON_ADD_COMMAND, enableAdd); |
356 |
|
410 |
|
357 |
// Remove button |
411 |
// Remove button |
358 |
getTreePart().setButtonEnabled(F_BUTTON_REMOVE, getRemovableObjectFromSelection(selection).size() > 0); |
412 |
getTreePart().setButtonEnabled(F_BUTTON_REMOVE, |
|
|
413 |
getRemovableObjectFromSelection(selection).size() > 0); |
359 |
|
414 |
|
360 |
// Up and Down buttons |
415 |
// Up and Down buttons |
361 |
boolean canMoveUp = true; |
416 |
boolean canMoveUp = true; |
362 |
boolean canMoveDown = true; |
417 |
boolean canMoveDown = true; |
363 |
if (firstSelectedObject == null || firstSelectedObject.getType() == ICtxHelpConstants.TYPE_ROOT || firstSelectedObject.getType() == ICtxHelpConstants.TYPE_DESCRIPTION || selection.size() > 1) { |
418 |
if (firstSelectedObject == null |
|
|
419 |
|| firstSelectedObject.getType() == ICtxHelpConstants.TYPE_ROOT |
420 |
|| firstSelectedObject.getType() == ICtxHelpConstants.TYPE_DESCRIPTION |
421 |
|| selection.size() > 1) { |
364 |
canMoveUp = false; |
422 |
canMoveUp = false; |
365 |
canMoveDown = false; |
423 |
canMoveDown = false; |
366 |
} else { |
424 |
} else { |
Lines 379-396
Link Here
|
379 |
getTreePart().setButtonEnabled(F_BUTTON_DOWN, canMoveDown); |
437 |
getTreePart().setButtonEnabled(F_BUTTON_DOWN, canMoveDown); |
380 |
} |
438 |
} |
381 |
|
439 |
|
382 |
/* (non-Javadoc) |
440 |
/* |
383 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#fillContextMenu(org.eclipse.jface.action.IMenuManager) |
441 |
* (non-Javadoc) |
|
|
442 |
* |
443 |
* @see |
444 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#fillContextMenu |
445 |
* (org.eclipse.jface.action.IMenuManager) |
384 |
*/ |
446 |
*/ |
385 |
protected void fillContextMenu(IMenuManager manager) { |
447 |
protected void fillContextMenu(IMenuManager manager) { |
386 |
IStructuredSelection selection = (IStructuredSelection) fTree.getSelection(); |
448 |
IStructuredSelection selection = (IStructuredSelection) fTree |
|
|
449 |
.getSelection(); |
387 |
Object object = selection.getFirstElement(); |
450 |
Object object = selection.getFirstElement(); |
388 |
// Has to be null or a CtxHelpObject object |
451 |
// Has to be null or a CtxHelpObject object |
389 |
CtxHelpObject firstSelectedObject = (CtxHelpObject) object; |
452 |
CtxHelpObject firstSelectedObject = (CtxHelpObject) object; |
390 |
|
453 |
|
391 |
// Populate the "New" sub-menu |
454 |
// Populate the "New" sub-menu |
392 |
if (firstSelectedObject != null) { |
455 |
if (firstSelectedObject != null) { |
393 |
MenuManager submenu = new MenuManager(CtxHelpMessages.CtxHelpTreeSection_16); |
456 |
MenuManager submenu = new MenuManager( |
|
|
457 |
CtxHelpMessages.CtxHelpTreeSection_16); |
394 |
boolean addMenu = false; |
458 |
boolean addMenu = false; |
395 |
if (updateAddContextActionWithSelection(firstSelectedObject)) { |
459 |
if (updateAddContextActionWithSelection(firstSelectedObject)) { |
396 |
submenu.add(fAddContextAction); |
460 |
submenu.add(fAddContextAction); |
Lines 411-417
Link Here
|
411 |
} |
475 |
} |
412 |
|
476 |
|
413 |
// Add the open link and show in actions |
477 |
// Add the open link and show in actions |
414 |
if (firstSelectedObject instanceof CtxHelpTopic && ((CtxHelpTopic) firstSelectedObject).getLocation() != null) { |
478 |
if (firstSelectedObject instanceof CtxHelpTopic |
|
|
479 |
&& ((CtxHelpTopic) firstSelectedObject).getLocation() != null) { |
415 |
fOpenLinkAction.setTarget((CtxHelpTopic) firstSelectedObject); |
480 |
fOpenLinkAction.setTarget((CtxHelpTopic) firstSelectedObject); |
416 |
manager.add(fOpenLinkAction); |
481 |
manager.add(fOpenLinkAction); |
417 |
fillContextMenuShowInAction(manager); |
482 |
fillContextMenuShowInAction(manager); |
Lines 419-425
Link Here
|
419 |
} |
484 |
} |
420 |
|
485 |
|
421 |
// Add clipboard actions |
486 |
// Add clipboard actions |
422 |
getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager); |
487 |
getPage().getPDEEditor().getContributor().contextMenuAboutToShow( |
|
|
488 |
manager); |
423 |
manager.add(new Separator()); |
489 |
manager.add(new Separator()); |
424 |
|
490 |
|
425 |
// Add remove action |
491 |
// Add remove action |
Lines 433-477
Link Here
|
433 |
/** |
499 |
/** |
434 |
* Creates and a new submenu in the given menu manager and adds actions to |
500 |
* Creates and a new submenu in the given menu manager and adds actions to |
435 |
* allow a linked file to be opened in various views. |
501 |
* allow a linked file to be opened in various views. |
436 |
* @param manager menu manager to add the submenu to |
502 |
* |
|
|
503 |
* @param manager |
504 |
* menu manager to add the submenu to |
437 |
*/ |
505 |
*/ |
438 |
private void fillContextMenuShowInAction(IMenuManager manager) { |
506 |
private void fillContextMenuShowInAction(IMenuManager manager) { |
439 |
String showInLabel = CtxHelpMessages.CtxHelpTreeSection_17; |
507 |
String showInLabel = CtxHelpMessages.CtxHelpTreeSection_17; |
440 |
|
508 |
|
441 |
// Add a label for the keybinding for Show In action, if one exists |
509 |
// Add a label for the keybinding for Show In action, if one exists |
442 |
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); |
510 |
IBindingService bindingService = (IBindingService) PlatformUI |
|
|
511 |
.getWorkbench().getAdapter(IBindingService.class); |
443 |
if (bindingService != null) { |
512 |
if (bindingService != null) { |
444 |
String keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.ui.navigate.showInQuickMenu"); //$NON-NLS-1$ |
513 |
String keyBinding = bindingService |
|
|
514 |
.getBestActiveBindingFormattedFor("org.eclipse.ui.navigate.showInQuickMenu"); //$NON-NLS-1$ |
445 |
if (keyBinding != null) { |
515 |
if (keyBinding != null) { |
446 |
showInLabel += '\t' + keyBinding; |
516 |
showInLabel += '\t' + keyBinding; |
447 |
} |
517 |
} |
448 |
} |
518 |
} |
449 |
|
519 |
|
450 |
IMenuManager showInMenu = new MenuManager(showInLabel); |
520 |
IMenuManager showInMenu = new MenuManager(showInLabel); |
451 |
showInMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getPage().getSite().getWorkbenchWindow())); |
521 |
showInMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getPage() |
|
|
522 |
.getSite().getWorkbenchWindow())); |
452 |
|
523 |
|
453 |
manager.add(showInMenu); |
524 |
manager.add(showInMenu); |
454 |
} |
525 |
} |
455 |
|
526 |
|
456 |
/** |
527 |
/** |
457 |
* Updates the add context action if the action should be available for the selection. |
528 |
* Updates the add context action if the action should be available for the |
458 |
* Updates enablement, parent object and target object. Returns true if the action |
529 |
* selection. Updates enablement, parent object and target object. Returns |
459 |
* should be available to the selection. |
530 |
* true if the action should be available to the selection. |
460 |
* @param selectedObject selected object |
531 |
* |
461 |
* @return true if the action should be available for the current selection, false otherwise |
532 |
* @param selectedObject |
462 |
*/ |
533 |
* selected object |
463 |
private boolean updateAddContextActionWithSelection(CtxHelpObject selectedObject) { |
534 |
* @return true if the action should be available for the current selection, |
464 |
if (selectedObject != null && selectedObject.canAddSibling(ICtxHelpConstants.TYPE_CONTEXT)) { |
535 |
* false otherwise |
|
|
536 |
*/ |
537 |
private boolean updateAddContextActionWithSelection( |
538 |
CtxHelpObject selectedObject) { |
539 |
if (selectedObject != null |
540 |
&& selectedObject.canAddSibling(ICtxHelpConstants.TYPE_CONTEXT)) { |
465 |
fAddContextAction.setParentObject(selectedObject.getParent()); |
541 |
fAddContextAction.setParentObject(selectedObject.getParent()); |
466 |
fAddContextAction.setTargetObject(selectedObject); |
542 |
fAddContextAction.setTargetObject(selectedObject); |
467 |
fAddContextAction.setEnabled(fModel.isEditable()); |
543 |
fAddContextAction.setEnabled(fModel.isEditable()); |
468 |
return true; |
544 |
return true; |
469 |
} else if (selectedObject != null && selectedObject.canAddChild(ICtxHelpConstants.TYPE_CONTEXT)) { |
545 |
} else if (selectedObject != null |
|
|
546 |
&& selectedObject.canAddChild(ICtxHelpConstants.TYPE_CONTEXT)) { |
470 |
fAddContextAction.setParentObject(selectedObject); |
547 |
fAddContextAction.setParentObject(selectedObject); |
471 |
fAddContextAction.setTargetObject(null); |
548 |
fAddContextAction.setTargetObject(null); |
472 |
fAddContextAction.setEnabled(fModel.isEditable()); |
549 |
fAddContextAction.setEnabled(fModel.isEditable()); |
473 |
return true; |
550 |
return true; |
474 |
} else if (fModel.getCtxHelpRoot().canAddChild(ICtxHelpConstants.TYPE_CONTEXT)) { |
551 |
} else if (fModel.getCtxHelpRoot().canAddChild( |
|
|
552 |
ICtxHelpConstants.TYPE_CONTEXT)) { |
475 |
fAddContextAction.setParentObject(fModel.getCtxHelpRoot()); |
553 |
fAddContextAction.setParentObject(fModel.getCtxHelpRoot()); |
476 |
fAddContextAction.setTargetObject(null); |
554 |
fAddContextAction.setTargetObject(null); |
477 |
fAddContextAction.setEnabled(fModel.isEditable()); |
555 |
fAddContextAction.setEnabled(fModel.isEditable()); |
Lines 481-493
Link Here
|
481 |
} |
559 |
} |
482 |
|
560 |
|
483 |
/** |
561 |
/** |
484 |
* Updates the add topic action if the action should be available for the selection. |
562 |
* Updates the add topic action if the action should be available for the |
485 |
* Updates enablement, parent object and target object. Returns true if the action |
563 |
* selection. Updates enablement, parent object and target object. Returns |
486 |
* should be available to the selection. |
564 |
* true if the action should be available to the selection. |
487 |
* @param selectedObject selected object |
565 |
* |
488 |
* @return true if the action should be available for the current selection, false otherwise |
566 |
* @param selectedObject |
|
|
567 |
* selected object |
568 |
* @return true if the action should be available for the current selection, |
569 |
* false otherwise |
489 |
*/ |
570 |
*/ |
490 |
private boolean updateAddTopicActionWithSelection(CtxHelpObject selectedObject) { |
571 |
private boolean updateAddTopicActionWithSelection( |
|
|
572 |
CtxHelpObject selectedObject) { |
491 |
if (selectedObject != null) { |
573 |
if (selectedObject != null) { |
492 |
if (selectedObject.canAddSibling(ICtxHelpConstants.TYPE_TOPIC)) { |
574 |
if (selectedObject.canAddSibling(ICtxHelpConstants.TYPE_TOPIC)) { |
493 |
fAddTopicAction.setParentObject(selectedObject.getParent()); |
575 |
fAddTopicAction.setParentObject(selectedObject.getParent()); |
Lines 505-524
Link Here
|
505 |
} |
587 |
} |
506 |
|
588 |
|
507 |
/** |
589 |
/** |
508 |
* Updates the add topic action if the action should be available for the selection. |
590 |
* Updates the add topic action if the action should be available for the |
509 |
* Updates enablement, parent object and target object. Returns true if the action |
591 |
* selection. Updates enablement, parent object and target object. Returns |
510 |
* should be available to the selection. |
592 |
* true if the action should be available to the selection. |
511 |
* @param selectedObject selected object |
593 |
* |
512 |
* @return true if the action should be available for the current selection, false otherwise |
594 |
* @param selectedObject |
|
|
595 |
* selected object |
596 |
* @return true if the action should be available for the current selection, |
597 |
* false otherwise |
513 |
*/ |
598 |
*/ |
514 |
private boolean updateAddCommandActionWithSelection(CtxHelpObject selectedObject) { |
599 |
private boolean updateAddCommandActionWithSelection( |
|
|
600 |
CtxHelpObject selectedObject) { |
515 |
if (selectedObject != null) { |
601 |
if (selectedObject != null) { |
516 |
if (selectedObject.canAddSibling(ICtxHelpConstants.TYPE_COMMAND)) { |
602 |
if (selectedObject.canAddSibling(ICtxHelpConstants.TYPE_COMMAND)) { |
517 |
fAddCommandAction.setParentObject(selectedObject.getParent()); |
603 |
fAddCommandAction.setParentObject(selectedObject.getParent()); |
518 |
fAddCommandAction.setTargetObject(selectedObject); |
604 |
fAddCommandAction.setTargetObject(selectedObject); |
519 |
fAddCommandAction.setEnabled(fModel.isEditable()); |
605 |
fAddCommandAction.setEnabled(fModel.isEditable()); |
520 |
return true; |
606 |
return true; |
521 |
} else if (selectedObject.canAddChild(ICtxHelpConstants.TYPE_COMMAND)) { |
607 |
} else if (selectedObject |
|
|
608 |
.canAddChild(ICtxHelpConstants.TYPE_COMMAND)) { |
522 |
fAddCommandAction.setParentObject(selectedObject); |
609 |
fAddCommandAction.setParentObject(selectedObject); |
523 |
fAddCommandAction.setTargetObject(null); |
610 |
fAddCommandAction.setTargetObject(null); |
524 |
fAddCommandAction.setEnabled(fModel.isEditable()); |
611 |
fAddCommandAction.setEnabled(fModel.isEditable()); |
Lines 529-572
Link Here
|
529 |
} |
616 |
} |
530 |
|
617 |
|
531 |
/** |
618 |
/** |
532 |
* Updates the remove action if the action should be available for the selection. |
619 |
* Updates the remove action if the action should be available for the |
533 |
* Updates enablement, parent object and target object. Returns true if the action |
620 |
* selection. Updates enablement, parent object and target object. Returns |
534 |
* should be available to the selection. |
621 |
* true if the action should be available to the selection. |
535 |
* @param selectedObject selected object |
622 |
* |
536 |
* @return true if the action should be available for the current selection, false otherwise |
623 |
* @param selectedObject |
|
|
624 |
* selected object |
625 |
* @return true if the action should be available for the current selection, |
626 |
* false otherwise |
537 |
*/ |
627 |
*/ |
538 |
private boolean updateRemoveActionWithSelection(IStructuredSelection selection) { |
628 |
private boolean updateRemoveActionWithSelection( |
|
|
629 |
IStructuredSelection selection) { |
539 |
List objectsToRemove = getRemovableObjectFromSelection(selection); |
630 |
List objectsToRemove = getRemovableObjectFromSelection(selection); |
540 |
fRemoveObjectAction.setToRemove((CtxHelpObject[]) objectsToRemove.toArray(new CtxHelpObject[objectsToRemove.size()])); |
631 |
fRemoveObjectAction.setToRemove((CtxHelpObject[]) objectsToRemove |
|
|
632 |
.toArray(new CtxHelpObject[objectsToRemove.size()])); |
541 |
fRemoveObjectAction.setEnabled(fModel.isEditable()); |
633 |
fRemoveObjectAction.setEnabled(fModel.isEditable()); |
542 |
return objectsToRemove.size() > 0; |
634 |
return objectsToRemove.size() > 0; |
543 |
} |
635 |
} |
544 |
|
636 |
|
545 |
/** |
637 |
/** |
546 |
* Returns a list of objects that is the subset of objects in the selection that |
638 |
* Returns a list of objects that is the subset of objects in the selection |
547 |
* can be removed. |
639 |
* that can be removed. |
548 |
* @param selection the selection |
640 |
* |
549 |
* @return list of {@link CtxHelpObject}s that can be removed, possibly empty. |
641 |
* @param selection |
|
|
642 |
* the selection |
643 |
* @return list of {@link CtxHelpObject}s that can be removed, possibly |
644 |
* empty. |
550 |
*/ |
645 |
*/ |
551 |
private List getRemovableObjectFromSelection(IStructuredSelection selection) { |
646 |
private List getRemovableObjectFromSelection(IStructuredSelection selection) { |
552 |
List objectsToRemove = new ArrayList(); |
647 |
List objectsToRemove = new ArrayList(); |
553 |
for (Iterator iterator = selection.iterator(); iterator.hasNext();) { |
648 |
for (Iterator iterator = selection.iterator(); iterator.hasNext();) { |
554 |
Object currentObject = iterator.next(); |
649 |
Object currentObject = iterator.next(); |
555 |
if (currentObject instanceof CtxHelpObject && ((CtxHelpObject) currentObject).canBeRemoved()) { |
650 |
if (currentObject instanceof CtxHelpObject |
|
|
651 |
&& ((CtxHelpObject) currentObject).canBeRemoved()) { |
556 |
objectsToRemove.add(currentObject); |
652 |
objectsToRemove.add(currentObject); |
557 |
} |
653 |
} |
558 |
} |
654 |
} |
559 |
return objectsToRemove; |
655 |
return objectsToRemove; |
560 |
} |
656 |
} |
561 |
|
657 |
|
562 |
/* (non-Javadoc) |
658 |
/* |
563 |
* @see org.eclipse.pde.internal.ui.editor.PDESection#doGlobalAction(java.lang.String) |
659 |
* (non-Javadoc) |
|
|
660 |
* |
661 |
* @see |
662 |
* org.eclipse.pde.internal.ui.editor.PDESection#doGlobalAction(java.lang |
663 |
* .String) |
564 |
*/ |
664 |
*/ |
565 |
public boolean doGlobalAction(String actionId) { |
665 |
public boolean doGlobalAction(String actionId) { |
566 |
boolean cutAction = actionId.equals(ActionFactory.CUT.getId()); |
666 |
boolean cutAction = actionId.equals(ActionFactory.CUT.getId()); |
567 |
|
667 |
|
568 |
if (cutAction || actionId.equals(ActionFactory.DELETE.getId())) { |
668 |
if (cutAction || actionId.equals(ActionFactory.DELETE.getId())) { |
569 |
updateRemoveActionWithSelection((IStructuredSelection) fTree.getSelection()); |
669 |
updateRemoveActionWithSelection((IStructuredSelection) fTree |
|
|
670 |
.getSelection()); |
570 |
fRemoveObjectAction.run(); |
671 |
fRemoveObjectAction.run(); |
571 |
return !cutAction; |
672 |
return !cutAction; |
572 |
} |
673 |
} |
Lines 579-600
Link Here
|
579 |
return false; |
680 |
return false; |
580 |
} |
681 |
} |
581 |
|
682 |
|
582 |
/* (non-Javadoc) |
683 |
/* |
583 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canPaste(java.lang.Object, java.lang.Object[]) |
684 |
* (non-Javadoc) |
|
|
685 |
* |
686 |
* @see |
687 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canPaste(java |
688 |
* .lang.Object, java.lang.Object[]) |
584 |
*/ |
689 |
*/ |
585 |
protected boolean canPaste(Object targetObject, Object[] sourceObjects) { |
690 |
protected boolean canPaste(Object targetObject, Object[] sourceObjects) { |
586 |
return canDropCopy(targetObject, sourceObjects, ViewerDropAdapter.LOCATION_ON); |
691 |
return canDropCopy(targetObject, sourceObjects, |
|
|
692 |
ViewerDropAdapter.LOCATION_ON); |
587 |
} |
693 |
} |
588 |
|
694 |
|
589 |
/* (non-Javadoc) |
695 |
/* |
590 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doPaste(java.lang.Object, java.lang.Object[]) |
696 |
* (non-Javadoc) |
|
|
697 |
* |
698 |
* @see |
699 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doPaste(java |
700 |
* .lang.Object, java.lang.Object[]) |
591 |
*/ |
701 |
*/ |
592 |
protected void doPaste(Object targetObject, Object[] sourceObjects) { |
702 |
protected void doPaste(Object targetObject, Object[] sourceObjects) { |
593 |
doDropCopy(targetObject, sourceObjects, ViewerDropAdapter.LOCATION_ON); |
703 |
doDropCopy(targetObject, sourceObjects, ViewerDropAdapter.LOCATION_ON); |
594 |
} |
704 |
} |
595 |
|
705 |
|
596 |
/* (non-Javadoc) |
706 |
/* |
597 |
* @see org.eclipse.pde.internal.ui.editor.TreeSection#handleDoubleClick(org.eclipse.jface.viewers.IStructuredSelection) |
707 |
* (non-Javadoc) |
|
|
708 |
* |
709 |
* @see |
710 |
* org.eclipse.pde.internal.ui.editor.TreeSection#handleDoubleClick(org. |
711 |
* eclipse.jface.viewers.IStructuredSelection) |
598 |
*/ |
712 |
*/ |
599 |
protected void handleDoubleClick(IStructuredSelection selection) { |
713 |
protected void handleDoubleClick(IStructuredSelection selection) { |
600 |
Object selected = selection.getFirstElement(); |
714 |
Object selected = selection.getFirstElement(); |
Lines 607-674
Link Here
|
607 |
|
721 |
|
608 |
/** |
722 |
/** |
609 |
* Opens the file that is linked in the given topic. |
723 |
* Opens the file that is linked in the given topic. |
610 |
* @param topic the topic containing a link to a file |
724 |
* |
|
|
725 |
* @param topic |
726 |
* the topic containing a link to a file |
611 |
*/ |
727 |
*/ |
612 |
public void open(CtxHelpTopic topic) { |
728 |
public void open(CtxHelpTopic topic) { |
613 |
IPath resourcePath = topic.getLocation(); |
729 |
IPath resourcePath = topic.getLocation(); |
614 |
if (!isEditable() || resourcePath == null || resourcePath.isEmpty()) { |
730 |
if (!isEditable() || resourcePath == null || resourcePath.isEmpty()) { |
615 |
MessageDialog.openWarning(PDEUserAssistanceUIPlugin.getActiveWorkbenchShell(), CtxHelpMessages.CtxHelpTreeSection_18, CtxHelpMessages.CtxHelpTreeSection_19); |
731 |
MessageDialog.openWarning(PDEUserAssistanceUIPlugin |
|
|
732 |
.getActiveWorkbenchShell(), |
733 |
CtxHelpMessages.CtxHelpTreeSection_18, |
734 |
CtxHelpMessages.CtxHelpTreeSection_19); |
616 |
return; |
735 |
return; |
617 |
} |
736 |
} |
618 |
|
737 |
|
619 |
IResource resource = fModel.getUnderlyingResource().getProject().findMember(resourcePath); |
738 |
IResource resource = fModel.getUnderlyingResource().getProject() |
|
|
739 |
.findMember(resourcePath); |
620 |
if (resource != null && resource instanceof IFile) { |
740 |
if (resource != null && resource instanceof IFile) { |
621 |
IPath path = resource.getFullPath(); |
741 |
IPath path = resource.getFullPath(); |
622 |
if (HelpEditorUtil.hasValidPageExtension(path)) { |
742 |
if (HelpEditorUtil.hasValidPageExtension(path)) { |
623 |
try { |
743 |
try { |
624 |
IDE.openEditor(PDEUserAssistanceUIPlugin.getActivePage(), (IFile) resource, true); |
744 |
IDE.openEditor(PDEUserAssistanceUIPlugin.getActivePage(), |
625 |
} catch (PartInitException e) { //suppress exception |
745 |
(IFile) resource, true); |
|
|
746 |
} catch (PartInitException e) { // suppress exception |
626 |
} |
747 |
} |
627 |
} else { |
748 |
} else { |
628 |
MessageDialog.openWarning(PDEUserAssistanceUIPlugin.getActiveWorkbenchShell(), CtxHelpMessages.CtxHelpTreeSection_20, CtxHelpMessages.CtxHelpTreeSection_21); |
749 |
MessageDialog.openWarning(PDEUserAssistanceUIPlugin |
|
|
750 |
.getActiveWorkbenchShell(), |
751 |
CtxHelpMessages.CtxHelpTreeSection_20, |
752 |
CtxHelpMessages.CtxHelpTreeSection_21); |
629 |
} |
753 |
} |
630 |
} else { |
754 |
} else { |
631 |
MessageDialog.openWarning(PDEUserAssistanceUIPlugin.getActiveWorkbenchShell(), CtxHelpMessages.CtxHelpTreeSection_22, CtxHelpMessages.CtxHelpTreeSection_23); |
755 |
MessageDialog.openWarning(PDEUserAssistanceUIPlugin |
|
|
756 |
.getActiveWorkbenchShell(), |
757 |
CtxHelpMessages.CtxHelpTreeSection_22, |
758 |
CtxHelpMessages.CtxHelpTreeSection_23); |
632 |
} |
759 |
} |
633 |
} |
760 |
} |
634 |
|
761 |
|
635 |
/* (non-Javadoc) |
762 |
/* |
636 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#buttonSelected(int) |
763 |
* (non-Javadoc) |
|
|
764 |
* |
765 |
* @see |
766 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#buttonSelected |
767 |
* (int) |
637 |
*/ |
768 |
*/ |
638 |
protected void buttonSelected(int index) { |
769 |
protected void buttonSelected(int index) { |
639 |
IStructuredSelection selection = (IStructuredSelection) fTree.getSelection(); |
770 |
IStructuredSelection selection = (IStructuredSelection) fTree |
|
|
771 |
.getSelection(); |
640 |
Object object = selection.getFirstElement(); |
772 |
Object object = selection.getFirstElement(); |
641 |
CtxHelpObject firstSelectedObject = (CtxHelpObject) object; |
773 |
CtxHelpObject firstSelectedObject = (CtxHelpObject) object; |
642 |
switch (index) { |
774 |
switch (index) { |
643 |
case F_BUTTON_ADD_CONTEXT : |
775 |
case F_BUTTON_ADD_CONTEXT: |
644 |
updateAddContextActionWithSelection(firstSelectedObject); |
776 |
updateAddContextActionWithSelection(firstSelectedObject); |
645 |
fAddContextAction.run(); |
777 |
fAddContextAction.run(); |
646 |
break; |
778 |
break; |
647 |
case F_BUTTON_ADD_TOPIC : |
779 |
case F_BUTTON_ADD_TOPIC: |
648 |
updateAddTopicActionWithSelection(firstSelectedObject); |
780 |
updateAddTopicActionWithSelection(firstSelectedObject); |
649 |
fAddTopicAction.run(); |
781 |
fAddTopicAction.run(); |
650 |
break; |
782 |
break; |
651 |
case F_BUTTON_ADD_COMMAND : |
783 |
case F_BUTTON_ADD_COMMAND: |
652 |
updateAddCommandActionWithSelection(firstSelectedObject); |
784 |
updateAddCommandActionWithSelection(firstSelectedObject); |
653 |
fAddCommandAction.run(); |
785 |
fAddCommandAction.run(); |
654 |
break; |
786 |
break; |
655 |
case F_BUTTON_REMOVE : |
787 |
case F_BUTTON_REMOVE: |
656 |
updateRemoveActionWithSelection(selection); |
788 |
updateRemoveActionWithSelection(selection); |
657 |
fRemoveObjectAction.run(); |
789 |
fRemoveObjectAction.run(); |
658 |
break; |
790 |
break; |
659 |
case F_BUTTON_UP : |
791 |
case F_BUTTON_UP: |
660 |
handleMoveAction(F_UP_FLAG); |
792 |
handleMoveAction(F_UP_FLAG); |
661 |
break; |
793 |
break; |
662 |
case F_BUTTON_DOWN : |
794 |
case F_BUTTON_DOWN: |
663 |
handleMoveAction(F_DOWN_FLAG); |
795 |
handleMoveAction(F_DOWN_FLAG); |
664 |
break; |
796 |
break; |
|
|
797 |
case F_BUTTON_BROKENLINK: |
798 |
handleLinkButton(); |
799 |
} |
800 |
} |
801 |
|
802 |
private void handleLinkButton() { |
803 |
ListDialog dialog = new ListDialog(PDEUserAssistanceUIPlugin |
804 |
.getActiveWorkbenchShell()); |
805 |
dialog.setContentProvider(new IStructuredContentProvider() { |
806 |
|
807 |
public void inputChanged(Viewer viewer, Object oldInput, |
808 |
Object newInput) { |
809 |
} |
810 |
|
811 |
public void dispose() { |
812 |
|
813 |
} |
814 |
|
815 |
public Object[] getElements(Object inputElement) { |
816 |
return (Object[]) inputElement; |
817 |
} |
818 |
}); |
819 |
|
820 |
dialog.setLabelProvider(new LabelProvider() { |
821 |
public String getText(Object element) { |
822 |
CtxHelpTopic topic = (CtxHelpTopic) element; |
823 |
return topic.getName(); |
824 |
} |
825 |
}); |
826 |
|
827 |
ArrayList links = new ArrayList(); |
828 |
CtxHelpRoot root = fModel.getCtxHelpRoot(); |
829 |
IDocumentElementNode[] contexts = root.getChildNodes(); |
830 |
for (int i = 0; i < contexts.length; i++) { |
831 |
IDocumentElementNode context = contexts[i]; |
832 |
IDocumentElementNode[] topics = context.getChildNodes(); |
833 |
for (int j = 0; j < topics.length; j++) { |
834 |
IDocumentElementNode node = topics[j]; |
835 |
if (node instanceof CtxHelpTopic) { |
836 |
CtxHelpTopic topic = (CtxHelpTopic) node; |
837 |
IPath location = topic.getLocation(); |
838 |
if (!isEditable() || location == null || location.isEmpty()) { |
839 |
links.add(topic); |
840 |
} else { |
841 |
String path = location.toOSString(); |
842 |
if (path.indexOf("#") > -1) { |
843 |
path = path.substring(0, path.indexOf("#")); |
844 |
location = Path.fromOSString(path); |
845 |
} |
846 |
IResource resource = fModel.getUnderlyingResource() |
847 |
.getProject().findMember(location); |
848 |
if (resource == null || !(resource instanceof IFile)) { |
849 |
links.add(topic); |
850 |
} |
851 |
} |
852 |
} |
853 |
} |
854 |
} |
855 |
dialog.setInput(links.toArray(new CtxHelpTopic[links.size()])); |
856 |
dialog.setMessage(CtxHelpMessages.CtxHelpTreeSection_25); |
857 |
dialog.setTitle(CtxHelpMessages.CtxHelpTreeSection_25); |
858 |
dialog.create(); |
859 |
dialog.getOkButton().setText(CtxHelpMessages.CtxHelpTreeSection_26); |
860 |
if (Window.OK == dialog.open()) { |
861 |
CtxHelpTopic topic = (CtxHelpTopic) ((Object[]) dialog.getResult())[0]; |
862 |
fTree.setSelection(new StructuredSelection(topic), true); |
665 |
} |
863 |
} |
666 |
} |
864 |
} |
667 |
|
865 |
|
668 |
/** |
866 |
/** |
669 |
* Move an object within the structure. |
867 |
* Move an object within the structure. |
670 |
* |
868 |
* |
671 |
* @param positionFlag The direction that the object will move, either F_UP_FLAG or F_DOWN_FLAG |
869 |
* @param positionFlag |
|
|
870 |
* The direction that the object will move, either F_UP_FLAG or |
871 |
* F_DOWN_FLAG |
672 |
*/ |
872 |
*/ |
673 |
private void handleMoveAction(int positionFlag) { |
873 |
private void handleMoveAction(int positionFlag) { |
674 |
IStructuredSelection sel = (IStructuredSelection) fTree.getSelection(); |
874 |
IStructuredSelection sel = (IStructuredSelection) fTree.getSelection(); |
Lines 681-747
Link Here
|
681 |
CtxHelpObject parent = ctxHelpObject.getParent(); |
881 |
CtxHelpObject parent = ctxHelpObject.getParent(); |
682 |
if (parent != null) { |
882 |
if (parent != null) { |
683 |
parent.moveChild(ctxHelpObject, positionFlag); |
883 |
parent.moveChild(ctxHelpObject, positionFlag); |
684 |
fTree.setSelection(new StructuredSelection(ctxHelpObject), true); |
884 |
fTree |
|
|
885 |
.setSelection(new StructuredSelection(ctxHelpObject), |
886 |
true); |
685 |
} |
887 |
} |
686 |
} |
888 |
} |
687 |
|
889 |
|
688 |
} |
890 |
} |
689 |
|
891 |
|
690 |
/* (non-Javadoc) |
892 |
/* |
|
|
893 |
* (non-Javadoc) |
894 |
* |
691 |
* @see org.eclipse.ui.forms.AbstractFormPart#refresh() |
895 |
* @see org.eclipse.ui.forms.AbstractFormPart#refresh() |
692 |
*/ |
896 |
*/ |
693 |
public void refresh() { |
897 |
public void refresh() { |
694 |
CtxHelpModel model = (CtxHelpModel) getPage().getModel(); |
898 |
CtxHelpModel model = (CtxHelpModel) getPage().getModel(); |
695 |
fTree.setInput(model); |
899 |
fTree.setInput(model); |
696 |
fTree.expandToLevel(2); |
900 |
fTree.expandToLevel(2); |
697 |
fTree.setSelection(new StructuredSelection(model.getCtxHelpRoot()), true); |
901 |
fTree.setSelection(new StructuredSelection(model.getCtxHelpRoot()), |
|
|
902 |
true); |
698 |
getManagedForm().fireSelectionChanged(this, fTree.getSelection()); |
903 |
getManagedForm().fireSelectionChanged(this, fTree.getSelection()); |
699 |
super.refresh(); |
904 |
super.refresh(); |
700 |
} |
905 |
} |
701 |
|
906 |
|
702 |
/* (non-Javadoc) |
907 |
/* |
|
|
908 |
* (non-Javadoc) |
909 |
* |
703 |
* @see org.eclipse.ui.forms.AbstractFormPart#dispose() |
910 |
* @see org.eclipse.ui.forms.AbstractFormPart#dispose() |
704 |
*/ |
911 |
*/ |
705 |
public void dispose() { |
912 |
public void dispose() { |
706 |
PDEUserAssistanceUIPlugin.getDefault().getLabelProvider().disconnect(this); |
913 |
PDEUserAssistanceUIPlugin.getDefault().getLabelProvider().disconnect( |
|
|
914 |
this); |
707 |
super.dispose(); |
915 |
super.dispose(); |
708 |
} |
916 |
} |
709 |
|
917 |
|
710 |
/* (non-Javadoc) |
918 |
/* |
711 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#isDragAndDropEnabled() |
919 |
* (non-Javadoc) |
|
|
920 |
* |
921 |
* @seeorg.eclipse.pde.internal.ui.editor.StructuredViewerSection# |
922 |
* isDragAndDropEnabled() |
712 |
*/ |
923 |
*/ |
713 |
protected boolean isDragAndDropEnabled() { |
924 |
protected boolean isDragAndDropEnabled() { |
714 |
return true; |
925 |
return true; |
715 |
} |
926 |
} |
716 |
|
927 |
|
717 |
/* (non-Javadoc) |
928 |
/* |
718 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#getSupportedDNDOperations() |
929 |
* (non-Javadoc) |
|
|
930 |
* |
931 |
* @seeorg.eclipse.pde.internal.ui.editor.StructuredViewerSection# |
932 |
* getSupportedDNDOperations() |
719 |
*/ |
933 |
*/ |
720 |
public int getSupportedDNDOperations() { |
934 |
public int getSupportedDNDOperations() { |
721 |
return DND.DROP_MOVE | DND.DROP_COPY; |
935 |
return DND.DROP_MOVE | DND.DROP_COPY; |
722 |
} |
936 |
} |
723 |
|
937 |
|
724 |
/* (non-Javadoc) |
938 |
/* |
725 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDropCopy(java.lang.Object, java.lang.Object[], int) |
939 |
* (non-Javadoc) |
|
|
940 |
* |
941 |
* @see |
942 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDropCopy |
943 |
* (java.lang.Object, java.lang.Object[], int) |
726 |
*/ |
944 |
*/ |
727 |
public void doDropCopy(Object targetObject, Object[] sourceObjects, int targetLocation) { |
945 |
public void doDropCopy(Object targetObject, Object[] sourceObjects, |
|
|
946 |
int targetLocation) { |
728 |
if (fDropTargetParent != null) { |
947 |
if (fDropTargetParent != null) { |
729 |
if (fDropTargetSibling != null) { |
948 |
if (fDropTargetSibling != null) { |
730 |
if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) { |
949 |
if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) { |
731 |
for (int i = 0; i < sourceObjects.length; i++) { |
950 |
for (int i = 0; i < sourceObjects.length; i++) { |
732 |
((CtxHelpObject) sourceObjects[i]).reconnect(fDropTargetParent, fModel); |
951 |
((CtxHelpObject) sourceObjects[i]).reconnect( |
733 |
fDropTargetParent.addChild((CtxHelpObject) sourceObjects[i], fDropTargetSibling, true); |
952 |
fDropTargetParent, fModel); |
|
|
953 |
fDropTargetParent.addChild( |
954 |
(CtxHelpObject) sourceObjects[i], |
955 |
fDropTargetSibling, true); |
734 |
} |
956 |
} |
735 |
} else { |
957 |
} else { |
736 |
for (int i = sourceObjects.length - 1; i >= 0; i--) { |
958 |
for (int i = sourceObjects.length - 1; i >= 0; i--) { |
737 |
((CtxHelpObject) sourceObjects[i]).reconnect(fDropTargetParent, fModel); |
959 |
((CtxHelpObject) sourceObjects[i]).reconnect( |
738 |
fDropTargetParent.addChild((CtxHelpObject) sourceObjects[i], fDropTargetSibling, false); |
960 |
fDropTargetParent, fModel); |
|
|
961 |
fDropTargetParent.addChild( |
962 |
(CtxHelpObject) sourceObjects[i], |
963 |
fDropTargetSibling, false); |
739 |
} |
964 |
} |
740 |
} |
965 |
} |
741 |
} else { |
966 |
} else { |
742 |
for (int i = 0; i < sourceObjects.length; i++) { |
967 |
for (int i = 0; i < sourceObjects.length; i++) { |
743 |
((CtxHelpObject) sourceObjects[i]).reconnect(fDropTargetParent, fModel); |
968 |
((CtxHelpObject) sourceObjects[i]).reconnect( |
744 |
fDropTargetParent.addChild((CtxHelpObject) sourceObjects[i]); |
969 |
fDropTargetParent, fModel); |
|
|
970 |
fDropTargetParent |
971 |
.addChild((CtxHelpObject) sourceObjects[i]); |
745 |
} |
972 |
} |
746 |
} |
973 |
} |
747 |
} |
974 |
} |
Lines 749-769
Link Here
|
749 |
fDropTargetSibling = null; |
976 |
fDropTargetSibling = null; |
750 |
} |
977 |
} |
751 |
|
978 |
|
752 |
/* (non-Javadoc) |
979 |
/* |
753 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDropMove(java.lang.Object, java.lang.Object[], int) |
980 |
* (non-Javadoc) |
|
|
981 |
* |
982 |
* @see |
983 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDropMove |
984 |
* (java.lang.Object, java.lang.Object[], int) |
754 |
*/ |
985 |
*/ |
755 |
public void doDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) { |
986 |
public void doDropMove(Object targetObject, Object[] sourceObjects, |
|
|
987 |
int targetLocation) { |
756 |
doDropCopy(targetObject, sourceObjects, targetLocation); |
988 |
doDropCopy(targetObject, sourceObjects, targetLocation); |
757 |
} |
989 |
} |
758 |
|
990 |
|
759 |
/* (non-Javadoc) |
991 |
/* |
760 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDropCopy(java.lang.Object, java.lang.Object[], int) |
992 |
* (non-Javadoc) |
|
|
993 |
* |
994 |
* @see |
995 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDropCopy |
996 |
* (java.lang.Object, java.lang.Object[], int) |
761 |
*/ |
997 |
*/ |
762 |
public boolean canDropCopy(Object targetObject, Object[] sourceObjects, int targetLocation) { |
998 |
public boolean canDropCopy(Object targetObject, Object[] sourceObjects, |
|
|
999 |
int targetLocation) { |
763 |
// Add as a child of the root |
1000 |
// Add as a child of the root |
764 |
if (targetObject == null || !(targetObject instanceof CtxHelpObject || ((CtxHelpObject) targetObject).getType() == ICtxHelpConstants.TYPE_ROOT)) { |
1001 |
if (targetObject == null |
|
|
1002 |
|| !(targetObject instanceof CtxHelpObject || ((CtxHelpObject) targetObject) |
1003 |
.getType() == ICtxHelpConstants.TYPE_ROOT)) { |
765 |
for (int i = 0; i < sourceObjects.length; i++) { |
1004 |
for (int i = 0; i < sourceObjects.length; i++) { |
766 |
if (!(sourceObjects[i] instanceof CtxHelpObject) || !fModel.getCtxHelpRoot().canAddChild(((CtxHelpObject) sourceObjects[i]).getType())) { |
1005 |
if (!(sourceObjects[i] instanceof CtxHelpObject) |
|
|
1006 |
|| !fModel.getCtxHelpRoot().canAddChild( |
1007 |
((CtxHelpObject) sourceObjects[i]).getType())) { |
767 |
return false; |
1008 |
return false; |
768 |
} |
1009 |
} |
769 |
} |
1010 |
} |
Lines 778-784
Link Here
|
778 |
if (targetLocation == ViewerDropAdapter.LOCATION_ON) { |
1019 |
if (targetLocation == ViewerDropAdapter.LOCATION_ON) { |
779 |
boolean result = true; |
1020 |
boolean result = true; |
780 |
for (int i = 0; i < sourceObjects.length; i++) { |
1021 |
for (int i = 0; i < sourceObjects.length; i++) { |
781 |
if (!(sourceObjects[i] instanceof CtxHelpObject) || !dropTarget.canAddChild(((CtxHelpObject) sourceObjects[i]).getType())) { |
1022 |
if (!(sourceObjects[i] instanceof CtxHelpObject) |
|
|
1023 |
|| !dropTarget |
1024 |
.canAddChild(((CtxHelpObject) sourceObjects[i]) |
1025 |
.getType())) { |
782 |
result = false; |
1026 |
result = false; |
783 |
break; |
1027 |
break; |
784 |
} |
1028 |
} |
Lines 793-799
Link Here
|
793 |
|
1037 |
|
794 |
// Add as a sibling of the target |
1038 |
// Add as a sibling of the target |
795 |
for (int i = 0; i < sourceObjects.length; i++) { |
1039 |
for (int i = 0; i < sourceObjects.length; i++) { |
796 |
if (!(sourceObjects[i] instanceof CtxHelpObject) || !dropTarget.canAddSibling(((CtxHelpObject) sourceObjects[i]).getType())) { |
1040 |
if (!(sourceObjects[i] instanceof CtxHelpObject) |
|
|
1041 |
|| !dropTarget |
1042 |
.canAddSibling(((CtxHelpObject) sourceObjects[i]) |
1043 |
.getType())) { |
797 |
return false; |
1044 |
return false; |
798 |
} |
1045 |
} |
799 |
} |
1046 |
} |
Lines 802-829
Link Here
|
802 |
return true; |
1049 |
return true; |
803 |
} |
1050 |
} |
804 |
|
1051 |
|
805 |
/* (non-Javadoc) |
1052 |
/* |
806 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDropMove(java.lang.Object, java.lang.Object[], int) |
1053 |
* (non-Javadoc) |
|
|
1054 |
* |
1055 |
* @see |
1056 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDropMove |
1057 |
* (java.lang.Object, java.lang.Object[], int) |
807 |
*/ |
1058 |
*/ |
808 |
public boolean canDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) { |
1059 |
public boolean canDropMove(Object targetObject, Object[] sourceObjects, |
|
|
1060 |
int targetLocation) { |
809 |
// Same as drop copy operation |
1061 |
// Same as drop copy operation |
810 |
return canDropCopy(targetObject, sourceObjects, targetLocation); |
1062 |
return canDropCopy(targetObject, sourceObjects, targetLocation); |
811 |
} |
1063 |
} |
812 |
|
1064 |
|
813 |
/* (non-Javadoc) |
1065 |
/* |
814 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDragCopy(java.lang.Object[]) |
1066 |
* (non-Javadoc) |
|
|
1067 |
* |
1068 |
* @see |
1069 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDragCopy |
1070 |
* (java.lang.Object[]) |
815 |
*/ |
1071 |
*/ |
816 |
public boolean canDragCopy(Object[] sourceObjects) { |
1072 |
public boolean canDragCopy(Object[] sourceObjects) { |
817 |
// Allow anything to be drag copied |
1073 |
// Allow anything to be drag copied |
818 |
return true; |
1074 |
return true; |
819 |
} |
1075 |
} |
820 |
|
1076 |
|
821 |
/* (non-Javadoc) |
1077 |
/* |
822 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDragMove(java.lang.Object[]) |
1078 |
* (non-Javadoc) |
|
|
1079 |
* |
1080 |
* @see |
1081 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#canDragMove |
1082 |
* (java.lang.Object[]) |
823 |
*/ |
1083 |
*/ |
824 |
public boolean canDragMove(Object[] sourceObjects) { |
1084 |
public boolean canDragMove(Object[] sourceObjects) { |
825 |
for (int i = 0; i < sourceObjects.length; i++) { |
1085 |
for (int i = 0; i < sourceObjects.length; i++) { |
826 |
if (!(sourceObjects[i] instanceof CtxHelpObject) || !((CtxHelpObject) sourceObjects[i]).canBeRemoved()) { |
1086 |
if (!(sourceObjects[i] instanceof CtxHelpObject) |
|
|
1087 |
|| !((CtxHelpObject) sourceObjects[i]).canBeRemoved()) { |
827 |
return false; |
1088 |
return false; |
828 |
} |
1089 |
} |
829 |
} |
1090 |
} |
Lines 831-838
Link Here
|
831 |
return true; |
1092 |
return true; |
832 |
} |
1093 |
} |
833 |
|
1094 |
|
834 |
/* (non-Javadoc) |
1095 |
/* |
835 |
* @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDragRemove(java.lang.Object[]) |
1096 |
* (non-Javadoc) |
|
|
1097 |
* |
1098 |
* @see |
1099 |
* org.eclipse.pde.internal.ui.editor.StructuredViewerSection#doDragRemove |
1100 |
* (java.lang.Object[]) |
836 |
*/ |
1101 |
*/ |
837 |
public void doDragRemove(Object[] sourceObjects) { |
1102 |
public void doDragRemove(Object[] sourceObjects) { |
838 |
updateRemoveActionWithSelection(new StructuredSelection(sourceObjects)); |
1103 |
updateRemoveActionWithSelection(new StructuredSelection(sourceObjects)); |
Lines 840-847
Link Here
|
840 |
fDragFromHere = false; |
1105 |
fDragFromHere = false; |
841 |
} |
1106 |
} |
842 |
|
1107 |
|
843 |
/* (non-Javadoc) |
1108 |
/* |
844 |
* @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) |
1109 |
* (non-Javadoc) |
|
|
1110 |
* |
1111 |
* @see |
1112 |
* org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse |
1113 |
* .pde.core.IModelChangedEvent) |
845 |
*/ |
1114 |
*/ |
846 |
public void modelChanged(IModelChangedEvent event) { |
1115 |
public void modelChanged(IModelChangedEvent event) { |
847 |
// No need to call super, world changed event handled here |
1116 |
// No need to call super, world changed event handled here |
Lines 851-857
Link Here
|
851 |
handleModelInsertType(event); |
1120 |
handleModelInsertType(event); |
852 |
} else if (event.getChangeType() == IModelChangedEvent.REMOVE) { |
1121 |
} else if (event.getChangeType() == IModelChangedEvent.REMOVE) { |
853 |
handleModelRemoveType(event); |
1122 |
handleModelRemoveType(event); |
854 |
} else if ((event.getChangeType() == IModelChangedEvent.CHANGE) && (event.getChangedProperty().equals(IDocumentElementNode.F_PROPERTY_CHANGE_TYPE_SWAP))) { |
1123 |
} else if ((event.getChangeType() == IModelChangedEvent.CHANGE) |
|
|
1124 |
&& (event.getChangedProperty() |
1125 |
.equals(IDocumentElementNode.F_PROPERTY_CHANGE_TYPE_SWAP))) { |
855 |
handleModelChangeTypeSwap(event); |
1126 |
handleModelChangeTypeSwap(event); |
856 |
} else if (event.getChangeType() == IModelChangedEvent.CHANGE) { |
1127 |
} else if (event.getChangeType() == IModelChangedEvent.CHANGE) { |
857 |
handleModelChangeType(event); |
1128 |
handleModelChangeType(event); |
Lines 860-866
Link Here
|
860 |
|
1131 |
|
861 |
/** |
1132 |
/** |
862 |
* Handles the swap event |
1133 |
* Handles the swap event |
863 |
* @param event the swap event |
1134 |
* |
|
|
1135 |
* @param event |
1136 |
* the swap event |
864 |
*/ |
1137 |
*/ |
865 |
private void handleModelChangeTypeSwap(IModelChangedEvent event) { |
1138 |
private void handleModelChangeTypeSwap(IModelChangedEvent event) { |
866 |
Object[] objects = event.getChangedObjects(); |
1139 |
Object[] objects = event.getChangedObjects(); |
Lines 873-879
Link Here
|
873 |
|
1146 |
|
874 |
/** |
1147 |
/** |
875 |
* The model is stale, refresh the UI |
1148 |
* The model is stale, refresh the UI |
876 |
* @param event The world-change event |
1149 |
* |
|
|
1150 |
* @param event |
1151 |
* The world-change event |
877 |
*/ |
1152 |
*/ |
878 |
private void handleModelEventWorldChanged(IModelChangedEvent event) { |
1153 |
private void handleModelEventWorldChanged(IModelChangedEvent event) { |
879 |
markStale(); |
1154 |
markStale(); |
Lines 881-887
Link Here
|
881 |
|
1156 |
|
882 |
/** |
1157 |
/** |
883 |
* Handle insertions in the model |
1158 |
* Handle insertions in the model |
884 |
* @param event the insertion event |
1159 |
* |
|
|
1160 |
* @param event |
1161 |
* the insertion event |
885 |
*/ |
1162 |
*/ |
886 |
private void handleModelInsertType(IModelChangedEvent event) { |
1163 |
private void handleModelInsertType(IModelChangedEvent event) { |
887 |
Object[] objects = event.getChangedObjects(); |
1164 |
Object[] objects = event.getChangedObjects(); |
Lines 890-898
Link Here
|
890 |
CtxHelpObject object = (CtxHelpObject) objects[i]; |
1167 |
CtxHelpObject object = (CtxHelpObject) objects[i]; |
891 |
if (object.getType() != ICtxHelpConstants.TYPE_ROOT) { |
1168 |
if (object.getType() != ICtxHelpConstants.TYPE_ROOT) { |
892 |
fTree.refresh(object.getParent()); |
1169 |
fTree.refresh(object.getParent()); |
893 |
// Select the new object in the tree, unless it is a description node |
1170 |
// Select the new object in the tree, unless it is a |
|
|
1171 |
// description node |
894 |
if (!(object instanceof CtxHelpDescription)) { |
1172 |
if (!(object instanceof CtxHelpDescription)) { |
895 |
fTree.setSelection(new StructuredSelection(object), true); |
1173 |
fTree.setSelection(new StructuredSelection(object), |
|
|
1174 |
true); |
896 |
} |
1175 |
} |
897 |
} |
1176 |
} |
898 |
} |
1177 |
} |
Lines 901-907
Link Here
|
901 |
|
1180 |
|
902 |
/** |
1181 |
/** |
903 |
* Handle removals in the model |
1182 |
* Handle removals in the model |
904 |
* @param event the removal event |
1183 |
* |
|
|
1184 |
* @param event |
1185 |
* the removal event |
905 |
*/ |
1186 |
*/ |
906 |
private void handleModelRemoveType(IModelChangedEvent event) { |
1187 |
private void handleModelRemoveType(IModelChangedEvent event) { |
907 |
Object[] objects = event.getChangedObjects(); |
1188 |
Object[] objects = event.getChangedObjects(); |
Lines 909-919
Link Here
|
909 |
if (objects[i] instanceof CtxHelpObject) { |
1190 |
if (objects[i] instanceof CtxHelpObject) { |
910 |
CtxHelpObject object = (CtxHelpObject) objects[i]; |
1191 |
CtxHelpObject object = (CtxHelpObject) objects[i]; |
911 |
fTree.remove(object); |
1192 |
fTree.remove(object); |
912 |
CtxHelpObject nextSelection = fRemoveObjectAction.getNextSelection(); |
1193 |
CtxHelpObject nextSelection = fRemoveObjectAction |
|
|
1194 |
.getNextSelection(); |
913 |
if (nextSelection != null) { |
1195 |
if (nextSelection != null) { |
914 |
fTree.refresh(object.getParent()); |
1196 |
fTree.refresh(object.getParent()); |
915 |
if (!fDragFromHere) { |
1197 |
if (!fDragFromHere) { |
916 |
fTree.setSelection(new StructuredSelection(nextSelection), true); |
1198 |
fTree.setSelection(new StructuredSelection( |
|
|
1199 |
nextSelection), true); |
917 |
} |
1200 |
} |
918 |
fRemoveObjectAction.clearNextSelection(); |
1201 |
fRemoveObjectAction.clearNextSelection(); |
919 |
} |
1202 |
} |
Lines 923-929
Link Here
|
923 |
|
1206 |
|
924 |
/** |
1207 |
/** |
925 |
* Handle an update to an object's properties |
1208 |
* Handle an update to an object's properties |
926 |
* @param event the update event |
1209 |
* |
|
|
1210 |
* @param event |
1211 |
* the update event |
927 |
*/ |
1212 |
*/ |
928 |
private void handleModelChangeType(IModelChangedEvent event) { |
1213 |
private void handleModelChangeType(IModelChangedEvent event) { |
929 |
Object[] objects = event.getChangedObjects(); |
1214 |
Object[] objects = event.getChangedObjects(); |