01: package com.xoetrope.svgscanner.wizard;
02:
03: import java.util.ArrayList;
04: import javax.swing.JCheckBox;
05: import javax.swing.DefaultListModel;
06:
07: import net.xoetrope.xui.data.XModel;
08: import net.xoetrope.swing.XEdit;
09: import net.xoetrope.swing.XList;
10: import net.xoetrope.swing.XRadioButton;
11:
12: import net.xoetrope.optional.annotation.Find;
13: import com.xoetrope.svgscanner.model.SynthModel;
14:
15: import com.xoetrope.swing.wizard.XWizard;
16:
17: /**
18: * An implementation class for the specific details of the new binding key's
19: * style setup
20: *
21: * <p> Copyright (c) Xoetrope Ltd., 2001-2007, This software is licensed under
22: * the GNU Public License (GPL), please see license.txt for more details. If
23: * you make commercial use of this software you must purchase a commercial
24: * license from Xoetrope.</p>
25: * <p>$Revision: 1.7 $</p>
26: */
27: public class BindingWizardStyles extends BindingWizardPage {
28: @Find
29: private XList stylesList;
30:
31: @Find
32: private XEdit styleNameEdit;
33:
34: @Find
35: private XRadioButton existingRb;
36:
37: private SynthModel synthModel;
38:
39: /**
40: * Creates a new instance of BindingWizardKeys
41: */
42: public BindingWizardStyles() {
43: synthModel = (SynthModel) ((XModel) rootModel.get("SynthModel"))
44: .get();
45: }
46:
47: public void pageCreated() {
48: fillStylesList();
49: }
50:
51: private void fillStylesList() {
52: stylesList.removeAll();
53:
54: ArrayList<String> names = synthModel.getStyleNames();
55: for (String name : names)
56: stylesList.addItem(name);
57: }
58:
59: public boolean canAdvance() {
60: return ((existingRb.isSelected() && (stylesList.getItemCount() > 0)) || (styleNameEdit
61: .getText().trim().length() > 0));
62: }
63:
64: public void useExisting() {
65: stylesList.setEnabled(true);
66: styleNameEdit.setEnabled(false);
67: }
68:
69: public void useNew() {
70: stylesList.setEnabled(false);
71: styleNameEdit.setEnabled(true);
72: }
73:
74: public void saveSettings() {
75: /** @todo use data bindings for the properties */
76: if (!existingRb.isSelected()) {
77: wizard.setProperty("NewStyleKey", true);
78: wizard.setProperty("StyleName", styleNameEdit.getText());
79: } else
80: wizard.setProperty("StyleName", stylesList
81: .getSelectedObject().toString());
82: }
83: }
|