chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r967123 - in /incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient: ClientHelper.java QueryFrame.java SwingClient.java model/ClientModel.java
Date Fri, 23 Jul 2010 15:09:10 GMT
Author: fmui
Date: Fri Jul 23 15:09:10 2010
New Revision: 967123

URL: http://svn.apache.org/viewvc?rev=967123&view=rev
Log:
- a few small improvements

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/QueryFrame.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/SwingClient.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.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=967123&r1=967122&r2=967123&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
Fri Jul 23 15:09:10 2010
@@ -34,78 +34,92 @@ import javax.swing.JOptionPane;
 
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 public class ClientHelper {
 
-	private static Log log = LogFactory.getLog(ClientHelper.class);
+    private static Log log = LogFactory.getLog(ClientHelper.class);
 
-	public static void showError(Component parent, Exception ex) {
-		log.error(ex.getClass().getSimpleName() + ": " + ex.getMessage(), ex);
-
-		JOptionPane.showMessageDialog(parent, ex.getClass().getSimpleName()
-				+ "\n" + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
-	}
-
-	public static ImageIcon getIcon(String name) {
-		URL imageURL = ClientHelper.class.getResource("/images/" + name);
-		if (imageURL != null) {
-			return new ImageIcon(imageURL);
-		}
-
-		return null;
-	}
-
-	public static String getDateString(GregorianCalendar cal) {
-		if (cal == null) {
-			return "-";
-		}
-
-		return cal.getTime().toString();
-	}
-
-	public static void download(Component component, Document doc,
-			String streamId) {
-		String filename = doc.getContentStreamFileName();
-
-		if (filename == null) {
-			return;
-		}
-
-		JFileChooser fileChooser = new JFileChooser();
-		fileChooser.setSelectedFile(new File(filename));
-
-		int chooseResult = fileChooser.showDialog(component, "Download");
-		if (chooseResult == JFileChooser.APPROVE_OPTION) {
-			InputStream inStream = null;
-			OutputStream outStream = null;
-			try {
-				ContentStream content = doc.getContentStream(streamId);
-				inStream = new BufferedInputStream(content.getStream());
-				outStream = new FileOutputStream(fileChooser.getSelectedFile());
-
-				byte[] buffer = new byte[4096];
-				int b;
-				while ((b = inStream.read(buffer)) > -1) {
-					outStream.write(buffer, 0, b);
-				}
-			} catch (Exception e) {
-				showError(component, e);
-			} finally {
-				if (inStream != null) {
-					try {
-						inStream.close();
-					} catch (IOException e) {
-					}
-				}
-				if (outStream != null) {
-					try {
-						outStream.close();
-					} catch (IOException e) {
-					}
-				}
-			}
-		}
-	}
+    public static void showError(Component parent, Exception ex) {
+        if (log.isErrorEnabled()) {
+            log.error(ex.getClass().getSimpleName() + ": " + ex.getMessage(), ex);
+
+            if (ex instanceof CmisBaseException) {
+                CmisBaseException cex = (CmisBaseException) ex;
+
+                if (cex.getCode() != null) {
+                    log.error("Error code: " + cex.getCode());
+                }
+
+                if (cex.getErrorContent() != null) {
+                    log.error("Error content: " + cex.getErrorContent());
+                }
+            }
+        }
+
+        JOptionPane.showMessageDialog(parent, ex.getClass().getSimpleName() + "\n" + ex.getMessage(),
"Error",
+                JOptionPane.ERROR_MESSAGE);
+    }
+
+    public static ImageIcon getIcon(String name) {
+        URL imageURL = ClientHelper.class.getResource("/images/" + name);
+        if (imageURL != null) {
+            return new ImageIcon(imageURL);
+        }
+
+        return null;
+    }
+
+    public static String getDateString(GregorianCalendar cal) {
+        if (cal == null) {
+            return "-";
+        }
+
+        return cal.getTime().toString();
+    }
+
+    public static void download(Component component, Document doc, String streamId) {
+        String filename = doc.getContentStreamFileName();
+
+        if (filename == null) {
+            return;
+        }
+
+        JFileChooser fileChooser = new JFileChooser();
+        fileChooser.setSelectedFile(new File(filename));
+
+        int chooseResult = fileChooser.showDialog(component, "Download");
+        if (chooseResult == JFileChooser.APPROVE_OPTION) {
+            InputStream inStream = null;
+            OutputStream outStream = null;
+            try {
+                ContentStream content = doc.getContentStream(streamId);
+                inStream = new BufferedInputStream(content.getStream());
+                outStream = new FileOutputStream(fileChooser.getSelectedFile());
+
+                byte[] buffer = new byte[4096];
+                int b;
+                while ((b = inStream.read(buffer)) > -1) {
+                    outStream.write(buffer, 0, b);
+                }
+            } catch (Exception e) {
+                showError(component, e);
+            } finally {
+                if (inStream != null) {
+                    try {
+                        inStream.close();
+                    } catch (IOException e) {
+                    }
+                }
+                if (outStream != null) {
+                    try {
+                        outStream.close();
+                    } catch (IOException e) {
+                    }
+                }
+            }
+        }
+    }
 }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java?rev=967123&r1=967122&r2=967123&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java
Fri Jul 23 15:09:10 2010
@@ -57,289 +57,282 @@ import org.apache.chemistry.opencmis.swi
 
 public class QueryFrame extends JFrame {
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private static final String WINDOW_TITLE = "CMIS Query";
-	private static final String DEFAULT_QUERY = "SELECT * FROM cmis:document";
+    private static final String WINDOW_TITLE = "CMIS Query";
+    private static final String DEFAULT_QUERY = "SELECT * FROM cmis:document";
 
-	private ClientModel model;
+    private ClientModel model;
 
-	private JTextArea queryText;
-	private JFormattedTextField maxHitsField;
-	private JCheckBox searchAllVersionsCheckBox;
-	private JTable resultsTable;
-	private JLabel queryTimeLabel;
-
-	public QueryFrame(ClientModel model) {
-		super();
-
-		this.model = model;
-		createGUI();
-	}
-
-	private void createGUI() {
-		setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
-		setPreferredSize(new Dimension(800, 600));
-		setMinimumSize(new Dimension(200, 60));
-
-		setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
-
-		// input
-		JPanel inputPanel = new JPanel();
-		inputPanel.setLayout(new BoxLayout(inputPanel, BoxLayout.LINE_AXIS));
-
-		queryText = new JTextArea(DEFAULT_QUERY, 5, 60);
-		inputPanel.add(queryText);
-
-		JPanel inputPanel2 = new JPanel();
-		inputPanel2.setPreferredSize(new Dimension(160, 100));
-		inputPanel2.setMaximumSize(inputPanel.getPreferredSize());
-		inputPanel2.setLayout(new GridBagLayout());
-
-		GridBagConstraints c = new GridBagConstraints();
-		c.fill = GridBagConstraints.HORIZONTAL;
-
-		JButton queryButton = new JButton("Query");
-		queryButton.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-				doQuery();
-			}
-		});
-
-		c.gridx = 0;
-		c.gridy = 0;
-		c.gridwidth = 2;
-		inputPanel2.add(queryButton, c);
-
-		maxHitsField = new JFormattedTextField(new NumberFormatter());
-		maxHitsField.setValue(new Integer(100));
-		maxHitsField.setColumns(5);
-
-		JLabel maxHitsLabel = new JLabel("Max hits:");
-		maxHitsLabel.setLabelFor(maxHitsField);
-
-		c.gridx = 0;
-		c.gridy = 1;
-		c.gridwidth = 1;
-		inputPanel2.add(maxHitsLabel, c);
-		c.gridx = 1;
-		c.gridy = 1;
-		c.gridwidth = 1;
-		inputPanel2.add(maxHitsField, c);
-
-		searchAllVersionsCheckBox = new JCheckBox("search all versions", false);
-		c.gridx = 0;
-		c.gridy = 2;
-		c.gridwidth = 2;
-		inputPanel2.add(searchAllVersionsCheckBox, c);
-
-		queryTimeLabel = new JLabel("(-- hits in -- seconds)");
-		c.gridx = 0;
-		c.gridy = 3;
-		c.gridwidth = 2;
-		inputPanel2.add(queryTimeLabel, c);
-
-		inputPanel.add(inputPanel2);
-
-		// table
-		resultsTable = new JTable();
-		resultsTable.setFillsViewportHeight(true);
-		resultsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
-
-		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 = resultsTable.getModel().getColumnCount();
-				for (int row = 0; row < rows; row++) {
-					int cols = resultsTable.getModel().getColumnCount();
-					for (int col = 0; col < cols; col++) {
-						sb.append(resultsTable.getModel().getValueAt(row, col));
-						sb.append("|");
-					}
-					sb.append("\n");
-				}
-
-				Clipboard clipboard = Toolkit.getDefaultToolkit()
-						.getSystemClipboard();
-				Transferable transferable = new StringSelection(sb.toString());
-				clipboard.setContents(transferable, null);
-			}
-		});
-
-		resultsTable.addMouseListener(new MouseListener() {
-			public void mouseExited(MouseEvent e) {
-			}
-
-			public void mouseEntered(MouseEvent e) {
-			}
-
-			public void mouseClicked(MouseEvent e) {
-			}
-
-			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());
-				}
-			}
-		});
-
-		add(new JSplitPane(JSplitPane.VERTICAL_SPLIT, inputPanel,
-				new JScrollPane(resultsTable)));
-
-		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-		pack();
-
-		setLocationRelativeTo(null);
-		setVisible(true);
-	}
-
-	private synchronized void doQuery() {
-		String text = queryText.getText();
-		text.replace('\n', ' ');
-
-		ItemIterable<QueryResult> results = null;
-
-		try {
-			setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
-			int maxHits = 1000;
-			try {
-				maxHitsField.commitEdit();
-				maxHits = ((Number) maxHitsField.getValue()).intValue();
-			} catch (Exception e) {
-			}
-
-			results = model.query(text, searchAllVersionsCheckBox.isSelected(),
-					maxHits);
-
-			ResultTableModel rtm = new ResultTableModel();
-
-			long startTime = System.currentTimeMillis();
-
-			int row = 0;
-			for (QueryResult qr : results.getPage(maxHits)) {
-				rtm.setColumnCount(Math.max(rtm.getColumnCount(), qr
-						.getProperties().size()));
-
-				for (PropertyData<?> prop : qr.getProperties()) {
-					rtm
-							.setValue(row, prop.getQueryName(), prop
-									.getFirstValue());
-				}
-
-				row++;
-			}
-			rtm.setRowCount(row);
-
-			long stopTime = System.currentTimeMillis();
-			float time = ((float) (stopTime - startTime)) / 1000f;
-			queryTimeLabel
-					.setText("(" + row + " hits in " + time + " seconds)");
-
-			resultsTable.setModel(rtm);
-		} catch (Exception ex) {
-			ClientHelper.showError(null, ex);
-			return;
-		} finally {
-			setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-		}
-	}
-
-	static class ResultTableModel extends AbstractTableModel {
-
-		private static final long serialVersionUID = 1L;
-
-		private int columnCount = 0;
-		private int rowCount = 0;
-		private Map<String, Integer> columnMapping = new HashMap<String, Integer>();
-		private Map<Integer, Map<Integer, Object>> data = new HashMap<Integer, Map<Integer,
Object>>();
-		private Map<Integer, Class<?>> columnClass = new HashMap<Integer, Class<?>>();
-
-		public ResultTableModel() {
-		}
-
-		public void setColumnCount(int columnCount) {
-			this.columnCount = columnCount;
-		}
-
-		public int getColumnCount() {
-			return columnCount;
-		}
-
-		public void setRowCount(int rowCount) {
-			this.rowCount = rowCount;
-		}
-
-		public int getRowCount() {
-			return rowCount;
-		}
-
-		public void setValue(int rowIndex, String queryName, Object value) {
-			Integer col = columnMapping.get(queryName);
-			if (col == null) {
-				col = columnMapping.size();
-				columnMapping.put(queryName, columnMapping.size());
-			}
-
-			if (value == null) {
-				return;
-			}
-
-			if (value instanceof GregorianCalendar) {
-				value = ClientHelper.getDateString((GregorianCalendar) value);
-			}
-
-			columnClass.put(col, value.getClass());
-
-			Map<Integer, Object> row = data.get(rowIndex);
-			if (row == null) {
-				row = new HashMap<Integer, Object>();
-				data.put(rowIndex, row);
-			}
-
-			row.put(col, value);
-		}
-
-		public Object getValueAt(int rowIndex, int columnIndex) {
-			Map<Integer, Object> row = data.get(rowIndex);
-			if (row == null) {
-				return null;
-			}
-
-			return row.get(columnIndex);
-		}
-
-		@Override
-		public String getColumnName(int column) {
-			for (Map.Entry<String, Integer> e : columnMapping.entrySet()) {
-				if (e.getValue().equals(column)) {
-					return e.getKey();
-				}
-			}
-
-			return "?";
-		}
-
-		@Override
-		public Class<?> getColumnClass(int columnIndex) {
-			Class<?> clazz = columnClass.get(columnIndex);
-			if (clazz != null) {
-				return clazz;
-			}
-
-			return String.class;
-		}
-	}
+    private JTextArea queryText;
+    private JFormattedTextField maxHitsField;
+    private JCheckBox searchAllVersionsCheckBox;
+    private JTable resultsTable;
+    private JLabel queryTimeLabel;
+
+    public QueryFrame(ClientModel model) {
+        super();
+
+        this.model = model;
+        createGUI();
+    }
+
+    private void createGUI() {
+        setTitle(WINDOW_TITLE + " - " + model.getRepositoryName());
+        setPreferredSize(new Dimension(800, 600));
+        setMinimumSize(new Dimension(200, 60));
+
+        setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
+
+        // input
+        JPanel inputPanel = new JPanel();
+        inputPanel.setLayout(new BoxLayout(inputPanel, BoxLayout.LINE_AXIS));
+
+        queryText = new JTextArea(DEFAULT_QUERY, 5, 60);
+        inputPanel.add(queryText);
+
+        JPanel inputPanel2 = new JPanel();
+        inputPanel2.setPreferredSize(new Dimension(160, 100));
+        inputPanel2.setMaximumSize(inputPanel.getPreferredSize());
+        inputPanel2.setLayout(new GridBagLayout());
+
+        GridBagConstraints c = new GridBagConstraints();
+        c.fill = GridBagConstraints.HORIZONTAL;
+
+        JButton queryButton = new JButton("Query");
+        queryButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                doQuery();
+            }
+        });
+
+        c.gridx = 0;
+        c.gridy = 0;
+        c.gridwidth = 2;
+        inputPanel2.add(queryButton, c);
+
+        maxHitsField = new JFormattedTextField(new NumberFormatter());
+        maxHitsField.setValue(Integer.valueOf(100));
+        maxHitsField.setColumns(5);
+
+        JLabel maxHitsLabel = new JLabel("Max hits:");
+        maxHitsLabel.setLabelFor(maxHitsField);
+
+        c.gridx = 0;
+        c.gridy = 1;
+        c.gridwidth = 1;
+        inputPanel2.add(maxHitsLabel, c);
+        c.gridx = 1;
+        c.gridy = 1;
+        c.gridwidth = 1;
+        inputPanel2.add(maxHitsField, c);
+
+        searchAllVersionsCheckBox = new JCheckBox("search all versions", false);
+        c.gridx = 0;
+        c.gridy = 2;
+        c.gridwidth = 2;
+        inputPanel2.add(searchAllVersionsCheckBox, c);
+
+        queryTimeLabel = new JLabel("(-- hits in -- seconds)");
+        c.gridx = 0;
+        c.gridy = 3;
+        c.gridwidth = 2;
+        inputPanel2.add(queryTimeLabel, c);
+
+        inputPanel.add(inputPanel2);
+
+        // table
+        resultsTable = new JTable();
+        resultsTable.setFillsViewportHeight(true);
+        resultsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+
+        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 = resultsTable.getModel().getColumnCount();
+                for (int row = 0; row < rows; row++) {
+                    int cols = resultsTable.getModel().getColumnCount();
+                    for (int col = 0; col < cols; col++) {
+                        sb.append(resultsTable.getModel().getValueAt(row, col));
+                        sb.append("|");
+                    }
+                    sb.append("\n");
+                }
+
+                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+                Transferable transferable = new StringSelection(sb.toString());
+                clipboard.setContents(transferable, null);
+            }
+        });
+
+        resultsTable.addMouseListener(new MouseListener() {
+            public void mouseExited(MouseEvent e) {
+            }
+
+            public void mouseEntered(MouseEvent e) {
+            }
+
+            public void mouseClicked(MouseEvent e) {
+            }
+
+            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());
+                }
+            }
+        });
+
+        add(new JSplitPane(JSplitPane.VERTICAL_SPLIT, inputPanel, new JScrollPane(resultsTable)));
+
+        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        pack();
+
+        setLocationRelativeTo(null);
+        setVisible(true);
+    }
+
+    private synchronized void doQuery() {
+        String text = queryText.getText();
+        text = text.replace('\n', ' ');
+
+        ItemIterable<QueryResult> results = null;
+
+        try {
+            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+            int maxHits = 1000;
+            try {
+                maxHitsField.commitEdit();
+                maxHits = ((Number) maxHitsField.getValue()).intValue();
+            } catch (Exception e) {
+            }
+
+            results = model.query(text, searchAllVersionsCheckBox.isSelected(), maxHits);
+
+            ResultTableModel rtm = new ResultTableModel();
+
+            long startTime = System.currentTimeMillis();
+
+            int row = 0;
+            for (QueryResult qr : results.getPage(maxHits)) {
+                rtm.setColumnCount(Math.max(rtm.getColumnCount(), qr.getProperties().size()));
+
+                for (PropertyData<?> prop : qr.getProperties()) {
+                    rtm.setValue(row, prop.getQueryName(), prop.getFirstValue());
+                }
+
+                row++;
+            }
+            rtm.setRowCount(row);
+
+            long stopTime = System.currentTimeMillis();
+            float time = ((float) (stopTime - startTime)) / 1000f;
+            queryTimeLabel.setText("(" + row + " hits in " + time + " seconds)");
+
+            resultsTable.setModel(rtm);
+        } catch (Exception ex) {
+            ClientHelper.showError(null, ex);
+            return;
+        } finally {
+            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+        }
+    }
+
+    static class ResultTableModel extends AbstractTableModel {
+
+        private static final long serialVersionUID = 1L;
+
+        private int columnCount = 0;
+        private int rowCount = 0;
+        private Map<String, Integer> columnMapping = new HashMap<String, Integer>();
+        private Map<Integer, Map<Integer, Object>> data = new HashMap<Integer,
Map<Integer, Object>>();
+        private Map<Integer, Class<?>> columnClass = new HashMap<Integer,
Class<?>>();
+
+        public ResultTableModel() {
+        }
+
+        public void setColumnCount(int columnCount) {
+            this.columnCount = columnCount;
+        }
+
+        public int getColumnCount() {
+            return columnCount;
+        }
+
+        public void setRowCount(int rowCount) {
+            this.rowCount = rowCount;
+        }
+
+        public int getRowCount() {
+            return rowCount;
+        }
+
+        public void setValue(int rowIndex, String queryName, Object value) {
+            Integer col = columnMapping.get(queryName);
+            if (col == null) {
+                col = columnMapping.size();
+                columnMapping.put(queryName, columnMapping.size());
+            }
+
+            if (value == null) {
+                return;
+            }
+
+            if (value instanceof GregorianCalendar) {
+                value = ClientHelper.getDateString((GregorianCalendar) value);
+            }
+
+            columnClass.put(col, value.getClass());
+
+            Map<Integer, Object> row = data.get(rowIndex);
+            if (row == null) {
+                row = new HashMap<Integer, Object>();
+                data.put(rowIndex, row);
+            }
+
+            row.put(col, value);
+        }
+
+        public Object getValueAt(int rowIndex, int columnIndex) {
+            Map<Integer, Object> row = data.get(rowIndex);
+            if (row == null) {
+                return null;
+            }
+
+            return row.get(columnIndex);
+        }
+
+        @Override
+        public String getColumnName(int column) {
+            for (Map.Entry<String, Integer> e : columnMapping.entrySet()) {
+                if (e.getValue().equals(column)) {
+                    return e.getKey();
+                }
+            }
+
+            return "?";
+        }
+
+        @Override
+        public Class<?> getColumnClass(int columnIndex) {
+            Class<?> clazz = columnClass.get(columnIndex);
+            if (clazz != null) {
+                return clazz;
+            }
+
+            return String.class;
+        }
+    }
 }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/SwingClient.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/SwingClient.java?rev=967123&r1=967122&r2=967123&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/SwingClient.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/SwingClient.java
