chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1096359 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main: java/org/apache/chemistry/opencmis/workbench/ java/org/apache/chemistry/opencmis/workbench/details/ java/org/apache/chemistry/opencm...
Date Sun, 24 Apr 2011 18:42:06 GMT
Author: fmui
Date: Sun Apr 24 18:42:05 2011
New Revision: 1096359

URL: http://svn.apache.org/viewvc?rev=1096359&view=rev
Log:
CMIS Workbench improvements (asynchronous retrieval of the version history, fewer scrollbars)

Modified:
    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/details/DetailsTabs.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/java/org/apache/chemistry/opencmis/workbench/details/VersionTable.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/META-INF/README

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=1096359&r1=1096358&r2=1096359&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
Sun Apr 24 18:42:05 2011
@@ -43,7 +43,6 @@ import javax.swing.JFrame;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
-import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.JToolBar;
 
@@ -256,7 +255,7 @@ public class ClientFrame extends JFrame 
         folderPanel = new FolderPanel(model);
         detailsTabs = new DetailsTabs(model);
 
-        split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, folderPanel, new JScrollPane(detailsTabs));
+        split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, folderPanel, detailsTabs);
 
         pane.add(split, BorderLayout.CENTER);
 
@@ -336,8 +335,8 @@ public class ClientFrame extends JFrame 
 
             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://chemistry.apache.org/java/opencmis.html"));
+            addConsoleMenu(cmisMenu, "OpenCMIS Documentation",
+                    new URI("http://chemistry.apache.org/java/opencmis.html"));
             addConsoleMenu(
                     cmisMenu,
                     "OpenCMIS Client API JavaDoc",

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/DetailsTabs.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/DetailsTabs.java?rev=1096359&r1=1096358&r2=1096359&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/DetailsTabs.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/DetailsTabs.java
Sun Apr 24 18:42:05 2011
@@ -59,7 +59,7 @@ public class DetailsTabs extends JTabbed
         typesPanel = new TypesPanel(model);
         extensionsPanel = new ExtensionsPanel(model);
 
-        addTab("Object", objectPanel);
+        addTab("Object", new JScrollPane(objectPanel));
         addTab("Actions", new JScrollPane(actionsPanel));
         addTab("Properties", new JScrollPane(propertyTable));
         addTab("Relationships", new JScrollPane(relationshipTable));

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=1096359&r1=1096358&r2=1096359&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
Sun Apr 24 18:42:05 2011
@@ -92,7 +92,7 @@ public class ObjectPanel extends InfoPan
                             @Override
                             public void run() {
                                 try {
-                                    List<String> pathsList = (pathObject).getPaths();
+                                    List<String> pathsList = pathObject.getPaths();
                                     if ((pathsList == null) || (pathsList.size() == 0)) {
                                         paths.setList(Collections.singletonList("(unfiled)"));
                                     } else {
@@ -100,6 +100,7 @@ public class ObjectPanel extends InfoPan
                                     }
                                 } catch (Exception e) {
                                     paths.setList(Collections.singletonList("(???)"));
+                                    // ClientHelper.showError(null, e);
                                 }
                                 ObjectPanel.this.revalidate();
                             }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/VersionTable.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/VersionTable.java?rev=1096359&r1=1096358&r2=1096359&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/VersionTable.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/VersionTable.java
Sun Apr 24 18:42:05 2011
@@ -22,40 +22,86 @@ import java.awt.Cursor;
 import java.awt.event.MouseEvent;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import javax.swing.SwingUtilities;
 
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.workbench.ClientHelper;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent;
 
 public class VersionTable extends AbstractDetailsTable {
 
     private static final long serialVersionUID = 1L;
 
-    private static final String[] COLUMN_NAMES = { "Name", "Label", "Latest", "Major", "Latest
Major", "Id", "Filename", "MIME Type", "Length" };
+    private static final String[] COLUMN_NAMES = { "Name", "Label", "Latest", "Major", "Latest
Major", "Id",
+            "Filename", "MIME Type", "Length" };
     private static final int[] COLUMN_WIDTHS = { 200, 200, 50, 50, 50, 400, 200, 100, 100
};
 
-    private static final int OLD = 60 * 1000;
-
     private List<Document> versions;
-    private String lastId;
-    private long lastTimestamp;
+    private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
 
     public VersionTable(ClientModel model) {
         super();
 
         versions = Collections.emptyList();
-        lastId = null;
-        lastTimestamp = System.currentTimeMillis();
         init(model, COLUMN_NAMES, COLUMN_WIDTHS);
     }
 
     @Override
+    public void objectLoaded(ClientModelEvent event) {
+        lock.writeLock().lock();
+        try {
+            versions = Collections.emptyList();
+        } finally {
+            lock.writeLock().unlock();
+        }
+
+        if (getObject() instanceof Document) {
+            final Document doc = (Document) getObject();
+
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+                        List<Document> newVersions = doc.getAllVersions(getClientModel().getClientSession()
+                                .geVersionOperationContext());
+
+                        lock.writeLock().lock();
+                        try {
+                            versions = newVersions;
+                        } finally {
+                            lock.writeLock().unlock();
+                        }
+                    } catch (Exception ex) {
+                        if (!(ex instanceof CmisNotSupportedException)) {
+                            ClientHelper.showError(null, ex);
+                        }
+                    } finally {
+                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+                    }
+                    ((DetailsTableModel) getModel()).fireTableDataChanged();
+                }
+            });
+        }
+
+        super.objectLoaded(event);
+    }
+
+    @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);
+        lock.readLock().lock();
+        try {
+            if (e.isShiftDown()) {
+                ClientHelper.download(this.getParent(), versions.get(rowIndex), null);
+            } else {
+                ClientHelper.open(this.getParent(), versions.get(rowIndex), null);
+            }
+        } finally {
+            lock.readLock().unlock();
         }
     }
 
