From 2c93aad7a43e9e1d63fb1f9171268c0fe94b12c7 Mon Sep 17 00:00:00 2001
From: Georgy Litvinov <git@litvinovg.pro>
Date: Thu, 30 Jul 2020 14:25:34 +0200
Subject: [PATCH] Configuration reader

---
 .../w2phtml/gui/ConfigurationReader.java      | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationReader.java

diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationReader.java b/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationReader.java
new file mode 100644
index 0000000..77fd3d2
--- /dev/null
+++ b/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationReader.java
@@ -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;
+	}
+
+}