Fri Jul 23 15:09:10 2010
@@ -27,39 +27,39 @@ import javax.swing.UIManager.LookAndFeel
 
 public class SwingClient {
 
-	public SwingClient() throws InterruptedException, InvocationTargetException {
+    public SwingClient() throws InterruptedException, InvocationTargetException {
 
-		// set up Swing
-		try {
-			boolean nimbus = false;
-
-			for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
-				if ("Nimbus".equals(info.getName())) {
-					UIManager.setLookAndFeel(info.getClassName());
-					nimbus = true;
-					break;
-				}
-			}
-
-			if (!nimbus) {
-				UIManager.setLookAndFeel(UIManager
-						.getSystemLookAndFeelClassName());
-			}
-		} catch (Exception e) {
-		}
-
-		JFrame.setDefaultLookAndFeelDecorated(true);
-		JDialog.setDefaultLookAndFeelDecorated(true);
-
-		// show client frame
-		javax.swing.SwingUtilities.invokeLater(new Runnable() {
-			public void run() {
-				new ClientFrame();
-			}
-		});
-	}
-
-	public static void main(String[] args) throws Exception {
-		new SwingClient();
-	}
+        // set up Swing
+        try {
+            boolean nimbus = false;
+
+            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+                if ("Nimbus".equals(info.getName())) {
+                    UIManager.setLookAndFeel(info.getClassName());
+                    nimbus = true;
+                    break;
+                }
+            }
+
+            if (!nimbus) {
+                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        JFrame.setDefaultLookAndFeelDecorated(true);
+        JDialog.setDefaultLookAndFeelDecorated(true);
+
+        // show client frame
+        javax.swing.SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+                new ClientFrame();
+            }
+        });
+    }
+
+    public static void main(String[] args) throws Exception {
+        new SwingClient();
+    }
 }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java?rev=967123&r1=967122&r2=967123&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java
