diff options
-rw-r--r-- | design/classdiagram.graphml | 387 | ||||
-rw-r--r-- | src/net/jesterpm/sermonuploader/SermonUploader.java | 57 | ||||
-rw-r--r-- | src/net/jesterpm/sermonuploader/config/Config.java | 39 | ||||
-rw-r--r-- | src/net/jesterpm/sermonuploader/control/ConfigureTask.java | 80 | ||||
-rw-r--r-- | src/net/jesterpm/sermonuploader/ui/ConfigurationWindow.java | 52 |
5 files changed, 615 insertions, 0 deletions
diff --git a/design/classdiagram.graphml b/design/classdiagram.graphml new file mode 100644 index 0000000..ed605e0 --- /dev/null +++ b/design/classdiagram.graphml @@ -0,0 +1,387 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd"> + <!--Created by yFiles for Java 2.9--> + <key for="graphml" id="d0" yfiles.type="resources"/> + <key for="port" id="d1" yfiles.type="portgraphics"/> + <key for="port" id="d2" yfiles.type="portgeometry"/> + <key for="port" id="d3" yfiles.type="portuserdata"/> + <key attr.name="url" attr.type="string" for="node" id="d4"/> + <key attr.name="description" attr.type="string" for="node" id="d5"/> + <key for="node" id="d6" yfiles.type="nodegraphics"/> + <key attr.name="Description" attr.type="string" for="graph" id="d7"/> + <key attr.name="url" attr.type="string" for="edge" id="d8"/> + <key attr.name="description" attr.type="string" for="edge" id="d9"/> + <key for="edge" id="d10" yfiles.type="edgegraphics"/> + <graph edgedefault="directed" id="G"> + <data key="d7"/> + <node id="n0"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="39.0" width="125.0" x="542.0" y="0.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="102.390625" x="11.3046875" y="10.515625">sermonuploader<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n1"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="30.0" x="116.5" y="79.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="14.939453125" x="7.5302734375" y="6.015625">ui<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n2"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="30.0" x="302.5" y="79.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="17.88671875" x="6.056640625" y="6.015625">s3<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n3"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="54.0" x="577.5" y="79.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="45.859375" x="4.0703125" y="6.015625">control<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n4"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="115.0" x="74.0" y="149.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="103.52734375" x="5.736328125" y="6.015625">ProgressWindow<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n5"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="147.0" x="208.99999999999997" y="149.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="132.958984375" x="7.020507812500028" y="6.015625">ConfigurationWindow<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n6"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="54.0" x="928.5" y="79.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="40.720703125" x="6.6396484375" y="6.015625">config<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n7"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="139.0" x="376.0" y="149.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="90.30859375" x="24.345703125" y="6.015625">ConfigureTask<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n8"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="139.0" x="535.0" y="149.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="73.931640625" x="32.5341796875" y="6.015625">UploadTask<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n9"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="139.0" x="694.0" y="149.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="130.755859375" x="4.1220703125" y="6.015625">UploadMetadataTask<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n10"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="115.0" x="898.0" y="149.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="42.501953125" x="36.2490234375" y="6.015625">Config<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n11"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="125.0" x="783.5" y="79.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="104.93359375" x="10.033203125" y="6.015625">SermonUploader<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <node id="n12"> + <data key="d5"/> + <data key="d6"> + <y:ShapeNode> + <y:Geometry height="30.0" width="54.0" x="0.0" y="149.0"/> + <y:Fill color="#FFCC00" transparent="false"/> + <y:BorderStyle color="#000000" type="line" width="1.0"/> + <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="41.79296875" x="6.103515625" y="6.015625">Action<y:LabelModel> + <y:SmartNodeLabelModel distance="4.0"/> + </y:LabelModel> + <y:ModelParameter> + <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/> + </y:ModelParameter> + </y:NodeLabel> + <y:Shape type="rectangle"/> + </y:ShapeNode> + </data> + </node> + <edge id="e0" source="n0" target="n1"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e1" source="n0" target="n2"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e2" source="n0" target="n3"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e3" source="n0" target="n6"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e4" source="n1" target="n4"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e5" source="n1" target="n5"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e6" source="n3" target="n7"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e7" source="n3" target="n8"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e8" source="n3" target="n9"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e9" source="n6" target="n10"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e10" source="n0" target="n11"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + <edge id="e11" source="n1" target="n12"> + <data key="d9"/> + <data key="d10"> + <y:PolyLineEdge> + <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/> + <y:LineStyle color="#000000" type="line" width="1.0"/> + <y:Arrows source="none" target="standard"/> + <y:BendStyle smoothed="false"/> + </y:PolyLineEdge> + </data> + </edge> + </graph> + <data key="d0"> + <y:Resources/> + </data> +</graphml> diff --git a/src/net/jesterpm/sermonuploader/SermonUploader.java b/src/net/jesterpm/sermonuploader/SermonUploader.java new file mode 100644 index 0000000..b3d623e --- /dev/null +++ b/src/net/jesterpm/sermonuploader/SermonUploader.java @@ -0,0 +1,57 @@ +/* + * Copyright 2012 Jesse Morgan + */ + +package net.jesterpm.sermonuploader; + +/** + * Application entry-point. + * + * @author Jesse Morgan <jesse@jesterpm.net> + */ +public class SermonUploader { + private static final String DEFAULT_CONFIG = System.getProperty("user.home") + + System.getProperty("file.separator") + ".sermonuploader"; + + public static void main(String... args) { + final Config appconfig = new Config(DEFAULT_CONFIG); + + if (args.length == 0) { + startConfigure(appconfig); + + } else { + if (args[0].equals("--help")) { + printHelp(); + } + + startUpload(appconfig, args[0]); + } + } + + private static void printHelp() { + System.out.println("SermonUploader - Podcast upload utility."); + System.out.println("Created by Jesse Morgan <jesse@jesterpm.net>"); + System.out.println("http://jesterpm.net/projects/sermonuploader"); + System.out.println(); + System.out.println("Usage: SermonUploader [directory]"); + System.out.println( + "\tWhen started with no arguments, the configuration dialog is opened."); + System.out.println("\tWhen started with one argument, it is assumed to " + + "be a directory with a metadata.txt file with upload instructions."); + System.out.println(); + } + + private static void startConfigure(final Config appconfig) { + ConfigurationWindow win = new ConfigurationWindow(); + ConfigureTask task = new ConfigureTask(appconfig, win); + + task.run(); + } + + public static void startUpload(final Config appconfig, final String dir) { + ProgressWindow win = new ProgressWindow(); + UploadTask task = new UploadTask(appconfig, win, dir); + + task.run(); + } +} diff --git a/src/net/jesterpm/sermonuploader/config/Config.java b/src/net/jesterpm/sermonuploader/config/Config.java new file mode 100644 index 0000000..d824464 --- /dev/null +++ b/src/net/jesterpm/sermonuploader/config/Config.java @@ -0,0 +1,39 @@ +/* + * Copyright 2012 Jesse Morgan + */ + +package net.jesterpm.sermonuploader.config; + +/** + * Configuration and metadata parser. + * + * @author Jesse Morgan <jesse@jesterpm.net> + */ +public class Config { + private final String mFilename; + private final Map<String, String> mConfig; + + /** + * Create a new Config object based on the given file. + */ + public Config(final String filename) { + mFilename = filename; + parse(); + } + + private void parse() { + + } + + public void save() { + + } + + public String get(final String key) { + return mConfig.get(key); + } + + public String put(final String key, final String obj) { + mConfig.put(key, obj); + } +} diff --git a/src/net/jesterpm/sermonuploader/control/ConfigureTask.java b/src/net/jesterpm/sermonuploader/control/ConfigureTask.java new file mode 100644 index 0000000..1960165 --- /dev/null +++ b/src/net/jesterpm/sermonuploader/control/ConfigureTask.java @@ -0,0 +1,80 @@ +/* + * Copyright 2012 Jesse Morgan + */ + +package net.jesterpm.sermonuploader.control; + +import net.jesterpm.sermonuploader.config.Config; + +import net.jesterpm.sermonuploader.ui.Action; +import net.jesterpm.sermonuploader.ui.ConfigurationWindow; + +/** + * Controller for the ConfigurationWindow. + * + * @author Jesse Morgan <jesse@jesterpm.net> + */ +public class ConfigureTask { + private final Config mAppConfig; + private final ConfigurationWindow mWin; + + public ConfigureTask(final Config appconfig, final ConfigurationWindow win) { + mAppConfig = appconfig; + mWin = win; + + mWin.setSaveAction(new Action() { + public void onAction() { + populateConfig(); + mAppConfig.save(); + mWin.setVisible(false); + }); + + mWin.setCancelAction(new Action() { + public void onAction() { + mWin.setVisible(false); + }); + + mWin.setAuthorizeAction(new Action() { + public void onAction() { + populateConfig(); + getAuthorization(); + }); + + populateWindow(); + } + + /** + * Set the fields in the configuration window. + */ + private void populateWindow() { + mWin.setAWSKey(Config.get("AWSAccessKeyId")); + mWin.setAWSSecret(Config.get("AWSSecretKey")); + mWin.setS3Bucket(Config.get("S3Bucket")); + mWin.setMetadataServer(Config.get("MetadataURL")); + mWin.setHasAuthKey(Config.get("MetadataAuthKey") != null); + } + + /** + * Populate the config from the window. + */ + private void populateConfig() { + Config.put("AWSAccessKeyId", mWin.getAWSKey()); + Config.put("AWSSecretKey", mWin.getAWSSecret()); + Config.put("S3Bucket", mWin.getS3Bucket()); + Config.put("MetadataURL", mWin.getMetadataServer()); + } + + /** + * Display the window. + */ + public void run() { + mWin.setVisible(true); + } + + /** + * Get an authorization token from the metadata service. + */ + private void getAuthorization() { + + } +} diff --git a/src/net/jesterpm/sermonuploader/ui/ConfigurationWindow.java b/src/net/jesterpm/sermonuploader/ui/ConfigurationWindow.java new file mode 100644 index 0000000..9dcc2dc --- /dev/null +++ b/src/net/jesterpm/sermonuploader/ui/ConfigurationWindow.java @@ -0,0 +1,52 @@ +/* + * Copyright 2012 Jesse Morgan + */ + +package net.jesterpm.sermonuploader.ui; + +/** + * UI for the configuration window. + * + * @author Jesse Morgan <jesse@jesterpm.net> + */ +public class ConfigurationWindow extends JFrame { + public ConfigurationWindow() { + // TODO: Build window. + } + + public void setAWSKey(final String value) { + + } + + public String getAWSKey() { + + } + + public void setAWSSecret(final String value) { + + } + + public String getAWSSecret() { + + } + + public void setS3Bucket(final String value) { + + } + + public String getS3Bucket() { + + } + + public void setMetadataServer(final String value) { + + } + + public String getMetadataServer() { + + } + + public void setHasAuthKey(final boolean value) { + + } +} |