@@ -65,12 +111,24 @@ public class VersionTable extends Abstra
             return 0;
         }
 
-        return getVersions().size();
+        lock.readLock().lock();
+        try {
+            return versions.size();
+        } finally {
+            lock.readLock().unlock();
+        }
     }
 
     @Override
     public Object getDetailValueAt(int rowIndex, int columnIndex) {
-        Document version = getVersions().get(rowIndex);
+        Document version = null;
+
+        lock.readLock().lock();
+        try {
+            version = versions.get(rowIndex);
+        } finally {
+            lock.readLock().unlock();
+        }
 
         switch (columnIndex) {
         case 0:
@@ -98,50 +156,12 @@ public class VersionTable extends Abstra
 
     @Override
     public Class<?> getDetailColumClass(int columnIndex) {
-        if((columnIndex == 2) || (columnIndex == 3) || (columnIndex == 4)) {
-            return Boolean.class;            
-        }
-        else if (columnIndex == 8) {
+        if ((columnIndex == 2) || (columnIndex == 3) || (columnIndex == 4)) {
+            return Boolean.class;
+        } else if (columnIndex == 8) {
             return Long.class;
         }
 
         return super.getDetailColumClass(columnIndex);
     }
-
-    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;
-    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java?rev=1096359&r1=1096358&r2=1096359&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
Sun Apr 24 18:42:05 2011
@@ -51,24 +51,39 @@ public class ClientSession {
     public static final String WORKBENCH_PREFIX = "cmis.workbench.";
     public static final String OBJECT_PREFIX = WORKBENCH_PREFIX + "object.";
     public static final String FOLDER_PREFIX = WORKBENCH_PREFIX + "folder.";
+    public static final String VERSION_PREFIX = WORKBENCH_PREFIX + "version.";
     public static final String ACCEPT_SELF_SIGNED_CERTIFICATES = WORKBENCH_PREFIX + "acceptSelfSignedCertificates";
 
     public enum Authentication {
         NONE, STANDARD, NTLM
     }
 
-    private static final Set<String> PROPERTY_SET = new HashSet<String>();
+    private static final Set<String> FOLDER_PROPERTY_SET = new HashSet<String>();
     static {
-        PROPERTY_SET.add(PropertyIds.OBJECT_ID);
-        PROPERTY_SET.add(PropertyIds.OBJECT_TYPE_ID);
-        PROPERTY_SET.add(PropertyIds.NAME);
-        PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_MIME_TYPE);
-        PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_LENGTH);
-        PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_FILE_NAME);
-        PROPERTY_SET.add(PropertyIds.CREATED_BY);
-        PROPERTY_SET.add(PropertyIds.CREATION_DATE);
-        PROPERTY_SET.add(PropertyIds.LAST_MODIFIED_BY);
-        PROPERTY_SET.add(PropertyIds.LAST_MODIFICATION_DATE);
+        FOLDER_PROPERTY_SET.add(PropertyIds.OBJECT_ID);
+        FOLDER_PROPERTY_SET.add(PropertyIds.OBJECT_TYPE_ID);
+        FOLDER_PROPERTY_SET.add(PropertyIds.NAME);
+        FOLDER_PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_MIME_TYPE);
+        FOLDER_PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_LENGTH);
+        FOLDER_PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_FILE_NAME);
+        FOLDER_PROPERTY_SET.add(PropertyIds.CREATED_BY);
+        FOLDER_PROPERTY_SET.add(PropertyIds.CREATION_DATE);
+        FOLDER_PROPERTY_SET.add(PropertyIds.LAST_MODIFIED_BY);
+        FOLDER_PROPERTY_SET.add(PropertyIds.LAST_MODIFICATION_DATE);
+    }
+
+    private static final Set<String> VERSION_PROPERTY_SET = new HashSet<String>();
+    static {
+        VERSION_PROPERTY_SET.add(PropertyIds.OBJECT_ID);
+        VERSION_PROPERTY_SET.add(PropertyIds.OBJECT_TYPE_ID);
+        VERSION_PROPERTY_SET.add(PropertyIds.NAME);
+        VERSION_PROPERTY_SET.add(PropertyIds.VERSION_LABEL);
+        VERSION_PROPERTY_SET.add(PropertyIds.IS_LATEST_VERSION);
+        VERSION_PROPERTY_SET.add(PropertyIds.IS_MAJOR_VERSION);
+        VERSION_PROPERTY_SET.add(PropertyIds.IS_LATEST_MAJOR_VERSION);
+        VERSION_PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_MIME_TYPE);
+        VERSION_PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_LENGTH);
+        VERSION_PROPERTY_SET.add(PropertyIds.CONTENT_STREAM_FILE_NAME);
     }
 
     private Map<String, String> sessionParameters;
