You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2010/10/03 14:44:36 UTC

svn commit: r1003956 - in /incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient: ./ details/

Author: fmui
Date: Sun Oct  3 12:44:35 2010
New Revision: 1003956

URL: http://svn.apache.org/viewvc?rev=1003956&view=rev
Log:
- changed double-click behaviour from download to open (press shift key to force download)
- added CMIS menu to console

Modified:
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/TypesFrame.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RenditionTable.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/VersionTable.java

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=1003956&r1=1003955&r2=1003956&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 Sun Oct  3 12:44:35 2010
@@ -23,6 +23,8 @@ import groovy.ui.Console;
 import java.awt.BorderLayout;
 import java.awt.Container;
 import java.awt.Cursor;
+import java.awt.Desktop;
+import java.awt.Desktop.Action;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -30,6 +32,7 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -38,6 +41,7 @@ import java.util.Properties;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JFrame;
+import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
@@ -297,6 +301,19 @@ public class ClientFrame extends JFrame 
 
             console.run();
 
+            JMenu cmisMenu = new JMenu("CMIS");
+            console.getFrame().getRootPane().getJMenuBar().add(cmisMenu);
+
+            addConsoleMenu(cmisMenu, "CMIS 1.0 Specification", new URI(
+                    "http://docs.oasis-open.org/cmis/CMIS/v1.0/os/cmis-spec-v1.0.html"));
+            addConsoleMenu(cmisMenu, "OpenCMIS Documentation", new URI(
+                    "http://incubator.apache.org/chemistry/opencmis.html"));
+            addConsoleMenu(
+                    cmisMenu,
+                    "OpenCMIS Client API JavaDoc",
+                    new URI(
+                            "http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/package-summary.html"));
+
             console.getInputArea().setText(readScript(path));
         } catch (Exception ex) {
             ClientHelper.showError(null, ex);
@@ -305,6 +322,25 @@ public class ClientFrame extends JFrame 
         }
     }
 
