Mercurial > projects > dwt-addons
annotate dwtx/jface/text/AbstractInformationControl.d @ 156:a9566845f1cb
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 25 Aug 2008 19:03:46 +0200 |
parents | 75302ef3f92f |
children | f8d52b926852 |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2008 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 | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.text.AbstractInformationControl; | |
14 | |
131 | 15 import dwtx.jface.text.IDocumentPartitioningListener; // packageimport |
16 import dwtx.jface.text.DefaultTextHover; // packageimport | |
17 import dwtx.jface.text.TextUtilities; // packageimport | |
18 import dwtx.jface.text.IInformationControlCreatorExtension; // packageimport | |
19 import dwtx.jface.text.AbstractInformationControlManager; // packageimport | |
20 import dwtx.jface.text.ITextViewerExtension2; // packageimport | |
21 import dwtx.jface.text.IDocumentPartitioner; // packageimport | |
22 import dwtx.jface.text.DefaultIndentLineAutoEditStrategy; // packageimport | |
23 import dwtx.jface.text.ITextSelection; // packageimport | |
24 import dwtx.jface.text.Document; // packageimport | |
25 import dwtx.jface.text.FindReplaceDocumentAdapterContentProposalProvider; // packageimport | |
26 import dwtx.jface.text.ITextListener; // packageimport | |
27 import dwtx.jface.text.BadPartitioningException; // packageimport | |
28 import dwtx.jface.text.ITextViewerExtension5; // packageimport | |
29 import dwtx.jface.text.IDocumentPartitionerExtension3; // packageimport | |
30 import dwtx.jface.text.IUndoManager; // packageimport | |
31 import dwtx.jface.text.ITextHoverExtension2; // packageimport | |
32 import dwtx.jface.text.IRepairableDocument; // packageimport | |
33 import dwtx.jface.text.IRewriteTarget; // packageimport | |
34 import dwtx.jface.text.DefaultPositionUpdater; // packageimport | |
35 import dwtx.jface.text.RewriteSessionEditProcessor; // packageimport | |
36 import dwtx.jface.text.TextViewerHoverManager; // packageimport | |
37 import dwtx.jface.text.DocumentRewriteSession; // packageimport | |
38 import dwtx.jface.text.TextViewer; // packageimport | |
39 import dwtx.jface.text.ITextViewerExtension8; // packageimport | |
40 import dwtx.jface.text.RegExMessages; // packageimport | |
41 import dwtx.jface.text.IDelayedInputChangeProvider; // packageimport | |
42 import dwtx.jface.text.ITextOperationTargetExtension; // packageimport | |
43 import dwtx.jface.text.IWidgetTokenOwner; // packageimport | |
44 import dwtx.jface.text.IViewportListener; // packageimport | |
45 import dwtx.jface.text.GapTextStore; // packageimport | |
46 import dwtx.jface.text.MarkSelection; // packageimport | |
47 import dwtx.jface.text.IDocumentPartitioningListenerExtension; // packageimport | |
48 import dwtx.jface.text.IDocumentAdapterExtension; // packageimport | |
49 import dwtx.jface.text.IInformationControlExtension; // packageimport | |
50 import dwtx.jface.text.IDocumentPartitioningListenerExtension2; // packageimport | |
51 import dwtx.jface.text.DefaultDocumentAdapter; // packageimport | |
52 import dwtx.jface.text.ITextViewerExtension3; // packageimport | |
53 import dwtx.jface.text.IInformationControlCreator; // packageimport | |
54 import dwtx.jface.text.TypedRegion; // packageimport | |
55 import dwtx.jface.text.ISynchronizable; // packageimport | |
56 import dwtx.jface.text.IMarkRegionTarget; // packageimport | |
57 import dwtx.jface.text.TextViewerUndoManager; // packageimport | |
58 import dwtx.jface.text.IRegion; // packageimport | |
59 import dwtx.jface.text.IInformationControlExtension2; // packageimport | |
60 import dwtx.jface.text.IDocumentExtension4; // packageimport | |
61 import dwtx.jface.text.IDocumentExtension2; // packageimport | |
62 import dwtx.jface.text.IDocumentPartitionerExtension2; // packageimport | |
63 import dwtx.jface.text.Assert; // packageimport | |
64 import dwtx.jface.text.DefaultInformationControl; // packageimport | |
65 import dwtx.jface.text.IWidgetTokenOwnerExtension; // packageimport | |
66 import dwtx.jface.text.DocumentClone; // packageimport | |
67 import dwtx.jface.text.DefaultUndoManager; // packageimport | |
68 import dwtx.jface.text.IFindReplaceTarget; // packageimport | |
69 import dwtx.jface.text.IAutoEditStrategy; // packageimport | |
70 import dwtx.jface.text.ILineTrackerExtension; // packageimport | |
71 import dwtx.jface.text.IUndoManagerExtension; // packageimport | |
72 import dwtx.jface.text.TextSelection; // packageimport | |
73 import dwtx.jface.text.DefaultAutoIndentStrategy; // packageimport | |
74 import dwtx.jface.text.IAutoIndentStrategy; // packageimport | |
75 import dwtx.jface.text.IPainter; // packageimport | |
76 import dwtx.jface.text.IInformationControl; // packageimport | |
77 import dwtx.jface.text.IInformationControlExtension3; // packageimport | |
78 import dwtx.jface.text.ITextViewerExtension6; // packageimport | |
79 import dwtx.jface.text.IInformationControlExtension4; // packageimport | |
80 import dwtx.jface.text.DefaultLineTracker; // packageimport | |
81 import dwtx.jface.text.IDocumentInformationMappingExtension; // packageimport | |
82 import dwtx.jface.text.IRepairableDocumentExtension; // packageimport | |
83 import dwtx.jface.text.ITextHover; // packageimport | |
84 import dwtx.jface.text.FindReplaceDocumentAdapter; // packageimport | |
85 import dwtx.jface.text.ILineTracker; // packageimport | |
86 import dwtx.jface.text.Line; // packageimport | |
87 import dwtx.jface.text.ITextViewerExtension; // packageimport | |
88 import dwtx.jface.text.IDocumentAdapter; // packageimport | |
89 import dwtx.jface.text.TextEvent; // packageimport | |
90 import dwtx.jface.text.BadLocationException; // packageimport | |
91 import dwtx.jface.text.AbstractDocument; // packageimport | |
92 import dwtx.jface.text.AbstractLineTracker; // packageimport | |
93 import dwtx.jface.text.TreeLineTracker; // packageimport | |
94 import dwtx.jface.text.ITextPresentationListener; // packageimport | |
95 import dwtx.jface.text.Region; // packageimport | |
96 import dwtx.jface.text.ITextViewer; // packageimport | |
97 import dwtx.jface.text.IDocumentInformationMapping; // packageimport | |
98 import dwtx.jface.text.MarginPainter; // packageimport | |
99 import dwtx.jface.text.IPaintPositionManager; // packageimport | |
100 import dwtx.jface.text.TextPresentation; // packageimport | |
101 import dwtx.jface.text.IFindReplaceTargetExtension; // packageimport | |
102 import dwtx.jface.text.ISlaveDocumentManagerExtension; // packageimport | |
103 import dwtx.jface.text.ISelectionValidator; // packageimport | |
104 import dwtx.jface.text.IDocumentExtension; // packageimport | |
105 import dwtx.jface.text.PropagatingFontFieldEditor; // packageimport | |
106 import dwtx.jface.text.ConfigurableLineTracker; // packageimport | |
107 import dwtx.jface.text.SlaveDocumentEvent; // packageimport | |
108 import dwtx.jface.text.IDocumentListener; // packageimport | |
109 import dwtx.jface.text.PaintManager; // packageimport | |
110 import dwtx.jface.text.IFindReplaceTargetExtension3; // packageimport | |
111 import dwtx.jface.text.ITextDoubleClickStrategy; // packageimport | |
112 import dwtx.jface.text.IDocumentExtension3; // packageimport | |
113 import dwtx.jface.text.Position; // packageimport | |
114 import dwtx.jface.text.TextMessages; // packageimport | |
115 import dwtx.jface.text.CopyOnWriteTextStore; // packageimport | |
116 import dwtx.jface.text.WhitespaceCharacterPainter; // packageimport | |
117 import dwtx.jface.text.IPositionUpdater; // packageimport | |
118 import dwtx.jface.text.DefaultTextDoubleClickStrategy; // packageimport | |
119 import dwtx.jface.text.ListLineTracker; // packageimport | |
120 import dwtx.jface.text.ITextInputListener; // packageimport | |
121 import dwtx.jface.text.BadPositionCategoryException; // packageimport | |
122 import dwtx.jface.text.IWidgetTokenKeeperExtension; // packageimport | |
123 import dwtx.jface.text.IInputChangedListener; // packageimport | |
124 import dwtx.jface.text.ITextOperationTarget; // packageimport | |
125 import dwtx.jface.text.IDocumentInformationMappingExtension2; // packageimport | |
126 import dwtx.jface.text.ITextViewerExtension7; // packageimport | |
127 import dwtx.jface.text.IInformationControlExtension5; // packageimport | |
128 import dwtx.jface.text.IDocumentRewriteSessionListener; // packageimport | |
129 import dwtx.jface.text.JFaceTextUtil; // packageimport | |
130 import dwtx.jface.text.AbstractReusableInformationControlCreator; // packageimport | |
131 import dwtx.jface.text.TabsToSpacesConverter; // packageimport | |
132 import dwtx.jface.text.CursorLinePainter; // packageimport | |
133 import dwtx.jface.text.ITextHoverExtension; // packageimport | |
134 import dwtx.jface.text.IEventConsumer; // packageimport | |
135 import dwtx.jface.text.IDocument; // packageimport | |
136 import dwtx.jface.text.IWidgetTokenKeeper; // packageimport | |
137 import dwtx.jface.text.DocumentCommand; // packageimport | |
138 import dwtx.jface.text.TypedPosition; // packageimport | |
139 import dwtx.jface.text.IEditingSupportRegistry; // packageimport | |
140 import dwtx.jface.text.IDocumentPartitionerExtension; // packageimport | |
141 import dwtx.jface.text.AbstractHoverInformationControlManager; // packageimport | |
142 import dwtx.jface.text.IEditingSupport; // packageimport | |
143 import dwtx.jface.text.IMarkSelection; // packageimport | |
144 import dwtx.jface.text.ISlaveDocumentManager; // packageimport | |
145 import dwtx.jface.text.DocumentEvent; // packageimport | |
146 import dwtx.jface.text.DocumentPartitioningChangedEvent; // packageimport | |
147 import dwtx.jface.text.ITextStore; // packageimport | |
148 import dwtx.jface.text.JFaceTextMessages; // packageimport | |
149 import dwtx.jface.text.DocumentRewriteSessionEvent; // packageimport | |
150 import dwtx.jface.text.SequentialRewriteTextStore; // packageimport | |
151 import dwtx.jface.text.DocumentRewriteSessionType; // packageimport | |
152 import dwtx.jface.text.TextAttribute; // packageimport | |
153 import dwtx.jface.text.ITextViewerExtension4; // packageimport | |
154 import dwtx.jface.text.ITypedRegion; // packageimport | |
155 | |
156 | |
129 | 157 import dwt.dwthelper.utils; |
158 | |
159 | |
160 | |
161 | |
162 import dwt.DWT; | |
163 import dwt.events.DisposeListener; | |
164 import dwt.events.FocusEvent; | |
165 import dwt.events.FocusListener; | |
166 import dwt.events.MouseAdapter; | |
167 import dwt.events.MouseEvent; | |
168 import dwt.events.MouseMoveListener; | |
169 import dwt.events.PaintEvent; | |
170 import dwt.events.PaintListener; | |
171 import dwt.graphics.Color; | |
172 import dwt.graphics.Cursor; | |
173 import dwt.graphics.Font; | |
174 import dwt.graphics.FontData; | |
175 import dwt.graphics.GC; | |
176 import dwt.graphics.Point; | |
177 import dwt.graphics.Rectangle; | |
178 import dwt.layout.FillLayout; | |
179 import dwt.layout.GridData; | |
180 import dwt.layout.GridLayout; | |
181 import dwt.widgets.Canvas; | |
182 import dwt.widgets.Composite; | |
183 import dwt.widgets.Control; | |
184 import dwt.widgets.Display; | |
185 import dwt.widgets.Event; | |
186 import dwt.widgets.Label; | |
187 import dwt.widgets.Listener; | |
188 import dwt.widgets.Shell; | |
189 import dwt.widgets.Slider; | |
190 import dwt.widgets.ToolBar; | |
191 import dwtx.core.runtime.Assert; | |
192 import dwtx.core.runtime.ListenerList; | |
193 import dwtx.jface.action.ToolBarManager; | |
194 import dwtx.jface.resource.JFaceResources; | |
195 import dwtx.jface.util.Geometry; | |
196 | |
197 | |
198 /** | |
199 * An abstract information control that can show content inside a shell. | |
200 * The information control can be created in two styles: | |
201 * <ul> | |
202 * <li>non-resizable tooltip with optional status</li> | |
203 * <li>resizable tooltip with optional tool bar</li> | |
204 * </ul> | |
205 * Additionally it can present either a status line containing a status text or | |
206 * a toolbar containing toolbar buttons. | |
207 * <p> | |
208 * Subclasses must either override {@link IInformationControl#setInformation(String)} | |
209 * or implement {@link IInformationControlExtension2}. | |
210 * They should also extend {@link #computeTrim()} if they create a content area | |
211 * with additional trim (e.g. scrollbars) and override {@link #getInformationPresenterControlCreator()}. | |
212 * </p> | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
213 * |
129 | 214 * @since 3.4 |
215 */ | |
216 public abstract class AbstractInformationControl : IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension4, IInformationControlExtension5 { | |
217 | |
218 /** The information control's shell. */ | |
146 | 219 private const Shell fShell; |
129 | 220 /** Composite containing the content created by subclasses. */ |
146 | 221 private const Composite fContentComposite; |
129 | 222 /** Whether the information control is resizable. */ |
146 | 223 private const bool fResizable; |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
224 |
129 | 225 /** Composite containing the status line content or <code>null</code> if none. */ |
226 private Composite fStatusComposite; | |
227 /** Separator between content and status line or <code>null</code> if none. */ | |
228 private Label fSeparator; | |
229 /** Label in the status line or <code>null</code> if none. */ | |
230 private Label fStatusLabel; | |
231 /** The toolbar manager used by the toolbar or <code>null</code> if none. */ | |
146 | 232 private const ToolBarManager fToolBarManager; |
129 | 233 /** Status line toolbar or <code>null</code> if none. */ |
234 private ToolBar fToolBar; | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
235 |
129 | 236 /** Listener for shell activation and deactivation. */ |
237 private Listener fShellListener; | |
238 /** All focus listeners registered to this information control. */ | |
239 private ListenerList fFocusListeners= new ListenerList(ListenerList.IDENTITY); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
240 |
129 | 241 /** Size constraints, x is the maxWidth and y is the maxHeight, or <code>null</code> if not set. */ |
242 private Point fSizeConstraints; | |
243 /** The size of the resize handle if already set, -1 otherwise */ | |
244 private int fResizeHandleSize; | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
245 |
129 | 246 /** |
247 * Creates an abstract information control with the given shell as parent. | |
248 * The control will not be resizable and optionally show a status line with | |
249 * the given status field text. | |
250 * <p> | |
251 * <em>Important: Subclasses are required to call {@link #create()} at the end of their constructor.</em> | |
252 * </p> | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
253 * |
129 | 254 * @param parentShell the parent of this control's shell |
255 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | |
256 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
257 public this(Shell parentShell, String statusFieldText) { |
129 | 258 this(parentShell, DWT.TOOL | DWT.ON_TOP, statusFieldText, null); |
259 } | |
260 | |
261 /** | |
262 * Creates an abstract information control with the given shell as parent. | |
263 * The control will be resizable and optionally show a tool bar managed by | |
264 * the given tool bar manager. | |
265 * <p> | |
266 * <em>Important: Subclasses are required to call {@link #create()} at the end of their constructor.</em> | |
267 * </p> | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
268 * |
129 | 269 * @param parentShell the parent of this control's shell |
270 * @param toolBarManager the manager or <code>null</code> if toolbar is not desired | |
271 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
272 public this(Shell parentShell, ToolBarManager toolBarManager) { |
129 | 273 this(parentShell, DWT.TOOL | DWT.ON_TOP | DWT.RESIZE, null, toolBarManager); |
274 } | |
275 | |
276 /** | |
277 * Creates an abstract information control with the given shell as parent. | |
278 * <p> | |
279 * <em>Important: Subclasses are required to call {@link #create()} at the end of their constructor.</em> | |
280 * </p> | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
281 * |
129 | 282 * @param parentShell the parent of this control's shell |
283 * @param isResizable <code>true</code> if the control should be resizable | |
284 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
285 public this(Shell parentShell, bool isResizable) { |
129 | 286 this(parentShell, DWT.TOOL | DWT.ON_TOP | (isResizable ? DWT.RESIZE : 0), null, null); |
287 } | |
288 | |
289 /** | |
290 * Creates an abstract information control with the given shell as parent. | |
291 * The given shell style is used for the shell (NO_TRIM will be removed to make sure there's a border). | |
292 * <p> | |
293 * The control will optionally show either a status line or a tool bar. | |
294 * At most one of <code>toolBarManager</code> or <code>statusFieldText</code> can be non-null. | |
295 * </p> | |
296 * <p> | |
297 * <strong>Important:</strong>: Subclasses are required to call {@link #create()} at the end of their constructor. | |
298 * </p> | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
299 * |
129 | 300 * @param parentShell the parent of this control's shell |
301 * @param shellStyle style of this control's shell | |
302 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | |
303 * @param toolBarManager the manager or <code>null</code> if toolbar is not desired | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
304 * |
129 | 305 * @deprecated clients should use one of the public constructors |
306 */ | |
156 | 307 this(Shell parentShell, int shellStyle, String statusFieldText, ToolBarManager toolBarManager) { |
129 | 308 Assert.isTrue(statusFieldText is null || toolBarManager is null); |
309 fResizeHandleSize= -1; | |
310 fToolBarManager= toolBarManager; | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
311 |
129 | 312 if ((shellStyle & DWT.NO_TRIM) !is 0) |
313 shellStyle&= ~(DWT.NO_TRIM | DWT.SHELL_TRIM); // make sure we get the OS border but no other trims | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
314 |
129 | 315 fResizable= (shellStyle & DWT.RESIZE) !is 0; // on GTK, Shell removes DWT.RESIZE if DWT.ON_TOP is set |
316 fShell= new Shell(parentShell, shellStyle); | |
317 Display display= fShell.getDisplay(); | |
318 Color foreground= display.getSystemColor(DWT.COLOR_INFO_FOREGROUND); | |
319 Color background= display.getSystemColor(DWT.COLOR_INFO_BACKGROUND); | |
320 setColor(fShell, foreground, background); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
321 |
129 | 322 GridLayout layout= new GridLayout(1, false); |
323 layout.marginHeight= 0; | |
324 layout.marginWidth= 0; | |
325 layout.verticalSpacing= 0; | |
326 fShell.setLayout(layout); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
327 |
129 | 328 fContentComposite= new Composite(fShell, DWT.NONE); |
329 fContentComposite.setLayoutData(new GridData(DWT.FILL, DWT.FILL, true, true)); | |
330 fContentComposite.setLayout(new FillLayout()); | |
331 setColor(fContentComposite, foreground, background); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
332 |
129 | 333 createStatusComposite(statusFieldText, toolBarManager, foreground, background); |
334 } | |
335 | |
156 | 336 private void createStatusComposite(String statusFieldText, ToolBarManager toolBarManager, Color foreground, Color background) { |
129 | 337 if (toolBarManager is null && statusFieldText is null) |
338 return; | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
339 |
129 | 340 fStatusComposite= new Composite(fShell, DWT.NONE); |
341 GridData gridData= new GridData(DWT.FILL, DWT.BOTTOM, true, false); | |
342 fStatusComposite.setLayoutData(gridData); | |
343 GridLayout statusLayout= new GridLayout(1, false); | |
344 statusLayout.marginHeight= 0; | |
345 statusLayout.marginWidth= 0; | |
346 statusLayout.verticalSpacing= 1; | |
347 fStatusComposite.setLayout(statusLayout); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
348 |
129 | 349 fSeparator= new Label(fStatusComposite, DWT.SEPARATOR | DWT.HORIZONTAL); |
350 fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
351 |
129 | 352 if (statusFieldText !is null) { |
353 createStatusLabel(statusFieldText, foreground, background); | |
354 } else { | |
355 createToolBar(toolBarManager); | |
356 } | |
357 } | |
358 | |
156 | 359 private void createStatusLabel(String statusFieldText, Color foreground, Color background) { |
129 | 360 fStatusLabel= new Label(fStatusComposite, DWT.RIGHT); |
361 fStatusLabel.setLayoutData(new GridData(DWT.FILL, DWT.CENTER, true, false)); | |
362 fStatusLabel.setText(statusFieldText); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
363 |
129 | 364 FontData[] fontDatas= JFaceResources.getDialogFont().getFontData(); |
365 for (int i= 0; i < fontDatas.length; i++) { | |
366 fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); | |
367 } | |
368 fStatusLabel.setFont(new Font(fStatusLabel.getDisplay(), fontDatas)); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
369 |
129 | 370 fStatusLabel.setForeground(fStatusLabel.getDisplay().getSystemColor(DWT.COLOR_WIDGET_DARK_SHADOW)); |
371 fStatusLabel.setBackground(background); | |
372 setColor(fStatusComposite, foreground, background); | |
373 } | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
374 |
129 | 375 private void createToolBar(ToolBarManager toolBarManager) { |
156 | 376 Composite bars= new Composite(fStatusComposite, DWT.NONE); |
129 | 377 bars.setLayoutData(new GridData(DWT.FILL, DWT.FILL, false, false)); |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
378 |
129 | 379 GridLayout layout= new GridLayout(3, false); |
380 layout.marginHeight= 0; | |
381 layout.marginWidth= 0; | |
382 layout.horizontalSpacing= 0; | |
383 layout.verticalSpacing= 0; | |
384 bars.setLayout(layout); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
385 |
129 | 386 fToolBar= toolBarManager.createControl(bars); |
387 GridData gd= new GridData(DWT.BEGINNING, DWT.BEGINNING, false, false); | |
388 fToolBar.setLayoutData(gd); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
389 |
129 | 390 Composite spacer= new Composite(bars, DWT.NONE); |
391 gd= new GridData(DWT.FILL, DWT.FILL, true, true); | |
392 gd.widthHint= 0; | |
393 gd.heightHint= 0; | |
394 spacer.setLayoutData(gd); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
395 |
129 | 396 addMoveSupport(spacer); |
397 addResizeSupportIfNecessary(bars); | |
398 } | |
399 | |
156 | 400 private void addResizeSupportIfNecessary(Composite bars) { |
129 | 401 // XXX: workarounds for |
402 // - https://bugs.eclipse.org/bugs/show_bug.cgi?id=219139 : API to add resize grip / grow box in lower right corner of shell | |
403 // - https://bugs.eclipse.org/bugs/show_bug.cgi?id=23980 : platform specific shell resize behavior | |
404 String platform= DWT.getPlatform(); | |
156 | 405 bool isWin= platform.equals("win32"); //$NON-NLS-1$ |
129 | 406 if (!isWin && !platform.equals("gtk")) //$NON-NLS-1$ |
407 return; | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
408 |
156 | 409 Canvas resizer= new Canvas(bars, DWT.NONE); |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
410 |
129 | 411 int size= getResizeHandleSize(bars); |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
412 |
129 | 413 GridData data= new GridData(DWT.END, DWT.END, false, true); |
414 data.widthHint= size; | |
415 data.heightHint= size; | |
416 resizer.setLayoutData(data); | |
156 | 417 resizer.addPaintListener(new class(isWin,resizer) PaintListener { |
418 bool isWin_; | |
419 Canvas resizer_; | |
420 this(bool a, Canvas b ){ | |
421 isWin_=a; | |
422 resizer_=b; | |
423 } | |
129 | 424 public void paintControl(PaintEvent e) { |
156 | 425 Point s= resizer_.getSize(); |
129 | 426 int x= s.x - 2; |
427 int y= s.y - 2; | |
428 int min= Math.min(x, y); | |
156 | 429 if (isWin_) { |
129 | 430 // draw dots |
156 | 431 e.gc.setBackground(resizer_.getDisplay().getSystemColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); |
129 | 432 int end= min - 1; |
433 for (int i= 0; i <= 2; i++) | |
434 for (int j= 0; j <= 2 - i; j++) | |
435 e.gc.fillRectangle(end - 4 * i, end - 4 * j, 2, 2); | |
436 end--; | |
156 | 437 e.gc.setBackground(resizer_.getDisplay().getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW)); |
129 | 438 for (int i= 0; i <= 2; i++) |
439 for (int j= 0; j <= 2 - i; j++) | |
440 e.gc.fillRectangle(end - 4 * i, end - 4 * j, 2, 2); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
441 |
129 | 442 } else { |
443 // draw diagonal lines | |
156 | 444 e.gc.setForeground(resizer_.getDisplay().getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW)); |
129 | 445 for (int i= 1; i < min; i+= 4) { |
446 e.gc.drawLine(i, y, x, i); | |
447 } | |
156 | 448 e.gc.setForeground(resizer_.getDisplay().getSystemColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); |
129 | 449 for (int i= 2; i < min; i+= 4) { |
450 e.gc.drawLine(i, y, x, i); | |
451 } | |
452 } | |
453 } | |
454 }); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
455 |
129 | 456 resizer.setCursor(new Cursor(resizer.getDisplay(), DWT.CURSOR_SIZESE)); |
156 | 457 MouseAdapter resizeSupport= new class(resizer) MouseAdapter { |
458 Canvas resizer_; | |
459 this(Canvas a){ | |
460 resizer_=a; | |
461 } | |
129 | 462 private MouseMoveListener fResizeListener; |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
463 |
129 | 464 public void mouseDown(MouseEvent e) { |
465 Point shellSize= fShell.getSize(); | |
156 | 466 int shellX= shellSize.x; |
467 int shellY= shellSize.y; | |
468 Point mouseLoc= resizer_.toDisplay(e.x, e.y); | |
469 int mouseX= mouseLoc.x; | |
470 int mouseY= mouseLoc.y; | |
471 fResizeListener= new class(shellX,shellY,mouseX,mouseY) MouseMoveListener { | |
472 int shellX_; | |
473 int shellY_; | |
474 int mouseX_; | |
475 int mouseY_; | |
476 this(int a, int b, int c, int d ){ | |
477 shellX_=a; | |
478 shellY_=b; | |
479 mouseX_=c; | |
480 mouseY_=d; | |
481 } | |
129 | 482 public void mouseMove(MouseEvent e2) { |
156 | 483 Point mouseLoc2= resizer_.toDisplay(e2.x, e2.y); |
484 int dx= mouseLoc2.x - mouseX_; | |
485 int dy= mouseLoc2.y - mouseY_; | |
486 setSize(shellX_ + dx, shellY_ + dy); | |
129 | 487 } |
488 }; | |
156 | 489 resizer_.addMouseMoveListener(fResizeListener); |
129 | 490 } |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
491 |
129 | 492 public void mouseUp(MouseEvent e) { |
156 | 493 resizer_.removeMouseMoveListener(fResizeListener); |
129 | 494 fResizeListener= null; |
495 } | |
496 }; | |
497 resizer.addMouseListener(resizeSupport); | |
498 } | |
499 | |
500 private int getResizeHandleSize(Composite parent) { | |
501 if (fResizeHandleSize is -1) { | |
502 Slider sliderV= new Slider(parent, DWT.VERTICAL); | |
503 Slider sliderH= new Slider(parent, DWT.HORIZONTAL); | |
504 int width= sliderV.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; | |
505 int height= sliderH.computeSize(DWT.DEFAULT, DWT.DEFAULT).y; | |
506 sliderV.dispose(); | |
507 sliderH.dispose(); | |
508 fResizeHandleSize= Math.min(width, height); | |
509 } | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
510 |
129 | 511 return fResizeHandleSize; |
512 } | |
513 | |
514 /** | |
515 * Adds support to move the shell by dragging the given control. | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
516 * |
129 | 517 * @param control the control that can be used to move the shell |
518 */ | |
156 | 519 private void addMoveSupport(Control control) { |
520 MouseAdapter moveSupport= new class(control) MouseAdapter { | |
129 | 521 private MouseMoveListener fMoveListener; |
156 | 522 Control control_; |
523 this(Control a){ | |
524 control_=a; | |
525 } | |
129 | 526 public void mouseDown(MouseEvent e) { |
527 Point shellLoc= fShell.getLocation(); | |
528 final int shellX= shellLoc.x; | |
529 final int shellY= shellLoc.y; | |
156 | 530 Point mouseLoc= control_.toDisplay(e.x, e.y); |
129 | 531 final int mouseX= mouseLoc.x; |
532 final int mouseY= mouseLoc.y; | |
135 | 533 fMoveListener= new class() MouseMoveListener { |
129 | 534 public void mouseMove(MouseEvent e2) { |
156 | 535 Point mouseLoc2= control_.toDisplay(e2.x, e2.y); |
129 | 536 int dx= mouseLoc2.x - mouseX; |
537 int dy= mouseLoc2.y - mouseY; | |
538 fShell.setLocation(shellX + dx, shellY + dy); | |
539 } | |
540 }; | |
156 | 541 control_.addMouseMoveListener(fMoveListener); |
129 | 542 } |
543 | |
544 public void mouseUp(MouseEvent e) { | |
156 | 545 control_.removeMouseMoveListener(fMoveListener); |
129 | 546 fMoveListener= null; |
547 } | |
548 }; | |
549 control.addMouseListener(moveSupport); | |
550 } | |
551 | |
552 /** | |
553 * Utility to set the foreground and the background color of the given | |
554 * control | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
555 * |
129 | 556 * @param control the control to modify |
557 * @param foreground the color to use for the foreground | |
558 * @param background the color to use for the background | |
559 */ | |
560 private static void setColor(Control control, Color foreground, Color background) { | |
561 control.setForeground(foreground); | |
562 control.setBackground(background); | |
563 } | |
564 | |
565 /** | |
566 * The shell of the popup window. | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
567 * |
129 | 568 * @return the shell used for the popup window |
569 */ | |
570 protected final Shell getShell() { | |
571 return fShell; | |
572 } | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
573 |
129 | 574 /** |
575 * The toolbar manager used to manage the toolbar, or <code>null</code> if | |
576 * no toolbar is shown. | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
577 * |
129 | 578 * @return the tool bar manager or <code>null</code> |
579 */ | |
580 protected final ToolBarManager getToolBarManager() { | |
581 return fToolBarManager; | |
582 } | |
583 | |
584 /** | |
585 * Creates the content of this information control. Subclasses must call | |
586 * this method at the end of their constructor(s). | |
587 */ | |
588 protected final void create() { | |
589 createContent(fContentComposite); | |
590 } | |
591 | |
592 /** | |
593 * Creates the content of the popup window. | |
594 * <p> | |
595 * Implementors will usually take over {@link Composite#getBackground()} and | |
596 * {@link Composite#getForeground()} from <code>parent</code>. | |
597 * </p> | |
598 * <p> | |
599 * Implementors are expected to consider {@link #isResizable()}: If | |
600 * <code>true</code>, they should show scrollbars if their content may | |
601 * exceed the size of the information control. If <code>false</code>, | |
602 * they should never show scrollbars. | |
603 * </p> | |
604 * <p> | |
605 * The given <code>parent</code> comes with a {@link FillLayout}. | |
606 * Subclasses may set a different layout. | |
607 * </p> | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
608 * |
129 | 609 * @param parent the container of the content |
610 */ | |
611 protected abstract void createContent(Composite parent); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
612 |
129 | 613 /** |
614 * Sets the information to be presented by this information control. | |
615 * <p> | |
616 * The default implementation does nothing. Subclasses must either override this method | |
617 * or implement {@link IInformationControlExtension2}. | |
618 * | |
619 * @param information the information to be presented | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
620 * |
129 | 621 * @see dwtx.jface.text.IInformationControl#setInformation(java.lang.String) |
622 */ | |
623 public void setInformation(String information) { | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
624 |
129 | 625 } |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
626 |
129 | 627 /** |
628 * Returns whether the information control is resizable. | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
629 * |
129 | 630 * @return <code>true</code> if the information control is resizable, |
631 * <code>false</code> if it is not resizable. | |
632 */ | |
633 public bool isResizable() { | |
634 return fResizable; | |
635 } | |
636 | |
637 /* | |
638 * @see IInformationControl#setVisible(bool) | |
639 */ | |
640 public void setVisible(bool visible) { | |
641 if (fShell.isVisible() is visible) | |
642 return; | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
643 |
129 | 644 fShell.setVisible(visible); |
645 } | |
646 | |
647 /* | |
648 * @see IInformationControl#dispose() | |
649 */ | |
650 public void dispose() { | |
651 if (fShell !is null && !fShell.isDisposed()) | |
652 fShell.dispose(); | |
653 } | |
654 | |
655 /* | |
656 * @see IInformationControl#setSize(int, int) | |
657 */ | |
658 public void setSize(int width, int height) { | |
659 fShell.setSize(width, height); | |
660 } | |
661 | |
662 /* | |
663 * @see IInformationControl#setLocation(Point) | |
664 */ | |
665 public void setLocation(Point location) { | |
666 fShell.setLocation(location); | |
667 } | |
668 | |
669 /* | |
670 * @see IInformationControl#setSizeConstraints(int, int) | |
671 */ | |
672 public void setSizeConstraints(int maxWidth, int maxHeight) { | |
673 fSizeConstraints= new Point(maxWidth, maxHeight); | |
674 } | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
675 |
129 | 676 /** |
677 * Returns the size constraints. | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
678 * |
129 | 679 * @return the size constraints or <code>null</code> if not set |
680 * @see #setSizeConstraints(int, int) | |
681 */ | |
682 protected final Point getSizeConstraints() { | |
683 return fSizeConstraints !is null ? Geometry.copy(fSizeConstraints) : null; | |
684 } | |
685 | |
686 /* | |
687 * @see IInformationControl#computeSizeHint() | |
688 */ | |
689 public Point computeSizeHint() { | |
690 // XXX: Verify whether this is a good default implementation. If yes, document it. | |
691 Point constrains= getSizeConstraints(); | |
692 if (constrains is null) | |
693 return fShell.computeSize(DWT.DEFAULT, DWT.DEFAULT, true); | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
694 |
129 | 695 return fShell.computeSize(constrains.x, constrains.y, true); |
696 } | |
697 | |
698 /** | |
699 * Computes the trim (status text and tool bar are considered as trim). | |
700 * Subclasses can extend this method to add additional trim (e.g. scroll | |
701 * bars for resizable information controls). | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
702 * |
129 | 703 * @see dwtx.jface.text.IInformationControlExtension3#computeTrim() |
704 */ | |
705 public Rectangle computeTrim() { | |
706 Rectangle trim= fShell.computeTrim(0, 0, 0, 0); | |
707 | |
708 if (fStatusComposite !is null) | |
709 trim.height+= fStatusComposite.computeSize(DWT.DEFAULT, DWT.DEFAULT).y; | |
710 | |
711 return trim; | |
712 } | |
713 | |
714 /* | |
715 * @see dwtx.jface.text.IInformationControlExtension3#getBounds() | |
716 */ | |
717 public Rectangle getBounds() { | |
718 return fShell.getBounds(); | |
719 } | |
720 | |
721 /** | |
722 * {@inheritDoc} | |
723 * <p> | |
724 * The default implementation always returns <code>false</code>. | |
725 * </p> | |
726 * @see dwtx.jface.text.IInformationControlExtension3#restoresLocation() | |
727 */ | |
728 public bool restoresLocation() { | |
729 return false; | |
730 } | |
731 | |
732 /** | |
733 * {@inheritDoc} | |
734 * <p> | |
735 * The default implementation always returns <code>false</code>. | |
736 * </p> | |
737 * @see dwtx.jface.text.IInformationControlExtension3#restoresSize() | |
738 */ | |
739 public bool restoresSize() { | |
740 return false; | |
741 } | |
742 | |
743 /* | |
744 * @see IInformationControl#addDisposeListener(DisposeListener) | |
745 */ | |
746 public void addDisposeListener(DisposeListener listener) { | |
747 fShell.addDisposeListener(listener); | |
748 } | |
749 | |
750 /* | |
751 * @see IInformationControl#removeDisposeListener(DisposeListener) | |
752 */ | |
753 public void removeDisposeListener(DisposeListener listener) { | |
754 fShell.removeDisposeListener(listener); | |
755 } | |
756 | |
757 /* | |
758 * @see IInformationControl#setForegroundColor(Color) | |
759 */ | |
760 public void setForegroundColor(Color foreground) { | |
761 fContentComposite.setForeground(foreground); | |
762 } | |
763 | |
764 /* | |
765 * @see IInformationControl#setBackgroundColor(Color) | |
766 */ | |
767 public void setBackgroundColor(Color background) { | |
768 fContentComposite.setBackground(background); | |
769 } | |
770 | |
771 /** | |
772 * {@inheritDoc} | |
773 * This method is not intended to be overridden by subclasses. | |
774 */ | |
775 public bool isFocusControl() { | |
776 return fShell.getDisplay().getActiveShell() is fShell; | |
777 } | |
778 | |
779 /** | |
780 * This default implementation sets the focus on the popup shell. | |
781 * Subclasses can override or extend. | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
782 * |
129 | 783 * @see IInformationControl#setFocus() |
784 */ | |
785 public void setFocus() { | |
786 bool focusTaken= fShell.setFocus(); | |
787 if (!focusTaken) | |
788 fShell.forceFocus(); | |
789 } | |
790 | |
791 /** | |
792 * {@inheritDoc} | |
793 * This method is not intended to be overridden by subclasses. | |
794 */ | |
156 | 795 public void addFocusListener(FocusListener listener) { |
129 | 796 if (fFocusListeners.isEmpty()) { |
135 | 797 fShellListener= new class() Listener { |
129 | 798 |
799 public void handleEvent(Event event) { | |
800 Object[] listeners= fFocusListeners.getListeners(); | |
801 for (int i= 0; i < listeners.length; i++) { | |
134 | 802 FocusListener focusListener= cast(FocusListener)listeners[i]; |
129 | 803 if (event.type is DWT.Activate) { |
804 focusListener.focusGained(new FocusEvent(event)); | |
805 } else { | |
806 focusListener.focusLost(new FocusEvent(event)); | |
807 } | |
808 } | |
809 } | |
810 }; | |
811 fShell.addListener(DWT.Deactivate, fShellListener); | |
812 fShell.addListener(DWT.Activate, fShellListener); | |
813 } | |
814 fFocusListeners.add(listener); | |
815 } | |
816 | |
817 /** | |
818 * {@inheritDoc} | |
819 * This method is not intended to be overridden by subclasses. | |
820 */ | |
821 public void removeFocusListener(FocusListener listener) { | |
822 fFocusListeners.remove(listener); | |
823 if (fFocusListeners.isEmpty()) { | |
824 fShell.removeListener(DWT.Activate, fShellListener); | |
825 fShell.removeListener(DWT.Deactivate, fShellListener); | |
826 fShellListener= null; | |
827 } | |
828 } | |
829 | |
830 /** | |
831 * Sets the text of the status field. | |
832 * <p> | |
833 * The default implementation currently only updates the status field when | |
834 * the popup shell is not visible. The status field can currently only be | |
835 * shown if the information control has been created with a non-null status | |
836 * field text. | |
837 * </p> | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
838 * |
129 | 839 * @param statusFieldText the text to be used in the optional status field |
840 * or <code>null</code> if the status field should be hidden | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
841 * |
129 | 842 * @see dwtx.jface.text.IInformationControlExtension4#setStatusText(java.lang.String) |
843 */ | |
844 public void setStatusText(String statusFieldText) { | |
845 if (fStatusLabel !is null && ! getShell().isVisible()) { | |
846 if (statusFieldText is null ) { | |
847 fStatusComposite.setVisible(false); | |
848 } else { | |
849 fStatusLabel.setText(statusFieldText); | |
850 fStatusComposite.setVisible(true); | |
851 } | |
852 } | |
853 } | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
854 |
129 | 855 /* |
856 * @see dwtx.jface.text.IInformationControlExtension5#containsControl(dwt.widgets.Control) | |
857 */ | |
858 public bool containsControl(Control control) { | |
859 do { | |
860 if (control is fShell) | |
861 return true; | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
862 if (cast(Shell)control ) |
129 | 863 return false; |
864 control= control.getParent(); | |
865 } while (control !is null); | |
866 return false; | |
867 } | |
868 | |
869 /* | |
870 * @see dwtx.jface.text.IInformationControlExtension5#isVisible() | |
871 */ | |
872 public bool isVisible() { | |
873 return fShell !is null && !fShell.isDisposed() && fShell.isVisible(); | |
874 } | |
875 | |
876 /** | |
877 * {@inheritDoc} | |
878 * This default implementation returns <code>null</code>. Subclasses may override. | |
879 */ | |
880 public IInformationControlCreator getInformationPresenterControlCreator() { | |
881 return null; | |
882 } | |
883 | |
884 /** | |
885 * Computes the size constraints based on the | |
886 * {@link JFaceResources#getDialogFont() dialog font}. Subclasses can | |
887 * override or extend. | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
888 * |
129 | 889 * @see dwtx.jface.text.IInformationControlExtension5#computeSizeConstraints(int, int) |
890 */ | |
891 public Point computeSizeConstraints(int widthInChars, int heightInChars) { | |
892 GC gc= new GC(fContentComposite); | |
893 gc.setFont(JFaceResources.getDialogFont()); | |
894 int width= gc.getFontMetrics().getAverageCharWidth(); | |
895 int height= gc.getFontMetrics().getHeight(); | |
896 gc.dispose(); | |
897 | |
898 return new Point(widthInChars * width, heightInChars * height); | |
899 } | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
135
diff
changeset
|
900 |
129 | 901 } |