Project

General

Profile

Download (2.96 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.apache.log4j.Logger;
15
import org.eclipse.swt.events.VerifyEvent;
16

    
17
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
18
import eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer;
19

    
20
/**
21
 * Checks text entered into a StyledText widget for line breaks, sends
22
 * split text to abstract method handleSplitText().
23
 *  <p>
24
 * VerifyListener interface methods break up the text into lines. Each line is sent individually
25
 * to the handleSplitText() method when the KeyListener interface method keyReleased() is called.
26
 * This is because if the StyledText widget is disposed before the key is released, an SWT
27
 * exception occurs.
28
 * <p>
29
 * The listener should be set on the StyledText widget as follows:
30
 * <code><pre>
31
 * 		StyledText styledText = new SourceViewer().getTextWidget();
32
 *		LineBreakListener lineBreakListener = new LineBreakListener() {
33
 *			public void handleSplitText(String text) {
34
 *				... some operation ...
35
 *			}
36
 *		};
37
 *
38
 *		styledText.addVerifyListener(lineBreakListener);
39
 *		styledText.addKeyListener(lineBreakListener);
40
 * </pre></code>
41
 *
42
 * @author p.ciardelli
43
 * @created 19.05.2008
44
 * @version 1.0
45
 */
46
public class LineBreakListenerFacadeImpl<T extends TaxonBase> extends LineBreakListenerFacade<T> {
47
	private static final Logger logger = Logger.getLogger(LineBreakListenerFacadeImpl.class);
48

    
49
	public LineBreakListenerFacadeImpl() {
50
		super();
51
	}
52

    
53
	public LineBreakListenerFacadeImpl(AbstractGroupedContainer<T> container) {
54
		super(container);
55
	}
56

    
57
	protected Object getInstanceInternal(AbstractGroupedContainer<T> container) throws OperationNotSupportedException 
58
	{
59
		throw new OperationNotSupportedException("LineBreakListener not supported.");
60
	}
61

    
62
	/**
63
	 * {@inheritDoc}
64
	 *
65
	 * Checks for 3 conditions of name viewer text:
66
	 *   1) no line breaks in text
67
	 *   2) line break at the end of the text
68
	 *   3) line break in the middle of the text
69
	 * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
70
	 */
71
	public void verifyText(VerifyEvent e) {
72
			try {
73
				throw new OperationNotSupportedException("LineBreakListener not supported.");
74
			} catch (OperationNotSupportedException e1) {
75
				logger.warn("LineBreakListenerFacedeImpl.verifyText(VerifyEvent): "+ e1.getMessage());
76
			}
77
	}
78
	
79
	/**
80
	 * <p>handleSplitText</p>
81
	 *
82
	 * @param text a {@link java.lang.String} object.
83
	 */
84
	public void handleSplitText(String text)
85
	{
86
		try {
87
			throw new OperationNotSupportedException("LineBreakListener not supported.");
88
		} catch (OperationNotSupportedException e) {
89
			logger.warn("LineBreakListenerFacedeImpl.verifyText(VerifyEvent): "+ e.getMessage());
90
		}
91
	}
92
}
(2-2/4)