+    private 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 e1) {
+                }
+            }
+        });
+
+        menu.add(menuItem);
+    }
+
     private List<CmisScript> readScriptLibrary() {
         InputStream stream = this.getClass().getResourceAsStream(GROOVY_SCRIPT_FOLDER + GROOVY_SCRIPT_LIBRARY);
         if (stream == null) {

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java?rev=1003956&r1=1003955&r2=1003956&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java Sun Oct  3 12:44:35 2010
@@ -19,8 +19,10 @@
 package org.apache.chemistry.opencmis.swingclient;
 
 import java.awt.Component;
-import java.io.BufferedInputStream;
+import java.awt.Desktop;
+import java.io.BufferedOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -42,6 +44,7 @@ import org.apache.commons.logging.LogFac
 public class ClientHelper {
 
     private static Log log = LogFactory.getLog(ClientHelper.class);
+    private static int BUFFER_SIZE = 64 * 1024;
 
     public static void showError(Component parent, Exception ex) {
         if (log.isErrorEnabled()) {
@@ -94,37 +97,61 @@ public class ClientHelper {
 
         int chooseResult = fileChooser.showDialog(component, "Download");
         if (chooseResult == JFileChooser.APPROVE_OPTION) {
-            InputStream inStream = null;
-            OutputStream outStream = null;
             try {
                 ContentStream content = doc.getContentStream(streamId);
                 if (content == null) {
                     throw new Exception("No content!");
                 }
 
-                inStream = new BufferedInputStream(content.getStream());
-                outStream = new FileOutputStream(fileChooser.getSelectedFile());
+                storeStream(content.getStream(), fileChooser.getSelectedFile());
+            } catch (Exception e) {
+                showError(component, e);
+            }
+        }
+    }
 
-                byte[] buffer = new byte[4096];
-                int b;
-                while ((b = inStream.read(buffer)) > -1) {
-                    outStream.write(buffer, 0, b);
-                }
+    public static void copy(Component component, File file) {
+        JFileChooser fileChooser = new JFileChooser();
+        fileChooser.setSelectedFile(new File(file.getName()));
+
+        int chooseResult = fileChooser.showDialog(component, "Download");
+        if (chooseResult == JFileChooser.APPROVE_OPTION) {
+            try {
+                storeStream(new FileInputStream(file), fileChooser.getSelectedFile());
             } catch (Exception e) {
                 showError(component, e);
-            } finally {
-                if (inStream != null) {
-                    try {
-                        inStream.close();
-                    } catch (IOException e) {
-                    }
-                }
-                if (outStream != null) {
-                    try {
-                        outStream.close();
-                    } catch (IOException e) {
-                    }
-                }
+            }
+        }
+    }
+
+    public static void open(Component component, Document doc, String streamId) {
+        if (!Desktop.isDesktopSupported()) {
+            download(component, doc, streamId);
+            return;
+        }
+
+        Desktop desktop = Desktop.getDesktop();
+
+        if (!desktop.isSupported(Desktop.Action.OPEN)) {
+            download(component, doc, streamId);
+            return;
+        }
+
+        File file = null;
+
+        try {
+            file = createTempFileFromDocument(doc, streamId);
+        } catch (Exception e) {
+            showError(component, e);
+        }
+
+        try {
+            desktop.open(file);
+        } catch (Exception e) {
+            if (e instanceof IOException) {
+                copy(component, file);
+            } else {
+                showError(component, e);
             }
         }
     }
@@ -143,47 +170,51 @@ public class ClientHelper {
         return tempFile;
     }
 
-    public static File createTempFileFromDocument(Document doc) throws Exception {
-        InputStream inStream = null;
-        OutputStream outStream = null;
+    public static File createTempFileFromDocument(Document doc, String streamId) throws Exception {
+        ContentStream content = doc.getContentStream(streamId);
+        if (content == null) {
+            throw new Exception("No content!");
+        }
 
-        try {
-            ContentStream content = doc.getContentStream();
-            if (content == null) {
-                throw new Exception("No content!");
-            }
+        String filename = content.getFileName();
+        if ((filename == null) || (filename.length() == 0)) {
+            filename = doc.getContentStreamFileName();
+        }
+        if ((filename == null) || (filename.length() == 0)) {
+            filename = doc.getName();
+        }
+        if ((filename == null) || (filename.length() == 0)) {
+            filename = "document";
+        }
 
-            inStream = new BufferedInputStream(content.getStream());
+        File tempFile = ClientHelper.createTempFile(filename);
+        storeStream(content.getStream(), tempFile);
 
-            String filename = doc.getContentStreamFileName();
-            if ((filename == null) || (filename.length() == 0)) {
-                filename = doc.getName();
-            }
-            if ((filename == null) || (filename.length() == 0)) {
-                filename = "document";
-            }
+        return tempFile;
+    }
 
-            File tempFile = ClientHelper.createTempFile(filename);
-            outStream = new FileOutputStream(tempFile);
+    private static void storeStream(InputStream in, File file) throws IOException {
+        OutputStream out = null;
+        try {
+            out = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE);
 
-            byte[] buffer = new byte[4096];
+            byte[] buffer = new byte[BUFFER_SIZE];
             int b;
-            while ((b = inStream.read(buffer)) > -1) {
-                outStream.write(buffer, 0, b);
+            while ((b = in.read(buffer)) > -1) {
+                out.write(buffer, 0, b);
             }
 
-            return tempFile;
         } finally {
-            if (inStream != null) {
+            if (in != null) {
                 try {
-                    inStream.close();
-                } catch (IOException e) {
+                    in.close();
+                } catch (Exception e) {
                 }
             }
-            if (outStream != null) {
+            if (out != null) {
                 try {
-                    outStream.close();
-                } catch (IOException e) {
+                    out.close();
+                } catch (Exception e) {
                 }
             }
         }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java?rev=1003956&r1=1003955&r2=1003956&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java Sun Oct  3 12:44:35 2010
@@ -114,7 +114,7 @@ public class FolderTable extends JTable 
         addMouseListener(new MouseAdapter() {
             public void mouseClicked(MouseEvent e) {
                 if (e.getClickCount() == 2) {
-                    doAction();
+                    doAction(e.isShiftDown());
                 }
             }
         });
@@ -124,8 +124,8 @@ public class FolderTable extends JTable 
             }
 
             public void keyReleased(KeyEvent e) {
-                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
-                    doAction();
+                if (e.getKeyCode() == KeyEvent.VK_SPACE) {
+                    doAction(e.isShiftDown());
                 }
             }
 
@@ -150,14 +150,18 @@ public class FolderTable extends JTable 
         ((FolderTableModel) getModel()).fireTableDataChanged();
     }
 
-    private void doAction() {
+    private void doAction(boolean alternate) {
         int row = getSelectedRow();
         if ((row > -1) && (row < model.getCurrentChildren().size())) {
             String id = getValueAt(row, ID_COLUMN).toString();
             CmisObject object = model.getFromCurrentChildren(id);
 
             if (object instanceof Document) {
-                download((Document) object);
+                if (alternate) {
+                    ClientHelper.download(this.getParent(), (Document) object, null);
+                } else {
+                    ClientHelper.open(this.getParent(), (Document) object, null);
+                }
             } else if (object instanceof Folder) {
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
@@ -172,10 +176,6 @@ public class FolderTable extends JTable 
         }
     }
 
-    private void download(Document doc) {
-        ClientHelper.download(this.getParent(), doc, null);
-    }
-
     class FolderTableModel extends AbstractTableModel {
 
         private static final long serialVersionUID = 1L;
@@ -311,7 +311,7 @@ public class FolderTable extends JTable 
 
                     File tempFile = null;
                     try {
-                        tempFile = ClientHelper.createTempFileFromDocument(doc);
+                        tempFile = ClientHelper.createTempFileFromDocument(doc, null);
                     } catch (Exception e) {
                         ClientHelper.showError(null, e);
                     }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/TypesFrame.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/TypesFrame.java?rev=1003956&r1=1003955&r2=1003956&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/TypesFrame.java (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/TypesFrame.java Sun Oct  3 12:44:35 2010
@@ -72,7 +72,7 @@ public class TypesFrame extends JFrame {
 
     private void createGUI() {
         setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
-        setPreferredSize(new Dimension(800, 700));
+        setPreferredSize(new Dimension(1000, 700));
         setMinimumSize(new Dimension(200, 60));
 
         typesTree = new JTree();

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java?rev=1003956&r1=1003955&r2=1003956&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java Sun Oct  3 12:44:35 2010
@@ -99,8 +99,8 @@ public abstract class AbstractDetailsTab
             public void mouseClicked(MouseEvent e) {
                 if (e.getClickCount() == 2) {
                     int row = getSelectedRow();
-                    if ((row > -1) && (row < getModel().getColumnCount())) {
-                        doubleClickAction(row);
+                    if ((row > -1) && (row < getModel().getRowCount())) {
+                        doubleClickAction(e, row);
                     }
                 }
             }
@@ -141,7 +141,7 @@ public abstract class AbstractDetailsTab
         return String.class;
     }
 
-    public void doubleClickAction(int rowIndex) {
+    public void doubleClickAction(MouseEvent e, int rowIndex) {
     }
 
     static class DetailsTableModel extends AbstractTableModel {

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java?rev=1003956&r1=1003955&r2=1003956&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java Sun Oct  3 12:44:35 2010
@@ -61,30 +61,47 @@ public class ExtensionsPanel extends JPa
         DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
 
         if (object != null) {
+            List<CmisExtensionElement> extensions;
+
             // object extensions
-            DefaultMutableTreeNode objectRootNode = new DefaultMutableTreeNode("Object");
-            addExtension(objectRootNode, object.getExtensions(ExtensionLevel.OBJECT));
-            rootNode.add(objectRootNode);
+            extensions = object.getExtensions(ExtensionLevel.OBJECT);
+            if ((extensions != null) && (!extensions.isEmpty())) {
+                DefaultMutableTreeNode objectRootNode = new DefaultMutableTreeNode("Object");
+                addExtension(objectRootNode, extensions);
+                rootNode.add(objectRootNode);
+            }
 
             // property extensions
-            DefaultMutableTreeNode propertiesRootNode = new DefaultMutableTreeNode("Properties");
-            addExtension(propertiesRootNode, object.getExtensions(ExtensionLevel.PROPERTIES));
-            rootNode.add(propertiesRootNode);
+            extensions = object.getExtensions(ExtensionLevel.PROPERTIES);
+            if ((extensions != null) && (!extensions.isEmpty())) {
+                DefaultMutableTreeNode propertiesRootNode = new DefaultMutableTreeNode("Properties");
+                addExtension(propertiesRootNode, extensions);
+                rootNode.add(propertiesRootNode);
+            }
 
             // allowable actions extensions
-            DefaultMutableTreeNode allowableActionsRootNode = new DefaultMutableTreeNode("Allowable Actions");
-            addExtension(allowableActionsRootNode, object.getExtensions(ExtensionLevel.ALLOWABLE_ACTIONS));
-            rootNode.add(allowableActionsRootNode);
+            extensions = object.getExtensions(ExtensionLevel.ALLOWABLE_ACTIONS);
+            if ((extensions != null) && (!extensions.isEmpty())) {
+                DefaultMutableTreeNode allowableActionsRootNode = new DefaultMutableTreeNode("Allowable Actions");
+                addExtension(allowableActionsRootNode, extensions);
+                rootNode.add(allowableActionsRootNode);
+            }
 
             // ACL extensions
-            DefaultMutableTreeNode aclRootNode = new DefaultMutableTreeNode("ACL");
-            addExtension(aclRootNode, object.getExtensions(ExtensionLevel.ACL));
-            rootNode.add(aclRootNode);
+            extensions = object.getExtensions(ExtensionLevel.ACL);
+            if ((extensions != null) && (!extensions.isEmpty())) {
+                DefaultMutableTreeNode aclRootNode = new DefaultMutableTreeNode("ACL");
+                addExtension(aclRootNode, extensions);
+                rootNode.add(aclRootNode);
+            }
 
             // policies extensions
-            DefaultMutableTreeNode policiesRootNode = new DefaultMutableTreeNode("Policies");
-            addExtension(policiesRootNode, object.getExtensions(ExtensionLevel.POLICIES));
-            rootNode.add(policiesRootNode);
+            extensions = object.getExtensions(ExtensionLevel.POLICIES);
+            if ((extensions != null) && (!extensions.isEmpty())) {
+                DefaultMutableTreeNode policiesRootNode = new DefaultMutableTreeNode("Policies");
+                addExtension(policiesRootNode, extensions);
+                rootNode.add(policiesRootNode);
+            }
         }
 
         DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RenditionTable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RenditionTable.java?rev=1003956&r1=1003955&r2=1003956&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RenditionTable.java (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RenditionTable.java Sun Oct  3 12:44:35 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.chemistry.opencmis.swingclient.details;
 
+import java.awt.event.MouseEvent;
+
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.client.api.Rendition;
 import org.apache.chemistry.opencmis.swingclient.ClientHelper;
@@ -25,51 +27,48 @@ import org.apache.chemistry.opencmis.swi
 
 public class RenditionTable extends AbstractDetailsTable {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
+
+    private static final String[] COLUMN_NAMES = { "Title", "Kind", "MIME Type", "Size", "Stream Id" };
+    private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 80, 200 };
 
-	private static final String[] COLUMN_NAMES = { "Title", "Kind",
-			"MIME Type", "Size", "Stream Id" };
-	private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 80, 200 };
-
-	public RenditionTable(ClientModel model) {
-		super();
-		init(model, COLUMN_NAMES, COLUMN_WIDTHS);
-	}
-
-	@Override
-	public void doubleClickAction(int rowIndex) {
-		String streamId = getObject().getRenditions().get(rowIndex)
-				.getStreamId();
-		ClientHelper.download(this.getParent(), (Document) getObject(),
-				streamId);
-	}
-
-	@Override
-	public int getDetailRowCount() {
-		if (getObject().getRenditions() == null) {
-			return 0;
-		}
-
-		return getObject().getRenditions().size();
-	}
-
-	@Override
-	public Object getDetailValueAt(int rowIndex, int columnIndex) {
-		Rendition rendition = getObject().getRenditions().get(rowIndex);
-
-		switch (columnIndex) {
-		case 0:
-			return rendition.getTitle();
-		case 1:
-			return rendition.getKind();
-		case 2:
-			return rendition.getMimeType();
-		case 3:
-			return rendition.getLength();
-		case 4:
-			return rendition.getStreamId();
-		}
+    public RenditionTable(ClientModel model) {
+        super();
+        init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+    }
+
+    @Override
+    public void doubleClickAction(MouseEvent e, int rowIndex) {
+        String streamId = getObject().getRenditions().get(rowIndex).getStreamId();
+        ClientHelper.download(this, (Document) getObject(), streamId);
+    }
+
+    @Override
+    public int getDetailRowCount() {
+        if (getObject().getRenditions() == null) {
+            return 0;
+        }
+
+        return getObject().getRenditions().size();
+    }
+
+    @Override
+    public Object getDetailValueAt(int rowIndex, int columnIndex) {
+        Rendition rendition = getObject().getRenditions().get(rowIndex);
+
+        switch (columnIndex) {
+        case 0:
+            return rendition.getTitle();
+        case 1:
+            return rendition.getKind();
+        case 2:
+            return rendition.getMimeType();
+        case 3:
+            return rendition.getLength();
+        case 4:
+            return rendition.getStreamId();
+        }
 
-		return null;
-	}
+        return null;
+    }
 }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/VersionTable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/VersionTable.java?rev=1003956&r1=1003955&r2=1003956&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/VersionTable.java (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/VersionTable.java Sun Oct  3 12:44:35 2010
@@ -19,6 +19,7 @@
 package org.apache.chemistry.opencmis.swingclient.details;
 
 import java.awt.Cursor;
+import java.awt.event.MouseEvent;
 import java.util.Collections;
 import java.util.List;
 
@@ -29,94 +30,97 @@ import org.apache.chemistry.opencmis.swi
 
 public class VersionTable extends AbstractDetailsTable {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private static final String[] COLUMN_NAMES = { "Name", "Label", "Major",
-			"Id" };
-	private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 400 };
-
-	private static final int OLD = 60 * 1000;
-
-	private List<Document> versions;
-	private String lastId;
-	private long lastTimestamp;
-
-	public VersionTable(ClientModel model) {
-		super();
-
-		versions = Collections.emptyList();
-		lastId = null;
-		lastTimestamp = System.currentTimeMillis();
-		init(model, COLUMN_NAMES, COLUMN_WIDTHS);
-	}
-
-	@Override
-	public void doubleClickAction(int rowIndex) {
-		ClientHelper.download(this.getParent(), getVersions().get(rowIndex),
-				null);
-	}
-
-	@Override
-	public int getDetailRowCount() {
-		if (!(getObject() instanceof Document)) {
-			return 0;
-		}
-
-		return getVersions().size();
-	}
-
-	@Override
-	public Object getDetailValueAt(int rowIndex, int columnIndex) {
-		Document version = getVersions().get(rowIndex);
-
-		switch (columnIndex) {
-		case 0:
-			return version.getName();
-		case 1:
-			return version.getVersionLabel();
-		case 2:
-			return version.isMajorVersion();
-		case 3:
-			return version.getId();
-		}
-
-		return null;
-	}
-
-	private List<Document> getVersions() {
-		// not a document -> no versions
-		if (!(getObject() instanceof Document)) {
-			versions = Collections.emptyList();
-			lastId = null;
-
-			return versions;
-		}
-
-		// if the versions have been fetched recently, don't reload
-		Document doc = (Document) getObject();
-		if (doc.getId().equals(lastId)) {
-			if (lastTimestamp + OLD > System.currentTimeMillis()) {
-				return versions;
-			}
-		}
-
-		// reset everything
-		lastId = doc.getId();
-		lastTimestamp = System.currentTimeMillis();
-		versions = Collections.emptyList();
-
-		// get versions
-		try {
-			setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-			versions = doc.getAllVersions();
-		} catch (Exception ex) {
-			if (!(ex instanceof CmisNotSupportedException)) {
-				ClientHelper.showError(null, ex);
-			}
-		} finally {
-			setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-		}
+    private static final String[] COLUMN_NAMES = { "Name", "Label", "Major", "Id" };
+    private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 400 };
 
-		return versions;
-	}
+    private static final int OLD = 60 * 1000;
+
+    private List<Document> versions;
+    private String lastId;
+    private long lastTimestamp;
+
+    public VersionTable(ClientModel model) {
+        super();
+
+        versions = Collections.emptyList();
+        lastId = null;
+        lastTimestamp = System.currentTimeMillis();
+        init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+    }
+
+    @Override
+    public void doubleClickAction(MouseEvent e, int rowIndex) {
+        if (e.isShiftDown()) {
+            ClientHelper.download(this.getParent(), getVersions().get(rowIndex), null);
+        } else {
+            ClientHelper.open(this.getParent(), getVersions().get(rowIndex), null);
+        }
+
+    }
+
+    @Override
+    public int getDetailRowCount() {
+        if (!(getObject() instanceof Document)) {
+            return 0;
+        }
+
+        return getVersions().size();
+    }
+
+    @Override
+    public Object getDetailValueAt(int rowIndex, int columnIndex) {
+        Document version = getVersions().get(rowIndex);
+
+        switch (columnIndex) {
+        case 0:
+            return version.getName();
+        case 1:
+            return version.getVersionLabel();
+        case 2:
+            return version.isMajorVersion();
+        case 3:
+            return version.getId();
+        }
+
+        return null;
+    }
+
+    private List<Document> getVersions() {
+        // not a document -> no versions
+        if (!(getObject() instanceof Document)) {
+            versions = Collections.emptyList();
+            lastId = null;
+
+            return versions;
+        }
+
+        // if the versions have been fetched recently, don't reload
+        Document doc = (Document) getObject();
+        if (doc.getId().equals(lastId)) {
+            if (lastTimestamp + OLD > System.currentTimeMillis()) {
+                return versions;
+            }
+        }
+
+        // reset everything
+        lastId = doc.getId();
+        lastTimestamp = System.currentTimeMillis();
+        versions = Collections.emptyList();
+
+        // get versions
+        try {
+            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+            versions = doc.getAllVersions();
+        } catch (Exception ex) {
+            if (!(ex instanceof CmisNotSupportedException)) {
+                ClientHelper.showError(null, ex);
+            }
+        } finally {
+            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+        }
+
+        return versions;
+    }
 }