chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1003880 - in /incubator/chemistry/opencmis-swingclient/trunk/src/main: java/org/apache/chemistry/opencmis/swingclient/ java/org/apache/chemistry/opencmis/swingclient/model/ java/org/apache/chemistry/opencmis/swingclient/swing/ resources/im...
Date Sat, 02 Oct 2010 20:47:57 GMT
Author: fmui
Date: Sat Oct  2 20:47:57 2010
New Revision: 1003880

URL: http://svn.apache.org/viewvc?rev=1003880&view=rev
Log:
- added change log frame
- added upload script

Added:
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ChangeLogFrame.java
  (with props)
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/GregorianCalendarRenderer.java
  (with props)
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/changelog.png
  (with props)
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/upload.groovy
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/FolderTable.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/RepositoryInfoFrame.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/model/ClientModel.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties

Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ChangeLogFrame.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ChangeLogFrame.java?rev=1003880&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ChangeLogFrame.java
(added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ChangeLogFrame.java
Sat Oct  2 20:47:57 2010
@@ -0,0 +1,207 @@
+/*
+ * 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.swingclient;
+
+import java.awt.BorderLayout;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Collection;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableColumn;
+
+import org.apache.chemistry.opencmis.client.api.ChangeEvent;
+import org.apache.chemistry.opencmis.client.api.ChangeEvents;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+import org.apache.chemistry.opencmis.swingclient.swing.CollectionRenderer;
+import org.apache.chemistry.opencmis.swingclient.swing.GregorianCalendarRenderer;
+
+public class ChangeLogFrame extends JFrame {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final String WINDOW_TITLE = "CMIS Change Log";
+
+    private ClientModel model;
+
+    private JTextField changeLogTokenField;
+    private ChangeLogTable changeLogTable;
+
+    public ChangeLogFrame(ClientModel model) {
+        super();
+
+        this.model = model;
+        createGUI();
+    }
+
+    private void createGUI() {
+        setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
+        setPreferredSize(new Dimension(700, 700));
+        setMinimumSize(new Dimension(200, 60));
+
+        setLayout(new BorderLayout());
+
+        JPanel inputPanel = new JPanel(new BorderLayout());
+
+        inputPanel.add(new JLabel("Change Log Token:"), BorderLayout.LINE_START);
+
+        changeLogTokenField = new JTextField();
+        inputPanel.add(changeLogTokenField, BorderLayout.CENTER);
+
+        JButton loadButton = new JButton("Load");
+        loadButton.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+
+                String changeLogToken = changeLogTokenField.getText();
+                if (changeLogToken.trim().length() == 0) {
+                    changeLogToken = null;
+                }
+
+                ChangeEvents events = null;
+                try {
+                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+                    events = model.getClientSession().getSession().getContentChanges(changeLogToken,
true, 1000);
+                } catch (Exception ex) {
+                    ClientHelper.showError(null, ex);
+                    return;
+                } finally {
+                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+                }
+
+                changeLogTable.setChangeEvents(events.getChangeEvents());
+                changeLogTokenField.setText(events.getlatestChangeLogToken() == null ? ""
: events
+                        .getlatestChangeLogToken());
+            }
+        });
+        inputPanel.add(loadButton, BorderLayout.LINE_END);
+
+        add(inputPanel, BorderLayout.PAGE_START);
+
+        changeLogTable = new ChangeLogTable();
+        add(new JScrollPane(changeLogTable), BorderLayout.CENTER);
+
+        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        pack();
+
+        setLocationRelativeTo(null);
+        setVisible(true);
+    }
+
+    static class ChangeLogTable extends JTable {
+
+        private static final long serialVersionUID = 1L;
+
+        private static final String[] COLUMN_NAMES = { "Change Type", "Object Id", "Change
Time", "Properties" };
+        private static final int[] COLUMN_WIDTHS = { 100, 200, 200, 400 };
+
+        private List<ChangeEvent> changeEvents;
+
+        public ChangeLogTable() {
+            setDefaultRenderer(GregorianCalendar.class, new GregorianCalendarRenderer());
+            setDefaultRenderer(Collection.class, new CollectionRenderer());
+            setModel(new ChangeLogTableModel(this));
+
+            setAutoResizeMode(AUTO_RESIZE_OFF);
+            setAutoCreateRowSorter(true);
+
+            for (int i = 0; i < COLUMN_WIDTHS.length; i++) {
+                TableColumn column = getColumnModel().getColumn(i);
+                column.setPreferredWidth(COLUMN_WIDTHS[i]);
+            }
+
+            setFillsViewportHeight(true);
+        }
+
+        public void setChangeEvents(List<ChangeEvent> changeEvents) {
+            this.changeEvents = changeEvents;
+            ((AbstractTableModel) getModel()).fireTableDataChanged();
+        }
+
+        public List<ChangeEvent> getChangeEvents() {
+            return changeEvents;
+        }
+
+        static class ChangeLogTableModel extends AbstractTableModel {
+
+            private static final long serialVersionUID = 1L;
+
+            private ChangeLogTable table;
+
+            public ChangeLogTableModel(ChangeLogTable table) {
+                this.table = table;
+            }
+
+            public String getColumnName(int columnIndex) {
+                return COLUMN_NAMES[columnIndex];
+            }
+
+            public int getColumnCount() {
+                return COLUMN_NAMES.length;
+            }
+
+            public int getRowCount() {
+                if (table.getChangeEvents() == null) {
+                    return 0;
+                }
+
+                return table.getChangeEvents().size();
+            }
+
+            public Object getValueAt(int rowIndex, int columnIndex) {
+                ChangeEvent event = table.getChangeEvents().get(rowIndex);
+
+                switch (columnIndex) {
+                case 0:
+                    return (event.getChangeType() == null ? "?" : event.getChangeType().value());
+                case 1:
+                    return (event.getObjectId() == null ? "?" : event.getObjectId());
+                case 2:
+                    return event.getChangeTime();
+                case 3:
+                    return event.getProperties().entrySet();
+                }
+
+                return null;
+            }
+
+            @Override
+            public Class<?> getColumnClass(int columnIndex) {
+                if (columnIndex == 2) {
+                    return GregorianCalendar.class;
+                } else if (columnIndex == 3) {
+                    return Collection.class;
+                }
+
+                return super.getColumnClass(columnIndex);
+            }
+        }
+    }
+}

Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ChangeLogFrame.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=1003880&r1=1003879&r2=1003880&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
Sat Oct  2 20:47:57 2010
@@ -58,9 +58,10 @@ public class ClientFrame extends JFrame 
     private static final int BUTTON_REPOSITORY_INFO = 1;
     private static final int BUTTON_TYPES = 2;
     private static final int BUTTON_QUERY = 3;
-    private static final int BUTTON_CONSOLE = 4;
-    private static final int BUTTON_CREATE_DOCUMENT = 5;
-    private static final int BUTTON_CREATE_FOLDER = 6;
+    private static final int BUTTON_CHANGELOG = 4;
+    private static final int BUTTON_CONSOLE = 5;
+    private static final int BUTTON_CREATE_DOCUMENT = 6;
+    private static final int BUTTON_CREATE_FOLDER = 7;
     private static final int BUTTON_LOG = 8;
     private static final int BUTTON_INFO = 9;
 
@@ -153,6 +154,16 @@ public class ClientFrame extends JFrame 
 
         toolBar.add(toolbarButton[BUTTON_QUERY]);
 
+        toolbarButton[BUTTON_CHANGELOG] = new JButton("Change Log", ClientHelper.getIcon("changelog.png"));
+        toolbarButton[BUTTON_CHANGELOG].setEnabled(false);
+        toolbarButton[BUTTON_CHANGELOG].addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                new ChangeLogFrame(model);
+            }
+        });
+
+        toolBar.add(toolbarButton[BUTTON_CHANGELOG]);
+
         toolbarButton[BUTTON_CONSOLE] = new JButton("Console", ClientHelper.getIcon("console.png"));
         toolbarButton[BUTTON_CONSOLE].setEnabled(false);
         toolbarButton[BUTTON_CONSOLE].addActionListener(new ActionListener() {
@@ -252,6 +263,7 @@ public class ClientFrame extends JFrame 
                 toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(true);
                 toolbarButton[BUTTON_TYPES].setEnabled(true);
                 toolbarButton[BUTTON_QUERY].setEnabled(model.supportsQuery());
+                toolbarButton[BUTTON_CHANGELOG].setEnabled(model.supportsChangeLog());
                 toolbarButton[BUTTON_CONSOLE].setEnabled(true);
                 toolbarButton[BUTTON_CREATE_DOCUMENT].setEnabled(true);
                 toolbarButton[BUTTON_CREATE_FOLDER].setEnabled(true);
@@ -261,6 +273,7 @@ public class ClientFrame extends JFrame 
                 toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(false);
                 toolbarButton[BUTTON_TYPES].setEnabled(false);
                 toolbarButton[BUTTON_QUERY].setEnabled(false);
+                toolbarButton[BUTTON_CHANGELOG].setEnabled(false);
                 toolbarButton[BUTTON_CONSOLE].setEnabled(false);
                 toolbarButton[BUTTON_CREATE_DOCUMENT].setEnabled(false);
                 toolbarButton[BUTTON_CREATE_FOLDER].setEnabled(false);
@@ -281,7 +294,7 @@ public class ClientFrame extends JFrame 
             Console console = new Console(this.getClass().getClassLoader());
             console.setVariable("session", model.getClientSession().getSession());
             console.setVariable("binding", model.getClientSession().getSession().getBinding());
-            
+
             console.run();
 
             console.getInputArea().setText(readScript(path));

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=1003880&r1=1003879&r2=1003880&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
Sat Oct  2 20:47:57 2010
@@ -43,7 +43,6 @@ import javax.swing.TransferHandler;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 import javax.swing.table.AbstractTableModel;
-import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.TableColumn;
 
 import org.apache.chemistry.opencmis.client.api.CmisObject;
@@ -53,6 +52,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
 import org.apache.chemistry.opencmis.swingclient.model.ClientModelEvent;
 import org.apache.chemistry.opencmis.swingclient.model.FolderListener;
+import org.apache.chemistry.opencmis.swingclient.swing.GregorianCalendarRenderer;
 
 public class FolderTable extends JTable implements FolderListener {
 
@@ -245,18 +245,6 @@ public class FolderTable extends JTable 
         }
     }
 
-    class GregorianCalendarRenderer extends DefaultTableCellRenderer {
-        private static final long serialVersionUID = 1L;
-
-        public GregorianCalendarRenderer() {
-            super();
-        }
-
-        public void setValue(Object value) {
-            setText(ClientHelper.getDateString((GregorianCalendar) value));
-        }
-    }
-
     class FolderTransferHandler extends TransferHandler {
 
         private static final long serialVersionUID = 1L;

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java?rev=1003880&r1=1003879&r2=1003880&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java
Sat Oct  2 20:47:57 2010
@@ -79,7 +79,7 @@ public class QueryFrame extends JFrame {
 
     private void createGUI() {
         setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
-        setPreferredSize(new Dimension(800, 600));
+        setPreferredSize(new Dimension(800, 700));
         setMinimumSize(new Dimension(200, 60));
 
         setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/RepositoryInfoFrame.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/RepositoryInfoFrame.java?rev=1003880&r1=1003879&r2=1003880&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/RepositoryInfoFrame.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/RepositoryInfoFrame.java
Sat Oct  2 20:47:57 2010
@@ -34,172 +34,149 @@ import org.apache.chemistry.opencmis.swi
 
 public class RepositoryInfoFrame extends JFrame {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private static final String WINDOW_TITLE = "CMIS Repository Info";
+    private static final String WINDOW_TITLE = "CMIS Repository Info";
 
-	private ClientModel model;
+    private ClientModel model;
 
-	public RepositoryInfoFrame(ClientModel model) {
-		super();
+    public RepositoryInfoFrame(ClientModel model) {
+        super();
 
-		this.model = model;
-		createGUI();
-	}
-
-	private void createGUI() {
-		setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
-		setPreferredSize(new Dimension(700, 700));
-		setMinimumSize(new Dimension(200, 60));
-
-		RepositoryInfo repInfo = null;
-		try {
-			repInfo = model.getRepositoryInfo();
-		} catch (Exception e) {
-			ClientHelper.showError(this, e);
-			dispose();
-		}
-
-		add(new JScrollPane(new RepositoryInfoPanel(repInfo)));
-
-		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-		pack();
-
-		setLocationRelativeTo(null);
-		setVisible(true);
-	}
-
-	static class RepositoryInfoPanel extends InfoPanel {
-
-		private static final long serialVersionUID = 1L;
-
-		private RepositoryInfo repInfo;
-
-		public RepositoryInfoPanel(RepositoryInfo repInfo) {
-			super();
-
-			this.repInfo = repInfo;
-			createGUI();
-		}
-
-		private void createGUI() {
-			setupGUI();
-
-			addLine("Name:", true).setText(repInfo.getName());
-			addLine("Id:").setText(repInfo.getId());
-			addLine("Description:").setText(repInfo.getDescription());
-			addLine("Vendor:").setText(repInfo.getVendorName());
-			addLine("Product:").setText(
-					repInfo.getProductName() + " "
-							+ repInfo.getProductVersion());
-			addLine("CMIS Version:").setText(repInfo.getCmisVersionSupported());
-			addLine("Root folder Id:").setText(repInfo.getRootFolderId());
-			addLine("Latest change token:").setText(
-					repInfo.getLatestChangeLogToken());
-			addLine("Thin client URI:").setText(repInfo.getThinClientUri());
-			addLine("Principal id anonymous:").setText(
-					repInfo.getPrincipalIdAnonymous());
-			addLine("Principal id anyone:").setText(
-					repInfo.getPrincipalIdAnyone());
-			addCheckBox("Changes incomplete:").setSelected(
-					is(repInfo.getChangesIncomplete()));
-			addLine("Changes on type:").setText(
-					repInfo.getChangesOnType() == null ? "" : repInfo
-							.getChangesOnType().toString());
-
-			if (repInfo.getCapabilities() != null) {
-				RepositoryCapabilities cap = repInfo.getCapabilities();
-
-				addLine("Capabilities", true).setText("");
-
-				addCheckBox("Get descendants supported:").setSelected(
-						is(cap.isGetDescendantsSupported()));
-				addCheckBox("Get folder tree supported:").setSelected(
-						is(cap.isGetFolderTreeSupported()));
-				addCheckBox("Unfiling supported:").setSelected(
-						is(cap.isUnfilingSupported()));
-				addCheckBox("Multifiling supported:").setSelected(
-						is(cap.isMultifilingSupported()));
-				addCheckBox("Version specific filing supported:").setSelected(
-						is(cap.isVersionSpecificFilingSupported()));
-				addLine("Query:").setText(str(cap.getQueryCapability()));
-				addLine("Joins:").setText(str(cap.getJoinCapability()));
-				addCheckBox("All versions searchable:").setSelected(
-						is(cap.isAllVersionsSearchableSupported()));
-				addCheckBox("PWC searchable:").setSelected(
-						is(cap.isPwcSearchableSupported()));
-				addCheckBox("PWC updatable:").setSelected(
-						is(cap.isPwcUpdatableSupported()));
-				addLine("Content stream updates:").setText(
-						str(cap.getContentStreamUpdatesCapability()));
-				addLine("Renditions:").setText(
-						str(cap.getRenditionsCapability()));
-				addLine("Changes:").setText(str(cap.getChangesCapability()));
-				addLine("ACLs:").setText(str(cap.getAclCapability()));
-			}
-
-			if (repInfo.getAclCapabilities() != null) {
-				AclCapabilities cap = repInfo.getAclCapabilities();
-
-				addLine("ACL Capabilities", true).setText("");
-
-				addLine("Supported permissions:").setText(
-						str(cap.getSupportedPermissions()));
-				addLine("ACL propagation:").setText(
-						str(cap.getAclPropagation()));
-
-				if (cap.getPermissions() != null) {
-					String[][] data = new String[cap.getPermissions().size()][2];
-
-					int i = 0;
-					for (PermissionDefinition pd : cap.getPermissions()) {
-						data[i][0] = pd.getId();
-						data[i][1] = pd.getDescription();
-						i++;
-					}
-
-					JTable permTable = new JTable(data, new String[] {
-							"Permission", "Description" });
-					permTable.setFillsViewportHeight(true);
-					addComponent("Permissions", new JScrollPane(permTable));
-				}
-
-				if (cap.getPermissionMapping() != null) {
-					String[][] data = new String[cap.getPermissionMapping()
-							.size()][2];
-
-					int i = 0;
-					for (PermissionMapping pm : cap.getPermissionMapping()
-							.values()) {
-						data[i][0] = pm.getKey();
-						data[i][1] = (pm.getPermissions() == null ? "" : pm
-								.getPermissions().toString());
-						i++;
-					}
-
-					JTable permMapTable = new JTable(data, new String[] {
-							"Key", "Permissions" });
-					permMapTable.setFillsViewportHeight(true);
-					addComponent("Permission mapping", new JScrollPane(
-							permMapTable));
-				}
-			}
-		}
-
-		private boolean is(Boolean b) {
-			if (b == null) {
-				return false;
-			}
-
-			return b.booleanValue();
-		}
-
-		private String str(Object o) {
-			if (o == null) {
-				return "?";
-			}
-
-			return o.toString();
-		}
-	}
+        this.model = model;
+        createGUI();
+    }
+
+    private void createGUI() {
+        setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
+        setPreferredSize(new Dimension(700, 700));
+        setMinimumSize(new Dimension(200, 60));
+
+        RepositoryInfo repInfo = null;
+        try {
+            repInfo = model.getRepositoryInfo();
+        } catch (Exception e) {
+            ClientHelper.showError(this, e);
+            dispose();
+            return;
+        }
+
+        add(new JScrollPane(new RepositoryInfoPanel(repInfo)));
+
+        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        pack();
+
+        setLocationRelativeTo(null);
+        setVisible(true);
+    }
+
+    static class RepositoryInfoPanel extends InfoPanel {
+
+        private static final long serialVersionUID = 1L;
+
+        private RepositoryInfo repInfo;
+
+        public RepositoryInfoPanel(RepositoryInfo repInfo) {
+            super();
+
+            this.repInfo = repInfo;
+            createGUI();
+        }
+
+        private void createGUI() {
+            setupGUI();
+
+            addLine("Name:", true).setText(repInfo.getName());
+            addLine("Id:").setText(repInfo.getId());
+            addLine("Description:").setText(repInfo.getDescription());
+            addLine("Vendor:").setText(repInfo.getVendorName());
+            addLine("Product:").setText(repInfo.getProductName() + " " + repInfo.getProductVersion());
+            addLine("CMIS Version:").setText(repInfo.getCmisVersionSupported());
+            addLine("Root folder Id:").setText(repInfo.getRootFolderId());
+            addLine("Latest change token:").setText(repInfo.getLatestChangeLogToken());
+            addLine("Thin client URI:").setText(repInfo.getThinClientUri());
+            addLine("Principal id anonymous:").setText(repInfo.getPrincipalIdAnonymous());
+            addLine("Principal id anyone:").setText(repInfo.getPrincipalIdAnyone());
+            addCheckBox("Changes incomplete:").setSelected(is(repInfo.getChangesIncomplete()));
+            addLine("Changes on type:").setText(
+                    repInfo.getChangesOnType() == null ? "" : repInfo.getChangesOnType().toString());
+
+            if (repInfo.getCapabilities() != null) {
+                RepositoryCapabilities cap = repInfo.getCapabilities();
+
+                addLine("Capabilities", true).setText("");
+
+                addCheckBox("Get descendants supported:").setSelected(is(cap.isGetDescendantsSupported()));
+                addCheckBox("Get folder tree supported:").setSelected(is(cap.isGetFolderTreeSupported()));
+                addCheckBox("Unfiling supported:").setSelected(is(cap.isUnfilingSupported()));
+                addCheckBox("Multifiling supported:").setSelected(is(cap.isMultifilingSupported()));
+                addCheckBox("Version specific filing supported:").setSelected(
+                        is(cap.isVersionSpecificFilingSupported()));
+                addLine("Query:").setText(str(cap.getQueryCapability()));
+                addLine("Joins:").setText(str(cap.getJoinCapability()));
+                addCheckBox("All versions searchable:").setSelected(is(cap.isAllVersionsSearchableSupported()));
+                addCheckBox("PWC searchable:").setSelected(is(cap.isPwcSearchableSupported()));
+                addCheckBox("PWC updatable:").setSelected(is(cap.isPwcUpdatableSupported()));
+                addLine("Content stream updates:").setText(str(cap.getContentStreamUpdatesCapability()));
+                addLine("Renditions:").setText(str(cap.getRenditionsCapability()));
+                addLine("Changes:").setText(str(cap.getChangesCapability()));
+                addLine("ACLs:").setText(str(cap.getAclCapability()));
+            }
+
+            if (repInfo.getAclCapabilities() != null) {
+                AclCapabilities cap = repInfo.getAclCapabilities();
+
+                addLine("ACL Capabilities", true).setText("");
+
+                addLine("Supported permissions:").setText(str(cap.getSupportedPermissions()));
+                addLine("ACL propagation:").setText(str(cap.getAclPropagation()));
+
+                if (cap.getPermissions() != null) {
+                    String[][] data = new String[cap.getPermissions().size()][2];
+
+                    int i = 0;
+                    for (PermissionDefinition pd : cap.getPermissions()) {
+                        data[i][0] = pd.getId();
+                        data[i][1] = pd.getDescription();
+                        i++;
+                    }
+
+                    JTable permTable = new JTable(data, new String[] { "Permission", "Description"
});
+                    permTable.setFillsViewportHeight(true);
+                    addComponent("Permissions", new JScrollPane(permTable));
+                }
+
+                if (cap.getPermissionMapping() != null) {
+                    String[][] data = new String[cap.getPermissionMapping().size()][2];
+
+                    int i = 0;
+                    for (PermissionMapping pm : cap.getPermissionMapping().values()) {
+                        data[i][0] = pm.getKey();
+                        data[i][1] = (pm.getPermissions() == null ? "" : pm.getPermissions().toString());
+                        i++;
+                    }
+
+                    JTable permMapTable = new JTable(data, new String[] { "Key", "Permissions"
});
+                    permMapTable.setFillsViewportHeight(true);
+                    addComponent("Permission mapping", new JScrollPane(permMapTable));
+                }
+            }
+        }
+
+        private boolean is(Boolean b) {
+            if (b == null) {
+                return false;
+            }
+
+            return b.booleanValue();
+        }
+
+        private String str(Object o) {
+            if (o == null) {
+                return "?";
+            }
+
+            return o.toString();
+        }
+    }
 }

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=1003880&r1=1003879&r2=1003880&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
Sat Oct  2 20:47:57 2010
@@ -72,7 +72,7 @@ public class TypesFrame extends JFrame {
 
     private void createGUI() {
         setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
-        setPreferredSize(new Dimension(800, 600));
+        setPreferredSize(new Dimension(800, 700));
         setMinimumSize(new Dimension(200, 60));
 
         typesTree = new JTree();
@@ -336,14 +336,14 @@ public class TypesFrame extends JFrame {
 
         static class PropertyDefinitionTableModel extends AbstractTableModel {
 
+            private static final long serialVersionUID = 1L;
+
             private PropertyDefinitionTable table;
 
             public PropertyDefinitionTableModel(PropertyDefinitionTable table) {
                 this.table = table;
             }
 
-            private static final long serialVersionUID = 1L;
-
             public String getColumnName(int columnIndex) {
                 return COLUMN_NAMES[columnIndex];
             }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java?rev=1003880&r1=1003879&r2=1003880&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
Sat Oct  2 20:47:57 2010
@@ -113,6 +113,16 @@ public class ClientModel {
         }
     }
 
+    public synchronized boolean supportsChangeLog() {
+        try {
+            return (getRepositoryInfo().getChangesOnType() != null)
+                    && (!getRepositoryInfo().getChangesOnType().isEmpty());
+        } catch (Exception e) {
+            return false;
+        }
+
+    }
+
     public synchronized void loadFolder(String folderId, boolean byPath) throws Exception
{
         try {
             Session session = clientSession.getSession();

Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/GregorianCalendarRenderer.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/GregorianCalendarRenderer.java?rev=1003880&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/GregorianCalendarRenderer.java
(added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/GregorianCalendarRenderer.java
Sat Oct  2 20:47:57 2010
@@ -0,0 +1,37 @@
+/*
+ * 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.swingclient.swing;
+
+import java.util.GregorianCalendar;
+
+import javax.swing.table.DefaultTableCellRenderer;
+
+import org.apache.chemistry.opencmis.swingclient.ClientHelper;
+
+public class GregorianCalendarRenderer extends DefaultTableCellRenderer {
+    private static final long serialVersionUID = 1L;
+
+    public GregorianCalendarRenderer() {
+        super();
+    }
+
+    public void setValue(Object value) {
+        setText(ClientHelper.getDateString((GregorianCalendar) value));
+    }
+}
\ No newline at end of file

Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/GregorianCalendarRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy?rev=1003880&r1=1003879&r2=1003880&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy
Sat Oct  2 20:47:57 2010
@@ -19,6 +19,8 @@
 package scripts
 
 import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
 
 import org.apache.chemistry.opencmis.commons.*
 import org.apache.chemistry.opencmis.commons.data.*
@@ -122,6 +124,24 @@ class CMIS {
         versioningState, session.getDefaultContext())
     }
     
+    Document createDocumentFromFile(parent, File file, String type = "cmis:document", 
+    VersioningState versioningState = VersioningState.MAJOR) {
+        CmisObject parentFolder = getFolder(parent)
+        
+        def name = file.getName()
+        def mimetype = org.apache.chemistry.opencmis.swingclient.model.MIMETypes.getMIMEType(file)
+        
+        def properties = [
+                    (PropertyIds.OBJECT_TYPE_ID): type,
+                    (PropertyIds.NAME): name
+                ]
+        
+        def contentStream = new ContentStreamImpl(name, file.size(), mimetype, new FileInputStream(file))
+        
+        return parentFolder.createDocument(properties, contentStream,
+        versioningState, session.getDefaultContext())
+    }
+    
     void delete(id) {
         getObject(id).delete(true)
     }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties?rev=1003880&r1=1003879&r2=1003880&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties
Sat Oct  2 20:47:57 2010
@@ -30,3 +30,4 @@ template.groovy = - Basic template -
 getdescendants.groovy = Print descendants tree
 query.groovy = Execute a query
 counttypes.groovy = Count types and sub types
+upload.groovy = Upload a local folder to the repository

Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/upload.groovy
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/upload.groovy?rev=1003880&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/upload.groovy
(added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/upload.groovy
Sat Oct  2 20:47:57 2010
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
+
+CMIS cmis = new scripts.CMIS(session)
+
+// destination folder
+Folder destFolder = cmis.getFolder("/")
+
+// source folder
+String localPath = "/some/local/folder"
+
+// upload folder tree
+upload(destFolder, localPath)
+
+
+//--------------------------------------------------
+
+def upload(destination, String localPath, 
+String folderType = "cmis:folder",
+String documentType = "cmis:document",
+VersioningState versioningState = VersioningState.MAJOR) {
+    
+    println "Uploading...\n"   
+    doUpload(destination, new File(localPath), folderType, documentType, versioningState)
+    println "\n...done."
+}
+
+def doUpload(Folder parent, File folder, String folderType, String documentType, VersioningState
versioningState) {
+    folder.eachFile {
+        println it.getName()
+        
+        if(it.isFile()) {
+            cmis.createDocumentFromFile(parent, it, documentType, versioningState)
+        }
+        else if(it.isDirectory()) {
+            Folder newFolder = cmis.createFolder(parent, it.getName(), folderType)
+            doUpload(newFolder, it, folderType, documentType, versioningState)
+        }
+    }
+}



Mime
View raw message