im groben und ganzen funktionierts. ich kann keine guis.

This commit is contained in:
da
2015-11-06 21:42:03 +01:00
parent 64515bdeb7
commit 830f652139
12 changed files with 333 additions and 33 deletions
+5
View File
@@ -0,0 +1,5 @@
/.idea
/out
/jLSLauncher.iml
/config.dat
# Created by .ignore support plugin (hsz.mobi)
+4 -1
View File
@@ -17,12 +17,15 @@ public class Config implements Serializable {
}
public String getStreamName(int streamIndex) {
return this.streamNames.get(streamIndex-1);
return this.streamNames.get(streamIndex);
}
public void addStream(String streamName) {
this.streamNames.add(streamName);
}
public void removeStream(Object streamName) {
this.streamNames.remove(streamName);
}
public ArrayList<String> getStreams() {
return this.streamNames;
}
@@ -2,7 +2,7 @@ package com.ixab.ConfigHandling;
import java.io.*;
public class ConfigFileHandler {
public class ConfigFileIOHandler {
public static Config load(String path) {
Config c = null;
try
@@ -33,7 +33,7 @@ public class ConfigFileHandler {
out.writeObject(c);
out.close();
fileOut.close();
System.out.printf("Config data is saved in config.dat");
System.out.println("Config data is saved in config.dat");
}catch(IOException i)
{
i.printStackTrace();
@@ -0,0 +1,13 @@
package com.ixab.ConfigHandling;
public class ConfigFileInstanceHandler {
public static Config getConfig() {
return config;
}
public static void setConfig(Config c) {
config = c;
}
private static Config config;
}
+52
View File
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ixab.GUI.ConfigLoadMenu">
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="600" height="400"/>
</constraints>
<properties>
<minimumSize width="600" height="55"/>
<preferredSize width="600" height="55"/>
</properties>
<border type="none"/>
<children>
<component id="ddf9a" class="javax.swing.JTextField" binding="textField1" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
<enabled value="true"/>
</properties>
</component>
<component id="1ba2b" class="javax.swing.JButton" binding="auswählenButton" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Auswählen..."/>
</properties>
</component>
<component id="7f8c5" class="javax.swing.JButton" binding="ladeKonfigurationButton" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<text value="Lade Konfiguration"/>
</properties>
</component>
<component id="d3eb2" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Konfigurationsdatei:"/>
</properties>
</component>
</children>
</grid>
</form>
+52
View File
@@ -0,0 +1,52 @@
package com.ixab.GUI;
import com.ixab.ConfigHandling.Config;
import com.ixab.ConfigHandling.ConfigFileIOHandler;
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ConfigLoadMenu {
private static JFrame frame;
private JPanel panel;
private JTextField textField1;
private JButton auswählenButton;
private JButton ladeKonfigurationButton;
public ConfigLoadMenu() {
auswählenButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JFileChooser jf = new JFileChooser();
jf.showOpenDialog(frame);
textField1.setText(jf.getSelectedFile().getAbsolutePath());
ladeKonfigurationButton.setText("Lade Konfiguration");
ladeKonfigurationButton.setEnabled(true);
}
});
ladeKonfigurationButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Config c = ConfigFileIOHandler.load(textField1.getText());
if (c == null) {
ladeKonfigurationButton.setText("ACHTUNG: Fehler beim Laden, neue Datei wählen!");
ladeKonfigurationButton.setEnabled(false);
} else {
ConfigFileInstanceHandler.setConfig(c);
StreamChooserMenu.main(null);
frame.dispose();
}
}
});
}
public static void main(String[] args) {
frame = new JFrame("ConfigLoadMenu");
frame.setContentPane(new ConfigLoadMenu().panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
-4
View File
@@ -1,4 +0,0 @@
package com.ixab.GUI;
public class ConfigMenu {
}
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ixab.GUI.ConfigMenu">
<grid id="27dc6" row-count="1" column-count="1" layout-manager="GridLayoutManager">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ixab.GUI.Main">
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
+15
View File
@@ -0,0 +1,15 @@
package com.ixab.GUI;
import javax.swing.*;
public class Main {
private JPanel panel;
public static void main(String[] args) {
JFrame frame = new JFrame("Main");
frame.setContentPane(new Main().panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
+111 -4
View File
@@ -1,13 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ixab.GUI.StreamChooserMenu">
<grid id="27dc6" row-count="1" column-count="1" layout-manager="GridLayoutManager">
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="3" column-count="10" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<xy x="20" y="20" width="556" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
<children>
<component id="cb567" class="javax.swing.JComboBox" binding="comboBox1" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="6" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="c34b7" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Zuschauer:"/>
</properties>
</component>
<component id="65a1f" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="nyi"/>
</properties>
</component>
<hspacer id="a6e26">
<constraints>
<grid row="1" column="5" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="35b31" class="javax.swing.JComboBox" binding="comboBox2" default-binding="true">
<constraints>
<grid row="0" column="9" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="afcf8" class="javax.swing.JTextField" binding="textField1" default-binding="true">
<constraints>
<grid row="2" column="2" row-span="1" col-span="7" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="a3649" class="javax.swing.JButton" binding="hinzufügenButton" default-binding="true">
<constraints>
<grid row="2" column="9" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Hinzufügen"/>
</properties>
</component>
<component id="16c11" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Neuer Stream:"/>
</properties>
</component>
<component id="cb42d" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Stream:"/>
</properties>
</component>
<component id="bbe9d" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="39" height="14"/>
</grid>
</constraints>
<properties>
<text value="Status:"/>
</properties>
</component>
<component id="e40fa" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="nyi"/>
</properties>
</component>
<component id="be49e" class="javax.swing.JButton" binding="streamAbspielenButton" default-binding="true">
<constraints>
<grid row="1" column="9" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Stream abspielen"/>
</properties>
</component>
<component id="3b81f" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="8" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Qualität:"/>
</properties>
</component>
<component id="7c5a1" class="javax.swing.JButton" binding="entfernenButton" default-binding="true">
<constraints>
<grid row="0" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Entfernen"/>
</properties>
</component>
</children>
</grid>
</form>
+61
View File
@@ -1,4 +1,65 @@
package com.ixab.GUI;
import com.ixab.ConfigHandling.Config;
import com.ixab.ConfigHandling.ConfigFileIOHandler;
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
import com.ixab.StreamHandling.StreamOpener;
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class StreamChooserMenu {
private JPanel panel;
private JComboBox comboBox1;
private JComboBox comboBox2;
private JTextField textField1;
private JButton hinzufügenButton;
private JButton streamAbspielenButton;
private JButton entfernenButton;
public StreamChooserMenu() {
this.initComboBoxes();
streamAbspielenButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBox1.getSelectedItem()), comboBox2.getSelectedItem().toString());
so.start();
}
});
hinzufügenButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ConfigFileInstanceHandler.getConfig().addStream(textField1.getText());
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
initComboBoxes();
textField1.setText("");
}
});
entfernenButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ConfigFileInstanceHandler.getConfig().removeStream(comboBox1.getSelectedItem());
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
initComboBoxes();
}
});
}
public void initComboBoxes() {
comboBox1.removeAllItems();
comboBox2.removeAllItems();
for (String streamName :
ConfigFileInstanceHandler.getConfig().getStreams()) {
comboBox1.addItem(streamName);
}
comboBox2.addItem("best"); comboBox2.addItem("high"); comboBox2.addItem("medium"); comboBox2.addItem("low"); comboBox2.addItem("mobile");
}
public static void main(String[] args) {
JFrame frame = new JFrame("StreamChooserMenu");
frame.setContentPane(new StreamChooserMenu().panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
+16 -19
View File
@@ -1,28 +1,25 @@
package com.ixab;
import com.ixab.ConfigHandling.Config;
import com.ixab.ConfigHandling.ConfigFileHandler;
import com.ixab.StreamHandling.StreamOpener;
import com.ixab.ConfigHandling.ConfigFileIOHandler;
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
import com.ixab.GUI.StreamChooserMenu;
public class Main {
private static boolean running = true;
public static void exitProgram() {
running = false;
}
private static Config c = null;
public static void main(String[] args) {
while (running) {
// TODO: config dialog
// TODO: stream choosing
//ConfigLoadMenu.main(null);
c = ConfigFileIOHandler.load();
if (c == null) {
initNewConfig();
c = ConfigFileIOHandler.load();
}
// begin test
//Config c = new Config();
Config c = ConfigFileHandler.load();
//c.addStream("cohhcarnage");
//c.setLSPath("e:\\downloads\\livestreamer-v1.11.1\\livestreamer.exe");
//ConfigFileHandler.save(c);
StreamOpener so = new StreamOpener(c, 1, "best");
so.start();
// end test
ConfigFileInstanceHandler.setConfig(c);
StreamChooserMenu.main(null);
}
public static void initNewConfig() {
c = new Config();
c.setLSPath("e:\\downloads\\livestreamer-v1.11.1\\livestreamer.exe");
ConfigFileIOHandler.save(c);
}
}