2015-11-06 18:15:26 +01:00
|
|
|
package com.ixab.GUI;
|
|
|
|
|
|
2015-11-06 21:42:03 +01:00
|
|
|
import com.ixab.ConfigHandling.ConfigFileIOHandler;
|
|
|
|
|
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
|
2015-11-07 00:19:11 +01:00
|
|
|
import com.ixab.StreamHandling.StreamInfo;
|
2015-11-06 21:42:03 +01:00
|
|
|
import com.ixab.StreamHandling.StreamOpener;
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
2015-11-07 00:56:35 +01:00
|
|
|
import java.awt.event.*;
|
2015-11-06 21:42:03 +01:00
|
|
|
|
2015-11-09 20:09:55 +01:00
|
|
|
public class MainWindow {
|
2015-11-06 21:42:03 +01:00
|
|
|
private JPanel panel;
|
2015-11-07 00:19:11 +01:00
|
|
|
private JComboBox comboBoxStreams;
|
2015-11-07 00:56:35 +01:00
|
|
|
private JComboBox comboBoxQuality;
|
2015-11-12 15:48:37 +01:00
|
|
|
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;
|
2015-11-06 21:42:03 +01:00
|
|
|
|
2015-11-09 20:09:55 +01:00
|
|
|
protected JLabel getErrorLabel() {
|
|
|
|
|
return errorLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JLabel errorLabel;
|
|
|
|
|
protected boolean lockStreamInfoGetter = false;
|
|
|
|
|
|
|
|
|
|
public MainWindow() {
|
|
|
|
|
MainWindowGate.setMainWindow(this);
|
2015-11-06 21:42:03 +01:00
|
|
|
this.initComboBoxes();
|
2015-11-12 15:48:37 +01:00
|
|
|
buttonPlayStream.addActionListener(new ActionListener() {
|
2015-11-06 21:42:03 +01:00
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-07 00:56:35 +01:00
|
|
|
StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBoxStreams.getSelectedItem()), comboBoxQuality.getSelectedItem().toString());
|
2015-11-06 21:42:03 +01:00
|
|
|
so.start();
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-11-12 15:48:37 +01:00
|
|
|
buttonAddStream.addActionListener(new ActionListener() {
|
2015-11-06 21:42:03 +01:00
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-06 22:16:23 +01:00
|
|
|
addNewStream();
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
|
|
|
|
});
|
2015-11-12 15:48:37 +01:00
|
|
|
buttonRemoveStream.addActionListener(new ActionListener() {
|
2015-11-06 21:42:03 +01:00
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-07 00:19:11 +01:00
|
|
|
ConfigFileInstanceHandler.getConfig().removeStream(comboBoxStreams.getSelectedItem());
|
2015-11-06 21:42:03 +01:00
|
|
|
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
|
2015-11-07 00:56:35 +01:00
|
|
|
lockStreamInfoGetter = true;
|
2015-11-06 22:16:23 +01:00
|
|
|
initStreamsComboBox();
|
2015-11-07 00:56:35 +01:00
|
|
|
lockStreamInfoGetter = false;
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
|
|
|
|
});
|
2015-11-07 00:19:11 +01:00
|
|
|
comboBoxStreams.addActionListener(new ActionListener() {
|
2015-11-06 22:16:23 +01:00
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-07 00:56:35 +01:00
|
|
|
if (!lockStreamInfoGetter) {
|
|
|
|
|
updateStreamDetails();
|
|
|
|
|
}
|
2015-11-06 22:16:23 +01:00
|
|
|
}
|
|
|
|
|
});
|
2015-11-12 15:48:37 +01:00
|
|
|
buttonReloadStreamData.addActionListener(new ActionListener() {
|
2015-11-06 22:16:23 +01:00
|
|
|
@Override
|
2015-11-09 20:09:55 +01:00
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
updateStreamDetails();
|
2015-11-06 22:16:23 +01:00
|
|
|
}
|
|
|
|
|
});
|
2015-11-12 15:48:37 +01:00
|
|
|
buttonSettings.addActionListener(new ActionListener() {
|
2015-11-07 00:56:35 +01:00
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-09 20:09:55 +01:00
|
|
|
SettingsWindow sw = new SettingsWindow();
|
|
|
|
|
sw.create();
|
2015-11-07 00:56:35 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
private void updateStreamDetails() {
|
2015-11-12 15:48:37 +01:00
|
|
|
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() + "...");
|
2015-11-06 22:16:23 +01:00
|
|
|
}
|
|
|
|
|
private void addNewStream() {
|
2015-11-09 20:09:55 +01:00
|
|
|
AddStreamDialog as = new AddStreamDialog();
|
|
|
|
|
as.create();
|
2015-11-06 22:16:23 +01:00
|
|
|
}
|
|
|
|
|
private void initComboBoxes() {
|
|
|
|
|
initQualityComboBox();
|
|
|
|
|
initStreamsComboBox();
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
2015-11-09 20:09:55 +01:00
|
|
|
protected void initStreamsComboBox() {
|
2015-11-07 00:19:11 +01:00
|
|
|
comboBoxStreams.removeAllItems();
|
2015-11-06 21:42:03 +01:00
|
|
|
for (String streamName :
|
|
|
|
|
ConfigFileInstanceHandler.getConfig().getStreams()) {
|
2015-11-07 00:19:11 +01:00
|
|
|
comboBoxStreams.addItem(streamName);
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
2015-11-06 22:16:23 +01:00
|
|
|
}
|
|
|
|
|
private void initQualityComboBox() {
|
2015-11-07 00:56:35 +01:00
|
|
|
comboBoxQuality.removeAllItems();
|
|
|
|
|
comboBoxQuality.addItem("best"); comboBoxQuality.addItem("high"); comboBoxQuality.addItem("medium"); comboBoxQuality.addItem("low"); comboBoxQuality.addItem("mobile");
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
|
|
|
|
public static void main(String[] args) {
|
2015-11-09 20:09:55 +01:00
|
|
|
JFrame frame = new JFrame("jLSLauncher "+ com.ixab.Main.getVersion());
|
|
|
|
|
frame.setContentPane(new MainWindow().panel);
|
2015-11-06 21:42:03 +01:00
|
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
|
frame.pack();
|
2015-11-06 22:16:23 +01:00
|
|
|
frame.setLocationByPlatform(true);
|
2015-11-06 21:42:03 +01:00
|
|
|
frame.setVisible(true);
|
2015-11-09 20:09:55 +01:00
|
|
|
frame.setResizable(false);
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
2015-11-06 18:15:26 +01:00
|
|
|
}
|