01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.gui.text;
19:
20: import java.awt.Dimension;
21: import java.util.logging.Logger;
22:
23: import javax.swing.ImageIcon;
24:
25: import de.finix.contelligent.client.gui.AbstractGUI;
26: import de.finix.contelligent.client.gui.ComponentEditor;
27: import de.finix.contelligent.client.gui.ComponentRenderer;
28: import de.finix.contelligent.client.gui.GUI;
29: import de.finix.contelligent.client.gui.UnsupportedGUIException;
30: import de.finix.contelligent.client.i18n.Resources;
31:
32: public class StyledTextGUI extends AbstractGUI {
33:
34: private static Logger logger = Logger.getLogger(TextGUI.class
35: .getName());
36:
37: private TextEditor textEditor = null;
38:
39: private void assureTextEditorCreated(boolean editable) {
40: if (textEditor == null) {
41: textEditor = new TextEditor();
42: textEditor.setComponent(getComponent());
43: textEditor.setView(getView());
44: textEditor.setEditable(editable);
45: textEditor.setGUI(this );
46: textEditor
47: .setFeatureSet(ContelligentEditorKit.HANDLE_CONTELLIGENT_TAG
48: | ContelligentEditorKit.HANDLE_MARKUP);
49: textEditor.setType("text");
50: textEditor.init();
51: } else if (textEditor.isEditable() != editable) {
52: // only change this, if neccessary as it may take quite some time...
53: textEditor.setEditable(editable);
54: }
55: }
56:
57: public boolean isSupported(int type) {
58: return (type == DEFAULT || type == TABLE);
59: }
60:
61: public ComponentEditor getEditor(int type)
62: throws UnsupportedGUIException {
63: if (!isSupported(type)) {
64: throw new UnsupportedGUIException(getComponent());
65: }
66: assureTextEditorCreated(true);
67: if (type == GUI.TABLE) {
68: textEditor.setPreferredSize(new Dimension(0, 120));
69: }
70: return textEditor;
71: }
72:
73: public ComponentRenderer getRenderer(int type)
74: throws UnsupportedGUIException {
75: if (!isSupported(type)) {
76: throw new UnsupportedGUIException(getComponent());
77: }
78: assureTextEditorCreated(false);
79: if (type == GUI.TABLE) {
80: textEditor.setPreferredSize(new Dimension(0, 120));
81: }
82: return textEditor;
83: }
84:
85: public String getName() {
86: return Resources.getLocalString("styled_text_gui");
87: }
88:
89: public ImageIcon getIcon() {
90: return Resources.htmlGUI;
91: }
92:
93: public boolean isCategorySensitive() {
94: return true;
95: }
96: }
|