chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1783119 [1/2] - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench: ./ src/main/java/org/apache/chemistry/opencmis/workbench/ src/main/java/org/apache/chemistry/opencmis/workbench/details/ src/main/resou...
Date Wed, 15 Feb 2017 16:20:39 GMT
Author: fmui
Date: Wed Feb 15 16:20:38 2017
New Revision: 1783119

URL: http://svn.apache.org/viewvc?rev=1783119&view=rev
Log:
added a bunch of Workbench improvements

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ConsoleHelper.java   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-file-document.groovy   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-folder.groovy   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-text-document.groovy   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/get-full-object.groovy   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/getchildren.groovy   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/query.groovy   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/snippet-library.properties   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/update-properties.groovy   (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml Wed Feb 15 16:20:38 2017
@@ -188,7 +188,7 @@
         <dependency>
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy-all</artifactId>
-            <version>2.4.7</version>
+            <version>2.4.8</version>
         </dependency>
         <dependency>
             <groupId>org.apache.logging.log4j</groupId>

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java Wed Feb 15 16:20:38 2017
@@ -30,11 +30,8 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowListener;
-import java.io.File;
 import java.lang.reflect.Method;
 import java.net.URI;
-import java.util.Collections;
-import java.util.List;
 import java.util.prefs.Preferences;
 
 import javax.swing.ImageIcon;
@@ -73,8 +70,6 @@ public class ClientFrame extends JFrame
 
     private static final Logger LOG = LoggerFactory.getLogger(ClientFrame.class);
 
-    private static final String SYSPROP_SCRIPTS = ClientSession.WORKBENCH_PREFIX + "scripts";
-
     private static final String WINDOW_TITLE = "CMIS Workbench";
 
     private static final int BUTTON_CONNECT = 0;
@@ -94,9 +89,6 @@ public class ClientFrame extends JFrame
     private static final String PREFS_HEIGHT = "height";
     private static final String PREFS_DIV = "div";
 
-    private static final String GROOVY_SCRIPT_FOLDER = "/scripts/";
-    private static final String GROOVY_SCRIPT_LIBRARY = "script-library.properties";
-
     private final Preferences prefs = Preferences.userNodeForPackage(this.getClass());
 
     private LoginDialog loginDialog;
@@ -174,10 +166,10 @@ public class ClientFrame extends JFrame
 
         toolbarButton = new JButton[10];
 
-        toolbarButton[BUTTON_CONNECT] = new JButton("Connection", new ConnectIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_CONNECT].setDisabledIcon(new ConnectIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_CONNECT] = new JButton("Connection",
+                new ConnectIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_CONNECT].setDisabledIcon(
+                new ConnectIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_CONNECT].addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
@@ -189,10 +181,10 @@ public class ClientFrame extends JFrame
 
         toolBar.addSeparator();
 
-        toolbarButton[BUTTON_REPOSITORY_INFO] = new JButton("Repository Info", new RepositoryInfoIcon(
-                ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_REPOSITORY_INFO].setDisabledIcon(new RepositoryInfoIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_REPOSITORY_INFO] = new JButton("Repository Info",
+                new RepositoryInfoIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_REPOSITORY_INFO].setDisabledIcon(
+                new RepositoryInfoIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(false);
         toolbarButton[BUTTON_REPOSITORY_INFO].addActionListener(new ActionListener() {
             @Override
@@ -203,10 +195,10 @@ public class ClientFrame extends JFrame
 
         toolBar.add(toolbarButton[BUTTON_REPOSITORY_INFO]);
 
-        toolbarButton[BUTTON_TYPES] = new JButton("Types", new TypesIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_TYPES].setDisabledIcon(new TypesIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_TYPES] = new JButton("Types",
+                new TypesIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_TYPES]
+                .setDisabledIcon(new TypesIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_TYPES].setEnabled(false);
         toolbarButton[BUTTON_TYPES].addActionListener(new ActionListener() {
             @Override
@@ -217,10 +209,10 @@ public class ClientFrame extends JFrame
 
         toolBar.add(toolbarButton[BUTTON_TYPES]);
 
-        toolbarButton[BUTTON_QUERY] = new JButton("Query", new QueryIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_QUERY].setDisabledIcon(new QueryIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_QUERY] = new JButton("Query",
+                new QueryIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_QUERY]
+                .setDisabledIcon(new QueryIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_QUERY].setEnabled(false);
         toolbarButton[BUTTON_QUERY].addActionListener(new ActionListener() {
             @Override
@@ -231,10 +223,10 @@ public class ClientFrame extends JFrame
 
         toolBar.add(toolbarButton[BUTTON_QUERY]);
 
-        toolbarButton[BUTTON_CHANGELOG] = new JButton("Change Log", new ChangeLogIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_CHANGELOG].setDisabledIcon(new ChangeLogIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_CHANGELOG] = new JButton("Change Log",
+                new ChangeLogIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_CHANGELOG].setDisabledIcon(
+                new ChangeLogIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_CHANGELOG].setEnabled(false);
         toolbarButton[BUTTON_CHANGELOG].addActionListener(new ActionListener() {
             @Override
@@ -245,10 +237,10 @@ public class ClientFrame extends JFrame
 
         toolBar.add(toolbarButton[BUTTON_CHANGELOG]);
 
-        toolbarButton[BUTTON_CONSOLE] = new JButton("Console", new ConsoleIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_CONSOLE].setDisabledIcon(new ConsoleIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_CONSOLE] = new JButton("Console",
+                new ConsoleIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_CONSOLE].setDisabledIcon(
+                new ConsoleIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_CONSOLE].setEnabled(false);
         toolbarButton[BUTTON_CONSOLE].addActionListener(new ActionListener() {
             @Override
@@ -260,22 +252,22 @@ public class ClientFrame extends JFrame
         toolBar.add(toolbarButton[BUTTON_CONSOLE]);
 
         toolbarConsolePopup = new JPopupMenu();
-        for (FileEntry fe : readScriptLibrary()) {
+        for (FileEntry fe : ConsoleHelper.readScriptLibrary()) {
             JMenuItem menuItem = new JMenuItem(fe.getName());
             final URI file = fe.getFile();
             menuItem.addActionListener(new ActionListener() {
                 @Override
                 public void actionPerformed(ActionEvent e) {
-                    ClientHelper.openConsole(ClientFrame.this, model, file);
+                    ConsoleHelper.openConsole(ClientFrame.this, model, file);
                 }
             });
             toolbarConsolePopup.add(menuItem);
         }
 
-        toolbarButton[BUTTON_TCK] = new JButton("TCK", new TckIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_TCK].setDisabledIcon(new TckIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_TCK] = new JButton("TCK",
+                new TckIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_TCK]
+                .setDisabledIcon(new TckIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_TCK].setEnabled(false);
         toolbarButton[BUTTON_TCK].addActionListener(new ActionListener() {
             @Override
@@ -339,10 +331,10 @@ public class ClientFrame extends JFrame
             }
         });
 
-        toolbarButton[BUTTON_CREATE] = new JButton("Create Object", new CreateObjectIcon(
-                ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_CREATE].setDisabledIcon(new CreateObjectIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_CREATE] = new JButton("Create Object",
+                new CreateObjectIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_CREATE].setDisabledIcon(
+                new CreateObjectIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_CREATE].setEnabled(false);
         toolbarButton[BUTTON_CREATE].addActionListener(new ActionListener() {
             @Override
@@ -355,10 +347,10 @@ public class ClientFrame extends JFrame
 
         toolBar.addSeparator();
 
-        toolbarButton[BUTTON_LOG] = new JButton("Log", new LogIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_LOG].setDisabledIcon(new LogIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_LOG] = new JButton("Log",
+                new LogIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_LOG]
+                .setDisabledIcon(new LogIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_LOG].addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
@@ -368,10 +360,10 @@ public class ClientFrame extends JFrame
 
         toolBar.add(toolbarButton[BUTTON_LOG]);
 
-        toolbarButton[BUTTON_INFO] = new JButton("Info", new InfoIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE));
-        toolbarButton[BUTTON_INFO].setDisabledIcon(new InfoIcon(ClientHelper.TOOLBAR_ICON_SIZE,
-                ClientHelper.TOOLBAR_ICON_SIZE, false));
+        toolbarButton[BUTTON_INFO] = new JButton("Info",
+                new InfoIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE));
+        toolbarButton[BUTTON_INFO]
+                .setDisabledIcon(new InfoIcon(ClientHelper.TOOLBAR_ICON_SIZE, ClientHelper.TOOLBAR_ICON_SIZE, false));
         toolbarButton[BUTTON_INFO].addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
@@ -393,8 +385,8 @@ public class ClientFrame extends JFrame
         addWindowListener(this);
 
         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-        setPreferredSize(new Dimension(prefs.getInt(PREFS_WIDTH, (int) (screenSize.getWidth() / 1.5)), prefs.getInt(
-                PREFS_HEIGHT, (int) (screenSize.getHeight() / 1.5))));
+        setPreferredSize(new Dimension(prefs.getInt(PREFS_WIDTH, (int) (screenSize.getWidth() / 1.5)),
+                prefs.getInt(PREFS_HEIGHT, (int) (screenSize.getHeight() / 1.5))));
         setMinimumSize(new Dimension(200, 60));
 
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@ -421,6 +413,8 @@ public class ClientFrame extends JFrame
             try {
                 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
+                folderPanel.clear();
+
                 LoadFolderWorker.loadFolderById(ClientFrame.this, model, clientSession.getStartFolderId());
                 LoadObjectWorker.loadObject(ClientFrame.this, model, clientSession.getStartFolderId());
 
@@ -462,26 +456,6 @@ public class ClientFrame extends JFrame
         }
     }
 
-    private List<FileEntry> readScriptLibrary() {
-
-        URI propFile = null;
-
-        String externalScripts = System.getProperty(SYSPROP_SCRIPTS);
-        if (externalScripts == null) {
-            propFile = ClientHelper.getClasspathURI(GROOVY_SCRIPT_FOLDER + GROOVY_SCRIPT_LIBRARY);
-        } else {
-            propFile = (new File(externalScripts)).toURI();
-        }
-
-        List<FileEntry> result = ClientHelper.readFileProperties(propFile);
-
-        if (result == null || result.isEmpty()) {
-            result = Collections.singletonList(new FileEntry("Groovy Console", null));
-        }
-
-        return result;
-    }
-
     @Override
     public void windowOpened(WindowEvent e) {
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java Wed Feb 15 16:20:38 2017
@@ -18,15 +18,9 @@
  */
 package org.apache.chemistry.opencmis.workbench;
 
-import groovy.lang.Binding;
-import groovy.ui.Console;
-import groovy.util.GroovyScriptEngine;
-
 import java.awt.Color;
 import java.awt.Component;
-import java.awt.Cursor;
 import java.awt.Desktop;
-import java.awt.Desktop.Action;
 import java.awt.Image;
 import java.awt.Toolkit;
 import java.awt.Window;
@@ -34,17 +28,13 @@ import java.awt.datatransfer.Clipboard;
 import java.awt.datatransfer.StringSelection;
 import java.awt.datatransfer.Transferable;
 import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Writer;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -58,33 +48,25 @@ import java.util.List;
 import java.util.Properties;
 
 import javax.imageio.ImageIO;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
 import javax.swing.AbstractAction;
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
 import javax.swing.InputMap;
 import javax.swing.JComponent;
 import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
 import javax.swing.JRootPane;
 import javax.swing.JTable;
 import javax.swing.KeyStroke;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
-import javax.swing.text.AttributeSet;
 import javax.swing.text.DefaultEditorKit;
 
 import org.apache.chemistry.opencmis.client.api.CmisObject;
 import org.apache.chemistry.opencmis.client.api.ObjectId;
-import org.apache.chemistry.opencmis.client.api.Session;
-import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.IOUtils;
-import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.swing.WorkbenchFileChooser;
 import org.apache.chemistry.opencmis.workbench.worker.OpenContentWorker;
 import org.apache.chemistry.opencmis.workbench.worker.StoreWorker;
@@ -290,7 +272,8 @@ public final class ClientHelper {
                 fileChooser.setSelectedFile(new File(file.getName()));
 
                 int chooseResult = fileChooser.showDialog(getComponent(), "Download");
-                if (chooseResult == WorkbenchFileChooser.APPROVE_OPTION && !file.equals(fileChooser.getSelectedFile())) {
+                if (chooseResult == WorkbenchFileChooser.APPROVE_OPTION
+                        && !file.equals(fileChooser.getSelectedFile())) {
                     try {
                         InputStream in = null;
                         OutputStream out = null;
@@ -561,148 +544,6 @@ public final class ClientHelper {
         }
     }
 
-    public static Console openConsole(final Component parent, final ClientModel model, final URI file) {
-        return openConsole(parent, model, file, null);
-    }
-
-    public static Console openConsole(final Component parent, final ClientModel model, final String soureCode) {
-        return openConsole(parent, model, null, soureCode);
-    }
-
-    public static Console openConsole(final Component parent, final ClientModel model, final URI file,
-            final String soureCode) {
-        try {
-            parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
-            final Session groovySession = model.getClientSession().getSession();
-            final String user = model.getClientSession().getSessionParameters().get(SessionParameter.USER);
-            final String title = "GroovyConsole - Repsository: " + groovySession.getRepositoryInfo().getId();
-
-            final Console console = new Console(parent.getClass().getClassLoader()) {
-                @Override
-                public void updateTitle() {
-                    JFrame frame = (JFrame) getFrame();
-
-                    if (getScriptFile() != null) {
-                        frame.setTitle(((File) getScriptFile()).getName() + (getDirty() ? " * " : "") + " - " + title);
-                    } else {
-                        frame.setTitle(title);
-                    }
-                }
-            };
-
-            console.setVariable("session", groovySession);
-            console.setVariable("binding", groovySession.getBinding());
-
-            console.run();
-
-            JMenu cmisMenu = new JMenu("CMIS");
-            console.getFrame().getRootPane().getJMenuBar().add(cmisMenu);
-
-            addConsoleMenu(cmisMenu, "CMIS 1.0 Specification", new URI(
-                    "https://docs.oasis-open.org/cmis/CMIS/v1.0/os/cmis-spec-v1.0.html"));
-            addConsoleMenu(cmisMenu, "CMIS 1.1 Specification", new URI(
-                    "https://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html"));
-            addConsoleMenu(cmisMenu, "OpenCMIS Documentation", new URI(
-                    "https://chemistry.apache.org/java/opencmis.html"));
-            addConsoleMenu(cmisMenu, "OpenCMIS Code Samples",
-                    new URI("https://chemistry.apache.org/docs/cmis-samples/"));
-            addConsoleMenu(cmisMenu, "OpenCMIS Client API JavaDoc", new URI(
-                    "https://chemistry.apache.org/java/javadoc/"));
-            cmisMenu.addSeparator();
-            JMenuItem menuItem = new JMenuItem("CMIS Session Details");
-            menuItem.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    AttributeSet style = console.getOutputStyle();
-                    console.clearOutput();
-                    console.appendOutputNl("Session ID:      " + groovySession.getBinding().getSessionId(), style);
-                    console.appendOutputNl("Repository ID:   " + groovySession.getRepositoryInfo().getId(), style);
-                    console.appendOutputNl("Repository name: " + groovySession.getRepositoryInfo().getName(), style);
-                    console.appendOutputNl("Binding:         " + groovySession.getBinding().getBindingType(), style);
-                    console.appendOutputNl("User:            " + user, style);
-                }
-            });
-            cmisMenu.add(menuItem);
-
-            if (file != null) {
-                console.getInputArea().setText(readFileAndRemoveHeader(file));
-            } else if (soureCode != null) {
-                console.getInputArea().setText(soureCode);
-            }
-
-            return console;
-        } catch (Exception ex) {
-            showError(null, ex);
-            return null;
-        } finally {
-            parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-        }
-    }
-
-    private static void addConsoleMenu(JMenu menu, String title, final URI url) {
-        if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Action.BROWSE)) {
-            return;
-        }
-
-        JMenuItem menuItem = new JMenuItem(title);
-        menuItem.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                try {
-                    Desktop.getDesktop().browse(url);
-                } catch (IOException ex) {
-                    showError(null, ex);
-                }
-            }
-        });
-
-        menu.add(menuItem);
-    }
-
-    public static void runGroovyScript(final Component parent, final ClientModel model, final File file,
-            final Writer out) {
-        try {
-            parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
-            String[] roots = new String[] { file.getParentFile().getAbsolutePath() };
-            GroovyScriptEngine gse = new GroovyScriptEngine(roots, parent.getClass().getClassLoader());
-            Binding binding = new Binding();
-            binding.setVariable("session", model.getClientSession().getSession());
-            binding.setVariable("binding", model.getClientSession().getSession().getBinding());
-            binding.setVariable("out", out);
-            gse.run(file.getName(), binding);
-        } catch (Exception ex) {
-            ClientHelper.showError(null, ex);
-        } finally {
-            parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-        }
-    }
-
-    public static void runJSR223Script(final Component parent, final ClientModel model, final File file,
-            final String ext, final Writer out) {
-        InputStreamReader reader = null;
-        try {
-            parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
-            reader = new InputStreamReader(new FileInputStream(file), IOUtils.UTF8);
-
-            ScriptEngineManager mgr = new ScriptEngineManager();
-            ScriptEngine engine = mgr.getEngineByExtension(ext);
-            engine.getContext().setWriter(out);
-            engine.getContext().setErrorWriter(out);
-            engine.put("session", model.getClientSession().getSession());
-            engine.put("binding", model.getClientSession().getSession().getBinding());
-            engine.put("out", new PrintWriter(out));
-            engine.eval(reader);
-        } catch (Exception ex) {
-            ClientHelper.showError(null, ex);
-        } finally {
-            IOUtils.closeQuietly(reader);
-            parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-        }
-    }
-
     public static class FileEntry implements Comparable<FileEntry> {
         private final String name;
         private final URI file;

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ConsoleHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ConsoleHelper.java?rev=1783119&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ConsoleHelper.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ConsoleHelper.java Wed Feb 15 16:20:38 2017
@@ -0,0 +1,399 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.workbench;
+
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Desktop;
+import java.awt.Desktop.Action;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
+import org.apache.chemistry.opencmis.workbench.ClientHelper.FileEntry;
+import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.model.ClientSession;
+
+import groovy.lang.Binding;
+import groovy.ui.Console;
+import groovy.util.GroovyScriptEngine;
+
+public class ConsoleHelper {
+
+    private static final String SYSPROP_SCRIPTS = ClientSession.WORKBENCH_PREFIX + "scripts";
+    private static final String SYSPROP_SNIPPETS = ClientSession.WORKBENCH_PREFIX + "snippets";
+
+    private static final String GROOVY_SCRIPT_FOLDER = "/scripts/";
+    private static final String GROOVY_SCRIPT_LIBRARY = "script-library.properties";
+    private static final String GROOVY_SNIPPET_FOLDER = "/snippets/";
+    private static final String GROOVY_SNIPPET_LIBRARY = "snippet-library.properties";
+
+    /**
+     * Open a Groovy console and load the script from the provided file.
+     */
+    public static Console openConsole(final Component parent, final ClientModel model, final URI file) {
+        return openConsole(parent, model, file, null);
+    }
+
+    /**
+     * Open a Groovy console and use the provided.
+     */
+    public static Console openConsole(final Component parent, final ClientModel model, final String soureCode) {
+        return openConsole(parent, model, null, soureCode);
+    }
+
+    private static Console openConsole(final Component parent, final ClientModel model, final URI file,
+            final String soureCode) {
+        try {
+            parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+            final Session groovySession = model.getClientSession().getSession();
+            final String user = model.getClientSession().getSessionParameters().get(SessionParameter.USER);
+            final String title = "GroovyConsole - Repsository: " + groovySession.getRepositoryInfo().getId();
+
+            final Console console = new Console(parent.getClass().getClassLoader()) {
+                @Override
+                public void updateTitle() {
+                    JFrame frame = (JFrame) getFrame();
+
+                    if (getScriptFile() != null) {
+                        frame.setTitle(((File) getScriptFile()).getName() + (getDirty() ? " * " : "") + " - " + title);
+                    } else {
+                        frame.setTitle(title);
+                    }
+                }
+            };
+
+            console.setVariable("session", groovySession);
+            console.setVariable("binding", groovySession.getBinding());
+
+            console.run();
+
+            // add menu
+            JMenu cmisMenu = new JMenu("CMIS");
+            console.getFrame().getRootPane().getJMenuBar().add(cmisMenu);
+
+            addConsoleMenu(cmisMenu, "CMIS 1.0 Specification",
+                    new URI("https://docs.oasis-open.org/cmis/CMIS/v1.0/os/cmis-spec-v1.0.html"));
+            addConsoleMenu(cmisMenu, "CMIS 1.1 Specification",
+                    new URI("https://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html"));
+            addConsoleMenu(cmisMenu, "OpenCMIS Documentation",
+                    new URI("https://chemistry.apache.org/java/opencmis.html"));
+            addConsoleMenu(cmisMenu, "OpenCMIS Code Samples",
+                    new URI("https://chemistry.apache.org/docs/cmis-samples/"));
+            addConsoleMenu(cmisMenu, "OpenCMIS Client API JavaDoc",
+                    new URI("https://chemistry.apache.org/java/javadoc/"));
+            cmisMenu.addSeparator();
+            JMenuItem menuItem = new JMenuItem("CMIS Session Details");
+            menuItem.addActionListener(new ActionListener() {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    AttributeSet style = console.getOutputStyle();
+                    console.clearOutput();
+                    console.appendOutputNl("Session ID:      " + groovySession.getBinding().getSessionId(), style);
+                    console.appendOutputNl("Repository ID:   " + groovySession.getRepositoryInfo().getId(), style);
+                    console.appendOutputNl("Repository name: " + groovySession.getRepositoryInfo().getName(), style);
+                    console.appendOutputNl("Binding:         " + groovySession.getBinding().getBindingType(), style);
+                    console.appendOutputNl("User:            " + user, style);
+                }
+            });
+            cmisMenu.add(menuItem);
+
+            // add popup menu
+
+            final JPopupMenu popup = new JPopupMenu();
+
+            final JMenuItem cutItem = new JMenuItem("Cut");
+            cutItem.addActionListener(new ActionListener() {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    try {
+                        String text = console.getInputArea().getSelectedText();
+                        if (text != null) {
+                            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+                            Transferable transferable = new StringSelection(text);
+                            clipboard.setContents(transferable, null);
+
+                            int start = console.getInputArea().getSelectionStart();
+                            int end = console.getInputArea().getSelectionEnd();
+                            console.getInputArea().getDocument().remove(start, end - start);
+                        }
+                    } catch (Exception ex) {
+                        ClientHelper.showError(console.getFrame().getRootPane(), ex);
+                    }
+                }
+            });
+            popup.add(cutItem);
+
+            final JMenuItem copyItem = new JMenuItem("Copy");
+            copyItem.addActionListener(new ActionListener() {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    String text = console.getInputArea().getSelectedText();
+                    if (text != null) {
+                        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+                        Transferable transferable = new StringSelection(text);
+                        clipboard.setContents(transferable, null);
+                    }
+                }
+            });
+            popup.add(copyItem);
+
+            final JMenuItem pasteItem = new JMenuItem("Paste");
+            pasteItem.addActionListener(new ActionListener() {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    try {
+                        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+                        Object content = clipboard.getData(DataFlavor.stringFlavor);
+                        if (content != null) {
+                            int start = console.getInputArea().getSelectionStart();
+                            int end = console.getInputArea().getSelectionEnd();
+                            if (end - start > 0) {
+                                console.getInputArea().getDocument().remove(start, end - start);
+                            }
+
+                            console.getInputArea().getDocument().insertString(console.getInputArea().getCaretPosition(),
+                                    content.toString(), null);
+                        }
+                    } catch (Exception ex) {
+                        ClientHelper.showError(console.getFrame().getRootPane(), ex);
+                    }
+                }
+            });
+            popup.add(pasteItem);
+
+            popup.addSeparator();
+
+            JMenu snippetsSubMenu = new JMenu("Snippets");
+            popup.add(snippetsSubMenu);
+
+            for (FileEntry entry : readSnippetLibrary()) {
+                String snippet = ClientHelper.readFileAndRemoveHeader(entry.getFile());
+
+                JMenuItem snippetItem = new JMenuItem(entry.getName());
+                snippetItem.addActionListener(new ConsolePopupMenuActionListener(console, snippet));
+                snippetsSubMenu.add(snippetItem);
+            }
+
+            console.getInputArea().addMouseListener(new MouseAdapter() {
+                @Override
+                public void mouseClicked(MouseEvent e) {
+                }
+
+                @Override
+                public void mousePressed(MouseEvent e) {
+                    maybeShowPopup(e);
+                }
+
+                @Override
+                public void mouseReleased(MouseEvent e) {
+                    maybeShowPopup(e);
+                }
+
+                private void maybeShowPopup(MouseEvent e) {
+                    if (e.isPopupTrigger()) {
+                        if (console.getInputArea().getSelectedText() != null) {
+                            cutItem.setEnabled(true);
+                            copyItem.setEnabled(true);
+
+                        } else {
+                            cutItem.setEnabled(false);
+                            copyItem.setEnabled(false);
+                        }
+
+                        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+                        pasteItem.setEnabled(clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor));
+
+                        popup.show(e.getComponent(), e.getX(), e.getY());
+                    }
+                }
+            });
+
+            // read source codeÏÍ
+            if (file != null) {
+                console.getInputArea().setText(ClientHelper.readFileAndRemoveHeader(file));
+            } else if (soureCode != null) {
+                console.getInputArea().setText(soureCode);
+            }
+
+            return console;
+        } catch (Exception ex) {
+            ClientHelper.showError(null, ex);
+            return null;
+        } finally {
+            parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+        }
+    }
+
+    private static void addConsoleMenu(JMenu menu, String title, final URI url) {
+        if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Action.BROWSE)) {
+            return;
+        }
+
+        JMenuItem menuItem = new JMenuItem(title);
+        menuItem.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                try {
+                    Desktop.getDesktop().browse(url);
+                } catch (IOException ex) {
+                    ClientHelper.showError(null, ex);
+                }
+            }
+        });
+
+        menu.add(menuItem);
+    }
+
+    public static List<FileEntry> readScriptLibrary() {
+        URI propFile = null;
+
+        String externalScripts = System.getProperty(SYSPROP_SCRIPTS);
+        if (externalScripts == null) {
+            propFile = ClientHelper.getClasspathURI(GROOVY_SCRIPT_FOLDER + GROOVY_SCRIPT_LIBRARY);
+        } else {
+            propFile = (new File(externalScripts)).toURI();
+        }
+
+        List<FileEntry> result = ClientHelper.readFileProperties(propFile);
+
+        if (result == null || result.isEmpty()) {
+            result = Collections.singletonList(new FileEntry("Groovy Console", null));
+        }
+
+        return result;
+    }
+
+    public static List<FileEntry> readSnippetLibrary() {
+        URI propFile = null;
+
+        String externalSnippets = System.getProperty(SYSPROP_SNIPPETS);
+        if (externalSnippets == null) {
+            propFile = ClientHelper.getClasspathURI(GROOVY_SNIPPET_FOLDER + GROOVY_SNIPPET_LIBRARY);
+        } else {
+            propFile = (new File(externalSnippets)).toURI();
+        }
+
+        List<FileEntry> result = ClientHelper.readFileProperties(propFile);
+
+        if (result == null) {
+            result = Collections.emptyList();
+        }
+
+        return result;
+    }
+
+    public static void runGroovyScript(final Component parent, final ClientModel model, final File file,
+            final Writer out) {
+        try {
+            parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+            String[] roots = new String[] { file.getParentFile().getAbsolutePath() };
+            GroovyScriptEngine gse = new GroovyScriptEngine(roots, parent.getClass().getClassLoader());
+            Binding binding = new Binding();
+            binding.setVariable("session", model.getClientSession().getSession());
+            binding.setVariable("binding", model.getClientSession().getSession().getBinding());
+            binding.setVariable("out", out);
+            gse.run(file.getName(), binding);
+        } catch (Exception ex) {
+            ClientHelper.showError(null, ex);
+        } finally {
+            parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+        }
+    }
+
+    public static void runJSR223Script(final Component parent, final ClientModel model, final File file,
+            final String ext, final Writer out) {
+        InputStreamReader reader = null;
+        try {
+            parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+            reader = new InputStreamReader(new FileInputStream(file), IOUtils.UTF8);
+
+            ScriptEngineManager mgr = new ScriptEngineManager();
+            ScriptEngine engine = mgr.getEngineByExtension(ext);
+            engine.getContext().setWriter(out);
+            engine.getContext().setErrorWriter(out);
+            engine.put("session", model.getClientSession().getSession());
+            engine.put("binding", model.getClientSession().getSession().getBinding());
+            engine.put("out", new PrintWriter(out));
+            engine.eval(reader);
+        } catch (Exception ex) {
+            ClientHelper.showError(null, ex);
+        } finally {
+            IOUtils.closeQuietly(reader);
+            parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+        }
+    }
+
+    // ---
+
+    private static class ConsolePopupMenuActionListener implements ActionListener {
+        private final Console console;
+        private final String snippet;
+
+        public ConsolePopupMenuActionListener(Console console, String snippet) {
+            this.console = console;
+            this.snippet = snippet;
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            try {
+                int start = console.getInputArea().getSelectionStart();
+                int end = console.getInputArea().getSelectionEnd();
+                if (end - start > 0) {
+                    console.getInputArea().getDocument().remove(start, end - start);
+                }
+                console.getInputArea().getDocument().insertString(console.getInputArea().getCaretPosition(), snippet,
+                        null);
+            } catch (BadLocationException ex) {
+                ClientHelper.showError(console.getFrame().getRootPane(), ex);
+            }
+        }
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ConsoleHelper.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java Wed Feb 15 16:20:38 2017
@@ -20,30 +20,43 @@ package org.apache.chemistry.opencmis.wo
 
 import java.awt.BorderLayout;
 import java.awt.Font;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 import java.util.List;
 import java.util.Map;
 
 import javax.swing.BorderFactory;
+import javax.swing.DropMode;
 import javax.swing.JComboBox;
+import javax.swing.JComponent;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
+import javax.swing.TransferHandler;
 
 import org.apache.chemistry.opencmis.client.SessionParameterMap;
+import org.apache.chemistry.opencmis.client.bindings.spi.ClientCertificateAuthenticationProvider;
+import org.apache.chemistry.opencmis.client.bindings.spi.OAuthAuthenticationProvider;
 import org.apache.chemistry.opencmis.client.bindings.spi.http.ApacheClientHttpInvoker;
 import org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker;
 import org.apache.chemistry.opencmis.client.bindings.spi.http.OkHttpHttpInvoker;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.workbench.ClientHelper.FileEntry;
 import org.apache.chemistry.opencmis.workbench.model.ClientSession;
 
@@ -105,10 +118,16 @@ public class ExpertLoginTab extends Abst
         add(configs, BorderLayout.PAGE_START);
 
         sessionParameterTextArea = new JTextArea();
-        sessionParameterTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, sessionParameterTextArea.getFont()
-                .getSize()));
+        sessionParameterTextArea
+                .setFont(new Font(Font.MONOSPACED, Font.PLAIN, sessionParameterTextArea.getFont().getSize()));
         add(new JScrollPane(sessionParameterTextArea), BorderLayout.CENTER);
 