@@ -76,6 +91,7 @@ public class ClientSession {
     private Session session;
     private OperationContext objectOperationContext;
     private OperationContext folderOperationContext;
+    private OperationContext versionOperationContext;
 
     public ClientSession(Map<String, String> sessionParameters) {
         if (sessionParameters == null) {
@@ -174,6 +190,10 @@ public class ClientSession {
         return folderOperationContext;
     }
 
+    public OperationContext geVersionOperationContext() {
+        return versionOperationContext;
+    }
+
     private void createOperationContexts() {
         // object operation context
         setDefault(OBJECT_PREFIX, sessionParameters, ClientOperationContext.FILTER, "*");
@@ -193,7 +213,7 @@ public class ClientSession {
             ObjectType type = session.getTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value());
 
             StringBuilder filter = new StringBuilder();
-            for (String propId : PROPERTY_SET) {
+            for (String propId : FOLDER_PROPERTY_SET) {
                 PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(propId);
                 if (propDef != null) {
                     if (filter.length() > 0) {
@@ -213,9 +233,36 @@ public class ClientSession {
                 IncludeRelationships.NONE.value());
         setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.RENDITION_FILTER,
"cmis:none");
         setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.ORDER_BY, null);
-        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.MAX_ITEMS_PER_PAGE,
"1000");
+        setDefault(FOLDER_PREFIX, sessionParameters, ClientOperationContext.MAX_ITEMS_PER_PAGE,
"10000");
 
         folderOperationContext = new ClientOperationContext(FOLDER_PREFIX, sessionParameters);
+
+        if (!sessionParameters.containsKey(VERSION_PREFIX + ClientOperationContext.FILTER))
{
+            ObjectType type = session.getTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value());
+
+            StringBuilder filter = new StringBuilder();
+            for (String propId : VERSION_PROPERTY_SET) {
+                PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(propId);
+                if (propDef != null) {
+                    if (filter.length() > 0) {
+                        filter.append(",");
+                    }
+                    filter.append(propDef.getQueryName());
+                }
+            }
+
+            sessionParameters.put(VERSION_PREFIX + ClientOperationContext.FILTER, filter.toString());
+        }
+
+        setDefault(VERSION_PREFIX, sessionParameters, ClientOperationContext.INCLUDE_ACLS,
"false");
+        setDefault(VERSION_PREFIX, sessionParameters, ClientOperationContext.INCLUDE_ALLOWABLE_ACTIONS,
"false");
+        setDefault(VERSION_PREFIX, sessionParameters, ClientOperationContext.INCLUDE_POLICIES,
"false");
+        setDefault(VERSION_PREFIX, sessionParameters, ClientOperationContext.INCLUDE_RELATIONSHIPS,
+                IncludeRelationships.NONE.value());
+        setDefault(VERSION_PREFIX, sessionParameters, ClientOperationContext.RENDITION_FILTER,
"cmis:none");
+        setDefault(VERSION_PREFIX, sessionParameters, ClientOperationContext.MAX_ITEMS_PER_PAGE,
"10000");
+
+        versionOperationContext = new ClientOperationContext(VERSION_PREFIX, sessionParameters);
     }
 
     private void setDefault(String prefix, Map<String, String> map, String key, String
value) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/META-INF/README
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/META-INF/README?rev=1096359&r1=1096358&r2=1096359&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/META-INF/README
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/META-INF/README
Sun Apr 24 18:42:05 2011
@@ -43,6 +43,16 @@ cmis.workbench.object.includeRelationshi
 cmis.workbench.object.renditionFilter
 
 
+Version operation context:
+
+cmis.workbench.version.filter
+cmis.workbench.version.includeAcls
+cmis.workbench.version.includeAllowableActions
+cmis.workbench.version.includePolicies
+cmis.workbench.version.includeRelationships
+cmis.workbench.version.renditionFilter
+cmis.workbench.version.maxItemsPerPage
+
 Others:
 
 cmis.workbench.acceptSelfSignedCertificates - disable SSL certificate check (true/false)
\ No newline at end of file



Mime
View raw message