[vlma-devel] commit: The Swing client is now able to display medias and servers. ( Adrien Grand )

git version control git at videolan.org
Sun Jul 27 02:52:34 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sun Jul 27 02:45:42 2008 +0200| [ba5e136ce81481d4f9ca4096c6e0df89a7df48b4]

The Swing client is now able to display medias and servers.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=ba5e136ce81481d4f9ca4096c6e0df89a7df48b4
---

 vlma-swing-client/.gitignore                       |    1 +
 vlma-swing-client/src/main/groovy/client.groovy    |   36 ---------
 .../groovy/org/videolan/vlma/client/client.groovy  |   84 ++++++++++++++++++++
 3 files changed, 85 insertions(+), 36 deletions(-)

diff --git a/vlma-swing-client/.gitignore b/vlma-swing-client/.gitignore
index beef00d..26f4a9a 100644
--- a/vlma-swing-client/.gitignore
+++ b/vlma-swing-client/.gitignore
@@ -1,3 +1,4 @@
+bin-groovy
 .classpath
 .project
 .settings
diff --git a/vlma-swing-client/src/main/groovy/client.groovy b/vlma-swing-client/src/main/groovy/client.groovy
deleted file mode 100644
index 45ea531..0000000
--- a/vlma-swing-client/src/main/groovy/client.groovy
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2008 the VideoLAN team
- *
- * This file is part of VLMa.
- *
- * VLMa is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * VLMa is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with VLMa. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.videolan.vlma.client
-
-import java.rmi.registry.LocateRegistry
-import java.rmi.registry.Registry
-
-import org.videolan.vlma.Data
-
-class Client {
-
-    static void main(args) {
-        def registry = LocateRegistry.getRegistry(9050)
-        def data = (Data) registry.lookup("VLMaDataService")
-        data.getMedias().each { item -> println "${item}" }
-    }
-
-}
diff --git a/vlma-swing-client/src/main/groovy/org/videolan/vlma/client/client.groovy b/vlma-swing-client/src/main/groovy/org/videolan/vlma/client/client.groovy
new file mode 100644
index 0000000..b88bfc0
--- /dev/null
+++ b/vlma-swing-client/src/main/groovy/org/videolan/vlma/client/client.groovy
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2008 the VideoLAN team
+ *
+ * This file is part of VLMa.
+ *
+ * VLMa is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * VLMa is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with VLMa. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package org.videolan.vlma.client
+
+import groovy.swing.SwingBuilder
+import java.awt.*
+import java.rmi.registry.*
+import javax.swing.*
+
+import org.videolan.vlma.Data
+
+/**
+ * A sample Swing client for VLMa daemon.
+ */
+class Client {
+
+    private static data
+
+    static getData() {
+        if (data != null) {
+            return data
+        } else {
+            def registry = LocateRegistry.getRegistry(9050)
+            data = (Data) registry.lookup("VLMaDataService")
+            return data
+        }
+    }
+
+    static void main(args) {
+        def swing = new SwingBuilder()
+        def frame = swing.frame(title: "VLMa Swing Client",
+                layout: new BorderLayout(),
+                defaultCloseOperation: JFrame.EXIT_ON_CLOSE
+        ) {
+            tabbedPane(tabPlacement: JTabbedPane.TOP) {
+                panel(name: "Welcome", constraints:BorderLayout.CENTER, layout: new BorderLayout()) {
+                    label(text: "Streaming state", constraints:BorderLayout.NORTH)
+                    panel(constraints:BorderLayout.CENTER) {
+                        scrollPane() {
+                            streamedMedias = new JTable((String[][]) getData().getMedias()
+                                    .findAll({ it.getProgram() != null })
+                                    .collect({ [it.getName(), it.getProgram().getPriority(), it.getProgram().getPlayer() ?: "Not assigned"] }),
+                                    (String[]) ["Name", "Priority", "Assigned to"])
+                            widget(streamedMedias)
+                        }
+                    }
+                }
+                panel(name: "Servers", constraints:BorderLayout.CENTER, layout: new BorderLayout()) {
+                    label(text: "Servers", constraints:BorderLayout.NORTH)
+                    panel(constraints:BorderLayout.CENTER) {
+                        scrollPane() {
+                            servers = new JTable((String[][]) getData().getServers()
+                                    .collect({ [it.getName(), it.getIp(), it.isUp() ? "Yes" : "No"] }),
+                                    (String[]) ["Name", "Address", "Up?"])
+                            widget(servers)
+                        }
+                    }
+                }
+            }
+        }
+        frame.pack()
+        frame.setSize(250, 300);
+        frame.show()
+    }
+
+}



More information about the vlma-devel mailing list