+        // drag and drop support
+        sessionParameterTextArea.setTransferHandler(new TextAreaTransferHandler());
+        sessionParameterTextArea.setDragEnabled(true);
+        sessionParameterTextArea.setDropMode(DropMode.INSERT);
+
+        // context menu
         final JPopupMenu popup = new JPopupMenu("Session Parameters");
         popup.add(createMenuGroup("Binding", SessionParameter.BINDING_TYPE, SessionParameter.ATOMPUB_URL,
                 SessionParameter.BROWSER_URL, SessionParameter.BROWSER_SUCCINCT,
@@ -123,8 +142,15 @@ public class ExpertLoginTab extends Abst
                 SessionParameter.USER_AGENT, SessionParameter.PROXY_USER, SessionParameter.PROXY_PASSWORD,
                 SessionParameter.CONNECT_TIMEOUT, SessionParameter.READ_TIMEOUT));
 
-        popup.add(createMenuGroup("OAuth", SessionParameter.OAUTH_CLIENT_ID, SessionParameter.OAUTH_CLIENT_SECRET,
-                SessionParameter.OAUTH_CODE, SessionParameter.OAUTH_TOKEN_ENDPOINT, SessionParameter.OAUTH_REDIRECT_URI));
+        popup.add(createMenuGroup("OAuth",
+                SessionParameter.AUTHENTICATION_PROVIDER_CLASS + "=" + OAuthAuthenticationProvider.class.getName(),
+                SessionParameter.OAUTH_CLIENT_ID, SessionParameter.OAUTH_CLIENT_SECRET, SessionParameter.OAUTH_CODE,
+                SessionParameter.OAUTH_TOKEN_ENDPOINT, SessionParameter.OAUTH_REDIRECT_URI));
+
+        popup.add(createMenuGroup("Client Certificate",
+                SessionParameter.AUTHENTICATION_PROVIDER_CLASS + "="
+                        + ClientCertificateAuthenticationProvider.class.getName(),
+                SessionParameter.CLIENT_CERT_KEYFILE, SessionParameter.CLIENT_CERT_PASSPHRASE));
 
         popup.add(createMenuGroup("HTTP Invoker",
                 SessionParameter.HTTP_INVOKER_CLASS + "=" + DefaultHttpInvoker.class.getName(),
@@ -214,4 +240,113 @@ public class ExpertLoginTab extends Abst
     public boolean transferSessionParametersToExpertTab() {
         return false;
     }
+
+    private class TextAreaTransferHandler extends TransferHandler {
+
+        private static final long serialVersionUID = 1L;
+
+        public TextAreaTransferHandler() {
+            super();
+        }
+
+        @Override
+        public boolean canImport(TransferSupport support) {
+            // we support files and strings
+            if (!support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)
+                    && !support.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+                return false;
+            }
+
+            if (!support.isDrop()) {
+                return false;
+            }
+
+            return true;
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public boolean importData(TransferSupport support) {
+            if (!canImport(support)) {
+                return false;
+            }
+
+            if (support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+                // we have file
+                File file = null;
+                try {
+                    List<File> fileList = (List<File>) support.getTransferable()
+                            .getTransferData(DataFlavor.javaFileListFlavor);
+
+                    // one file only
+                    if (fileList == null || fileList.size() != 1 || fileList.get(0) == null
+                            || !fileList.get(0).isFile()) {
+                        return false;
+                    }
+
+                    file = fileList.get(0);
+                } catch (Exception ex) {
+                    ClientHelper.showError(null, ex);
+                    return false;
+                }
+
+                // read the first 100 lines
+                InputStream stream = null;
+                try {
+                    stream = new BufferedInputStream(new FileInputStream(file));
+                    sessionParameterTextArea.setText(IOUtils.readAllLines(stream, 100));
+                } catch (IOException e) {
+                    ClientHelper.showError(ExpertLoginTab.this, e);
+                } finally {
+                    IOUtils.closeQuietly(stream);
+                }
+            } else if (support.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+                // we have string
+                try {
+                    sessionParameterTextArea
+                            .setText((String) support.getTransferable().getTransferData(DataFlavor.stringFlavor));
+                } catch (Exception e) {
+                    ClientHelper.showError(ExpertLoginTab.this, e);
+                }
+            } else {
+                return false;
+            }
+
+            return true;
+        }
+
+        @Override
+        public int getSourceActions(JComponent c) {
+            return COPY;
+        }
+
+        @Override
+        protected Transferable createTransferable(JComponent c) {
+            return new Transferable() {
+                @Override
+                public boolean isDataFlavorSupported(DataFlavor flavor) {
+                    return flavor == DataFlavor.stringFlavor;
+                }
+
+                @Override
+                public DataFlavor[] getTransferDataFlavors() {
+                    return new DataFlavor[] { DataFlavor.stringFlavor };
+                }
+
+                @Override
+                public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
+                    if (flavor != DataFlavor.stringFlavor) {
+                        throw new UnsupportedFlavorException(flavor);
+                    }
+
+                    String s = sessionParameterTextArea.getSelectedText();
+                    if (s == null) {
+                        s = sessionParameterTextArea.getText();
+                    }
+
+                    return s;
+                }
+            };
+        }
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java Wed Feb 15 16:20:38 2017
@@ -21,15 +21,13 @@ package org.apache.chemistry.opencmis.wo
 import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
 
 import javax.swing.BorderFactory;
 import javax.swing.BoxLayout;
 import javax.swing.JButton;
+import javax.swing.JComboBox;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
-import javax.swing.JTextField;
 import javax.swing.SwingUtilities;
 
 import org.apache.chemistry.opencmis.client.api.Folder;
@@ -44,12 +42,14 @@ public class FolderPanel extends JPanel
 
     private static final long serialVersionUID = 1L;
 
+    private static final int HISTORY = 10;
+
     private final ClientModel model;
 
     private String parentId;
 
     private JButton upButton;
-    private JTextField pathField;
+    private JComboBox<String> pathField;
     private JButton goButton;
     private FolderTable folderTable;
 
@@ -71,7 +71,7 @@ public class FolderPanel extends JPanel
 
                 if (currentFolder != null) {
                     String path = currentFolder.getPath();
-                    pathField.setText(path);
+                    setPath(path);
 
                     Folder parent = null;
                     try {
@@ -87,7 +87,7 @@ public class FolderPanel extends JPanel
                         upButton.setEnabled(true);
                     }
                 } else {
-                    pathField.setText("???");
+                    setPath(null);
                     parentId = null;
                     upButton.setEnabled(false);
                 }
@@ -136,21 +136,14 @@ public class FolderPanel extends JPanel
         });
         panel.add(upButton);
 
