1
/*FreeMind - A Program for creating and viewing Mindmaps
2
*Copyright (C) 2000-2006 Joerg Mueller, Daniel Polansky, Christian Foltin and others.
4
*See COPYING for Details
6
*This program is free software; you can redistribute it and/or
7
*modify it under the terms of the GNU General Public License
8
*as published by the Free Software Foundation; either version 2
9
*of the License, or (at your option) any later version.
11
*This program is distributed in the hope that it will be useful,
12
*but WITHOUT ANY WARRANTY; without even the implied warranty of
13
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
*GNU General Public License for more details.
16
*You should have received a copy of the GNU General Public License
17
*along with this program; if not, write to the Free Software
18
*Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* Created on 25.02.2006
22
/*$Id: ScriptEditorProperty.java,v 1.1.2.6 2008/07/04 20:44:02 christianfoltin Exp $*/
23
package freemind.common;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27
import java.util.Iterator;
29
import javax.swing.JButton;
30
import javax.swing.JLabel;
31
import javax.swing.JPopupMenu;
33
import com.jgoodies.forms.builder.DefaultFormBuilder;
35
import freemind.main.HtmlTools;
36
import freemind.modes.mindmapmode.MindMapController;
37
import freemind.modes.mindmapmode.MindMapController.MindMapControllerPlugin;
39
public class ScriptEditorProperty extends PropertyBean implements
40
PropertyControl, ActionListener {
42
public interface ScriptEditorStarter extends MindMapControllerPlugin {
43
String startEditor(String scriptInput);
53
final JPopupMenu menu = new JPopupMenu();
55
private final MindMapController mMindMapController;
57
private static java.util.logging.Logger logger = null;
61
public ScriptEditorProperty(String description, String label,
62
MindMapController pMindMapController) {
64
this.description = description;
66
mMindMapController = pMindMapController;
68
logger = mMindMapController.getFrame().getLogger(
69
this.getClass().getName());
71
mButton = new JButton();
72
mButton.addActionListener(this);
76
public String getDescription() {
80
public String getLabel() {
84
public void setValue(String value) {
85
setScriptValue(value);
88
public String getValue() {
89
return HtmlTools.unicodeToHTMLUnicodeEntity(HtmlTools.toXMLEscapedText(script));
92
public void layout(DefaultFormBuilder builder, TextTranslator pTranslator) {
93
JLabel label = builder.append(pTranslator.getText(getLabel()), mButton);
94
label.setToolTipText(pTranslator.getText(getDescription()));
97
public void actionPerformed(ActionEvent arg0) {
98
// search for plugin that handles the script editor.
99
for (Iterator iter = mMindMapController.getPlugins().iterator(); iter
101
MindMapControllerPlugin plugin = (MindMapControllerPlugin) iter
103
if (plugin instanceof ScriptEditorStarter) {
104
ScriptEditorStarter starter = (ScriptEditorStarter) plugin;
105
String resultScript = starter.startEditor(script);
106
if (resultScript != null) {
107
script = resultScript;
108
firePropertyChangeEvent();
116
private void setScriptValue(String result) {
117
if (result == null) {
120
script = HtmlTools.toXMLUnescapedText(HtmlTools.unescapeHTMLUnicodeEntity(result));
121
logger.fine("Setting script to " +script);
122
mButton.setText(script);
127
// private Color getColorValue() {
131
public void setEnabled(boolean pEnabled) {
132
mButton.setEnabled(pEnabled);