[ADDED/MODIFIED] Mehr Stream Daten. Threading.

This commit is contained in:
toksikk
2015-11-12 15:48:37 +01:00
parent 19b2195dc3
commit 6a05f5f447
8 changed files with 299 additions and 101 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ package com.ixab.GUI;
public class ErrorMessageGate {
public static void setErrorText(String s) {
// TODO: na was wohl?
MainWindow mw = MainWindowGate.getMainWindow();
mw.getErrorLabel().setText(s);
}
}
+102 -71
View File
@@ -3,11 +3,11 @@
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="4" column-count="5" 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="650" height="400"/>
<xy x="20" y="20" width="650" height="500"/>
</constraints>
<properties>
<minimumSize width="650" height="200"/>
<preferredSize width="650" height="200"/>
<minimumSize width="650" height="400"/>
<preferredSize width="650" height="400"/>
</properties>
<border type="none"/>
<children>
@@ -39,7 +39,7 @@
<text value="Qualität:"/>
</properties>
</component>
<component id="7c5a1" class="javax.swing.JButton" binding="entfernenButton" default-binding="true">
<component id="7c5a1" class="javax.swing.JButton" binding="buttonRemoveStream" 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>
@@ -47,7 +47,7 @@
<text value="Ausgw. Stream entfernen"/>
</properties>
</component>
<grid id="7567d" layout-manager="GridLayoutManager" row-count="4" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="7567d" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="5" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -71,52 +71,97 @@
<text value="Kategorie:"/>
</properties>
</component>
<component id="2a9d4" class="javax.swing.JLabel" binding="labelStreamTitle">
<constraints>
<grid row="0" 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=""/>
</properties>
</component>
<component id="dcbec" class="javax.swing.JLabel" binding="labelStreamGame">
<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=""/>
</properties>
</component>
<hspacer id="7a444">
<constraints>
<grid row="1" column="3" 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="658e2" class="javax.swing.JLabel">
<constraints>
<grid row="3" 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="Vorschau:"/>
</properties>
</component>
<grid id="8ebda" binding="previewImagePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="31cd7" 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>
<grid row="3" column="1" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="136f3" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="658e2" 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="Vorschau:"/>
</properties>
</component>
<grid id="8ebda" binding="panelPreviewImage" 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>
<grid row="0" column="1" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="320" height="180"/>
<preferred-size width="320" height="180"/>
<maximum-size width="320" height="180"/>
</grid>
</constraints>
<properties>
<background color="-1"/>
</properties>
<border type="none"/>
<children/>
</grid>
<hspacer id="8b583">
<constraints>
<grid row="0" column="2" row-span="2" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="edf84">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
<component id="7fec7" class="javax.swing.JTextField" binding="textFieldStreamTitle">
<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"/>
</properties>
</component>
<component id="544c8" class="javax.swing.JTextField" binding="textFieldStreamGame">
<constraints>
<grid row="1" 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"/>
</properties>
</component>
<grid id="75d86" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="bbe9d" 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="Status:"/>
</properties>
</component>
<component id="7f132" class="javax.swing.JTextField" binding="textFieldStreamStatus">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="50" height="-1"/>
<preferred-size width="50" height="-1"/>
<maximum-size width="50" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="c34b7" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@@ -125,37 +170,23 @@
<text value="Zuschauer:"/>
</properties>
</component>
<component id="65a1f" class="javax.swing.JLabel" binding="labelStreamViewers">
<component id="97d89" class="javax.swing.JTextField" binding="textFieldStreamViewers">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="70" height="-1"/>
<preferred-size width="70" height="-1"/>
<maximum-size width="70" height="-1"/>
</grid>
</constraints>
<properties>
<text value=""/>
<editable value="false"/>
</properties>
</component>
<hspacer id="b1486">
<hspacer id="903e4">
<constraints>
<grid row="0" column="4" 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="e40fa" class="javax.swing.JLabel" binding="labelStreamStatus">
<constraints>
<grid row="0" 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=""/>
</properties>
</component>
<component id="bbe9d" 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">
<preferred-size width="39" height="14"/>
</grid>
</constraints>
<properties>
<text value="Status:"/>
</properties>
</component>
</children>
</grid>
</children>
@@ -173,7 +204,7 @@
<properties/>
<border type="none"/>
<children>
<component id="48958" class="javax.swing.JButton" binding="neuLadenButton" default-binding="true">
<component id="48958" class="javax.swing.JButton" binding="buttonReloadStreamData" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
@@ -181,7 +212,7 @@
<text value="Stream Infos neu laden"/>
</properties>
</component>
<component id="be49e" class="javax.swing.JButton" binding="streamAbspielenButton" default-binding="true">
<component id="be49e" class="javax.swing.JButton" binding="buttonPlayStream" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
@@ -189,7 +220,7 @@
<text value="Stream abspielen"/>
</properties>
</component>
<component id="95ee2" class="javax.swing.JButton" binding="einstellungenButton" default-binding="true">
<component id="95ee2" class="javax.swing.JButton" binding="buttonSettings" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
@@ -197,7 +228,7 @@
<text value="Einstellungen"/>
</properties>
</component>
<component id="a3649" class="javax.swing.JButton" binding="hinzufügenButton" default-binding="true">
<component id="a3649" class="javax.swing.JButton" binding="buttonAddStream" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
+36 -21
View File
@@ -12,17 +12,17 @@ public class MainWindow {
private JPanel panel;
private JComboBox comboBoxStreams;
private JComboBox comboBoxQuality;
private JTextField textField1;
private JButton hinzufügenButton;
private JButton streamAbspielenButton;
private JButton entfernenButton;
private JLabel labelStreamStatus;
private JLabel labelStreamViewers;
private JLabel labelStreamTitle;
private JLabel labelStreamGame;
private JButton neuLadenButton;
private JPanel previewImagePanel;
private JButton einstellungenButton;
private JButton buttonAddStream;
private JButton buttonPlayStream;
private JButton buttonRemoveStream;
private JTextField textFieldStreamStatus;
private JTextField textFieldStreamViewers;
private JTextField textFieldStreamTitle;
private JTextField textFieldStreamGame;
private JButton buttonReloadStreamData;
private JPanel panelPreviewImage;
private JButton buttonSettings;
private Thread updateThread;
protected JLabel getErrorLabel() {
return errorLabel;
@@ -34,20 +34,20 @@ public class MainWindow {
public MainWindow() {
MainWindowGate.setMainWindow(this);
this.initComboBoxes();
streamAbspielenButton.addActionListener(new ActionListener() {
buttonPlayStream.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBoxStreams.getSelectedItem()), comboBoxQuality.getSelectedItem().toString());
so.start();
}
});
hinzufügenButton.addActionListener(new ActionListener() {
buttonAddStream.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addNewStream();
}
});
entfernenButton.addActionListener(new ActionListener() {
buttonRemoveStream.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ConfigFileInstanceHandler.getConfig().removeStream(comboBoxStreams.getSelectedItem());
@@ -65,13 +65,13 @@ public class MainWindow {
}
}
});
neuLadenButton.addActionListener(new ActionListener() {
buttonReloadStreamData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateStreamDetails();
}
});
einstellungenButton.addActionListener(new ActionListener() {
buttonSettings.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SettingsWindow sw = new SettingsWindow();
@@ -80,11 +80,26 @@ public class MainWindow {
});
}
private void updateStreamDetails() {
StreamInfo.initStreamData(comboBoxStreams.getSelectedItem().toString());
labelStreamStatus.setText(StreamInfo.getStatus());
labelStreamGame.setText(StreamInfo.getGame());
labelStreamViewers.setText(StreamInfo.getViewers());
labelStreamTitle.setText(StreamInfo.getTitle());
if (updateThread != null) {
if (updateThread.isAlive()) {
updateThread.interrupt();
}
}
Runnable r = new Runnable() {
@Override
public void run() {
StreamInfo.initStreamData(comboBoxStreams.getSelectedItem().toString());
textFieldStreamStatus.setText(StreamInfo.getStatus());
textFieldStreamGame.setText(StreamInfo.getGame());
textFieldStreamViewers.setText(StreamInfo.getViewers());
textFieldStreamTitle.setText(StreamInfo.getTitle());
panelPreviewImage.getGraphics().drawImage(StreamInfo.getPreviewImage(),0,0,null);
}
};
Thread t = new Thread(r);
this.updateThread = t;
t.start();
ErrorMessageGate.setErrorText("Lade Stream-Daten von " + comboBoxStreams.getSelectedItem().toString() + "...");
}
private void addNewStream() {
AddStreamDialog as = new AddStreamDialog();
+27 -1
View File
@@ -49,7 +49,7 @@
</grid>
</children>
</grid>
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="e3588" layout-manager="GridLayoutManager" row-count="4" 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>
<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"/>
@@ -102,6 +102,32 @@
<grid row="0" column="1" 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="c3f1e" class="javax.swing.JLabel">
<constraints>
<grid row="3" 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="Benutzer Import:"/>
</properties>
</component>
<component id="3e70" class="javax.swing.JTextField" binding="twitchBenutzernameTextField" default-binding="true">
<constraints>
<grid row="3" 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>
<text value="Twitch-Benutzername"/>
</properties>
</component>
<component id="9749e" class="javax.swing.JButton" binding="buttonImportUserData">
<constraints>
<grid row="3" 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="Importieren"/>
</properties>
</component>
</children>
</grid>
</children>
+20 -1
View File
@@ -1,6 +1,8 @@
package com.ixab.GUI;
import com.ixab.ConfigHandling.ConfigFileIOHandler;
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
import com.ixab.UserInfoHandling.UserInfo;
import javax.swing.*;
import java.awt.event.*;
@@ -12,6 +14,8 @@ public class SettingsWindow extends JDialog {
private JCheckBox debugmodusCheckBox;
private JTextField textField1;
private JButton suchenButton;
private JTextField twitchBenutzernameTextField;
private JButton buttonImportUserData;
public SettingsWindow() {
textField1.setText(ConfigFileInstanceHandler.getConfig().getLSPath());
@@ -54,10 +58,25 @@ public class SettingsWindow extends JDialog {
if (jfc.getSelectedFile() != null) textField1.setText(jfc.getSelectedFile().getAbsolutePath());
}
});
buttonImportUserData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
UserInfo.initUserFollowData(twitchBenutzernameTextField.getText());
UserInfo.getFollowedChannelNames();
}
});
twitchBenutzernameTextField.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
super.focusGained(e);
twitchBenutzernameTextField.setText("");
}
});
}
private void onOK() {
// add your code here
ConfigFileInstanceHandler.getConfig().setLSPath(textField1.getText());
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
dispose();
}