-        pathField = new JTextField("");
-        pathField.addKeyListener(new KeyListener() {
-            @Override
-            public void keyTyped(KeyEvent e) {
-            }
-
-            @Override
-            public void keyReleased(KeyEvent e) {
-                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
-                    loadFolder();
-                }
-            }
+        pathField = new JComboBox<String>();
+        pathField.setEditable(true);
+        pathField.setMaximumRowCount(HISTORY);
 
+        pathField.getEditor().addActionListener(new ActionListener() {
             @Override
-            public void keyPressed(KeyEvent e) {
+            public void actionPerformed(ActionEvent e) {
+                loadFolder();
             }
         });
         panel.add(pathField);
@@ -173,8 +166,45 @@ public class FolderPanel extends JPanel
         add(new JScrollPane(folderTable), BorderLayout.CENTER);
     }
 
+    public void clear() {
+        pathField.removeAllItems();
+    }
+
+    private void setPath(String path) {
+        if (path == null) {
+            // no path -> object couldn't be loaded
+            pathField.setSelectedItem("");
+            return;
+        }
+
+        // if the new path already exists in the history, remove it
+        int i = 0;
+        while (i < pathField.getItemCount()) {
+            if (path.equals(pathField.getItemAt(i))) {
+                pathField.removeItemAt(i);
+            } else {
+                i++;
+            }
+        }
+
+        // add new path at the top
+        pathField.insertItemAt(path, 0);
+
+        // cut history
+        while (pathField.getItemCount() > HISTORY) {
+            pathField.removeItemAt(HISTORY);
+        }
+
+        // select the path in combo box
+        pathField.setSelectedIndex(0);
+    }
+
+    private String getPath() {
+        return pathField.getEditor().getItem().toString().trim();
+    }
+
     private void loadFolder() {
-        LoadFolderWorker.loadFolder(this, model, pathField.getText().trim());
+        LoadFolderWorker.loadFolder(this, model, getPath());
     }
 
     private void loadParentFolder() {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java Wed Feb 15 16:20:38 2017
@@ -470,6 +470,10 @@ public class FolderTable extends JTable
 
                 @Override
                 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
+                    if (flavor != DataFlavor.javaFileListFlavor) {
+                        throw new UnsupportedFlavorException(flavor);
+                    }
+
                     try {
                         TempFileContentWorker worker = new TempFileContentWorker(null, (Document) object);
                         return Collections.singletonList(worker.executeSync());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.java Wed Feb 15 16:20:38 2017
@@ -19,7 +19,6 @@
 package org.apache.chemistry.opencmis.workbench.details;
 
 import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNullOrEmpty;
-import groovy.ui.Console;
 
 import java.awt.BorderLayout;
 import java.awt.Cursor;
@@ -58,6 +57,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.tck.CmisTestGroup;
 import org.apache.chemistry.opencmis.workbench.ClientHelper;
+import org.apache.chemistry.opencmis.workbench.ConsoleHelper;
 import org.apache.chemistry.opencmis.workbench.WorkbenchScale;
 import org.apache.chemistry.opencmis.workbench.checks.ObjectComplianceTestGroup;
 import org.apache.chemistry.opencmis.workbench.checks.SwingReport;
@@ -69,6 +69,8 @@ import org.apache.chemistry.opencmis.wor
 import org.apache.chemistry.opencmis.workbench.worker.LoadObjectWorker;
 import org.apache.chemistry.opencmis.workbench.worker.TempFileContentWorker;
 
+import groovy.ui.Console;
+
 public class ObjectPanel extends InfoPanel implements ObjectListener {
 
     private static final long serialVersionUID = 1L;
@@ -177,11 +179,10 @@ public class ObjectPanel extends InfoPan
                                 pwcField.setText("(not checked out)");
                             }
 
-                            sizeField.setText(doc.getContentStreamLength() >= 0 ? NumberFormat.getInstance().format(
-                                    doc.getContentStreamLength())
-                                    + " bytes" : "");
-                            mimeTypeField.setText(doc.getContentStreamMimeType() != null ? doc
-                                    .getContentStreamMimeType() : "");
+                            sizeField.setText(doc.getContentStreamLength() >= 0
+                                    ? NumberFormat.getInstance().format(doc.getContentStreamLength()) + " bytes" : "");
+                            mimeTypeField.setText(
+                                    doc.getContentStreamMimeType() != null ? doc.getContentStreamMimeType() : "");
                         } else {
                             latestAccessibleStateIdField.setText("");
                             pwcField.setText("");
@@ -336,8 +337,8 @@ public class ObjectPanel extends InfoPan
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    Map<String, String> parameters = new HashMap<String, String>(getClientModel().getClientSession()
-                            .getSessionParameters());
+                    Map<String, String> parameters = new HashMap<String, String>(
+                            getClientModel().getClientSession().getSessionParameters());
                     parameters.put(SessionParameter.REPOSITORY_ID, getClientModel().getRepositoryInfo().getId());
                     String objectId = getClientModel().getCurrentObject().getId();
 
@@ -362,7 +363,7 @@ public class ObjectPanel extends InfoPan
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
-                    ClientHelper.openConsole(ObjectPanel.this, getClientModel(),
+                    ConsoleHelper.openConsole(ObjectPanel.this, getClientModel(),
                             createGroovySourceCode(getClientModel().getCurrentObject()));
                 } catch (Exception ex) {
                     ClientHelper.showError(null, ex);
@@ -385,7 +386,7 @@ public class ObjectPanel extends InfoPan
                         TempFileContentWorker worker = new TempFileContentWorker(ObjectPanel.this, doc) {
                             @Override
                             protected void processTempFile(File file) {
-                                Console console = ClientHelper.openConsole(ObjectPanel.this, getClientModel(),
+                                Console console = ConsoleHelper.openConsole(ObjectPanel.this, getClientModel(),
                                         (String) null);
                                 if (console != null) {
                                     console.loadScriptFile(file);
@@ -418,7 +419,8 @@ public class ObjectPanel extends InfoPan
                         scriptOutput.setVisible(true);
                         scriptOutput.invalidate();
 
-                        ClientHelper.runJSR223Script(ObjectPanel.this, getClientModel(), file, ext, scriptOutputWriter);
+                        ConsoleHelper.runJSR223Script(ObjectPanel.this, getClientModel(), file, ext,
+                                scriptOutputWriter);
                     }
                 };
                 worker.executeTask();
@@ -442,7 +444,8 @@ public class ObjectPanel extends InfoPan
         sb.append("import org.apache.chemistry.opencmis.commons.*\n");
         sb.append("import org.apache.chemistry.opencmis.commons.data.*\n");
         sb.append("import org.apache.chemistry.opencmis.commons.enums.*\n");
-        sb.append("import org.apache.chemistry.opencmis.client.api.*\n\n");
+        sb.append("import org.apache.chemistry.opencmis.client.api.*\n");
+        sb.append("import org.apache.chemistry.opencmis.client.util.*\n\n");
 
         sb.append("// ");
         sb.append(object.getName());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy Wed Feb 15 16:20:38 2017
@@ -21,6 +21,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*
 import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.client.util.*
 
 println "'cmis:document' and subtypes:     ${countTypes('cmis:document')}"
 println "'cmis:item' and subtypes:         ${countTypes('cmis:item')}"

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy Wed Feb 15 16:20:38 2017
@@ -21,6 +21,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*
 import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.client.util.*
 
 cmis = new scripts.CMIS(session)
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy Wed Feb 15 16:20:38 2017
@@ -21,6 +21,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*
 import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.client.util.*
 
 CmisObject root = session.getRootFolder()
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy Wed Feb 15 16:20:38 2017
@@ -21,6 +21,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*
 import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.client.util.*
 
 String cql = "SELECT cmis:objectId, cmis:name, cmis:contentStreamLength FROM cmis:document"
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy Wed Feb 15 16:20:38 2017
@@ -21,6 +21,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*
 import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.client.util.*
 
 // variable 'session' is bound to the current OpenCMIS session
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy Wed Feb 15 16:20:38 2017
@@ -21,6 +21,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*
 import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.client.util.*
 
 Folder folder = (Folder) session.getObjectByPath("/")
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy Wed Feb 15 16:20:38 2017
@@ -21,6 +21,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*
 import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.client.util.*
 
 // def cmis = new scripts.CMIS(session)
 // println session.repositoryInfo.name

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy?rev=1783119&r1=1783118&r2=1783119&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy Wed Feb 15 16:20:38 2017
@@ -21,6 +21,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*
 import org.apache.chemistry.opencmis.client.api.*
+import org.apache.chemistry.opencmis.client.util.*
 
 cmis = new scripts.CMIS(session)
 

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-file-document.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-file-document.groovy?rev=1783119&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-file-document.groovy (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-file-document.groovy Wed Feb 15 16:20:38 2017
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+Folder parentFolder = ...
+File file = ...
+
+def properties = [
+    (PropertyIds.OBJECT_TYPE_ID): "cmis:document",
+    (PropertyIds.NAME): file.name
+]
+
+def contentStream = ContentStreamUtils.createFileContentStream(file)
+
+parentFolder.createDocument(properties, contentStream, VersioningState.NONE)
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-file-document.groovy
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-folder.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-folder.groovy?rev=1783119&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-folder.groovy (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-folder.groovy Wed Feb 15 16:20:38 2017
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+Folder parentFolder = ...
+String name = "new folder"
+
+def properties = [
+    (PropertyIds.OBJECT_TYPE_ID): "cmis:folder",
+    (PropertyIds.NAME): name
+]
+
+parentFolder.createFolder(properties)
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-folder.groovy
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-text-document.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-text-document.groovy?rev=1783119&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-text-document.groovy (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-text-document.groovy Wed Feb 15 16:20:38 2017
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+Folder parentFolder = ...
+String name = "document.txt"
+String content = "content"
+
+def properties = [
+    (PropertyIds.OBJECT_TYPE_ID): "cmis:document",
+    (PropertyIds.NAME): name
+]
+
+def contentStream = ContentStreamUtils.createTextContentStream(name, content)
+
+parentFolder.createDocument(properties, contentStream, VersioningState.NONE)
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/create-text-document.groovy
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/get-full-object.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/get-full-object.groovy?rev=1783119&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/get-full-object.groovy (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/get-full-object.groovy Wed Feb 15 16:20:38 2017
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ 
+OperationContext ctxt = OperationContextUtils.createMaximumOperationContext()
+CmisObject cmisObject = session.getObject("...", ctxt)
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/get-full-object.groovy
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/getchildren.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/getchildren.groovy?rev=1783119&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/getchildren.groovy (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/getchildren.groovy Wed Feb 15 16:20:38 2017
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ 
+Folder folder = ...
+OperationContext ctxt = OperationContextUtils.createMaximumOperationContext()
+
+folder.getChildren(ctxt).each { child ->
+    println "${child.name} (${child.id}) [${child.type.id}]"
+}
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/getchildren.groovy
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/query.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/query.groovy?rev=1783119&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/query.groovy (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/query.groovy Wed Feb 15 16:20:38 2017
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+String queryStmt = "SELECT * FROM cmis:document"
+
+for(QueryResult hit: session.query(queryStmt, false)) {
+    hit.properties.each{ println "${it.queryName}: ${it.firstValue}" }
+    println "----------------------------------"
+}
\ No newline at end of file

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/snippets/query.groovy
------------------------------------------------------------------------------
    svn:eol-style = LF



Mime
View raw message