chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r996864 - in /incubator/chemistry/opencmis-swingclient/trunk: pom.xml src/main/java/org/apache/chemistry/opencmis/swingclient/details/DetailsTabs.java src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
Date Tue, 14 Sep 2010 12:22:28 GMT
Author: fmui
Date: Tue Sep 14 12:22:28 2010
New Revision: 996864

URL: http://svn.apache.org/viewvc?rev=996864&view=rev
Log:
- switched Swing Client to OpenCMIS 0.2.0
- added extensions view tab

Added:
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
  (with props)
Modified:
    incubator/chemistry/opencmis-swingclient/trunk/pom.xml
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/DetailsTabs.java

Modified: incubator/chemistry/opencmis-swingclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/pom.xml?rev=996864&r1=996863&r2=996864&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/pom.xml (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/pom.xml Tue Sep 14 12:22:28 2010
@@ -227,7 +227,7 @@
         <dependency>
             <groupId>org.apache.chemistry.opencmis</groupId>
             <artifactId>chemistry-opencmis-client-impl</artifactId>
-            <version>0.1.0-incubating-SNAPSHOT</version>
+            <version>0.2.0-incubating-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>log4j</groupId>

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/DetailsTabs.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/DetailsTabs.java?rev=996864&r1=996863&r2=996864&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/DetailsTabs.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/DetailsTabs.java
Tue Sep 14 12:22:28 2010
@@ -25,43 +25,46 @@ import org.apache.chemistry.opencmis.swi
 
 public class DetailsTabs extends JTabbedPane {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private ClientModel model;
+    private ClientModel model;
 
-	private ObjectPanel objectPanel;
-	private ActionsPanel actionsPanel;
-	private PropertyTable propertyTable;
-	private RelationshipTable relationshipTable;
-	private RenditionTable renditionTable;
-	private ACLTable aclTable;
-	private PolicyTable policyTable;
-	private VersionTable versionTable;
-
-	public DetailsTabs(ClientModel model) {
-		super(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
-
-		this.model = model;
-		createGUI();
-	}
-
-	private void createGUI() {
-		objectPanel = new ObjectPanel(model);
-		actionsPanel = new ActionsPanel(model);
-		propertyTable = new PropertyTable(model);
-		relationshipTable = new RelationshipTable(model);
-		renditionTable = new RenditionTable(model);
-		aclTable = new ACLTable(model);
-		policyTable = new PolicyTable(model);
-		versionTable = new VersionTable(model);
-
-		addTab("Object", objectPanel);
-		addTab("Actions", new JScrollPane(actionsPanel));
-		addTab("Properties", new JScrollPane(propertyTable));
-		addTab("Relationships", new JScrollPane(relationshipTable));
-		addTab("Renditions", new JScrollPane(renditionTable));
-		addTab("ACL", new JScrollPane(aclTable));
-		addTab("Policies", new JScrollPane(policyTable));
-		addTab("Versions", new JScrollPane(versionTable));
-	}
+    private ObjectPanel objectPanel;
+    private ActionsPanel actionsPanel;
+    private PropertyTable propertyTable;
+    private RelationshipTable relationshipTable;
+    private RenditionTable renditionTable;
+    private ACLTable aclTable;
+    private PolicyTable policyTable;
+    private VersionTable versionTable;
+    private ExtensionsPanel extensionsPanel;
+
+    public DetailsTabs(ClientModel model) {
+        super(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
+
+        this.model = model;
+        createGUI();
+    }
+
+    private void createGUI() {
+        objectPanel = new ObjectPanel(model);
+        actionsPanel = new ActionsPanel(model);
+        propertyTable = new PropertyTable(model);
+        relationshipTable = new RelationshipTable(model);
+        renditionTable = new RenditionTable(model);
+        aclTable = new ACLTable(model);
+        policyTable = new PolicyTable(model);
+        versionTable = new VersionTable(model);
+        extensionsPanel = new ExtensionsPanel(model);
+
+        addTab("Object", objectPanel);
+        addTab("Actions", new JScrollPane(actionsPanel));
+        addTab("Properties", new JScrollPane(propertyTable));
+        addTab("Relationships", new JScrollPane(relationshipTable));
+        addTab("Renditions", new JScrollPane(renditionTable));
+        addTab("ACL", new JScrollPane(aclTable));
+        addTab("Policies", new JScrollPane(policyTable));
+        addTab("Versions", new JScrollPane(versionTable));
+        addTab("Extensions", new JScrollPane(extensionsPanel));
+    }
 }

Added: 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=996864&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
(added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ExtensionsPanel.java
Tue Sep 14 12:22:28 2010
@@ -0,0 +1,140 @@
+/*
+ * 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.details;
+
+import java.awt.Color;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeSelectionModel;
+
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.enums.ExtensionLevel;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModelEvent;
+import org.apache.chemistry.opencmis.swingclient.model.ObjectListener;
+
+public class ExtensionsPanel extends JPanel implements ObjectListener {
+
+    private static final long serialVersionUID = 1L;
+
+    private ClientModel model;
+
+    private JTree extensionsTree;
+
+    public ExtensionsPanel(ClientModel model) {
+        super();
+
+        this.model = model;
+        model.addObjectListener(this);
+
+        createGUI();
+    }
+
+    @Override
+    public void objectLoaded(ClientModelEvent event) {
+        CmisObject object = model.getCurrentObject();
+
+        DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
+
+        // object extensions
+        DefaultMutableTreeNode objectRootNode = new DefaultMutableTreeNode("Object");
+        addExtension(objectRootNode, object.getExtensions(ExtensionLevel.OBJECT));
+        rootNode.add(objectRootNode);
+
+        // property extensions
+        DefaultMutableTreeNode propertiesRootNode = new DefaultMutableTreeNode("Properties");
+        addExtension(propertiesRootNode, object.getExtensions(ExtensionLevel.PROPERTIES));
+        rootNode.add(propertiesRootNode);
+
+        // allowable actions extensions
+        DefaultMutableTreeNode allowableActionsRootNode = new DefaultMutableTreeNode("Allowable
Actions");
+        addExtension(allowableActionsRootNode, object.getExtensions(ExtensionLevel.ALLOWABLE_ACTIONS));
+        rootNode.add(allowableActionsRootNode);
+
+        // ACL extensions
+        DefaultMutableTreeNode aclRootNode = new DefaultMutableTreeNode("ACL");
+        addExtension(aclRootNode, object.getExtensions(ExtensionLevel.ACL));
+        rootNode.add(aclRootNode);
+
+        // policies extensions
+        DefaultMutableTreeNode policiesRootNode = new DefaultMutableTreeNode("Policies");
+        addExtension(policiesRootNode, object.getExtensions(ExtensionLevel.POLICIES));
+        rootNode.add(policiesRootNode);
+
+        DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
+
+        extensionsTree.setModel(treeModel);
+    }
+
+    private void addExtension(DefaultMutableTreeNode parent, List<CmisExtensionElement>
extensions) {
+        if ((extensions == null) || (extensions.isEmpty())) {
+            return;
+        }
+
+        for (CmisExtensionElement ext : extensions) {
+            DefaultMutableTreeNode node = new DefaultMutableTreeNode(new ExtensionNode(ext));
+            parent.add(node);
+
+            if (ext.getChildren().size() > 0) {
+                addExtension(node, ext.getChildren());
+            }
+        }
+    }
+
+    private void createGUI() {
+        setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+        setBorder(BorderFactory.createEmptyBorder());
+        setBackground(Color.WHITE);
+
+        extensionsTree = new JTree();
+        extensionsTree.setRootVisible(false);
+        extensionsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+        extensionsTree.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+        extensionsTree.setModel(new DefaultTreeModel(null));
+
+        JScrollPane pane = new JScrollPane(extensionsTree);
+        pane.setBorder(BorderFactory.createEmptyBorder());
+
+        add(pane);
+    }
+
+    static class ExtensionNode {
+        private CmisExtensionElement extension;
+
+        public ExtensionNode(CmisExtensionElement extension) {
+            this.extension = extension;
+        }
+
+        @Override
+        public String toString() {
+            return (extension.getNamespace() == null ? "" : "{" + extension.getNamespace()
+ "}") + extension.getName()
+                    + (!extension.getAttributes().isEmpty() ? " " + extension.getAttributes()
: "")
+                    + (extension.getChildren().isEmpty() ? ": " + extension.getValue() :
"");
+        }
+    }
+}

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



Mime
View raw message