KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > config > CfgGeneral


1 /*
2  * Authors:
3  * Stefanovic Nenad chupo@iis.ns.ac.yu
4  * Bojanic Sasa sasaboy@neobee.net
5  *
6  */

7
8 package org.enhydra.jawe.config;
9
10
11
12 import java.awt.*;
13 import javax.swing.*;
14
15 import org.enhydra.jawe.*;
16 import org.enhydra.jawe.misc.PFLocale;
17
18 public class CfgGeneral extends BaseConfigPane{
19
20    private JTextField txtRecentList, txtEncoding;
21    private JComboBox startingLocale, conformanceClass;
22    private JCheckBox validationStatus, useBubblesStatus, allowUndefinedStart,
23       allowUndefinedEnd, fileLockingStatus;
24
25    private String JavaDoc[] confClasses = {"", "FULL_BLOCKED", "LOOP_BLOCKED", "NON_BLOCKED"};
26
27    public CfgGeneral(String JavaDoc name){
28
29       super(name);
30
31       validationStatus = new JCheckBox();
32       addComponent("Config.General.Validation.Label",validationStatus);
33
34       useBubblesStatus = new JCheckBox();
35       addComponent("Config.General.UseBubbles.Label",useBubblesStatus);
36
37       allowUndefinedStart=new JCheckBox();
38       addComponent("Config.General.AllowUndefinedStartActivity.Label",allowUndefinedStart);
39
40       allowUndefinedEnd=new JCheckBox();
41       addComponent("Config.General.AllowUndefinedEndActivity.Label",allowUndefinedEnd);
42
43       startingLocale = new JComboBox();
44       refillStartingLanguageCombo();
45       addComponent("Config.General.StartingLanguage.Label",startingLocale );
46
47       conformanceClass =new JComboBox();
48       refillConformanceClassCombo();
49       boolean mccst=JaWEConfig.getInstance().getMandatoryConformanceClassSettingStatus();
50       if (mccst) {
51          addComponent("Config.General.MandatoryConformanceClass.Label",conformanceClass);
52       } else {
53          conformanceClass.setVisible(false);
54       }
55
56       txtRecentList = new JTextField();
57       addComponent("Config.General.RecentFileListSize.Label", txtRecentList);
58
59       txtEncoding = new JTextField();
60       addComponent("Config.General.Encoding.Label", txtEncoding);
61
62       fileLockingStatus=new JCheckBox();
63       addComponent("Config.General.FileLocking.Label",fileLockingStatus);
64
65       readConf();
66    }
67
68    public void readConf(){
69       validationStatus.setSelected(JaWEConfig.getInstance().getValidationStatus());
70       useBubblesStatus.setSelected(JaWEConfig.getInstance().getUseBubblesStatus());
71       allowUndefinedStart.setSelected(JaWEConfig.getInstance().getAllowUndefinedStartActivity());
72       allowUndefinedEnd.setSelected(JaWEConfig.getInstance().getAllowUndefinedEndActivity());
73       startingLocale.setSelectedItem(
74                                      PFLocale.createPFLocale(JaWEConfig.getInstance().getStartingLocale()));
75       txtRecentList.setText(
76                             Integer.toString(JaWEConfig.getInstance().getRecentFileListSize()));
77       txtEncoding.setText(JaWEConfig.getInstance().getEncoding());
78       conformanceClass.setSelectedItem(
79                                        ResourceManager.getLanguageDependentString(JaWEConfig.getInstance().getMandatoryConformanceClass()+"Key"));
80       fileLockingStatus.setSelected(JaWEConfig.getInstance().getFileLockingStatus());
81    }
82
83    public void save(){
84       JaWEConfig.getInstance().setValidationStatus(validationStatus.isSelected());
85       JaWEConfig.getInstance().setUseBubblesStatus(useBubblesStatus.isSelected());
86       JaWEConfig.getInstance().setAllowUndefinedStartActivity(allowUndefinedStart.isSelected());
87       JaWEConfig.getInstance().setAllowUndefinedEndActivity(allowUndefinedEnd.isSelected());
88       Object JavaDoc selSl=startingLocale.getSelectedItem();
89       if (selSl instanceof PFLocale) {
90          JaWEConfig.getInstance().setStartingLocale(((PFLocale)selSl).getLocaleString());
91       } else {
92          JaWEConfig.getInstance().setStartingLocale("");
93       }
94       JaWEConfig.getInstance().setRecentFileListSize(
95                                                      Integer.parseInt(txtRecentList.getText()));
96       JaWEConfig.getInstance().setEncoding(txtEncoding.getText());
97       int si=conformanceClass.getSelectedIndex();
98       if (si==-1) si=0;
99       JaWEConfig.getInstance().setMandatoryConformanceClass(confClasses[si]);
100       JaWEConfig.getInstance().setFileLockingStatus(fileLockingStatus.isSelected());
101    }
102
103    public Component getComponent(){
104       return this;
105    }
106
107    public void refreshLanguageDependentStrings () {
108       super.refreshLanguageDependentStrings();
109       refillConformanceClassCombo();
110       refillStartingLanguageCombo();
111    }
112
113    private void refillConformanceClassCombo () {
114       conformanceClass.removeAllItems();
115       conformanceClass.addItem("");
116       for (int i=1; i<4; i++) {
117          conformanceClass.addItem(ResourceManager.getLanguageDependentString(confClasses[i]+"Key"));
118       }
119    }
120
121    private void refillStartingLanguageCombo () {
122       startingLocale.removeAllItems();
123       startingLocale.addItem("");
124       java.util.List JavaDoc pfs=Utils.findPropertyFiles();
125       for (int i=0; i<pfs.size(); i++) {
126          startingLocale.addItem(pfs.get(i));
127       }
128    }
129
130 }
131
132
Popular Tags