001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.mail.gui.composer.text;
017:
018: import java.awt.Font;
019: import java.util.Observable;
020: import java.util.Observer;
021:
022: import javax.swing.JComponent;
023: import javax.swing.JTextPane;
024: import javax.swing.event.CaretEvent;
025: import javax.swing.event.CaretListener;
026: import javax.swing.event.DocumentEvent;
027: import javax.swing.event.DocumentListener;
028:
029: import org.columba.core.config.Config;
030: import org.columba.core.gui.base.HighlighterDocument;
031: import org.columba.core.xml.XmlElement;
032: import org.columba.mail.gui.composer.AbstractEditorController;
033: import org.columba.mail.gui.composer.ComposerController;
034:
035: /**
036: * Editor controller used when composing plain text mails.
037: *
038: * @author frd, Karl Peder Olesen (karlpeder)
039: *
040: */
041: public class TextEditorController extends AbstractEditorController {
042:
043: /** The editor view, i.e. the component used for editing text */
044: private TextEditorView view;
045:
046: /** Document used in the editor view */
047: private HighlighterDocument document;
048:
049: public TextEditorController(ComposerController controller) {
050: super (controller);
051:
052: document = new HighlighterDocument();
053:
054: view = new TextEditorView(this , document);
055: setView(view);
056:
057: // view.addCaretListener(this);
058:
059: }
060:
061: // public void installListener() {
062: // view.installListener(this);
063: // }
064:
065: // public void updateComponents(boolean b) {
066: // if (b) {
067: // if (this.getController().getModel().getBodyText() != null) {
068: // view.setText(controller.getModel().getBodyText());
069: // } else {
070: // view.setText("");
071: // }
072: // } else {
073: // if (view.getText() != null) {
074: // this.getController().getModel().setBodyText(view.getText());
075: // }
076: // }
077: // }
078:
079: @Override
080: public void undo() {
081: document.undo();
082: }
083:
084: @Override
085: public void redo() {
086: document.redo();
087: }
088:
089: /************* DocumentListener implementation *******************/
090: // public void insertUpdate(DocumentEvent e) {
091: // }
092: //
093: // public void removeUpdate(DocumentEvent e) {
094: // }
095: //
096: // public void changedUpdate(DocumentEvent e) {
097: // }
098:
099: /************************** CaretUpdateListener interface *****************/
100:
101: /* (non-Javadoc)
102: * @see javax.swing.event.CaretListener#caretUpdate(javax.swing.event.CaretEvent)
103: */
104: // public void caretUpdate(CaretEvent arg0) {
105: // //FocusManager.getInstance().updateActions();
106: // }
107:
108: /* (non-Javadoc)
109: * @see org.columba.mail.gui.composer.AbstractEditorController#setViewText(java.lang.String)
110: */
111: public void setViewText(String text) {
112: view.setText(text);
113: view.revalidate();
114: }
115:
116: }
|