summaryrefslogtreecommitdiff
path: root/cmpcj/src/de/schwarzrot/control/config/ConfigDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'cmpcj/src/de/schwarzrot/control/config/ConfigDialog.java')
-rw-r--r--cmpcj/src/de/schwarzrot/control/config/ConfigDialog.java76
1 files changed, 71 insertions, 5 deletions
diff --git a/cmpcj/src/de/schwarzrot/control/config/ConfigDialog.java b/cmpcj/src/de/schwarzrot/control/config/ConfigDialog.java
index 4bc71c7..923a8c9 100644
--- a/cmpcj/src/de/schwarzrot/control/config/ConfigDialog.java
+++ b/cmpcj/src/de/schwarzrot/control/config/ConfigDialog.java
@@ -26,20 +26,29 @@
package de.schwarzrot.control.config;
+import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.KeyStroke;
+import javax.swing.ListSelectionModel;
+import bibliothek.gui.dock.common.CControl;
+import bibliothek.gui.dock.common.CGrid;
+import bibliothek.gui.dock.common.theme.ThemeMap;
+import bibliothek.gui.dock.util.WindowProvider;
+import bibliothek.gui.dock.util.WindowProviderListener;
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
-import ca.odell.glazedlists.GlazedLists;
import ca.odell.glazedlists.swing.DefaultEventTableModel;
+import de.schwarzrot.base.dock.BasicDockable;
import de.schwarzrot.base.util.AbstractDialog;
import de.schwarzrot.base.util.ApplicationServiceProvider;
import de.schwarzrot.control.table.PlayerDefinitionTableFormat;
@@ -50,18 +59,26 @@ import de.schwarzrot.media.domain.MediaServer;
import de.schwarzrot.media.domain.PlayerDefinition;
-public class ConfigDialog extends AbstractDialog {
+public class ConfigDialog extends AbstractDialog implements WindowProvider {
private static final long serialVersionUID = 713L;
public ConfigDialog(Window parent) {
super(parent, true, DialogMode.CANCEL_APPROVE, Orientation.Right);
config = ApplicationServiceProvider.getService(Config.class);
+ listeners = new ArrayList<WindowProviderListener>();
+ setFixedSize(new Dimension(520, 320));
}
@Override
- public JComponent createContentPane() {
+ public void addWindowProviderListener(WindowProviderListener windowproviderlistener) {
+ if (!listeners.contains(windowproviderlistener))
+ listeners.add(windowproviderlistener);
+ }
+
+
+ public JComponent create_Old_ContentPane() {
JTabbedPane rv = new JTabbedPane();
rv.addTab("server", createServerTable());
@@ -71,12 +88,50 @@ public class ConfigDialog extends AbstractDialog {
}
+ @Override
+ public JComponent createContentPane() {
+ CControl docking = new CControl(this);
+ CGrid grid = new CGrid(docking);
+
+ docking.setTheme(ThemeMap.KEY_ECLIPSE_THEME);
+ BasicDockable servers = new BasicDockable("servers", msgBundle.getMessage(getClass().getSimpleName()
+ + ".servers"), createServerTable());
+ BasicDockable players = new BasicDockable("players", msgBundle.getMessage(getClass().getSimpleName()
+ + ".players"), createPlayerTable());
+
+ servers.setMinimizable(false);
+ servers.setExternalizable(false);
+ servers.setMaximizable(false);
+ players.setMinimizable(false);
+ players.setExternalizable(false);
+ players.setMaximizable(false);
+ grid.add(0, 0, 1, 1, players);
+ grid.add(0, 0, 1, 1, servers);
+ docking.getContentArea().deploy(grid);
+
+ return docking.getContentArea();
+ }
+
+
+ @Override
+ public void removeWindowProviderListener(WindowProviderListener windowproviderlistener) {
+ if (listeners.contains(windowproviderlistener))
+ listeners.remove(windowproviderlistener);
+ }
+
+
+ @Override
+ public Window searchWindow() {
+ return this;
+ }
+
+
protected JComponent createPlayerTable() {
playerDefinitions = new BasicEventList<PlayerDefinition>();
for (AbstractMediaNode.SupportedMediaType mt : AbstractMediaNode.SupportedMediaType.values()) {
if (mt == AbstractMediaNode.SupportedMediaType.Unknown)
break;
- PlayerDefinition pd = config.getPlayerMap().get(mt);
+ PlayerDefinition pd = (PlayerDefinition) config.getPlayerMap().get(mt).clone(); // so we can revert changes
pd.setMediaType(mt);
playerDefinitions.add(pd);
@@ -96,6 +151,8 @@ public class ConfigDialog extends AbstractDialog {
playerTable.getColumnModel().getColumn(i).setMaxWidth(cw);
}
}
+ playerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+
return playerTableScrollPane;
}
@@ -106,7 +163,9 @@ public class ConfigDialog extends AbstractDialog {
protected JComponent createServerTable() {
- serverDefinitions = GlazedLists.eventList(config.getKnownServers());
+ serverDefinitions = new BasicEventList<MediaServer>();
+ for (MediaServer s : config.getKnownServers())
+ serverDefinitions.add((MediaServer) s.clone());
ServerDefinitionTableFormat stf = new ServerDefinitionTableFormat();
DefaultEventTableModel<MediaServer> tm = new DefaultEventTableModel<MediaServer>(serverDefinitions, stf);
JTable serverTable = new JTable(tm);
@@ -131,6 +190,7 @@ public class ConfigDialog extends AbstractDialog {
}
});
serverTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), "createServerDefinition");
+ serverTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
return serverTableScrollPane;
}
@@ -140,12 +200,18 @@ public class ConfigDialog extends AbstractDialog {
protected void performApprove() {
System.out.println("should save config now!?!");
List<MediaServer> cfgServers = config.getKnownServers();
+ AbstractMediaNode.SupportedMediaType[] allTypes = AbstractMediaNode.SupportedMediaType.values();
+ Map<AbstractMediaNode.SupportedMediaType, PlayerDefinition> cfgPlayers = config.getPlayerMap();
+ int mx = allTypes.length - 1;
cfgServers.clear();
cfgServers.addAll(serverDefinitions);
+ for (int i = 0; i < mx; ++i)
+ cfgPlayers.put(allTypes[i], playerDefinitions.get(i));
}
private EventList<MediaServer> serverDefinitions;
private EventList<PlayerDefinition> playerDefinitions;
+ private List<WindowProviderListener> listeners;
private Config config;
}