Configuration reader
This commit is contained in:
parent
fa22dc688e
commit
2c93aad7a4
1 changed files with 69 additions and 0 deletions
|
@ -0,0 +1,69 @@
|
|||
package pro.litvinovg.w2phtml.gui;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
|
||||
import pro.litvinovg.xml.Debug;
|
||||
|
||||
public class ConfigurationReader {
|
||||
|
||||
List checkBoxes = new ArrayList<javax.swing.JCheckBox>();
|
||||
List textFields = new ArrayList<javax.swing.JTextField>();
|
||||
List labels = new ArrayList<javax.swing.JLabel>();
|
||||
private XComponentContext context;
|
||||
|
||||
|
||||
public ConfigurationReader(HashMap<String, Component> configuration, XComponentContext context) {
|
||||
this.context = context;
|
||||
readOptions(configuration);
|
||||
}
|
||||
|
||||
private void readOptions(HashMap<String, Component> configuration) {
|
||||
Set<String> options = configuration.keySet();
|
||||
for (String optionName : options) {
|
||||
//Debug.printLog(string, context);
|
||||
String optionValue = null;
|
||||
Component component = configuration.get(optionName);
|
||||
if (component.getClass().equals(JTextField.class)) {
|
||||
optionValue = ((JTextField) component).getText();
|
||||
} else if (component.getClass().equals(JCheckBox.class)) {
|
||||
optionValue = Boolean.toString(((JCheckBox) component).isSelected());
|
||||
} else if (component.getClass().equals(JLabel.class)) {
|
||||
optionValue = ((JLabel) component).getText();
|
||||
}
|
||||
Debug.printLog(optionName + " : " + optionValue, context);
|
||||
|
||||
}
|
||||
/*for (Component component : components) {
|
||||
if (component.getClass().equals(JTextField.class)) {
|
||||
textFields.add(component);
|
||||
} else if (component.getClass().equals(JCheckBox.class)) {
|
||||
checkBoxes.add(component);
|
||||
} else if (component.getClass().equals(JLabel.class)) {
|
||||
labels.add(component);
|
||||
}
|
||||
}
|
||||
for (Iterator iterator = checkBoxes.iterator(); iterator.hasNext();) {
|
||||
JCheckBox checkBox = (JCheckBox) iterator.next();
|
||||
checkBox.get
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
public String[] getCommandLine() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue