chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r999996 - in /incubator/chemistry/opencmis-swingclient/trunk: ./ src/main/java/org/apache/chemistry/opencmis/swingclient/ src/main/resources/images/ src/main/resources/scripts/
Date Wed, 22 Sep 2010 14:47:30 GMT
Author: fmui
Date: Wed Sep 22 14:47:29 2010
New Revision: 999996

URL: http://svn.apache.org/viewvc?rev=999996&view=rev
Log:
added Groovy console to Swing Client

Added:
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/console.png 
 (with props)
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy
Modified:
    incubator/chemistry/opencmis-swingclient/trunk/pom.xml
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java

Modified: incubator/chemistry/opencmis-swingclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/pom.xml?rev=999996&r1=999995&r2=999996&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/pom.xml (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/pom.xml Wed Sep 22 14:47:29 2010
@@ -230,6 +230,11 @@
             <version>0.2.0-incubating-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-all</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <version>1.2.16</version>

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java?rev=999996&r1=999995&r2=999996&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java
Wed Sep 22 14:47:29 2010
@@ -18,12 +18,17 @@
  */
 package org.apache.chemistry.opencmis.swingclient;
 
+import groovy.ui.Console;
+
 import java.awt.BorderLayout;
 import java.awt.Container;
 import java.awt.Cursor;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
@@ -46,11 +51,15 @@ public class ClientFrame extends JFrame 
     private static final int BUTTON_REPOSITORY_INFO = 1;
     private static final int BUTTON_TYPES = 2;
     private static final int BUTTON_QUERY = 3;
-    private static final int BUTTON_CREATE_DOCUMENT = 4;
-    private static final int BUTTON_CREATE_FOLDER = 5;
+    private static final int BUTTON_CONSOLE = 4;
+    private static final int BUTTON_CREATE_DOCUMENT = 5;
+    private static final int BUTTON_CREATE_FOLDER = 6;
     private static final int BUTTON_LOG = 8;
     private static final int BUTTON_INFO = 9;
 
+    private static final String GROOVY_SCRIPT_FOLDER = "/scripts/";
+    private static final String GROOVY_STARTUP_SCRIPT = "startup.groovy";
+
     private LoginDialog loginDialog;
     private LogFrame logFrame;
     private InfoDialog infoDialog;
@@ -105,8 +114,8 @@ public class ClientFrame extends JFrame 
 
         toolBar.addSeparator();
 
-        toolbarButton[BUTTON_REPOSITORY_INFO] = new JButton("Repository Info", ClientHelper
-                .getIcon("repository-info.png"));
+        toolbarButton[BUTTON_REPOSITORY_INFO] = new JButton("Repository Info",
+                ClientHelper.getIcon("repository-info.png"));
         toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(false);
         toolbarButton[BUTTON_REPOSITORY_INFO].addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
@@ -136,6 +145,45 @@ public class ClientFrame extends JFrame 
 
         toolBar.add(toolbarButton[BUTTON_QUERY]);
 
+        toolbarButton[BUTTON_CONSOLE] = new JButton("Console", ClientHelper.getIcon("console.png"));
+        toolbarButton[BUTTON_CONSOLE].setEnabled(false);
+        toolbarButton[BUTTON_CONSOLE].addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                try {
+                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+                    Console console = new Console();
+                    console.setVariable("session", model.getClientSession().getSession());
+                    console.setVariable("binding", model.getClientSession().getSession().getBinding());
+                    console.run();
+
+                    InputStream stream = this.getClass().getResourceAsStream(
+                            GROOVY_SCRIPT_FOLDER + GROOVY_STARTUP_SCRIPT);
+                    if (stream == null) {
+                        throw new Exception("Groovy startup script is missing!");
+                    } else {
+
+                        BufferedReader reader = new BufferedReader(new InputStreamReader(stream,
"UTF-8"));
+                        StringBuilder sb = new StringBuilder();
+                        String s;
+
+                        while ((s = reader.readLine()) != null) {
+                            sb.append(s);
+                            sb.append("\n");
+                        }
+
+                        console.getInputArea().setText(sb.toString());
+                    }
+                } catch (Exception ex) {
+                    ClientHelper.showError(thisFrame, ex);
+                } finally {
+                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+                }
+            }
+        });
+
+        toolBar.add(toolbarButton[BUTTON_CONSOLE]);
+
         toolBar.addSeparator();
 
         toolbarButton[BUTTON_CREATE_DOCUMENT] = new JButton("Create Document", ClientHelper.getIcon("newdocument.png"));
@@ -212,6 +260,7 @@ public class ClientFrame extends JFrame 
                 toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(true);
                 toolbarButton[BUTTON_TYPES].setEnabled(true);
                 toolbarButton[BUTTON_QUERY].setEnabled(model.supportsQuery());
+                toolbarButton[BUTTON_CONSOLE].setEnabled(true);
                 toolbarButton[BUTTON_CREATE_DOCUMENT].setEnabled(true);
                 toolbarButton[BUTTON_CREATE_FOLDER].setEnabled(true);
 
@@ -220,6 +269,7 @@ public class ClientFrame extends JFrame 
                 toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(false);
                 toolbarButton[BUTTON_TYPES].setEnabled(false);
                 toolbarButton[BUTTON_QUERY].setEnabled(false);
+                toolbarButton[BUTTON_CONSOLE].setEnabled(false);
                 toolbarButton[BUTTON_CREATE_DOCUMENT].setEnabled(false);
                 toolbarButton[BUTTON_CREATE_FOLDER].setEnabled(false);
 

Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/console.png
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/console.png?rev=999996&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/console.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy?rev=999996&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy
(added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy
Wed Sep 22 14:47:29 2010
@@ -0,0 +1,17 @@
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.commons.enums.*;
+
+println "Variable 'session' is bound to the current OpenCMIS session."
+println ""
+println "Reposiory: " + session.getRepositoryInfo().getName()
+println ""
+
+Folder root = session.getRootFolder()
+println "--- Root Folder: " + root.getName() + " ---"
+println ""
+
+for(CmisObject object: root.getChildren()) { 
+  println object.getName() + " \t(" + object.getType().getId() + ")"
+}



Mime
View raw message