KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > composer > text > TextEditorController


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.composer.text;
17
18 import java.awt.Font JavaDoc;
19 import java.util.Observable JavaDoc;
20 import java.util.Observer JavaDoc;
21
22 import javax.swing.JComponent JavaDoc;
23 import javax.swing.JTextPane JavaDoc;
24 import javax.swing.event.CaretEvent JavaDoc;
25 import javax.swing.event.CaretListener JavaDoc;
26 import javax.swing.event.DocumentEvent JavaDoc;
27 import javax.swing.event.DocumentListener JavaDoc;
28
29 import org.columba.core.config.Config;
30 import org.columba.core.gui.base.HighlighterDocument;
31 import org.columba.core.xml.XmlElement;
32 import org.columba.mail.gui.composer.AbstractEditorController;
33 import org.columba.mail.gui.composer.ComposerController;
34
35
36 /**
37  * Editor controller used when composing plain text mails.
38  *
39  * @author frd, Karl Peder Olesen (karlpeder)
40  *
41  */

42 public class TextEditorController extends AbstractEditorController
43     {
44
45     /** The editor view, i.e. the component used for editing text */
46     private TextEditorView view;
47
48     /** Document used in the editor view */
49     private HighlighterDocument document;
50
51
52
53     public TextEditorController(ComposerController controller) {
54         super(controller);
55
56
57         document = new HighlighterDocument();
58
59         view = new TextEditorView(this, document);
60         setView(view);
61
62        // view.addCaretListener(this);
63

64
65     }
66
67
68 // public void installListener() {
69
// view.installListener(this);
70
// }
71

72 // public void updateComponents(boolean b) {
73
// if (b) {
74
// if (this.getController().getModel().getBodyText() != null) {
75
// view.setText(controller.getModel().getBodyText());
76
// } else {
77
// view.setText("");
78
// }
79
// } else {
80
// if (view.getText() != null) {
81
// this.getController().getModel().setBodyText(view.getText());
82
// }
83
// }
84
// }
85

86
87     @Override JavaDoc
88     public void undo() {
89         document.undo();
90     }
91
92     @Override JavaDoc
93     public void redo() {
94         document.redo();
95     }
96
97     /************* DocumentListener implementation *******************/
98 // public void insertUpdate(DocumentEvent e) {
99
// }
100
//
101
// public void removeUpdate(DocumentEvent e) {
102
// }
103
//
104
// public void changedUpdate(DocumentEvent e) {
105
// }
106

107
108
109     /************************** CaretUpdateListener interface *****************/
110
111     /* (non-Javadoc)
112      * @see javax.swing.event.CaretListener#caretUpdate(javax.swing.event.CaretEvent)
113      */

114 // public void caretUpdate(CaretEvent arg0) {
115
// //FocusManager.getInstance().updateActions();
116
// }
117

118
119
120     /* (non-Javadoc)
121      * @see org.columba.mail.gui.composer.AbstractEditorController#setViewText(java.lang.String)
122      */

123     public void setViewText(String JavaDoc text) {
124         view.setText(text);
125         view.revalidate();
126     }
127
128
129
130
131
132
133 }
134
Popular Tags