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 2015/12/11 14:59:44 UTC
svn commit: r1719421 [1/2] - in
/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench:
./ details/ icons/ swing/ types/
Author: fmui
Date: Fri Dec 11 13:59:44 2015
New Revision: 1719421
URL: http://svn.apache.org/viewvc?rev=1719421&view=rev
Log:
Workbench: first step of redesigning the types frame
Added:
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/icons/ChoiceIcon.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ChoicesTree.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ExtensionsTree.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTree.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTreePane.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeSplitPane.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypesFrame.java
Removed:
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypeSplitPane.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java
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/RepositoryInfoFrame.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ExtensionsPanel.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/TypesPanel.java
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=1719421&r1=1719420&r2=1719421&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 Fri Dec 11 13:59:44 2015
@@ -61,6 +61,7 @@ import org.apache.chemistry.opencmis.wor
import org.apache.chemistry.opencmis.workbench.icons.TypesIcon;
import org.apache.chemistry.opencmis.workbench.model.ClientModel;
import org.apache.chemistry.opencmis.workbench.model.ClientSession;
+import org.apache.chemistry.opencmis.workbench.types.TypesFrame;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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=1719421&r1=1719420&r2=1719421&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 Fri Dec 11 13:59:44 2015
@@ -19,12 +19,10 @@
package org.apache.chemistry.opencmis.workbench;
import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNotEmpty;
-import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNullOrEmpty;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
-import java.util.List;
import java.util.Map;
import javax.swing.Icon;
@@ -39,7 +37,6 @@ 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.ExtensionFeature;
import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
@@ -49,6 +46,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.enums.PropertyType;
import org.apache.chemistry.opencmis.workbench.icons.ExtensionIcon;
import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.swing.ExtensionsTree;
import org.apache.chemistry.opencmis.workbench.swing.InfoPanel;
public class RepositoryInfoFrame extends JFrame {
@@ -70,7 +68,7 @@ public class RepositoryInfoFrame extends
setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- setPreferredSize(new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 1.5)));
+ setPreferredSize(new Dimension((int) (screenSize.getWidth() / 2.5), (int) (screenSize.getHeight() / 1.5)));
setMinimumSize(new Dimension(200, 60));
RepositoryInfo repInfo = null;
@@ -304,32 +302,7 @@ public class RepositoryInfoFrame extends
}
if (isNotEmpty(repInfo.getExtensions())) {
- JTree extensionsTree = new JTree();
- extensionsTree.setRootVisible(false);
- extensionsTree.setCellRenderer(new ExtensionTreeCellRenderer());
- 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 (isNullOrEmpty(extensions)) {
- return;
- }
-
- for (CmisExtensionElement ext : extensions) {
- DefaultMutableTreeNode node = new DefaultMutableTreeNode(new ExtensionNode(ext));
- parent.add(node);
-
- if (isNotEmpty(ext.getChildren())) {
- addExtension(node, ext.getChildren());
- }
+ addComponent("Extensions:", new JScrollPane(new ExtensionsTree(repInfo.getExtensions())));
}
}
@@ -357,22 +330,6 @@ 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() : "");
- }
- }
-
static class ExtensionFeatureCellRenderer extends DefaultTreeCellRenderer {
private static final long serialVersionUID = 1L;
@@ -395,23 +352,6 @@ public class RepositoryInfoFrame extends
return comp;
}
- }
-
- static class ExtensionTreeCellRenderer extends DefaultTreeCellRenderer {
-
- private static final long serialVersionUID = 1L;
-
- private static final Icon EXTENSION_ICON = new ExtensionIcon(ClientHelper.OBJECT_ICON_SIZE,
- ClientHelper.OBJECT_ICON_SIZE);
-
- @Override
- public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
- boolean leaf, int row, boolean hasFocus) {
- Component comp = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
- setIcon(EXTENSION_ICON);
-
- return comp;
- }
}
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ExtensionsPanel.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/ExtensionsPanel.java?rev=1719421&r1=1719420&r2=1719421&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ExtensionsPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ExtensionsPanel.java Fri Dec 11 13:59:44 2015
@@ -121,6 +121,10 @@ public class ExtensionsPanel extends JPa
DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
extensionsTree.setModel(treeModel);
+
+ for (int i = 0; i < extensionsTree.getRowCount(); i++) {
+ extensionsTree.expandRow(i);
+ }
}
});
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/TypesPanel.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/TypesPanel.java?rev=1719421&r1=1719420&r2=1719421&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/TypesPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/TypesPanel.java Fri Dec 11 13:59:44 2015
@@ -21,10 +21,10 @@ package org.apache.chemistry.opencmis.wo
import javax.swing.SwingUtilities;
import org.apache.chemistry.opencmis.client.api.CmisObject;
-import org.apache.chemistry.opencmis.workbench.TypeSplitPane;
import org.apache.chemistry.opencmis.workbench.model.ClientModel;
import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent;
import org.apache.chemistry.opencmis.workbench.model.ObjectListener;
+import org.apache.chemistry.opencmis.workbench.types.TypeSplitPane;
public class TypesPanel extends TypeSplitPane implements ObjectListener {
Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/icons/ChoiceIcon.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/icons/ChoiceIcon.java?rev=1719421&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/icons/ChoiceIcon.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/icons/ChoiceIcon.java Fri Dec 11 13:59:44 2015
@@ -0,0 +1,77 @@
+/*
+ * 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.workbench.icons;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.GeneralPath;
+
+public class ChoiceIcon extends AbstractWorkbenchIcon {
+
+ public ChoiceIcon() {
+ super();
+ }
+
+ public ChoiceIcon(int width, int height) {
+ super(width, height);
+ }
+
+ @Override
+ protected int getOrginalHeight() {
+ return 64;
+ }
+
+ @Override
+ protected int getOrginalWidth() {
+ return 64;
+ }
+
+ @Override
+ protected Color getColor() {
+ return new Color(0x73a4d1);
+ }
+
+ @Override
+ protected void paint(Graphics2D g) {
+ GeneralPath shape = new GeneralPath();
+
+ shape.moveTo(46.0, 32.0);
+ shape.curveTo(46.0, 30.901001, 45.408, 29.94, 44.525, 29.417);
+ shape.lineTo(44.525, 29.417);
+ shape.lineTo(22.561, 16.438);
+ shape.curveTo(22.553001, 16.433, 22.545, 16.428999, 22.537, 16.424);
+ shape.lineTo(22.526001, 16.417);
+ shape.lineTo(22.526001, 16.417);
+ shape.curveTo(22.079, 16.153, 21.557, 16.0, 21.0, 16.0);
+ shape.curveTo(19.343, 16.0, 18.0, 17.343, 18.0, 19.0);
+ shape.lineTo(18.0, 45.0);
+ shape.curveTo(18.0, 46.657, 19.343, 48.0, 21.0, 48.0);
+ shape.curveTo(21.557, 48.0, 22.079, 47.848, 22.526001, 47.583);
+ shape.lineTo(22.526001, 47.583);
+ shape.lineTo(22.537, 47.576);
+ shape.curveTo(22.545, 47.57, 22.553001, 47.566, 22.561, 47.562);
+ shape.lineTo(44.525, 34.583);
+ shape.lineTo(44.525, 34.583);
+ shape.curveTo(45.408, 34.061, 46.0, 33.1, 46.0, 32.0);
+ shape.closePath();
+
+ g.setPaint(getColor());
+ g.fill(shape);
+ }
+}
Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ChoicesTree.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ChoicesTree.java?rev=1719421&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ChoicesTree.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ChoicesTree.java Fri Dec 11 13:59:44 2015
@@ -0,0 +1,86 @@
+/*
+ * 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.workbench.swing;
+
+import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNotEmpty;
+import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNullOrEmpty;
+
+import java.util.List;
+
+import javax.swing.Icon;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.workbench.ClientHelper;
+import org.apache.chemistry.opencmis.workbench.icons.ChoiceIcon;
+
+@SuppressWarnings("rawtypes")
+public class ChoicesTree extends InfoTree<List<Choice>> {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Icon CHOICE_ICON = new ChoiceIcon(ClientHelper.OBJECT_ICON_SIZE, ClientHelper.OBJECT_ICON_SIZE);
+
+ public ChoicesTree() {
+ super();
+ }
+
+ public ChoicesTree(final List<Choice> choices) {
+ super(choices);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void buildTree(DefaultMutableTreeNode parent, List<Choice> choices) {
+ if (isNullOrEmpty(choices)) {
+ return;
+ }
+
+ for (Choice choice : choices) {
+ DefaultMutableTreeNode node = new DefaultMutableTreeNode(new ChoiceNode(choice));
+ parent.add(node);
+
+ if (isNotEmpty(choice.getChoice())) {
+ buildTree(node, choice.getChoice());
+ }
+ }
+ }
+
+ @Override
+ protected Icon getIcon() {
+ return CHOICE_ICON;
+ }
+
+ private static class ChoiceNode {
+ private final Choice choice;
+
+ public ChoiceNode(Choice choice) {
+ this.choice = choice;
+ }
+
+ @Override
+ public String toString() {
+ String displayName = choice.getDisplayName() == null ? "" : choice.getDisplayName() + ": ";
+ String value = choice.getValue() == null ? "" : (choice.getValue().size() == 1 ? choice.getValue().get(0)
+ .toString() : choice.getValue().toString());
+
+ return displayName + value;
+ }
+ }
+}
Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ExtensionsTree.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ExtensionsTree.java?rev=1719421&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ExtensionsTree.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/ExtensionsTree.java Fri Dec 11 13:59:44 2015
@@ -0,0 +1,83 @@
+/*
+ * 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.workbench.swing;
+
+import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNotEmpty;
+import static org.apache.chemistry.opencmis.commons.impl.CollectionsHelper.isNullOrEmpty;
+
+import java.util.List;
+
+import javax.swing.Icon;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.workbench.ClientHelper;
+import org.apache.chemistry.opencmis.workbench.icons.ExtensionIcon;
+
+public class ExtensionsTree extends InfoTree<List<CmisExtensionElement>> {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Icon EXTENSION_ICON = new ExtensionIcon(ClientHelper.OBJECT_ICON_SIZE,
+ ClientHelper.OBJECT_ICON_SIZE);
+
+ public ExtensionsTree() {
+ super();
+ }
+
+ public ExtensionsTree(final List<CmisExtensionElement> extensions) {
+ super(extensions);
+ }
+
+ @Override
+ protected void buildTree(DefaultMutableTreeNode parent, List<CmisExtensionElement> extensions) {
+ if (isNullOrEmpty(extensions)) {
+ return;
+ }
+
+ for (CmisExtensionElement ext : extensions) {
+ DefaultMutableTreeNode node = new DefaultMutableTreeNode(new ExtensionNode(ext));
+ parent.add(node);
+
+ if (isNotEmpty(ext.getChildren())) {
+ buildTree(node, ext.getChildren());
+ }
+ }
+ }
+
+ @Override
+ protected Icon getIcon() {
+ return EXTENSION_ICON;
+ }
+
+ private 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() : "");
+ }
+ }
+}
Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTree.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTree.java?rev=1719421&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTree.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTree.java Fri Dec 11 13:59:44 2015
@@ -0,0 +1,82 @@
+/*
+ * 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.workbench.swing;
+
+import java.awt.Component;
+
+import javax.swing.Icon;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeSelectionModel;
+
+public abstract class InfoTree<E> extends JTree {
+
+ private static final long serialVersionUID = 1L;
+
+ public InfoTree() {
+ super();
+
+ setRootVisible(false);
+ setCellRenderer(new DataTreeCellRenderer(getIcon()));
+ getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+ setModel(null);
+ }
+
+ public InfoTree(final E data) {
+ this();
+ setData(data);
+ }
+
+ public final void setData(final E data) {
+ DefaultMutableTreeNode extRootNode = new DefaultMutableTreeNode("data");
+ buildTree(extRootNode, data);
+
+ setModel(new DefaultTreeModel(extRootNode));
+
+ for (int i = 0; i < getRowCount(); i++) {
+ expandRow(i);
+ }
+ }
+
+ protected abstract void buildTree(DefaultMutableTreeNode parent, E data);
+
+ protected abstract Icon getIcon();
+
+ static class DataTreeCellRenderer extends DefaultTreeCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Icon icon;
+
+ public DataTreeCellRenderer(Icon icon) {
+ this.icon = icon;
+ }
+
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
+ boolean leaf, int row, boolean hasFocus) {
+ Component comp = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+ setIcon(icon);
+
+ return comp;
+ }
+ }
+}
Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTreePane.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTreePane.java?rev=1719421&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTreePane.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoTreePane.java Fri Dec 11 13:59:44 2015
@@ -0,0 +1,47 @@
+/*
+ * 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.workbench.swing;
+
+import java.awt.Dimension;
+
+import javax.swing.JScrollPane;
+
+import org.apache.chemistry.opencmis.workbench.WorkbenchScale;
+
+public class InfoTreePane<E> extends JScrollPane {
+
+ private static final long serialVersionUID = 1L;
+
+ private InfoTree<E> infoTree;
+
+ public InfoTreePane(InfoTree<E> infoTree) {
+ this(infoTree, 300, 200);
+ }
+
+ public InfoTreePane(InfoTree<E> infoTree, int width, int height) {
+ super(infoTree);
+ this.infoTree = infoTree;
+ setPreferredSize(new Dimension(WorkbenchScale.scaleInt(width), WorkbenchScale.scaleInt(height)));
+ }
+
+ public void setData(final E data) {
+ infoTree.setData(data);
+ setVisible(data != null);
+ }
+}
Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java?rev=1719421&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/PropertyDefinitionsSplitPane.java Fri Dec 11 13:59:44 2015
@@ -0,0 +1,465 @@
+/*
+ * 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.workbench.types;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableColumn;
+
+import org.apache.chemistry.opencmis.client.api.ObjectType;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDateTimeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyIntegerDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
+import org.apache.chemistry.opencmis.commons.enums.DateTimeResolution;
+import org.apache.chemistry.opencmis.commons.enums.DecimalPrecision;
+import org.apache.chemistry.opencmis.workbench.ClientHelper;
+import org.apache.chemistry.opencmis.workbench.WorkbenchScale;
+import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.swing.ChoicesTree;
+import org.apache.chemistry.opencmis.workbench.swing.CollectionRenderer;
+import org.apache.chemistry.opencmis.workbench.swing.ExtensionsTree;
+import org.apache.chemistry.opencmis.workbench.swing.InfoPanel;
+import org.apache.chemistry.opencmis.workbench.swing.InfoTreePane;
+import org.apache.chemistry.opencmis.workbench.swing.YesNoLabel;
+
+public class PropertyDefinitionsSplitPane extends JSplitPane {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final int ID_COLUMN = 1;
+
+ private final ClientModel model;
+
+ private PropertyDefinitionsTable propertyDefinitionsTable;
+ private PropertyDefinitionInfoPanel propertyDefinitionPanel;
+
+ public PropertyDefinitionsSplitPane(ClientModel model) {
+ super(JSplitPane.HORIZONTAL_SPLIT);
+
+ this.model = model;
+
+ createGUI();
+ }
+
+ protected ClientModel getClientModel() {
+ return model;
+ }
+
+ private void createGUI() {
+ propertyDefinitionPanel = new PropertyDefinitionInfoPanel(model);
+ propertyDefinitionsTable = new PropertyDefinitionsTable(propertyDefinitionPanel);
+
+ setLeftComponent(new JScrollPane(propertyDefinitionsTable));
+ setRightComponent(new JScrollPane(propertyDefinitionPanel));
+ setDividerLocation(0.5);
+ setOneTouchExpandable(true);
+ setResizeWeight(0.5);
+ }
+
+ public void setType(ObjectType type) {
+ propertyDefinitionsTable.setType(type);
+ }
+
+ static class PropertyDefinitionsTable extends JTable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String[] COLUMN_NAMES = { "Name", "Id", "Description", "Local Namespace", "Local Name",
+ "Query Name", "Type", "Cardinality", "Updatability", "Queryable", "Orderable", "Required", "Inherited",
+ "Default Value", "Open Choice", "Choices" };
+ private static final int[] COLUMN_WIDTHS = { 200, 200, 200, 200, 200, 200, 80, 80, 80, 50, 50, 50, 50, 200, 50,
+ 200 };
+
+ private ObjectType type;
+ private List<PropertyDefinition<?>> propertyDefintions;
+ private final PropertyDefinitionInfoPanel propertyInfoPanel;
+
+ public PropertyDefinitionsTable(final PropertyDefinitionInfoPanel propertyInfoPanel) {
+ this.propertyInfoPanel = propertyInfoPanel;
+
+ setDefaultRenderer(Collection.class, new CollectionRenderer());
+ setModel(new PropertyDefinitionTableModel(this));
+
+ setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ setAutoResizeMode(AUTO_RESIZE_OFF);
+ setAutoCreateRowSorter(true);
+
+ for (int i = 0; i < COLUMN_WIDTHS.length; i++) {
+ TableColumn column = getColumnModel().getColumn(i);
+ column.setPreferredWidth(WorkbenchScale.scaleInt(COLUMN_WIDTHS[i]));
+ }
+
+ setRowHeight((int) (getFontMetrics(getFont()).getHeight() * 1.1));
+
+ final JPopupMenu popup = new JPopupMenu();
+ JMenuItem menuItem = new JMenuItem("Copy to clipboard");
+ popup.add(menuItem);
+
+ menuItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ ClientHelper.copyTableToClipboard(PropertyDefinitionsTable.this);
+ }
+ });
+
+ addMouseListener(new MouseAdapter() {
+ @Override
+ public void mousePressed(MouseEvent e) {
+ maybeShowPopup(e);
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ maybeShowPopup(e);
+ }
+
+ private void maybeShowPopup(MouseEvent e) {
+ if (e.isPopupTrigger()) {
+ popup.show(e.getComponent(), e.getX(), e.getY());
+ }
+ }
+ });
+
+ getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ if (e.getValueIsAdjusting()) {
+ return;
+ }
+
+ int row = getSelectedRow();
+ if (row > -1) {
+ String propId = getModel().getValueAt(getRowSorter().convertRowIndexToModel(row), ID_COLUMN)
+ .toString();
+ propertyInfoPanel.setPropertyDefinition(type.getPropertyDefinitions().get(propId));
+ }
+ }
+ });
+
+ setFillsViewportHeight(true);
+ }
+
+ public void setType(ObjectType type) {
+ this.type = type;
+
+ if ((type != null) && (type.getPropertyDefinitions() != null)) {
+ propertyDefintions = new ArrayList<PropertyDefinition<?>>();
+ for (PropertyDefinition<?> propDef : type.getPropertyDefinitions().values()) {
+ propertyDefintions.add(propDef);
+ }
+
+ Collections.sort(propertyDefintions, new Comparator<PropertyDefinition<?>>() {
+ @Override
+ public int compare(PropertyDefinition<?> pd1, PropertyDefinition<?> pd2) {
+ return pd1.getId().compareTo(pd2.getId());
+ }
+ });
+ } else {
+ propertyDefintions = null;
+ }
+
+ ((AbstractTableModel) getModel()).fireTableDataChanged();
+
+ if (type.getPropertyDefinitions() != null && !type.getPropertyDefinitions().isEmpty()) {
+ getSelectionModel().setSelectionInterval(0, 0);
+ } else {
+ propertyInfoPanel.setPropertyDefinition(null);
+ }
+ }
+
+ public ObjectType getType() {
+ return type;
+ }
+
+ public List<PropertyDefinition<?>> getPropertyDefinitions() {
+ return propertyDefintions;
+ }
+
+ static class PropertyDefinitionTableModel extends AbstractTableModel {
+
+ private static final long serialVersionUID = 1L;
+
+ private final PropertyDefinitionsTable table;
+
+ public PropertyDefinitionTableModel(PropertyDefinitionsTable table) {
+ this.table = table;
+ }
+
+ @Override
+ public String getColumnName(int columnIndex) {
+ return COLUMN_NAMES[columnIndex];
+ }
+
+ @Override
+ public int getColumnCount() {
+ return COLUMN_NAMES.length;
+ }
+
+ @Override
+ public int getRowCount() {
+ if (table.getPropertyDefinitions() == null) {
+ return 0;
+ }
+
+ return table.getPropertyDefinitions().size();
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ PropertyDefinition<?> propDef = table.getPropertyDefinitions().get(rowIndex);
+
+ switch (columnIndex) {
+ case 0:
+ return propDef.getDisplayName();
+ case 1:
+ return propDef.getId();
+ case 2:
+ return propDef.getDescription();
+ case 3:
+ return propDef.getLocalNamespace();
+ case 4:
+ return propDef.getLocalName();
+ case 5:
+ return propDef.getQueryName();
+ case 6:
+ return propDef.getPropertyType();
+ case 7:
+ return propDef.getCardinality();
+ case 8:
+ return propDef.getUpdatability();
+ case 9:
+ return propDef.isQueryable();
+ case 10:
+ return propDef.isOrderable();
+ case 11:
+ return propDef.isRequired();
+ case 12:
+ return propDef.isInherited();
+ case 13:
+ return propDef.getDefaultValue();
+ case 14:
+ return propDef.isOpenChoice();
+ case 15:
+ return propDef.getChoices();
+ default:
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ if ((columnIndex == 13) || (columnIndex == 15)) {
+ return Collection.class;
+ }
+
+ return super.getColumnClass(columnIndex);
+ }
+ }
+ }
+
+ static class PropertyDefinitionInfoPanel extends InfoPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ private JTextField nameField;
+ private JTextField descriptionField;
+ private JTextField idField;
+ private JTextField localNamespaceField;
+ private JTextField localNameField;
+ private JTextField queryNameField;
+ private JTextField propertyTypeField;
+ private JTextField cardinalityField;
+ private JTextField updatabilityField;
+ private YesNoLabel queryableLabel;
+ private YesNoLabel orderableLabel;
+ private YesNoLabel requiredLabel;
+ private YesNoLabel inheritedLabel;
+ private InfoList defaultValueField;
+ private YesNoLabel openChoiceLabel;
+ @SuppressWarnings("rawtypes")
+ private InfoTreePane<List<Choice>> choicesTree;
+ private JTextField minField;
+ private JTextField maxField;
+ private JTextField maxLengthField;
+ private JTextField precisionField;
+ private JTextField dateTimeResolutionField;
+ private InfoTreePane<List<CmisExtensionElement>> extensionsTree;
+
+ public PropertyDefinitionInfoPanel(ClientModel model) {
+ super(model);
+ createGUI();
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void setPropertyDefinition(PropertyDefinition<?> propDef) {
+ if (propDef != null) {
+ nameField.setText(propDef.getDisplayName());
+ descriptionField.setText(propDef.getDescription());
+ idField.setText(propDef.getId());
+ localNamespaceField.setText(propDef.getLocalNamespace());
+ localNameField.setText(propDef.getLocalName());
+ queryNameField.setText(propDef.getQueryName());
+
+ propertyTypeField
+ .setText(propDef.getPropertyType() == null ? "???" : propDef.getPropertyType().value());
+ cardinalityField.setText(propDef.getCardinality() == null ? "???" : propDef.getCardinality().value());
+ updatabilityField
+ .setText(propDef.getUpdatability() == null ? "???" : propDef.getUpdatability().value());
+ queryableLabel.setValue(is(propDef.isQueryable()));
+ orderableLabel.setValue(is(propDef.isOrderable()));
+ requiredLabel.setValue(is(propDef.isRequired()));
+ inheritedLabel.setValue(is(propDef.isInherited()));
+ defaultValueField.setList(propDef.getDefaultValue());
+ openChoiceLabel.setValue(is(propDef.isOpenChoice()));
+
+ List choices = (List) propDef.getChoices();
+ choicesTree.setData(choices == null || choices.isEmpty() ? null : choices);
+
+ if (propDef instanceof PropertyIntegerDefinition) {
+ maxLengthField.setText("");
+ BigInteger min = ((PropertyIntegerDefinition) propDef).getMinValue();
+ minField.setText(min == null ? "" : min.toString());
+ BigInteger max = ((PropertyIntegerDefinition) propDef).getMaxValue();
+ maxField.setText(max == null ? "" : max.toString());
+ precisionField.setText("");
+ dateTimeResolutionField.setText("");
+ } else if (propDef instanceof PropertyDecimalDefinition) {
+ maxLengthField.setText("");
+ BigDecimal min = ((PropertyDecimalDefinition) propDef).getMinValue();
+ minField.setText(min == null ? "" : min.toPlainString());
+ BigDecimal max = ((PropertyDecimalDefinition) propDef).getMaxValue();
+ maxField.setText(max == null ? "" : max.toPlainString());
+ DecimalPrecision precision = ((PropertyDecimalDefinition) propDef).getPrecision();
+ precisionField.setText(precision == null ? "" : precision.value().toString() + "-bit precision");
+ dateTimeResolutionField.setText("");
+ } else if (propDef instanceof PropertyStringDefinition) {
+ BigInteger maxLen = ((PropertyStringDefinition) propDef).getMaxLength();
+ maxLengthField.setText(maxLen == null ? "" : maxLen.toString());
+ minField.setText("");
+ maxField.setText("");
+ precisionField.setText("");
+ dateTimeResolutionField.setText("");
+ } else if (propDef instanceof PropertyDateTimeDefinition) {
+ maxLengthField.setText("");
+ minField.setText("");
+ maxField.setText("");
+ precisionField.setText("");
+ DateTimeResolution dateTimeResolution = ((PropertyDateTimeDefinition) propDef)
+ .getDateTimeResolution();
+ dateTimeResolutionField.setText(dateTimeResolution == null ? "" : dateTimeResolution.value());
+ } else {
+ minField.setText("");
+ maxField.setText("");
+ maxLengthField.setText("");
+ precisionField.setText("");
+ dateTimeResolutionField.setText("");
+ }
+
+ extensionsTree.setData(propDef.getExtensions());
+ } else {
+ nameField.setText("");
+ descriptionField.setText("");
+ idField.setText("");
+ localNamespaceField.setText("");
+ localNameField.setText("");
+ queryNameField.setText("");
+ propertyTypeField.setText("");
+ cardinalityField.setText("");
+ updatabilityField.setText("");
+ queryableLabel.setValue(false);
+ orderableLabel.setValue(false);
+ requiredLabel.setValue(false);
+ inheritedLabel.setValue(false);
+ defaultValueField.removeAll();
+ openChoiceLabel.setValue(false);
+ choicesTree.setData(null);
+ maxLengthField.setText("");
+ minField.setText("");
+ maxField.setText("");
+ precisionField.setText("");
+ dateTimeResolutionField.setText("");
+ extensionsTree.setData(null);
+ }
+
+ revalidate();
+ }
+
+ private boolean is(Boolean b) {
+ if (b == null) {
+ return false;
+ }
+
+ return b.booleanValue();
+ }
+
+ @SuppressWarnings("rawtypes")
+ private void createGUI() {
+ setupGUI();
+
+ nameField = addLine("Name:", true);
+ descriptionField = addLine("Description:");
+ idField = addLine("Id:");
+ localNamespaceField = addLine("Local Namespace:");
+ localNameField = addLine("Local Name:");
+ queryNameField = addLine("Query Name:");
+ propertyTypeField = addLine("Property Type:");
+ cardinalityField = addLine("Cardinality:");
+ updatabilityField = addLine("Updatability:");
+ queryableLabel = addYesNoLabel("Queryable:");
+ orderableLabel = addYesNoLabel("Orderable:");
+ requiredLabel = addYesNoLabel("Required:");
+ inheritedLabel = addYesNoLabel("Inherited:");
+ defaultValueField = addComponent("Default Value:", new InfoList());
+ openChoiceLabel = addYesNoLabel("Open Choice:");
+ choicesTree = addComponent("Choices:", new InfoTreePane<List<Choice>>(new ChoicesTree()));
+ maxLengthField = addLine("Max Length:");
+ minField = addLine("Min:");
+ maxField = addLine("Max:");
+ precisionField = addLine("Precision:");
+ dateTimeResolutionField = addLine("DateTime Resolution:");
+ extensionsTree = addComponent("Extensions:", new InfoTreePane<List<CmisExtensionElement>>(
+ new ExtensionsTree()));
+ }
+ }
+}
Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java?rev=1719421&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeDefinitionInfoPanel.java Fri Dec 11 13:59:44 2015
@@ -0,0 +1,175 @@
+package org.apache.chemistry.opencmis.workbench.types;
+
+import java.util.List;
+
+import javax.swing.JTextField;
+
+import org.apache.chemistry.opencmis.client.api.ObjectType;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.swing.BaseTypeLabel;
+import org.apache.chemistry.opencmis.workbench.swing.ExtensionsTree;
+import org.apache.chemistry.opencmis.workbench.swing.InfoPanel;
+import org.apache.chemistry.opencmis.workbench.swing.InfoTreePane;
+import org.apache.chemistry.opencmis.workbench.swing.YesNoLabel;
+
+public class TypeDefinitionInfoPanel extends InfoPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ private JTextField nameField;
+ private JTextField descriptionField;
+ private JTextField idField;
+ private JTextField localNamespaceField;
+ private JTextField localNameField;
+ private JTextField queryNameField;
+ private BaseTypeLabel baseTypeField;
+ private YesNoLabel creatableLabel;
+ private YesNoLabel fileableLabel;
+ private YesNoLabel queryableLabel;
+ private YesNoLabel includeInSuperTypeLabel;
+ private YesNoLabel fulltextIndexedLabel;
+ private YesNoLabel aclLabel;
+ private YesNoLabel policyLabel;
+ private YesNoLabel versionableLabel;
+ private JTextField contentStreamAllowedField;
+ private JTextField allowedSourceTypesField;
+ private JTextField allowedTargetTypesField;
+ private JTextField typeMutabilityField;
+ private InfoTreePane<List<CmisExtensionElement>> extensionsTree;
+
+ public TypeDefinitionInfoPanel(ClientModel model) {
+ super(model);
+ createGUI();
+ }
+
+ public void setType(ObjectType type) {
+ if (type != null) {
+ nameField.setText(type.getDisplayName());
+ descriptionField.setText(type.getDescription());
+ idField.setText(type.getId());
+ localNamespaceField.setText(type.getLocalNamespace());
+ localNameField.setText(type.getLocalName());
+ queryNameField.setText(type.getQueryName());
+ baseTypeField.setValue(type.getBaseTypeId());
+ creatableLabel.setValue(is(type.isCreatable()));
+ fileableLabel.setValue(is(type.isFileable()));
+ queryableLabel.setValue(is(type.isQueryable()));
+ includeInSuperTypeLabel.setValue(is(type.isIncludedInSupertypeQuery()));
+ fulltextIndexedLabel.setValue(is(type.isFulltextIndexed()));
+ aclLabel.setValue(is(type.isControllableAcl()));
+ policyLabel.setValue(is(type.isControllablePolicy()));
+
+ if (type.getTypeMutability() != null) {
+ StringBuilder sb = new StringBuilder(64);
+
+ if (Boolean.TRUE.equals(type.getTypeMutability().canCreate())) {
+ sb.append("create");
+ }
+
+ if (Boolean.TRUE.equals(type.getTypeMutability().canUpdate())) {
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+ sb.append("update");
+ }
+
+ if (Boolean.TRUE.equals(type.getTypeMutability().canDelete())) {
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+ sb.append("delete");
+ }
+
+ typeMutabilityField.setText(sb.toString());
+ } else {
+ typeMutabilityField.setText("");
+ }
+
+ if (type instanceof DocumentTypeDefinition) {
+ DocumentTypeDefinition docType = (DocumentTypeDefinition) type;
+ versionableLabel.setVisible(true);
+ versionableLabel.setValue(is(docType.isVersionable()));
+ contentStreamAllowedField.setVisible(true);
+ contentStreamAllowedField.setText(docType.getContentStreamAllowed() == null ? "???" : docType
+ .getContentStreamAllowed().value());
+ } else {
+ versionableLabel.setVisible(false);
+ contentStreamAllowedField.setVisible(false);
+ }
+
+ if (type instanceof RelationshipTypeDefinition) {
+ RelationshipTypeDefinition relationshipType = (RelationshipTypeDefinition) type;
+ allowedSourceTypesField.setVisible(true);
+ allowedSourceTypesField.setText(relationshipType.getAllowedSourceTypeIds() == null ? "???"
+ : relationshipType.getAllowedSourceTypeIds().toString());
+ allowedTargetTypesField.setVisible(true);
+ allowedTargetTypesField.setText(relationshipType.getAllowedTargetTypeIds() == null ? "???"
+ : relationshipType.getAllowedTargetTypeIds().toString());
+ } else {
+ allowedSourceTypesField.setVisible(false);
+ allowedTargetTypesField.setVisible(false);
+ }
+
+ extensionsTree.setData(type.getExtensions());
+ } else {
+ nameField.setText("");
+ descriptionField.setText("");
+ idField.setText("");
+ localNamespaceField.setText("");
+ localNameField.setText("");
+ queryNameField.setText("");
+ baseTypeField.setValue(null);
+ creatableLabel.setValue(false);
+ fileableLabel.setValue(false);
+ queryableLabel.setValue(false);
+ includeInSuperTypeLabel.setValue(false);
+ fulltextIndexedLabel.setValue(false);
+ aclLabel.setValue(false);
+ policyLabel.setValue(false);
+ versionableLabel.setVisible(false);
+ contentStreamAllowedField.setVisible(false);
+ allowedSourceTypesField.setVisible(false);
+ allowedTargetTypesField.setVisible(false);
+ typeMutabilityField.setText("");
+ extensionsTree.setData(null);
+ }
+
+ revalidate();
+ }
+
+ private void createGUI() {
+ setupGUI();
+
+ nameField = addLine("Name:", true);
+ descriptionField = addLine("Description:");
+ idField = addLine("Id:");
+ localNamespaceField = addLine("Local Namespace:");
+ localNameField = addLine("Local Name:");
+ queryNameField = addLine("Query Name:");
+ baseTypeField = addBaseTypeLabel("Base Type:");
+ creatableLabel = addYesNoLabel("Creatable:");
+ fileableLabel = addYesNoLabel("Fileable:");
+ queryableLabel = addYesNoLabel("Queryable:");
+ includeInSuperTypeLabel = addYesNoLabel("In Super Type Queries:");
+ fulltextIndexedLabel = addYesNoLabel("Full Text Indexed:");
+ aclLabel = addYesNoLabel("ACL Controlable:");
+ policyLabel = addYesNoLabel("Policy Controlable:");
+ typeMutabilityField = addLine("Type Mutability:");
+ versionableLabel = addYesNoLabel("Versionable:");
+ contentStreamAllowedField = addLine("Content Stream Allowed:");
+ allowedSourceTypesField = addLine("Allowed Source Types:");
+ allowedTargetTypesField = addLine("Allowed Target Types:");
+ extensionsTree = addComponent("Extensions:", new InfoTreePane<List<CmisExtensionElement>>(new ExtensionsTree()));
+ }
+
+ private boolean is(Boolean b) {
+ if (b == null) {
+ return false;
+ }
+
+ return b.booleanValue();
+ }
+}
\ No newline at end of file
Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeSplitPane.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeSplitPane.java?rev=1719421&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeSplitPane.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/types/TypeSplitPane.java Fri Dec 11 13:59:44 2015
@@ -0,0 +1,65 @@
+/*
+ * 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.workbench.types;
+
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+
+import org.apache.chemistry.opencmis.client.api.ObjectType;
+import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+
+public class TypeSplitPane extends JSplitPane {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final int ID_COLUMN = 1;
+
+ private final ClientModel model;
+
+ private TypeDefinitionInfoPanel typePanel;
+
+ private PropertyDefinitionsSplitPane propertyDefinitionSplitPane;
+
+ public TypeSplitPane(ClientModel model) {
+ super(JSplitPane.HORIZONTAL_SPLIT);
+
+ this.model = model;
+
+ createGUI();
+ }
+
+ protected ClientModel getClientModel() {
+ return model;
+ }
+
+ private void createGUI() {
+ typePanel = new TypeDefinitionInfoPanel(model);
+ propertyDefinitionSplitPane = new PropertyDefinitionsSplitPane(model);
+
+ setLeftComponent(new JScrollPane(typePanel));
+ setRightComponent(propertyDefinitionSplitPane);
+
+ setDividerLocation(0.3);
+ }
+
+ public void setType(ObjectType type) {
+ typePanel.setType(type);
+ propertyDefinitionSplitPane.setType(type);
+ }
+}