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