1
/*******************************************************************************
2
* Copyright (c) 2006, 2010 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM Corporation - initial API and implementation
10
* Wind River Systems, Inc. - extended implementation
11
* Navid Mehregani (TI) - Bugzilla 310191 - Detail pane does not clear up when DSF-GDB session is terminated
12
*******************************************************************************/
13
package org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.numberformat.detail;
15
import java.util.ArrayList;
16
import java.util.HashMap;
17
import java.util.HashSet;
18
import java.util.Iterator;
19
import java.util.List;
22
import java.util.concurrent.Executor;
24
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
25
import org.eclipse.cdt.dsf.debug.internal.ui.IDsfDebugHelpContextIds;
26
import org.eclipse.cdt.dsf.debug.internal.ui.IInternalDsfDebugUIConstants;
27
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.detailsupport.DetailPaneMaxLengthAction;
28
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.detailsupport.DetailPaneWordWrapAction;
29
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.detailsupport.MessagesForDetailPane;
30
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.detailsupport.TextViewerAction;
31
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
32
import org.eclipse.cdt.dsf.debug.ui.viewmodel.IDebugVMConstants;
33
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueVMUtil;
34
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
35
import org.eclipse.cdt.dsf.ui.concurrent.SimpleDisplayExecutor;
36
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
37
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
38
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
39
import org.eclipse.cdt.dsf.ui.viewmodel.properties.IElementPropertiesProvider;
40
import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdate;
41
import org.eclipse.cdt.dsf.ui.viewmodel.properties.VMPropertiesUpdate;
42
import org.eclipse.core.runtime.IAdaptable;
43
import org.eclipse.core.runtime.IProgressMonitor;
44
import org.eclipse.core.runtime.IStatus;
45
import org.eclipse.core.runtime.Status;
46
import org.eclipse.core.runtime.jobs.Job;
47
import org.eclipse.debug.core.DebugPlugin;
48
import org.eclipse.debug.core.model.IDebugModelProvider;
49
import org.eclipse.debug.core.model.IValue;
50
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
51
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
52
import org.eclipse.debug.ui.IDebugModelPresentation;
53
import org.eclipse.debug.ui.IDebugUIConstants;
54
import org.eclipse.debug.ui.IDebugView;
55
import org.eclipse.debug.ui.IDetailPane2;
56
import org.eclipse.debug.ui.IValueDetailListener;
57
import org.eclipse.jface.action.IAction;
58
import org.eclipse.jface.action.IMenuListener;
59
import org.eclipse.jface.action.IMenuManager;
60
import org.eclipse.jface.action.MenuManager;
61
import org.eclipse.jface.action.Separator;
62
import org.eclipse.jface.resource.JFaceResources;
63
import org.eclipse.jface.text.BadLocationException;
64
import org.eclipse.jface.text.Document;
65
import org.eclipse.jface.text.DocumentEvent;
66
import org.eclipse.jface.text.IDocument;
67
import org.eclipse.jface.text.IDocumentListener;
68
import org.eclipse.jface.text.IFindReplaceTarget;
69
import org.eclipse.jface.text.ITextOperationTarget;
70
import org.eclipse.jface.text.ITextViewer;
71
import org.eclipse.jface.text.TextViewer;
72
import org.eclipse.jface.util.IPropertyChangeListener;
73
import org.eclipse.jface.util.PropertyChangeEvent;
74
import org.eclipse.jface.viewers.ISelectionChangedListener;
75
import org.eclipse.jface.viewers.ISelectionProvider;
76
import org.eclipse.jface.viewers.IStructuredSelection;
77
import org.eclipse.jface.viewers.ITreeSelection;
78
import org.eclipse.jface.viewers.SelectionChangedEvent;
79
import org.eclipse.jface.viewers.TreePath;
80
import org.eclipse.jface.viewers.Viewer;
81
import org.eclipse.swt.SWT;
82
import org.eclipse.swt.events.FocusAdapter;
83
import org.eclipse.swt.events.FocusEvent;
84
import org.eclipse.swt.layout.GridData;
85
import org.eclipse.swt.widgets.Composite;
86
import org.eclipse.swt.widgets.Control;
87
import org.eclipse.swt.widgets.Display;
88
import org.eclipse.swt.widgets.Menu;
89
import org.eclipse.ui.IViewSite;
90
import org.eclipse.ui.IWorkbenchActionConstants;
91
import org.eclipse.ui.IWorkbenchCommandConstants;
92
import org.eclipse.ui.IWorkbenchPart;
93
import org.eclipse.ui.IWorkbenchPartSite;
94
import org.eclipse.ui.PlatformUI;
95
import org.eclipse.ui.actions.ActionFactory;
96
import org.eclipse.ui.progress.WorkbenchJob;
97
import org.eclipse.ui.texteditor.IUpdate;
99
public class NumberFormatDetailPane implements IDetailPane2, IAdaptable, IPropertyChangeListener {
102
* The <code>IWorkbenchPartSite</code> that the details area (and the
103
* variables view) belongs to.
105
private IWorkbenchPartSite fWorkbenchPartSite;
108
* Map of actions. Keys are strings, values
109
* are <code>IAction</code>.
111
private Map<String, IAction> fActionMap = new HashMap<String, IAction>();
114
* Collection to track actions that should be updated when selection occurs.
116
private List<String> fSelectionActions = new ArrayList<String>();
119
* @see org.eclipse.debug.ui.IDetailPane#init(org.eclipse.ui.IWorkbenchPartSite)
121
public void init(IWorkbenchPartSite workbench) {
122
fWorkbenchPartSite = workbench;
127
* Adds an action to the Map storing actions. Removes it if action is null.
129
* @param actionID The ID of the action, used as the key in the Map
130
* @param action The action associated with the ID
132
protected void setAction(String actionID, IAction action) {
133
if (action == null) {
134
fActionMap.remove(actionID);
136
fActionMap.put(actionID, action);
141
* Adds the given action to the global action handler for the ViewSite.
142
* A call to <code>updateActionBars()</code> must be called after changes
143
* to propagate changes through the workbench.
145
* @param actionID The ID of the action
146
* @param action The action to be set globally
148
protected void setGlobalAction(String actionID, IAction action){
149
getViewSite().getActionBars().setGlobalActionHandler(actionID, action);
153
* Adds the given action to the list of actions that will be updated when
154
* <code>updateSelectionDependentActions()</code> is called. If the string
155
* is null it will not be added to the list.
157
* @param actionID The ID of the action which should be updated
159
protected void setSelectionDependantAction(String actionID){
160
if (actionID != null) fSelectionActions.add(actionID);
164
* Gets the action out of the map, casts it to an <code>IAction</code>
166
* @param actionID The ID of the action to find
167
* @return The action associated with the ID or null if none is found.
169
protected IAction getAction(String actionID) {
170
return fActionMap.get(actionID);
174
* Calls the update method of the action with the given action ID.
175
* The action must exist in the action map and must be an instance of
176
* </code>IUpdate</code>
178
* @param actionId The ID of the action to update
180
protected void updateAction(String actionId) {
181
IAction action= getAction(actionId);
182
if (action instanceof IUpdate) {
183
((IUpdate) action).update();
188
* Iterates through the list of selection dependent actions and
189
* updates them. Use <code>setSelectionDependentAction(String actionID)</code>
190
* to add an action to the list. The action must have been added to the known
191
* actions map by calling <code>setAction(String actionID, IAction action)</code>
192
* before it can be updated by this method.
194
protected void updateSelectionDependentActions() {
195
Iterator<String> iterator= fSelectionActions.iterator();
196
while (iterator.hasNext()) {
197
updateAction(iterator.next());
202
* Gets the view site for this view. May be null if this detail pane
203
* is not part of a view.
205
* @return The site for this view or <code>null</code>
207
protected IViewSite getViewSite(){
208
if (fWorkbenchPartSite == null){
211
return (IViewSite) fWorkbenchPartSite.getPart().getSite();
216
* Gets the workbench part site for this view. May be null if this detail pane
217
* is not part of a view.
219
* @return The workbench part site or <code>null</code>
221
protected IWorkbenchPartSite getWorkbenchPartSite() {
222
return fWorkbenchPartSite;
226
* Returns whether this detail pane is being displayed in a view with a workbench part site.
228
* @return whether this detail pane is being displayed in a view with a workbench part site.
230
protected boolean isInView(){
231
return fWorkbenchPartSite != null;
235
* These are the IDs for the actions in the context menu
237
protected static final String DETAIL_COPY_ACTION = ActionFactory.COPY.getId() + ".TextDetailPane"; //$NON-NLS-1$
238
protected static final String DETAIL_SELECT_ALL_ACTION = IDebugView.SELECT_ALL_ACTION + ".TextDetailPane"; //$NON-NLS-1$
239
protected static final String DETAIL_WORD_WRAP_ACTION = DsfUIPlugin.PLUGIN_ID + ".detail_pane_word_wrap"; //$NON-NLS-1$
240
protected static final String DETAIL_MAX_LENGTH_ACTION = "MaxLength"; //$NON-NLS-1$
243
* The ID, name and description of this pane are stored in constants so that the class
244
* does not have to be instantiated to access them.
246
public static final String ID = "NumberFormatPane"; //$NON-NLS-1$
249
* Useful shortened names for the internationalized strings.
251
public static String FORMAT_SEPARATOR = MessagesForNumberFormatDetailPane.NumberFormatDetailPane_format_separator__label;
252
public static String NAME = MessagesForNumberFormatDetailPane.NumberFormatDetailPane_Name_label;
253
public static String SPACES = MessagesForNumberFormatDetailPane.NumberFormatDetailPane_Spaces_label;
254
public static String CRLF = MessagesForNumberFormatDetailPane.NumberFormatDetailPane_CarriageReturn_label;
255
public static String DOTS = MessagesForNumberFormatDetailPane.NumberFormatDetailPane_DotDotDot_label;
258
* Job to compute the details for a selection
260
class DetailJob extends Job implements IValueDetailListener {
261
private IPresentationContext fPresentationContext;
262
private Object fViewerInput;
263
private ITreeSelection fElements;
264
private boolean fFirst = true;
265
private IProgressMonitor fMonitor;
267
public DetailJob(IPresentationContext context, Object viewerInput, ITreeSelection elements,
268
IDebugModelPresentation model)
270
super("compute variable details"); //$NON-NLS-1$
272
fPresentationContext = context;
273
fViewerInput = viewerInput;
274
fElements = elements;
277
public IProgressMonitor getDetailMonitor() {
282
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
285
protected IStatus run(final IProgressMonitor monitor) {
286
if ( fMonitor != null && ! fMonitor.isCanceled() ) {
287
fMonitor.setCanceled(true);
290
TreePath[] paths = fElements.getPaths();
291
for (int i = 0; i < paths.length; i++) {
292
if (monitor.isCanceled()) {
295
final TreePath path = paths[i];
296
Object element = paths[i].getLastSegment();
298
final IElementPropertiesProvider propertiesProvider =
299
(IElementPropertiesProvider)DebugPlugin.getAdapter(element, IElementPropertiesProvider.class);
302
if (fWorkbenchPartSite != null) {
303
display = fWorkbenchPartSite.getShell().getDisplay();
305
display = PlatformUI.getWorkbench().getDisplay();
307
final Executor executor = SimpleDisplayExecutor.getSimpleDisplayExecutor(display);
308
Set<String> properties = new HashSet<String>(1);
309
properties.add(IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS);
310
propertiesProvider.update(new IPropertiesUpdate[] { new VMPropertiesUpdate(
311
properties, path, fViewerInput, fPresentationContext,
312
new DataRequestMonitor<Map<String,Object>>(executor, null) {
314
protected void handleCompleted() {
316
// Bugzilla 310191: Detail pane does not clear up when DSF-GDB session is terminated
317
if (fMonitor.isCanceled())
320
Set<String> properties = new HashSet<String>(1);
321
properties.add(IElementPropertiesProvider.PROP_NAME);
322
final String[] formats = (String[])getData().get(
323
IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS);
324
if (formats != null) {
325
for (String format : formats) {
326
properties.add(FormattedValueVMUtil.getPropertyForFormatId(format, null));
330
propertiesProvider.update(new IPropertiesUpdate[] { new VMPropertiesUpdate(
331
properties, path, fViewerInput, fPresentationContext,
332
new DataRequestMonitor<Map<String,Object>>(executor, null) {
334
protected void handleSuccess() {
335
StringBuffer finalResult = new StringBuffer();
336
finalResult.append(NAME).append(getData().get(IElementPropertiesProvider.PROP_NAME)).append(CRLF);
338
if (formats != null) {
339
for (int i = 0; i < formats.length; i++) {
340
String formatId = formats[i];
341
finalResult.append(SPACES);
342
finalResult.append( FormattedValueVMUtil.getFormatLabel(formatId) );
343
finalResult.append(FORMAT_SEPARATOR);
344
finalResult.append( getData().get(FormattedValueVMUtil.getPropertyForFormatId(formatId, null)) );
345
if ( i < formats.length + 1 ) {
346
finalResult.append(CRLF);
350
detailComputed(null, finalResult.toString());
354
protected void handleErrorOrWarning() {
355
detailComputed(null, getStatus().getMessage());
365
return Status.OK_STATUS;
369
* @see org.eclipse.core.runtime.jobs.Job#canceling()
372
protected void canceling() {
374
synchronized (this) {
380
* @see org.eclipse.debug.ui.IValueDetailListener#detailComputed(org.eclipse.debug.core.model.IValue, java.lang.String)
382
public void detailComputed(IValue value, final String result) {
383
synchronized (this) {
385
if (!fMonitor.isCanceled()) {
386
WorkbenchJob append = new WorkbenchJob("append details") { //$NON-NLS-1$
388
public IStatus runInUIThread(IProgressMonitor monitor) {
389
if (!fMonitor.isCanceled()) {
390
String insert = result;
393
length = getDetailDocument().getLength();
396
insert = CRLF + result;
399
int max = DsfUIPlugin.getDefault().getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH);
400
if (max > 0 && insert.length() > max) {
401
insert = insert.substring(0, max) + DOTS;
404
getDetailDocument().set(insert);
407
getDetailDocument().replace(length, 0,insert);
409
} catch (BadLocationException e) {
413
return Status.OK_STATUS;
416
append.setSystem(true);
419
synchronized (this) {
426
* The model presentation used to produce the string details for a
429
private String fDebugModelIdentifier;
432
* The text viewer in which the computed string detail
433
* of selected variables will be displayed.
435
private TextViewer fTextViewer;
438
* The last selection displayed in the text viewer.
440
private IStructuredSelection fLastDisplayed = null;
443
* Variables used to create the detailed information for a selection
445
private IDocument fDetailDocument;
446
private DetailJob fDetailJob = null;
449
* @see org.eclipse.debug.ui.IDetailPane#createControl(org.eclipse.swt.widgets.Composite)
451
public Control createControl(Composite parent) {
453
createTextViewer(parent);
456
createViewSpecificComponents();
458
DsfUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
459
JFaceResources.getFontRegistry().addListener(this);
462
return fTextViewer.getControl();
466
* Creates the text viewer in the given parent composite
468
* @param parent Parent composite to create the text viewer in
470
private void createTextViewer(Composite parent) {
472
// Create & configure a TextViewer
473
fTextViewer = new TextViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL);
474
fTextViewer.setDocument(getDetailDocument());
475
fTextViewer.getTextWidget().setFont(JFaceResources.getFont(IDebugUIConstants.PREF_DETAIL_PANE_FONT));
476
fTextViewer.getTextWidget().setWordWrap(DsfUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDsfDebugUIConstants.PREF_DETAIL_PANE_WORD_WRAP));
477
fTextViewer.setEditable(false);
478
PlatformUI.getWorkbench().getHelpSystem().setHelp(fTextViewer.getTextWidget(), IDsfDebugHelpContextIds.DETAIL_PANE);
479
Control control = fTextViewer.getControl();
480
GridData gd = new GridData(GridData.FILL_BOTH);
481
control.setLayoutData(gd);
485
* Creates listeners and other components that should only be added to the
486
* text viewer when this detail pane is inside a view.
488
private void createViewSpecificComponents(){
490
// Add a document listener so actions get updated when the document changes
491
getDetailDocument().addDocumentListener(new IDocumentListener() {
492
public void documentAboutToBeChanged(DocumentEvent event) {}
493
public void documentChanged(DocumentEvent event) {
494
updateSelectionDependentActions();
498
// Add the selection listener so selection dependent actions get updated.
499
fTextViewer.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {
500
public void selectionChanged(SelectionChangedEvent event) {
501
updateSelectionDependentActions();
505
// Add a focus listener to update actions when details area gains focus
506
fTextViewer.getControl().addFocusListener(new FocusAdapter() {
508
public void focusGained(FocusEvent e) {
510
setGlobalAction(IDebugView.SELECT_ALL_ACTION, getAction(DETAIL_SELECT_ALL_ACTION));
511
setGlobalAction(IDebugView.COPY_ACTION, getAction(DETAIL_COPY_ACTION));
513
getViewSite().getActionBars().updateActionBars();
517
public void focusLost(FocusEvent e) {
519
setGlobalAction(IDebugView.SELECT_ALL_ACTION, null);
520
setGlobalAction(IDebugView.COPY_ACTION, null);
522
getViewSite().getActionBars().updateActionBars();
526
// Add a context menu to the detail area
527
createDetailContextMenu(fTextViewer.getTextWidget());
531
* Creates the actions to add to the context menu
533
private void createActions() {
535
TextViewerAction textAction= new TextViewerAction(fTextViewer, ITextOperationTarget.SELECT_ALL);
536
textAction.configureAction(MessagesForDetailPane.DetailPane_Select_All, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
537
textAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL);
538
PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, IDsfDebugHelpContextIds.DETAIL_PANE_SELECT_ALL_ACTION);
539
setAction(DETAIL_SELECT_ALL_ACTION, textAction);
541
textAction= new TextViewerAction(fTextViewer, ITextOperationTarget.COPY);
542
textAction.configureAction(MessagesForDetailPane.DetailPane_Copy, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
543
textAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
544
PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, IDsfDebugHelpContextIds.DETAIL_PANE_COPY_ACTION);
545
setAction(DETAIL_COPY_ACTION, textAction);
547
setSelectionDependantAction(DETAIL_COPY_ACTION);
549
updateSelectionDependentActions();
551
IAction action = new DetailPaneWordWrapAction(fTextViewer);
552
setAction(DETAIL_WORD_WRAP_ACTION, action);
554
action = new DetailPaneMaxLengthAction(fTextViewer.getControl().getShell());
555
setAction(DETAIL_MAX_LENGTH_ACTION,action);
559
* Create the context menu particular to the detail pane. Note that anyone
560
* wishing to contribute an action to this menu must use
561
* <code>IDebugUIConstants.VARIABLE_VIEW_DETAIL_ID</code> as the
562
* <code>targetID</code> in the extension XML.
564
protected void createDetailContextMenu(Control menuControl) {
565
MenuManager menuMgr= new MenuManager();
566
menuMgr.setRemoveAllWhenShown(true);
567
menuMgr.addMenuListener(new IMenuListener() {
568
public void menuAboutToShow(IMenuManager mgr) {
569
fillDetailContextMenu(mgr);
572
Menu menu= menuMgr.createContextMenu(menuControl);
573
menuControl.setMenu(menu);
575
getViewSite().registerContextMenu(IDebugUIConstants.VARIABLE_VIEW_DETAIL_ID, menuMgr, fTextViewer.getSelectionProvider());
579
* Adds items to the detail pane's context menu including any extension defined
582
* @param menu The menu to add the item to.
584
protected void fillDetailContextMenu(IMenuManager menu) {
586
menu.add(new Separator(IDebugUIConstants.VARIABLE_GROUP));
587
menu.add(new Separator());
588
menu.add(getAction(DETAIL_COPY_ACTION));
589
menu.add(getAction(DETAIL_SELECT_ALL_ACTION));
590
menu.add(new Separator());
591
menu.add(getAction(DETAIL_WORD_WRAP_ACTION));
592
menu.add(getAction(DETAIL_MAX_LENGTH_ACTION));
593
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
597
* @see org.eclipse.debug.ui.IDetailPane#display(org.eclipse.jface.viewers.IStructuredSelection)
599
public void display(IStructuredSelection selection) {
601
if (selection == null){
606
fLastDisplayed = selection;
608
if ( selection.isEmpty() || !(selection instanceof ITreeSelection) ) {
613
Object firstElement = selection.getFirstElement();
614
if (firstElement instanceof IAdaptable) {
615
IDebugModelProvider debugModelProvider =
616
(IDebugModelProvider)((IAdaptable)firstElement).getAdapter(IDebugModelProvider.class);
617
if (debugModelProvider != null) {
618
String[] ids = debugModelProvider.getModelIdentifiers();
619
if (ids != null && ids.length > 0) {
620
setDebugModel(ids[0]);
625
synchronized (this) {
626
if (fDetailJob != null) {
629
if (fWorkbenchPartSite != null) {
630
IWorkbenchPart part = fWorkbenchPartSite.getPart();
631
if (part instanceof IDebugView) {
632
Viewer viewer = ((IDebugView)part).getViewer();
633
Object input = viewer.getInput();
634
if (input != null && viewer instanceof TreeModelViewer) {
635
TreeModelViewer treeModelViewer = (TreeModelViewer)viewer;
636
fDetailJob = new DetailJob(treeModelViewer.getPresentationContext(), input,
637
(ITreeSelection)selection, null);
638
fDetailJob.schedule();
641
} else if (firstElement instanceof IDMVMContext) {
642
IVMNode vmNode = ((IDMVMContext) firstElement).getVMNode();
643
if (vmNode != null) {
644
Object input = firstElement;
645
IVMProvider vmProvider = vmNode.getVMProvider();
646
final IPresentationContext context= vmProvider.getPresentationContext();
647
if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(context.getId())) {
648
// magic access to viewer input - see ExpressionVMProvider
649
input = context.getProperty("__viewerInput"); //$NON-NLS-1$
651
fDetailJob = new DetailJob(context, input, (ITreeSelection)selection, null);
652
fDetailJob.schedule();
659
* @see org.eclipse.debug.ui.IDetailPane#setFocus()
661
public boolean setFocus(){
662
if (fTextViewer != null){
663
fTextViewer.getTextWidget().setFocus();
672
public void dispose(){
674
fSelectionActions.clear();
676
if (fDetailJob != null) fDetailJob.cancel();
677
fDebugModelIdentifier = null; // Setting this to null makes sure the text viewer is reconfigured with the model presentation after disposal
678
if (fTextViewer != null && fTextViewer.getControl() != null) {
679
fTextViewer.getControl().dispose();
684
DsfUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
685
JFaceResources.getFontRegistry().removeListener(this);
690
* @see org.eclipse.debug.ui.IDetailPane#getDescription()
692
public String getDescription() {
693
return MessagesForDetailPane.NumberFormatDetailPane_Description;
697
* @see org.eclipse.debug.ui.IDetailPane#getID()
699
public String getID() {
704
* @see org.eclipse.debug.ui.IDetailPane#getName()
706
public String getName() {
707
return MessagesForDetailPane.NumberFormatDetailPane_Name;
711
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
713
@SuppressWarnings("rawtypes")
714
public Object getAdapter(Class required) {
715
if (IFindReplaceTarget.class.equals(required)) {
716
return fTextViewer.getFindReplaceTarget();
718
if (ITextViewer.class.equals(required)) {
725
* Lazily instantiate and return a Document for the detail pane text viewer.
727
protected IDocument getDetailDocument() {
728
if (fDetailDocument == null) {
729
fDetailDocument = new Document();
731
return fDetailDocument;
735
* Clears the text viewer, removes all text.
737
protected void clearTextViewer(){
738
if (fDetailJob != null) {
741
// Bugzilla 310191: Detail pane does not clear up when DSF-GDB session is terminated
742
IProgressMonitor progressMonitor = fDetailJob.getDetailMonitor();
743
if (progressMonitor!=null)
744
progressMonitor.setCanceled(true);
746
fLastDisplayed = null;
747
fDetailDocument.set(""); //$NON-NLS-1$
748
fTextViewer.setEditable(false);
752
* Configures the details viewer for the debug model
753
* currently being displayed
755
protected void configureDetailsViewer() {
756
fTextViewer.setEditable(false);
760
* Returns the identifier of the debug model being displayed
761
* in this view, or <code>null</code> if none.
763
* @return debug model identifier
765
protected String getDebugModel() {
766
return fDebugModelIdentifier;
770
* Sets the identifier of the debug model being displayed
771
* in this view, or <code>null</code> if none.
773
* @param id debug model identifier of the type of debug
774
* elements being displayed in this view
776
protected void setDebugModel(String id) {
777
if (id != fDebugModelIdentifier) {
778
fDebugModelIdentifier = id;
779
configureDetailsViewer();
784
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
786
public void propertyChange(PropertyChangeEvent event) {
787
String propertyName= event.getProperty();
788
if (propertyName.equals(IDebugUIConstants.PREF_DETAIL_PANE_FONT)) {
789
fTextViewer.getTextWidget().setFont(JFaceResources.getFont(IDebugUIConstants.PREF_DETAIL_PANE_FONT));
790
} else if (propertyName.equals(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH)) {
791
display(fLastDisplayed);
792
} else if (propertyName.equals(IInternalDsfDebugUIConstants.PREF_DETAIL_PANE_WORD_WRAP)) {
793
fTextViewer.getTextWidget().setWordWrap(DsfUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDsfDebugUIConstants.PREF_DETAIL_PANE_WORD_WRAP));
794
getAction(DETAIL_WORD_WRAP_ACTION).setChecked(DsfUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDsfDebugUIConstants.PREF_DETAIL_PANE_WORD_WRAP));
799
* @see org.eclipse.debug.ui.IDetailPane2#getSelectionProvider()
801
public ISelectionProvider getSelectionProvider() {
802
if (fTextViewer != null) {
803
return fTextViewer.getSelectionProvider();