Author: fmui
Date: Wed Sep 22 10:55:12 2010
New Revision: 999866
URL: http://svn.apache.org/viewvc?rev=999866&view=rev
Log:
Swing Client improvement: added support for lists in table cells
Added:
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
(with props)
Modified:
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.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/TypesFrame.java
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/PropertyTable.java
Modified:
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java?rev=999866&r1=999865&r2=999866&view=diff
==============================================================================
---
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java
(original)
+++
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java
Wed Sep 22 10:55:12 2010
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
+import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import javax.swing.ImageIcon;
@@ -74,10 +75,11 @@ public class ClientHelper {
public static String getDateString(GregorianCalendar cal) {
if (cal == null) {
- return "-";
+ return "";
}
- return cal.getTime().toString();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss ZZZ");
+ return sdf.format(cal.getTime());
}
public static void download(Component component, Document doc, String
streamId) {
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=999866&r1=999865&r2=999866&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
Wed Sep 22 10:55:12 2010
@@ -28,7 +28,6 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.HashMap;
@@ -249,15 +248,12 @@ public class FolderTable extends JTable
class GregorianCalendarRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
- private SimpleDateFormat sdf;
-
public GregorianCalendarRenderer() {
super();
- sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss ZZZ");
}
public void setValue(Object value) {
- setText((value == null) ? "" : sdf.format(((GregorianCalendar)
value).getTime()));
+ setText(ClientHelper.getDateString((GregorianCalendar) value));
}
}
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=999866&r1=999865&r2=999866&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
Wed Sep 22 10:55:12 2010
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.sw
import java.awt.Cursor;
import java.awt.Dimension;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -46,364 +47,364 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import
org.apache.chemistry.opencmis.commons.definitions.RelationshipTypeDefinition;
import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+import org.apache.chemistry.opencmis.swingclient.swing.CollectionRenderer;
import org.apache.chemistry.opencmis.swingclient.swing.InfoPanel;
public class TypesFrame extends JFrame {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- private static final String WINDOW_TITLE = "CMIS Types";
+ private static final String WINDOW_TITLE = "CMIS Types";
- private ClientModel model;
+ private ClientModel model;
- private JTree typesTree;
- private TypeInfoPanel typePanel;
- private PropertyDefinitionTable propertyDefinitionTable;
-
- public TypesFrame(ClientModel model) {
- super();
-
- this.model = model;
- createGUI();
- loadData();
- }
-
- private void createGUI() {
- setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
- setPreferredSize(new Dimension(800, 600));
- setMinimumSize(new Dimension(200, 60));
-
- typesTree = new JTree();
- typesTree.setRootVisible(false);
- typesTree.getSelectionModel().setSelectionMode(
- TreeSelectionModel.SINGLE_TREE_SELECTION);
-
- typesTree.addTreeSelectionListener(new TreeSelectionListener() {
- public void valueChanged(TreeSelectionEvent e) {
- DefaultMutableTreeNode node =
(DefaultMutableTreeNode) ((JTree) e
-
.getSource()).getLastSelectedPathComponent();
-
- if (node == null) {
- return;
- }
-
- ObjectType type = ((TypeNode)
node.getUserObject()).getType();
- typePanel.setType(type);
- propertyDefinitionTable.setType(type);
- }
- });
-
- typePanel = new TypeInfoPanel();
- propertyDefinitionTable = new PropertyDefinitionTable();
-
- JSplitPane typeSplitPane = new
JSplitPane(JSplitPane.VERTICAL_SPLIT,
- new JScrollPane(typePanel), new JScrollPane(
- propertyDefinitionTable));
- typeSplitPane.setDividerLocation(300);
-
- JSplitPane splitPane = new
JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
- new JScrollPane(typesTree), typeSplitPane);
- splitPane.setDividerLocation(300);
-
- add(splitPane);
-
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- pack();
-
- setLocationRelativeTo(null);
- setVisible(true);
- }
-
- private void loadData() {
- try {
-
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- DefaultMutableTreeNode rootNode = new
DefaultMutableTreeNode();
-
- List<Tree<ObjectType>> types =
model.getTypeDescendants();
- for (Tree<ObjectType> tt : types) {
- addLevel(rootNode, tt);
- }
-
- DefaultTreeModel treeModel = new
DefaultTreeModel(rootNode);
- typesTree.setModel(treeModel);
- } catch (Exception ex) {
- ClientHelper.showError(null, ex);
- return;
- } finally {
-
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- private void addLevel(DefaultMutableTreeNode parent, Tree<ObjectType>
tree) {
- DefaultMutableTreeNode node = new DefaultMutableTreeNode(new
TypeNode(
- tree.getItem()));
- parent.add(node);
-
- if (tree.getChildren() != null) {
- for (Tree<ObjectType> tt : tree.getChildren()) {
- addLevel(node, tt);
- }
- }
- }
-
- static class TypeNode {
- private ObjectType type;
-
- public TypeNode(ObjectType type) {
- this.type = type;
- }
-
- public ObjectType getType() {
- return type;
- }
-
- @Override
- public String toString() {
- return type.getDisplayName() + " (" + type.getId() +
")";
- }
- }
-
- static class TypeInfoPanel 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 baseTypeField;
- private JCheckBox creatableBox;
- private JCheckBox fileableBox;
- private JCheckBox queryableBox;
- private JCheckBox aclBox;
- private JCheckBox policyBox;
- private JCheckBox versionableBox;
- private JTextField contentStreamAllowedField;
- private JTextField allowedSourceTypesField;
- private JTextField allowedTargetTypesField;
-
- public TypeInfoPanel() {
- super();
- 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.setText(type.getBaseTypeId().value());
-
creatableBox.setSelected(is(type.isCreatable()));
- fileableBox.setSelected(is(type.isFileable()));
-
queryableBox.setSelected(is(type.isQueryable()));
-
aclBox.setSelected(is(type.isControllableAcl()));
-
policyBox.setSelected(is(type.isControllablePolicy()));
-
- if (type instanceof DocumentTypeDefinition) {
- DocumentTypeDefinition docType =
(DocumentTypeDefinition) type;
- versionableBox.setVisible(true);
-
versionableBox.setSelected(is(docType.isVersionable()));
-
contentStreamAllowedField.setVisible(true);
-
contentStreamAllowedField.setText(docType
-
.getContentStreamAllowed() == null ? "???"
- :
docType.getContentStreamAllowed().toString());
- } else {
- versionableBox.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);
- }
- } else {
- nameField.setText("");
- descriptionField.setText("");
- idField.setText("");
- localNamespaceField.setText("");
- localNameField.setText("");
- queryNameField.setText("");
- baseTypeField.setText("");
- creatableBox.setSelected(false);
- fileableBox.setSelected(false);
- queryableBox.setSelected(false);
- aclBox.setSelected(false);
- policyBox.setSelected(false);
- versionableBox.setVisible(false);
- contentStreamAllowedField.setVisible(false);
- allowedSourceTypesField.setVisible(false);
- allowedTargetTypesField.setVisible(false);
- }
-
- 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 = addLine("Base Type:");
- creatableBox = addCheckBox("Creatable:");
- fileableBox = addCheckBox("Fileable:");
- queryableBox = addCheckBox("Queryable:");
- aclBox = addCheckBox("ACL controlable:");
- policyBox = addCheckBox("Policy controlable:");
- versionableBox = addCheckBox("Versionable:");
- contentStreamAllowedField = addLine("Content stream
allowed:");
- allowedSourceTypesField = addLine("Allowed source
types:");
- allowedTargetTypesField = addLine("Allowed target
types:");
- }
-
- private boolean is(Boolean b) {
- if (b == null) {
- return false;
- }
-
- return b.booleanValue();
- }
- }
-
- static class PropertyDefinitionTable 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", "Required",
- "Inherited" };
- private static final int[] COLUMN_WIDTHS = { 200, 200, 200,
200, 200,
- 200, 80, 80, 80, 50, 50, 50 };
-
- private ObjectType type;
- private List<PropertyDefinition<?>> propertyDefintions;
-
- public PropertyDefinitionTable() {
- setModel(new PropertyDefinitionTableModel(this));
-
- setAutoResizeMode(AUTO_RESIZE_OFF);
-
- for (int i = 0; i < COLUMN_WIDTHS.length; i++) {
- TableColumn column =
getColumnModel().getColumn(i);
- column.setPreferredWidth(COLUMN_WIDTHS[i]);
- }
-
- 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<?>>() {
- public int
compare(PropertyDefinition<?> pd1,
-
PropertyDefinition<?> pd2) {
- return
pd1.getId().compareTo(pd2.getId());
- }
- });
- } else {
- propertyDefintions = null;
- }
-
- ((AbstractTableModel)
getModel()).fireTableDataChanged();
- }
-
- public ObjectType getType() {
- return type;
- }
-
- public List<PropertyDefinition<?>> getPropertyDefinitions() {
- return propertyDefintions;
- }
-
- static class PropertyDefinitionTableModel extends
AbstractTableModel {
-
- 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];
- }
-
- public int getColumnCount() {
- return COLUMN_NAMES.length;
- }
-
- public int getRowCount() {
- if (table.getPropertyDefinitions() == null) {
- return 0;
- }
-
- return table.getPropertyDefinitions().size();
- }
-
- 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.isRequired();
- case 11:
- return propDef.isInherited();
- }
-
- return null;
- }
- }
- }
+ private JTree typesTree;
+ private TypeInfoPanel typePanel;
+ private PropertyDefinitionTable propertyDefinitionTable;
+
+ public TypesFrame(ClientModel model) {
+ super();
+
+ this.model = model;
+ createGUI();
+ loadData();
+ }
+
+ private void createGUI() {
+ setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
+ setPreferredSize(new Dimension(800, 600));
+ setMinimumSize(new Dimension(200, 60));
+
+ typesTree = new JTree();
+ typesTree.setRootVisible(false);
+
typesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+
+ typesTree.addTreeSelectionListener(new TreeSelectionListener() {
+ public void valueChanged(TreeSelectionEvent e) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)
((JTree) e.getSource())
+ .getLastSelectedPathComponent();
+
+ if (node == null) {
+ return;
+ }
+
+ ObjectType type = ((TypeNode) node.getUserObject()).getType();
+ typePanel.setType(type);
+ propertyDefinitionTable.setType(type);
+ }
+ });
+
+ typePanel = new TypeInfoPanel();
+ propertyDefinitionTable = new PropertyDefinitionTable();
+
+ JSplitPane typeSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
new JScrollPane(typePanel),
+ new JScrollPane(propertyDefinitionTable));
+ typeSplitPane.setDividerLocation(300);
+
+ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new
JScrollPane(typesTree), typeSplitPane);
+ splitPane.setDividerLocation(300);
+
+ add(splitPane);
+
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ pack();
+
+ setLocationRelativeTo(null);
+ setVisible(true);
+ }
+
+ private void loadData() {
+ try {
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
+
+ List<Tree<ObjectType>> types = model.getTypeDescendants();
+ for (Tree<ObjectType> tt : types) {
+ addLevel(rootNode, tt);
+ }
+
+ DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
+ typesTree.setModel(treeModel);
+ } catch (Exception ex) {
+ ClientHelper.showError(null, ex);
+ return;
+ } finally {
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ private void addLevel(DefaultMutableTreeNode parent, Tree<ObjectType>
tree) {
+ DefaultMutableTreeNode node = new DefaultMutableTreeNode(new
TypeNode(tree.getItem()));
+ parent.add(node);
+
+ if (tree.getChildren() != null) {
+ for (Tree<ObjectType> tt : tree.getChildren()) {
+ addLevel(node, tt);
+ }
+ }
+ }
+
+ static class TypeNode {
+ private ObjectType type;
+
+ public TypeNode(ObjectType type) {
+ this.type = type;
+ }
+
+ public ObjectType getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return type.getDisplayName() + " (" + type.getId() + ")";
+ }
+ }
+
+ static class TypeInfoPanel 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 baseTypeField;
+ private JCheckBox creatableBox;
+ private JCheckBox fileableBox;
+ private JCheckBox queryableBox;
+ private JCheckBox aclBox;
+ private JCheckBox policyBox;
+ private JCheckBox versionableBox;
+ private JTextField contentStreamAllowedField;
+ private JTextField allowedSourceTypesField;
+ private JTextField allowedTargetTypesField;
+
+ public TypeInfoPanel() {
+ super();
+ 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.setText(type.getBaseTypeId().value());
+ creatableBox.setSelected(is(type.isCreatable()));
+ fileableBox.setSelected(is(type.isFileable()));
+ queryableBox.setSelected(is(type.isQueryable()));
+ aclBox.setSelected(is(type.isControllableAcl()));
+ policyBox.setSelected(is(type.isControllablePolicy()));
+
+ if (type instanceof DocumentTypeDefinition) {
+ DocumentTypeDefinition docType = (DocumentTypeDefinition)
type;
+ versionableBox.setVisible(true);
+ versionableBox.setSelected(is(docType.isVersionable()));
+ contentStreamAllowedField.setVisible(true);
+
contentStreamAllowedField.setText(docType.getContentStreamAllowed() == null ?
"???" : docType
+ .getContentStreamAllowed().toString());
+ } else {
+ versionableBox.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);
+ }
+ } else {
+ nameField.setText("");
+ descriptionField.setText("");
+ idField.setText("");
+ localNamespaceField.setText("");
+ localNameField.setText("");
+ queryNameField.setText("");
+ baseTypeField.setText("");
+ creatableBox.setSelected(false);
+ fileableBox.setSelected(false);
+ queryableBox.setSelected(false);
+ aclBox.setSelected(false);
+ policyBox.setSelected(false);
+ versionableBox.setVisible(false);
+ contentStreamAllowedField.setVisible(false);
+ allowedSourceTypesField.setVisible(false);
+ allowedTargetTypesField.setVisible(false);
+ }
+
+ 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 = addLine("Base Type:");
+ creatableBox = addCheckBox("Creatable:");
+ fileableBox = addCheckBox("Fileable:");
+ queryableBox = addCheckBox("Queryable:");
+ aclBox = addCheckBox("ACL controlable:");
+ policyBox = addCheckBox("Policy controlable:");
+ versionableBox = addCheckBox("Versionable:");
+ contentStreamAllowedField = addLine("Content stream allowed:");
+ allowedSourceTypesField = addLine("Allowed source types:");
+ allowedTargetTypesField = addLine("Allowed target types:");
+ }
+
+ private boolean is(Boolean b) {
+ if (b == null) {
+ return false;
+ }
+
+ return b.booleanValue();
+ }
+ }
+
+ static class PropertyDefinitionTable 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", "Required", "Inherited",
+ "Default Value", "Choices" };
+ private static final int[] COLUMN_WIDTHS = { 200, 200, 200, 200, 200,
200, 80, 80, 80, 50, 50, 50, 200, 200 };
+
+ private ObjectType type;
+ private List<PropertyDefinition<?>> propertyDefintions;
+
+ public PropertyDefinitionTable() {
+ setDefaultRenderer(Collection.class, new CollectionRenderer());
+ setModel(new PropertyDefinitionTableModel(this));
+
+ setAutoResizeMode(AUTO_RESIZE_OFF);
+
+ for (int i = 0; i < COLUMN_WIDTHS.length; i++) {
+ TableColumn column = getColumnModel().getColumn(i);
+ column.setPreferredWidth(COLUMN_WIDTHS[i]);
+ }
+
+ 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<?>>() {
+ public int compare(PropertyDefinition<?> pd1,
PropertyDefinition<?> pd2) {
+ return pd1.getId().compareTo(pd2.getId());
+ }
+ });
+ } else {
+ propertyDefintions = null;
+ }
+
+ ((AbstractTableModel) getModel()).fireTableDataChanged();
+ }
+
+ public ObjectType getType() {
+ return type;
+ }
+
+ public List<PropertyDefinition<?>> getPropertyDefinitions() {
+ return propertyDefintions;
+ }
+
+ static class PropertyDefinitionTableModel extends AbstractTableModel {
+
+ 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];
+ }
+
+ public int getColumnCount() {
+ return COLUMN_NAMES.length;
+ }
+
+ public int getRowCount() {
+ if (table.getPropertyDefinitions() == null) {
+ return 0;
+ }
+
+ return table.getPropertyDefinitions().size();
+ }
+
+ 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.isRequired();
+ case 11:
+ return propDef.isInherited();
+ case 12:
+ return propDef.getDefaultValue();
+ case 13:
+ return propDef.getChoices();
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ if ((columnIndex == 12) || (columnIndex == 13)) {
+ return Collection.class;
+ }
+
+ return super.getColumnClass(columnIndex);
+ }
+ }
+ }
}
Modified:
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java?rev=999866&r1=999865&r2=999866&view=diff
==============================================================================
---
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java
(original)
+++
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java
Wed Sep 22 10:55:12 2010
@@ -18,6 +18,8 @@
*/
package org.apache.chemistry.opencmis.swingclient.details;
+import java.util.Collection;
+
import org.apache.chemistry.opencmis.commons.data.Ace;
import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
@@ -48,11 +50,22 @@ public class ACLTable extends AbstractDe
case 0:
return ace.getPrincipalId();
case 1:
- return ace.getPermissions().toString();
+ return ace.getPermissions();
case 2:
return ace.isDirect();
}
return null;
}
+
+ @Override
+ public Class<?> getDetailColumClass(int columnIndex) {
+ if (columnIndex == 1) {
+ return Collection.class;
+ } else if (columnIndex == 2) {
+ return Boolean.class;
+ }
+
+ return super.getDetailColumClass(columnIndex);
+ }
}
Modified:
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java?rev=999866&r1=999865&r2=999866&view=diff
==============================================================================
---
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java
(original)
+++
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java
Wed Sep 22 10:55:12 2010
@@ -26,6 +26,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
+import java.util.Collection;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
@@ -37,141 +38,148 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
import org.apache.chemistry.opencmis.swingclient.model.ClientModelEvent;
import org.apache.chemistry.opencmis.swingclient.model.ObjectListener;
+import org.apache.chemistry.opencmis.swingclient.swing.CollectionRenderer;
-public abstract class AbstractDetailsTable extends JTable implements
- ObjectListener {
+public abstract class AbstractDetailsTable extends JTable implements
ObjectListener {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- private ClientModel model;
- private String[] columnNames;
+ private ClientModel model;
+ private String[] columnNames;
- public void init(ClientModel model, String[] columnNames,
- int[] colummnWidths) {
- this.model = model;
- model.addObjectListener(this);
-
- this.columnNames = columnNames;
-
- setModel(new DetailsTableModel(this));
-
- setAutoResizeMode(AUTO_RESIZE_OFF);
- setAutoCreateRowSorter(true);
-
- for (int i = 0; i < colummnWidths.length; i++) {
- TableColumn column = getColumnModel().getColumn(i);
- column.setPreferredWidth(colummnWidths[i]);
- }
-
- setFillsViewportHeight(true);
-
- final JPopupMenu popup = new JPopupMenu();
- JMenuItem menuItem = new JMenuItem("Copy to clipboard");
- popup.add(menuItem);
-
- menuItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- StringBuilder sb = new StringBuilder();
- int rows = getDetailRowCount();
- for (int row = 0; row < rows; row++) {
- int cols = getColumnNames().length;
- for (int col = 0; col < cols; col++) {
- sb.append(getDetailValueAt(row,
col));
- sb.append("|");
- }
- sb.append("\n");
- }
-
- Clipboard clipboard =
Toolkit.getDefaultToolkit()
- .getSystemClipboard();
- Transferable transferable = new
StringSelection(sb.toString());
- clipboard.setContents(transferable, null);
- }
- });
-
- addMouseListener(new MouseListener() {
- public void mouseExited(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- }
-
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2) {
- int row = getSelectedRow();
- if ((row > -1) && (row <
getModel().getColumnCount())) {
- doubleClickAction(row);
- }
- }
- }
-
- public void mousePressed(MouseEvent e) {
- maybeShowPopup(e);
- }
-
- public void mouseReleased(MouseEvent e) {
- maybeShowPopup(e);
- }
-
- private void maybeShowPopup(MouseEvent e) {
- if (e.isPopupTrigger()) {
- popup.show(e.getComponent(), e.getX(),
e.getY());
- }
- }
- });
- }
-
- public void objectLoaded(ClientModelEvent event) {
- ((DetailsTableModel) getModel()).fireTableDataChanged();
- }
-
- public CmisObject getObject() {
- return model.getCurrentObject();
- }
-
- public String[] getColumnNames() {
- return columnNames;
- }
-
- public abstract int getDetailRowCount();
-
- public abstract Object getDetailValueAt(int rowIndex, int columnIndex);
-
- public void doubleClickAction(int rowIndex) {
- }
-
- static class DetailsTableModel extends AbstractTableModel {
-
- private AbstractDetailsTable table;
-
- public DetailsTableModel(AbstractDetailsTable table) {
- this.table = table;
- }
-
- private static final long serialVersionUID = 1L;
-
- public String getColumnName(int columnIndex) {
- return table.getColumnNames()[columnIndex];
- }
-
- public int getColumnCount() {
- return table.getColumnNames().length;
- }
-
- public int getRowCount() {
- if (table.getObject() == null) {
- return 0;
- }
-
- return table.getDetailRowCount();
- }
-
- public Object getValueAt(int rowIndex, int columnIndex) {
- if (table.getObject() == null) {
- return null;
- }
-
- return table.getDetailValueAt(rowIndex, columnIndex);
- }
- }
+ public void init(ClientModel model, String[] columnNames, int[]
colummnWidths) {
+ this.model = model;
+ model.addObjectListener(this);
+
+ this.columnNames = columnNames;
+
+ setModel(new DetailsTableModel(this));
+
+ setDefaultRenderer(Collection.class, new CollectionRenderer());
+ setAutoResizeMode(AUTO_RESIZE_OFF);
+ setAutoCreateRowSorter(true);
+
+ for (int i = 0; i < colummnWidths.length; i++) {
+ TableColumn column = getColumnModel().getColumn(i);
+ column.setPreferredWidth(colummnWidths[i]);
+ }
+
+ setFillsViewportHeight(true);
+
+ final JPopupMenu popup = new JPopupMenu();
+ JMenuItem menuItem = new JMenuItem("Copy to clipboard");
+ popup.add(menuItem);
+
+ menuItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ StringBuilder sb = new StringBuilder();
+ int rows = getDetailRowCount();
+ for (int row = 0; row < rows; row++) {
+ int cols = getColumnNames().length;
+ for (int col = 0; col < cols; col++) {
+ sb.append(getDetailValueAt(row, col));
+ sb.append("|");
+ }
+ sb.append("\n");
+ }
+
+ Clipboard clipboard =
Toolkit.getDefaultToolkit().getSystemClipboard();
+ Transferable transferable = new StringSelection(sb.toString());
+ clipboard.setContents(transferable, null);
+ }
+ });
+
+ addMouseListener(new MouseListener() {
+ public void mouseExited(MouseEvent e) {
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
+ int row = getSelectedRow();
+ if ((row > -1) && (row < getModel().getColumnCount())) {
+ doubleClickAction(row);
+ }
+ }
+ }
+
+ public void mousePressed(MouseEvent e) {
+ maybeShowPopup(e);
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ maybeShowPopup(e);
+ }
+
+ private void maybeShowPopup(MouseEvent e) {
+ if (e.isPopupTrigger()) {
+ popup.show(e.getComponent(), e.getX(), e.getY());
+ }
+ }
+ });
+ }
+
+ public void objectLoaded(ClientModelEvent event) {
+ ((DetailsTableModel) getModel()).fireTableDataChanged();
+ }
+
+ public CmisObject getObject() {
+ return model.getCurrentObject();
+ }
+
+ public String[] getColumnNames() {
+ return columnNames;
+ }
+
+ public abstract int getDetailRowCount();
+
+ public abstract Object getDetailValueAt(int rowIndex, int columnIndex);
+
+ public Class<?> getDetailColumClass(int columnIndex) {
+ return String.class;
+ }
+
+ public void doubleClickAction(int rowIndex) {
+ }
+
+ static class DetailsTableModel extends AbstractTableModel {
+
+ private AbstractDetailsTable table;
+
+ public DetailsTableModel(AbstractDetailsTable table) {
+ this.table = table;
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ public String getColumnName(int columnIndex) {
+ return table.getColumnNames()[columnIndex];
+ }
+
+ public int getColumnCount() {
+ return table.getColumnNames().length;
+ }
+
+ public int getRowCount() {
+ if (table.getObject() == null) {
+ return 0;
+ }
+
+ return table.getDetailRowCount();
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ if (table.getObject() == null) {
+ return null;
+ }
+
+ return table.getDetailValueAt(rowIndex, columnIndex);
+ }
+
+ public Class<?> getColumnClass(int columnIndex) {
+ return table.getDetailColumClass(columnIndex);
+ }
+ }
}
Modified:
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/PropertyTable.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/PropertyTable.java?rev=999866&r1=999865&r2=999866&view=diff
==============================================================================
---
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/PropertyTable.java
(original)
+++
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/PropertyTable.java
Wed Sep 22 10:55:12 2010
@@ -18,40 +18,50 @@
*/
package org.apache.chemistry.opencmis.swingclient.details;
+import java.util.Collection;
+
import org.apache.chemistry.opencmis.client.api.Property;
import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
public class PropertyTable extends AbstractDetailsTable {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
+
+ private static final String[] COLUMN_NAMES = { "Name", "Id", "Type",
"Value" };
+ private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 300 };
- private static final String[] COLUMN_NAMES = { "Name", "Id", "Type",
- "Value" };
- private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 300 };
-
- public PropertyTable(ClientModel model) {
- super();
- init(model, COLUMN_NAMES, COLUMN_WIDTHS);
- }
-
- public int getDetailRowCount() {
- return getObject().getProperties().size();
- }
-
- public Object getDetailValueAt(int rowIndex, int columnIndex) {
- Property<?> property =
getObject().getProperties().get(rowIndex);
-
- switch (columnIndex) {
- case 0:
- return property.getDefinition().getDisplayName();
- case 1:
- return property.getId();
- case 2:
- return
property.getDefinition().getPropertyType().value();
- case 3:
- return property.getValuesAsString();
- }
+ public PropertyTable(ClientModel model) {
+ super();
+ init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+ }
+
+ public int getDetailRowCount() {
+ return getObject().getProperties().size();
+ }
+
+ public Object getDetailValueAt(int rowIndex, int columnIndex) {
+ Property<?> property = getObject().getProperties().get(rowIndex);
+
+ switch (columnIndex) {
+ case 0:
+ return property.getDefinition().getDisplayName();
+ case 1:
+ return property.getId();
+ case 2:
+ return property.getDefinition().getPropertyType().value();
+ case 3:
+ return property.getValues();
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getDetailColumClass(int columnIndex) {
+ if (columnIndex == 3) {
+ return Collection.class;
+ }
- return null;
- }
+ return super.getDetailColumClass(columnIndex);
+ }
}
Added:
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java?rev=999866&view=auto
==============================================================================
---
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
(added)
+++
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
Wed Sep 22 10:55:12 2010
@@ -0,0 +1,76 @@
+/*
+ * 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.awt.Component;
+import java.util.Collection;
+import java.util.GregorianCalendar;
+
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+
+import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.swingclient.ClientHelper;
+
+public class CollectionRenderer extends DefaultTableCellRenderer {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,
+ int row, int column) {
+ Component comp = super.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
+
+ int height = (int) getPreferredSize().getHeight();
+ if (height > (getFontMetrics(getFont()).getHeight() +
getInsets().bottom + getInsets().top)) {
+ table.setRowHeight(row, height);
+ }
+
+ return comp;
+ }
+
+ @Override
+ protected void setValue(Object value) {
+ Collection<?> col = (Collection<?>) value;
+
+ if ((col == null) || (col.isEmpty())) {
+ super.setValue("");
+ return;
+ }
+
+ // build string
+ StringBuilder sb = new StringBuilder("<html>");
+ if (col != null) {
+ for (Object o : col) {
+ if (o == null) {
+ sb.append("<i>null</i>");
+ } else if (o instanceof GregorianCalendar) {
+ sb.append(ClientHelper.getDateString((GregorianCalendar)
o));
+ } else if (o instanceof Choice<?>) {
+ sb.append(((Choice<?>) o).getValue());
+ } else {
+ sb.append(o.toString());
+ }
+ sb.append("<br/>");
+ }
+ }
+ sb.append("</html>");
+
+ super.setValue(sb.toString());
+ }
+}
Propchange:
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native