Project

General

Profile

Download (11.2 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy 
4
 * http://www.e-taxonomy.eu
5
 * 
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

    
10
package eu.etaxonomy.taxeditor.singlesource.editor.name.container;
11

    
12
import javax.naming.OperationNotSupportedException;
13

    
14
import org.eclipse.jface.viewers.TableViewer;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.SWTException;
17
import org.eclipse.swt.events.FocusListener;
18
import org.eclipse.swt.events.ModifyEvent;
19
import org.eclipse.swt.events.ModifyListener;
20
import org.eclipse.swt.events.MouseListener;
21
import org.eclipse.swt.events.VerifyEvent;
22
import org.eclipse.swt.events.VerifyListener;
23
import org.eclipse.swt.graphics.Color;
24
import org.eclipse.swt.graphics.Font;
25
import org.eclipse.swt.graphics.Image;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Menu;
29
import org.eclipse.swt.widgets.Widget;
30
import org.eclipse.ui.IEditorSite;
31

    
32
import eu.etaxonomy.taxeditor.singlesource.org.eclipse.jface.text.IPosition;
33

    
34

    
35
/**
36
 * SourceViewer implementation called by NameComposite.
37
 *
38
 * @author p.ciardelli
39
 * @created 27.05.2008
40
 * @version 1.0
41
 */
42
public class NameViewerFacadeImpl extends TableViewer implements INameViewer {
43

    
44
	public NameViewerFacadeImpl(Composite parent) {
45
		super(parent, SWT.NONE);
46
		setItemCount(1);
47
	}
48
	
49
	
50
	/**
51
	 * <p>setLayoutData</p>
52
	 *
53
	 * @param layoutData the new layout data for the receiver.
54
	 */
55
	public void setLayoutData(Object layoutData)
56
	{
57
		getControl().setLayoutData(layoutData);
58
	}
59

    
60
	/**
61
	 * <p>setBackground</p>
62
	 *
63
	 * @param color a {@link org.eclipse.swt.graphics.Color} object.
64
	 */
65
	public void setBackground(Color color) {
66
		getTable().getItem(0).setBackground(color);
67
		getControl().setBackground(color);
68
	}
69

    
70
	/**
71
	 * <p>setForeground</p>
72
	 *
73
	 * @param color a {@link org.eclipse.swt.graphics.Color} object.
74
	 */
75
	public void setForeground(Color color) {
76
		getTable().getItem(0).setForeground(color);
77
		getControl().setForeground(color);
78
		getControl().getParent().setForeground(color);
79
	}
80

    
81
	/**
82
	 * <p>setFocus</p>
83
	 *
84
	 * @return color a {@link org.eclipse.swt.graphics.Color} object.
85
	 */
86
	public boolean setFocus() {
87
		return getControl().setFocus();
88
	}
89

    
90
	/**
91
	 * Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
92
	 *
93
	 * @param font the new font (or null) 
94
	 */
95
	public void setFont(Font font)
96
	{
97
		getTable().getItem(0).setFont(font);
98
	}
99

    
100
	/**
101
	 * <p>setIcon</p>
102
	 *
103
	 * @param icon a {@link org.eclipse.swt.graphics.Image} object.
104
	 */
105
	public void setIcon(Image icon) {
106
		getTable().getItem(0).setImage(icon);
107
	}
108
	
109
	
110
	/**
111
	 * <p>setText</p>
112
	 *
113
	 * @param text a {@link java.lang.String} object.
114
	 */
115
	public void setText(String text) {
116
		getTable().getItem(0).setText(text);
117
	}
118

    
119
	/**
120
	 * <p>getText</p>
121
	 *
122
	 * @return a {@link java.lang.String} object.
123
	 */
124
	public String getText() {
125
		return getTable().getItem(0).getText();
126
	}
127

    
128
	/**
129
	 * <p>setMenu</p>
130
	 *
131
	 * @param menu a {@link org.eclipse.swt.widgets.Menu} object.
132
	 */
133
	public void setMenu(Menu menu) {
134
		getControl().setMenu(menu);
135
	}
136

    
137
	/**
138
	 * Adds the listener to the collection of listeners who will be notified when the NameViewer gains or loses focus, by sending it one of the messages defined in the FocusListener interface.
139
	 *     
140
	 * @param listener the listener which should be notified
141
	 * 
142
	 * @throws IllegalArgumentException
143
	 * @throws SWTException
144
	 */
145
	public void addFocusListener(FocusListener listener)
146
	{
147
		getControl().addFocusListener(listener);
148
	}
149

    
150
	/**
151
	 * Removes the listener to the collection of listeners who will be notified when the NameViewer gains or loses focus, by sending it one of the messages defined in the FocusListener interface.
152
	 *     
153
	 * @param listener the listener which should be notified
154
	 * 
155
	 * @throws IllegalArgumentException
156
	 * @throws SWTException
157
	 */
158
	public void removeFocusListener(FocusListener listener)
159
	{
160
		getControl().removeFocusListener(listener);
161
	}
162

    
163
	/**
164
	 * Adds the listener to the collection of listeners who will be notified when mouse buttons are pressed and released.
165
	 *     
166
	 * @param listener the listener which should be notified
167
	 * 
168
	 * @throws IllegalArgumentException
169
	 * @throws SWTException
170
	 */
171
	public void addMouseListener(MouseListener listener)
172
	{
173
		getControl().addMouseListener(listener);
174
	}
175

    
176
	/**
177
	 * Removes the listener to the collection of listeners who will be notified when mouse buttons are pressed and released.
178
	 *     
179
	 * @param listener the listener which should be notified
180
	 * 
181
	 * @throws IllegalArgumentException
182
	 * @throws SWTException
183
	 */
184
	public void removeMouseListener(MouseListener listener)
185
	{
186
		getControl().removeMouseListener(listener);
187
	}
188

    
189
	/**
190
	 * Adds the listener to the collection of listeners who will be notified when the text is modified.
191
	 *     
192
	 * @param listener the listener which should be notified
193
	 * 
194
	 * @throws IllegalArgumentException
195
	 * @throws SWTException
196
	 */
197
	public void addModifyListener(ModifyListener listener)
198
	{
199
		ModifyEvent.addListener(getControl(), listener);
200
	}
201

    
202
	/**
203
	 * Removes the listener to the collection of listeners who will be notified when the text is modified.
204
	 *     
205
	 * @param listener the listener which should be notified
206
	 * 
207
	 * @throws IllegalArgumentException
208
	 * @throws SWTException
209
	 */
210
	public void removeModifyListener(ModifyListener listener)
211
	{
212
		ModifyEvent.removeListener(getControl(), listener);
213
	}
214

    
215
	/**
216
	 * Adds the listener to the collection of listeners who will be notified when the text is about to be modified.
217
	 *     
218
	 * @param listener the listener which should be notified
219
	 * 
220
	 * @throws IllegalArgumentException
221
	 * @throws SWTException
222
	 */
223
	public void addVerifyListener(VerifyListener listener)
224
	{
225
		VerifyEvent.addListener(getControl(), listener);
226
	}
227

    
228
	/**
229
	 * Removes the listener to the collection of listeners who will be notified when the text is about to be modified.
230
	 *     
231
	 * @param listener the listener which should be notified
232
	 * 
233
	 * @throws IllegalArgumentException
234
	 * @throws SWTException
235
	 */
236
	public void removeVerifyListener(VerifyListener listener)
237
	{
238
		VerifyEvent.removeListener(getControl(), listener);
239
	}
240

    
241

    
242
	/**
243
	 * Sets the editable state.
244
	 * 
245
	 * @param editable the editable state
246
	 * @throws OperationNotSupportedException 
247
	 * @link org.eclipse.jface.text.ITextViewer
248
	 */
249
	public void setEditable(boolean editable) throws OperationNotSupportedException
250
	{
251
		throw new OperationNotSupportedException("NameViewer.setEditable(boolean) not supported !");
252
	}
253

    
254
	/**
255
	 * Enables the receiver if the argument is true, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.
256
	 *
257
	 * @param enabled the new enabled state
258
	 * @throws OperationNotSupportedException 
259
	 * 
260
	 * @link org.eclipse.swt.widgets.Control 
261
	 */
262
	public void setEnabled(boolean enabled) throws OperationNotSupportedException
263
	{
264
		throw new OperationNotSupportedException("NameViewer.setEnabled(boolean) not supported !");
265
	}
266

    
267
	/**
268
	 * Gets the control, which is supposed to be draggable
269
	 * @return draggable control
270
	 */
271
	public Control getDraggableControl()
272
	{
273
		return getControl();
274
	}
275

    
276
	/**
277
	 * Gets the Ruler, if implemented
278
	 * @return Ruler
279
	 * 
280
	 * @throws OperationNotSupportedException If VerticalRulers were not available (RAP)
281
	 */
282
	public Control getVerticalRulerControl() throws OperationNotSupportedException
283
	{
284
		throw new OperationNotSupportedException("NameViewer.getVerticalRulerControl() not supported !");
285
	}
286
	/**
287
	 * Gets the StyledTextWidget, if implemented
288
	 * @return text widget
289
	 * 
290
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
291
	 */
292
	public Widget getStyledText() throws OperationNotSupportedException
293
	{
294
		throw new OperationNotSupportedException("NameViewer.getStyledText() not supported !");
295
	}
296

    
297
	/**
298
	 * Gets the SourceViewer's document text, if implemented
299
	 * @return document
300
	 * 
301
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
302
	 */
303
	public String getDocumentAsString() throws OperationNotSupportedException
304
	{
305
		throw new OperationNotSupportedException("NameViewer.getDocumentAsString() not supported !");
306
	}
307

    
308
	/**
309
	 * Sets the SourceViewer's document text, if implemented
310
	 * @param text
311
	 * 
312
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
313
	 */
314
	public void setDocumentAsString(String text) throws OperationNotSupportedException
315
	{
316
		throw new OperationNotSupportedException("NameViewer.setDocumentAsString(String) not supported !");
317
	}
318

    
319
	/**
320
	 * Gets the SourceViewer's document, if implemented
321
	 * @return document
322
	 * 
323
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
324
	 */
325
	public int getDocumentLength() throws OperationNotSupportedException
326
	{
327
		throw new OperationNotSupportedException("NameViewer.getDocumentLength() not supported !");
328
	}
329

    
330
	/**
331
	 * <p>setCursorToEOL</p>
332
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
333
	 */
334
	public void setCursorToEOL() throws OperationNotSupportedException
335
	{
336
		throw new OperationNotSupportedException("NameViewer.setCursorToEOL() not supported !");
337
	}
338

    
339
	/**
340
	 * <p>getCursorPosition</p>
341
	 *
342
	 * @return a int.
343
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
344
	 */
345
	public int getCursorPosition() throws OperationNotSupportedException
346
	{
347
		throw new OperationNotSupportedException("NameViewer.getCursorPosition() not supported !");
348
	}
349

    
350
	/**
351
	 * <p>setCursorPosition</p>
352
	 *
353
	 * @param offset a int.
354
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
355
	 */
356
	public void setCursorPosition(int offset) throws OperationNotSupportedException
357
	{
358
		throw new OperationNotSupportedException("NameViewer.setCursorPosition(int) not supported !");
359
	}
360

    
361
	/**
362
	 * <p>createUndoSupport</p>
363
	 *
364
	 * @param editorSite a {@link org.eclipse.ui.IEditorSite} object.
365
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
366
	 */
367
	public void createUndoSupport(IEditorSite editorSite) throws OperationNotSupportedException
368
	{
369
		throw new OperationNotSupportedException("NameViewer.createUndoSupport(IEditorSite) not supported !");
370
	}
371

    
372
	/**
373
	 * <p>createUndoSupport_</p>
374
	 *
375
	 * @param editorSite a {@link org.eclipse.ui.IEditorSite} object.
376
	 * @throws OperationNotSupportedException if functionality is not available (in RAP)
377
	 */
378
	public void createUndoSupport_(IEditorSite editorSite) throws OperationNotSupportedException
379
	{
380
		throw new OperationNotSupportedException("NameViewer.createUndoSupport_(IEditorSite) not supported !");
381
	}
382
	/**
383
	 * <p>clearAnnotations</p>
384
	 */
385
	public void clearAnnotations() throws OperationNotSupportedException
386
	{
387
		throw new OperationNotSupportedException("NameViewer.clearAnnotations() not supported !");
388
	}
389

    
390
	@Override
391
	public void addAnnotation(IEditorAnnotation annotation, IPosition position) throws OperationNotSupportedException
392
	{
393
		throw new OperationNotSupportedException("NameViewer.addAnnotation(EditorAnnotationFacade,Object) not supported !");
394
	}
395
}
396

    
(4-4/4)