Fri Jul 23 15:09:10 2010
@@ -67,8 +67,6 @@ public class ClientModel {
         PROPERTY_SET.add(PropertyIds.LAST_MODIFICATION_DATE);
     }
 
-    private static OperationContext FOLDER_OC = null;
-
     private static final OperationContext OBJECT_OC = new OperationContextImpl(Collections.singleton("*"),
true, true,
             true, IncludeRelationships.BOTH, Collections.singleton("*"), false, null, true,
1000);
 
@@ -77,6 +75,8 @@ public class ClientModel {
 
     private ClientSession clientSession;
 
+    private OperationContext folderOC = null;
+
     private Folder currentFolder = null;
     private List<CmisObject> currentChildren = Collections.emptyList();
     private CmisObject currentObject = null;
@@ -105,7 +105,7 @@ public class ClientModel {
 
     public synchronized void setClientSession(ClientSession clientSession) {
         this.clientSession = clientSession;
-        FOLDER_OC = createFolderOperationContext();
+        folderOC = createFolderOperationContext();
     }
 
     public synchronized RepositoryInfo getRepositoryInfo() throws Exception {
@@ -150,7 +150,7 @@ public class ClientModel {
             }
 
             List<CmisObject> children = new ArrayList<CmisObject>();
-            ItemIterable<CmisObject> iter = ((Folder) folderObject).getChildren(FOLDER_OC);
+            ItemIterable<CmisObject> iter = ((Folder) folderObject).getChildren(folderOC);
             for (CmisObject child : iter) {
                 children.add(child);
             }



Mime
View raw message