chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1239790 - /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
Date Thu, 02 Feb 2012 19:48:43 GMT
Author: fmui
Date: Thu Feb  2 19:48:43 2012
New Revision: 1239790

URL: http://svn.apache.org/viewvc?rev=1239790&view=rev
Log:
Workbench: added extension tree to repository info window

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java?rev=1239790&r1=1239789&r2=1239790&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
Thu Feb  2 19:48:43 2012
@@ -19,12 +19,19 @@
 package org.apache.chemistry.opencmis.workbench;
 
 import java.awt.Dimension;
+import java.util.List;
 
+import javax.swing.BorderFactory;
 import javax.swing.JFrame;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeSelectionModel;
 
 import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
 import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
 import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
@@ -163,6 +170,34 @@ public class RepositoryInfoFrame extends
                     addComponent("Permission mapping:", new JScrollPane(permMapTable));
                 }
             }
+
+            if (repInfo.getExtensions() != null && !repInfo.getExtensions().isEmpty())
{
+                JTree extensionsTree = new JTree();
+                extensionsTree.setRootVisible(false);
+                extensionsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+       
+                DefaultMutableTreeNode extRootNode = new DefaultMutableTreeNode("Extensions");
+                addExtension(extRootNode, repInfo.getExtensions());
+
+                extensionsTree.setModel(new DefaultTreeModel(extRootNode));
+
+                addComponent("Extensions:", new JScrollPane(extensionsTree));
+            }
+        }
+
+        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 boolean is(Boolean b) {
@@ -180,5 +215,21 @@ public class RepositoryInfoFrame extends
 
             return o.toString();
         }
+
+        static class ExtensionNode {
+            private final 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()
: "");
+            }
+        }
     }
 }



Mime
View raw message