001: /*
002: JSmooth: a VM wrapper toolkit for Windows
003: Copyright (C) 2003 Rodrigo Reyes <reyes@charabia.net>
004:
005: This program is free software; you can redistribute it and/or modify
006: it under the terms of the GNU General Public License as published by
007: the Free Software Foundation; either version 2 of the License, or
008: (at your option) any later version.
009:
010: This program is distributed in the hope that it will be useful,
011: but WITHOUT ANY WARRANTY; without even the implied warranty of
012: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: GNU General Public License for more details.
014:
015: You should have received a copy of the GNU General Public License
016: along with this program; if not, write to the Free Software
017: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
018:
019: */
020:
021: package net.charabia.jsmoothgen.application.gui.editors;
022:
023: import net.charabia.jsmoothgen.skeleton.*;
024: import net.charabia.jsmoothgen.application.*;
025: import net.charabia.jsmoothgen.application.gui.*;
026: import net.charabia.jsmoothgen.application.gui.util.*;
027: import javax.swing.*;
028: import java.awt.event.*;
029: import java.util.*;
030: import com.l2fprod.common.swing.*;
031: import com.l2fprod.common.propertysheet.*;
032:
033: import se.datadosen.component.RiverLayout;
034:
035: public class SkeletonChooser extends Editor implements
036: JSmoothModelBean.SkeletonChangedListener {
037: private JComboBox m_skelcombo = new JComboBox();
038: // private HTMLPane m_skeldesc = new HTMLPane() {
039: // public java.awt.Dimension getPreferredSize()
040: // {
041: // java.awt.Dimension d = super.getPreferredSize();
042: // if (d.height<100)
043: // d.height=100;
044: // return d;
045: // }
046: // };
047:
048: private JEditorPane m_skeldesc = new JEditorPane("text/html",
049: "<html></html>");
050:
051: public SkeletonChooser() {
052: // PanelLayout pl = new PanelLayout();
053: // setLayout(pl);
054: setLayout(new RiverLayout());
055: m_skelcombo.addItem("<none>");
056: for (Iterator i = Main.SKELETONS.getIteratorNoDebugName(); i
057: .hasNext();) {
058: m_skelcombo.addItem(i.next().toString());
059: }
060: add("hfill", m_skelcombo);
061: JPanel jp = new JPanel();
062: jp.setLayout(new java.awt.BorderLayout());
063: jp.add(new JScrollPane(m_skeldesc) {
064: public java.awt.Dimension getMinimumSize() {
065: return new java.awt.Dimension(10, 100);
066: }
067:
068: public java.awt.Dimension getPreferredSize() {
069: return new java.awt.Dimension(10, 100);
070: }
071: }, java.awt.BorderLayout.CENTER);
072: add("br hfill", jp);
073: m_skeldesc.setEditable(false);
074: m_skelcombo
075: .addActionListener(new java.awt.event.ActionListener() {
076: public void actionPerformed(
077: java.awt.event.ActionEvent evt) {
078: updateModel();
079: doLayout();
080: validate();
081: repaint();
082: }
083: });
084: }
085:
086: private void updateSkeletonData() {
087: String skelname = (String) m_skelcombo.getSelectedItem();
088: if (skelname == null)
089: return;
090:
091: SkeletonBean skel = Main.SKELETONS.getSkeleton(skelname);
092:
093: // System.out.println("SKEL: " + skel.toString());
094: if (skel != null) {
095: m_skeldesc.setText(Main.local(skel.getDescription()));
096: m_skeldesc.setCaretPosition(0);
097: }
098: }
099:
100: public void dataChanged() {
101: String skelname = m_model.getSkeletonName();
102: if (skelname != null) {
103: SkeletonBean skel = Main.SKELETONS.getSkeleton(skelname);
104: if (skel != null) {
105: m_skeldesc.setText(Main.local(skel.getDescription()));
106: m_skeldesc.setCaretPosition(0);
107: m_skelcombo.setSelectedItem(skelname);
108: } else {
109: m_skelcombo.setSelectedItem("");
110: m_skeldesc.setText("");
111: m_skeldesc.setCaretPosition(0);
112: }
113: } else {
114: m_skelcombo.setSelectedItem("");
115: m_skeldesc.setText(Main.local("SKEL_CHOOSER_NONE"));
116: m_skeldesc.setCaretPosition(0);
117: }
118: }
119:
120: public void updateModel() {
121: String skelname = (String) m_skelcombo.getSelectedItem();
122: if (skelname == null)
123: return;
124:
125: if (skelname.equals("<none>"))
126: skelname = "<none>";
127:
128: m_model.setSkeletonName(skelname);
129: }
130:
131: public String getLabel() {
132: return "SKELETONCHOOSER_LABEL";
133: }
134:
135: public String getDescription() {
136: return "SKELETONCHOOSER_HELP";
137: }
138:
139: public void skeletonChanged() {
140: dataChanged();
141: }
142:
143: public boolean needsBigSpace() {
144: return true;
145: }
146:
147: }
|