Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2010 Wind River Systems 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 |
7 |
* |
8 |
* Contributors: |
9 |
* Wind River Systems - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.cdt.dsf.debug.ui.viewmodel.expression; |
12 |
|
13 |
import java.text.MessageFormat; |
14 |
|
15 |
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; |
16 |
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; |
17 |
import org.eclipse.cdt.dsf.debug.ui.viewmodel.IDebugVMConstants; |
18 |
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; |
19 |
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMNode; |
20 |
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode; |
21 |
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider; |
22 |
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta; |
23 |
import org.eclipse.core.runtime.IStatus; |
24 |
import org.eclipse.core.runtime.Status; |
25 |
import org.eclipse.debug.core.model.IExpression; |
26 |
import org.eclipse.debug.core.model.IWatchExpression; |
27 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; |
28 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; |
29 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor; |
30 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; |
31 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate; |
32 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; |
33 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; |
34 |
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; |
35 |
import org.eclipse.debug.ui.DebugUITools; |
36 |
import org.eclipse.debug.ui.IDebugUIConstants; |
37 |
import org.eclipse.jface.resource.JFaceResources; |
38 |
import org.eclipse.jface.viewers.CellEditor; |
39 |
import org.eclipse.jface.viewers.ICellModifier; |
40 |
import org.eclipse.jface.viewers.TextCellEditor; |
41 |
import org.eclipse.jface.viewers.TreePath; |
42 |
import org.eclipse.swt.widgets.Composite; |
43 |
|
44 |
/** |
45 |
* Expression VM Node which handles displaying disabled expressions. |
46 |
* |
47 |
* @since 2.1 |
48 |
*/ |
49 |
public class DisabledExpressionVMNode extends AbstractVMNode |
50 |
implements IExpressionVMNode, IElementEditor |
51 |
{ |
52 |
|
53 |
/** Cached reference to a cell modifier for editing expression strings of disabled expressions */ |
54 |
private WatchExpressionCellModifier fWatchExpressionCellModifier = new WatchExpressionCellModifier(); |
55 |
|
56 |
|
57 |
private static class DisabledExpressionVMContext extends InvalidExpressionVMContext { |
58 |
|
59 |
private static final MessageFormat NO_COLUMN_FORMAT = new MessageFormat(MessagesForExpressionVM.DisabledExpressionVMNode_disabled_no_columns); |
60 |
|
61 |
DisabledExpressionVMContext(IVMNode node, IExpression expression) { |
62 |
super(node, expression); |
63 |
} |
64 |
|
65 |
/** |
66 |
* Updates the label for the DisabledExpressionVMNode. |
67 |
*/ |
68 |
@Override |
69 |
public void update(ILabelUpdate[] updates) { |
70 |
for (ILabelUpdate update : updates) { |
71 |
if (update.getColumnIds() == null) { |
72 |
update.setLabel(NO_COLUMN_FORMAT.format( new Object[] { getExpression().getExpressionText() }), 0); |
73 |
update.setImageDescriptor(DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ), 0); |
74 |
} else { |
75 |
String[] columnIds = update.getColumnIds(); |
76 |
|
77 |
for (int i = 0; i < update.getColumnIds().length; i++) { |
78 |
if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnIds[i]) || |
79 |
IDebugVMConstants.COLUMN_ID__NAME.equals(columnIds[i])) |
80 |
{ |
81 |
update.setLabel(getExpression().getExpressionText(), i); |
82 |
update.setImageDescriptor(DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ), i); |
83 |
} else { |
84 |
update.setLabel(MessagesForExpressionVM.DisabledExpressionVMNode_disabled_value, i); |
85 |
} |
86 |
update.setFontData(JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0], i); |
87 |
} |
88 |
} |
89 |
update.done(); |
90 |
} |
91 |
} |
92 |
|
93 |
} |
94 |
|
95 |
public DisabledExpressionVMNode(IVMProvider provider) { |
96 |
super(provider); |
97 |
} |
98 |
|
99 |
public boolean canParseExpression(IExpression expression) { |
100 |
return expression instanceof IWatchExpression && !((IWatchExpression)expression).isEnabled(); |
101 |
} |
102 |
|
103 |
public int getDeltaFlagsForExpression(IExpression expression, Object event) { |
104 |
return IModelDelta.NO_CHANGE; |
105 |
} |
106 |
|
107 |
public int getDeltaFlags(Object event) { |
108 |
return IModelDelta.NO_CHANGE; |
109 |
} |
110 |
|
111 |
public void buildDelta(Object event, VMDelta parent, int nodeOffset, RequestMonitor requestMonitor) { |
112 |
requestMonitor.done(); |
113 |
} |
114 |
|
115 |
public void update(IChildrenCountUpdate[] updates) { |
116 |
for (IViewerUpdate update : updates) { |
117 |
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ |
118 |
update.done(); |
119 |
} |
120 |
} |
121 |
|
122 |
public void update(IChildrenUpdate[] updates) { |
123 |
for (IViewerUpdate update : updates) { |
124 |
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ |
125 |
update.done(); |
126 |
} |
127 |
} |
128 |
|
129 |
public void update(IHasChildrenUpdate[] updates) { |
130 |
for (IViewerUpdate update : updates) { |
131 |
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ |
132 |
update.done(); |
133 |
} |
134 |
} |
135 |
|
136 |
public void update(IExpressionUpdate update) { |
137 |
update.setExpressionElement(new DisabledExpressionVMContext(this, update.getExpression())); |
138 |
update.done(); |
139 |
} |
140 |
|
141 |
public void buildDeltaForExpression(IExpression expression, int elementIdx, Object event, VMDelta parentDelta, |
142 |
TreePath path, RequestMonitor rm) |
143 |
{ |
144 |
rm.done(); |
145 |
} |
146 |
|
147 |
public void buildDeltaForExpressionElement(Object element, int elementIdx, Object event, VMDelta parentDelta, |
148 |
RequestMonitor rm) { |
149 |
rm.done(); |
150 |
} |
151 |
|
152 |
public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent) { |
153 |
if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnId)) { |
154 |
return new TextCellEditor(parent); |
155 |
} |
156 |
return null; |
157 |
} |
158 |
|
159 |
public ICellModifier getCellModifier(IPresentationContext context, Object element) { |
160 |
return fWatchExpressionCellModifier; |
161 |
} |
162 |
|
163 |
} |