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 2010/07/22 13:19:11 UTC
svn commit: r966582 [1/3] - in
/incubator/chemistry/opencmis-swingclient/trunk: ./ src/ src/main/
src/main/assembly/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/chemistry/
src/main/java/org/apache/chemistry/open...
Author: fmui
Date: Thu Jul 22 11:19:09 2010
New Revision: 966582
URL: http://svn.apache.org/viewvc?rev=966582&view=rev
Log:
initial CMIS Swing Client code
Added:
incubator/chemistry/opencmis-swingclient/trunk/
incubator/chemistry/opencmis-swingclient/trunk/pom.xml (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/
incubator/chemistry/opencmis-swingclient/trunk/src/main/
incubator/chemistry/opencmis-swingclient/trunk/src/main/assembly/
incubator/chemistry/opencmis-swingclient/trunk/src/main/assembly/client-assembly.xml (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientWriterAppender.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateDocumentDialog.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateFolderDialog.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LogFrame.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/RepositoryInfoFrame.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/SwingClient.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/TypesFrame.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/CancelCheckOutPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/CheckInPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/CheckOutPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/DeleteContentStreamPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/DeletePanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/DeleteTreePanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/MovePanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/actions/SetContentStreamPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ACLTable.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/AbstractDetailsTable.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ActionsPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/DetailsTabs.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/ObjectPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/PolicyTable.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/PropertyTable.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RelationshipTable.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/RenditionTable.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/details/VersionTable.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientModelEvent.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/FolderListener.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/MIMETypes.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ObjectListener.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/ActionPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CreateDialog.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/InfoPanel.java (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/META-INF/
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/META-INF/README (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/connect.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/document.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/folder.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/info.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/log.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/newdocument.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/newfolder.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/policy.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/query.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/relationship.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/repository-info.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/images/types.png (with props)
incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/log4j.properties (with props)
Added: incubator/chemistry/opencmis-swingclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/pom.xml?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/pom.xml (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/pom.xml Thu Jul 22 11:19:09 2010
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <!--
+ Licensed 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>7</version>
+ </parent>
+
+ <!-- Project Information -->
+
+ <groupId>org.apache.chemistry.opencmis.swingclient</groupId>
+ <artifactId>chemistry-opencmis-swingclient</artifactId>
+ <name>OpenCMIS Swing Client</name>
+ <version>0.1.0-incubating-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <organization>
+ <name>The Apache Software Foundation</name>
+ <url>http://www.apache.org/</url>
+ </organization>
+
+ <url>http://incubator.apache.org/chemistry/</url>
+ <ciManagement>
+ <system>Hudson Zones Apache</system>
+ <url>http://hudson.zones.apache.org/hudson/view/Chemistry/</url>
+ </ciManagement>
+ <inceptionYear>2010</inceptionYear>
+ <description>
+ OpenCMIS Swing Client is a CMIS desktop client.
+ </description>
+
+ <licenses>
+ <license>
+ <name>Apache 2</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/chemistry/opencmis-swingclient/trunk</connection>
+ <developerConnection>scn:svn:https://svn.apache.org/repos/asf/incubator/chemistry/opencmis-swingclient/trunk</developerConnection>
+ <url>http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk</url>
+ </scm>
+
+ <issueManagement>
+ <system>Jira</system>
+ <url>https://issues.apache.org/jira/browse/CMIS</url>
+ </issueManagement>
+
+ <mailingLists>
+ <mailingList>
+ <name>Chemistry Development List</name>
+ <subscribe>chemistry-dev-subscribe@incubator.apache.org</subscribe>
+ <unsubscribe>chemistry-dev-unsubscribe@incubator.apache.org</unsubscribe>
+ <post>chemistry-dev@incubator.apache.org</post>
+ <archive>
+ http://mail-archives.apache.org/mod_mbox/incubator-chemistry-dev/
+ </archive>
+ </mailingList>
+ <mailingList>
+ <name>Chemistry Source Control List</name>
+ <subscribe>chemistry-commits-subscribe@incubator.apache.org</subscribe>
+ <unsubscribe>chemistry-commits-unsubscribe@incubator.apache.org</unsubscribe>
+ <post>chemistry-commits@incubator.apache.org</post>
+ <archive>
+ http://mail-archives.apache.org/mod_mbox/incubator-chemistry-commits/
+ </archive>
+ </mailingList>
+ </mailingLists>
+
+ <developers>
+ <developer>
+ <name>Florian Müller</name>
+ <id>fmui</id>
+ <roles>
+ <role>committer</role>
+ </roles>
+ <email>fmui@apache.org</email>
+ </developer>
+ </developers>
+
+ <!-- Project Environment -->
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compile.source>1.5</maven.compile.source>
+ <maven.compile.target>1.5</maven.compile.target>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-5</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <target>${maven.compile.target}</target>
+ <source>${maven.compile.source}</source>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <inherited>true</inherited>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <includePom>true</includePom>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ <filtering>false</filtering>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <downloadJavadocs>true</downloadJavadocs>
+ <workspace>.</workspace>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <addMavenDescriptor>false</addMavenDescriptor>
+ <manifest>
+ <mainClass>org.apache.chemistry.opencmis.swingclient.SwingClient</mainClass>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>lib/</classpathPrefix>
+ </manifest>
+ <manifestEntries>
+ <X-Compile-Source-JDK>${maven.compile.source}</X-Compile-Source-JDK>
+ <X-Compile-Target-JDK>${maven.compile.target}</X-Compile-Target-JDK>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/client-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.chemistry.opencmis</groupId>
+ <artifactId>chemistry-opencmis-client-impl</artifactId>
+ <version>0.2.0-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ </dependency>
+ <!--
+ Added to gather the latest Apache licenses to be added in
+ assemblies
+ -->
+ <dependency>
+ <groupId>org.apache</groupId>
+ <artifactId>apache-jar-resource-bundle</artifactId>
+ <version>1.4</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Propchange: incubator/chemistry/opencmis-swingclient/trunk/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/assembly/client-assembly.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/assembly/client-assembly.xml?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/assembly/client-assembly.xml (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/assembly/client-assembly.xml Thu Jul 22 11:19:09 2010
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ 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.
+ -->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
+ <!-- To build this, run "mvn package assembly:assembly" -->
+ <id>bin</id>
+ <formats>
+ <format>zip</format>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>${project.build.directory}/classes/META-INF</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>README*</include>
+ <include>LICENSE*</include>
+ <include>NOTICE*</include>
+ <include>DEPENDENCIES*</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <outputDirectory></outputDirectory>
+ <directory>${project.build.directory}</directory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ <excludes>
+ <exclude>*source*</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ <useProjectArtifact>false</useProjectArtifact>
+ <scope>runtime</scope>
+ </dependencySet>
+ </dependencySets>
+
+</assembly>
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/assembly/client-assembly.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,244 @@
+/*
+ * 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;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JToolBar;
+
+import org.apache.chemistry.opencmis.swingclient.details.DetailsTabs;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+import org.apache.chemistry.opencmis.swingclient.model.ClientSession;
+
+public class ClientFrame extends JFrame {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String WINDOW_TITLE = "CMIS Swing Client";
+
+ private static final int BUTTON_CONNECT = 0;
+ private static final int BUTTON_REPOSITORY_INFO = 1;
+ private static final int BUTTON_TYPES = 2;
+ private static final int BUTTON_QUERY = 3;
+ private static final int BUTTON_CREATE_DOCUMENT = 4;
+ private static final int BUTTON_CREATE_FOLDER = 5;
+ private static final int BUTTON_LOG = 8;
+ private static final int BUTTON_INFO = 9;
+
+ private LoginDialog loginDialog;
+ private LogFrame logFrame;
+ private InfoDialog infoDialog;
+
+ private JToolBar toolBar;
+ private JButton[] toolbarButton;
+
+ private FolderPanel folderPanel;
+ private DetailsTabs detailsTabs;
+
+ private ClientModel model;
+
+ public ClientFrame() {
+ super();
+
+ model = new ClientModel();
+ createGUI();
+ showLoginForm();
+ }
+
+ private void createGUI() {
+ setTitle(WINDOW_TITLE);
+ setPreferredSize(new Dimension(1000, 600));
+ setMinimumSize(new Dimension(200, 60));
+
+ setLayout(new BorderLayout());
+
+ final ClientFrame thisFrame = this;
+ loginDialog = new LoginDialog(this);
+ logFrame = new LogFrame();
+ infoDialog = new InfoDialog(this);
+
+ Container pane = getContentPane();
+
+ toolBar = new JToolBar("CMIS Toolbar", JToolBar.HORIZONTAL);
+
+ toolbarButton = new JButton[10];
+
+ toolbarButton[BUTTON_CONNECT] = new JButton("Connection", ClientHelper
+ .getIcon("connect.png"));
+ toolbarButton[BUTTON_CONNECT].addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ showLoginForm();
+ }
+ });
+
+ toolBar.add(toolbarButton[BUTTON_CONNECT]);
+
+ toolBar.addSeparator();
+
+ toolbarButton[BUTTON_REPOSITORY_INFO] = new JButton("Repository Info",
+ ClientHelper.getIcon("repository-info.png"));
+ toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(false);
+ toolbarButton[BUTTON_REPOSITORY_INFO]
+ .addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ new RepositoryInfoFrame(model);
+ }
+ });
+
+ toolBar.add(toolbarButton[BUTTON_REPOSITORY_INFO]);
+
+ toolbarButton[BUTTON_TYPES] = new JButton("Types", ClientHelper
+ .getIcon("types.png"));
+ toolbarButton[BUTTON_TYPES].setEnabled(false);
+ toolbarButton[BUTTON_TYPES].addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ new TypesFrame(model);
+ }
+ });
+
+ toolBar.add(toolbarButton[BUTTON_TYPES]);
+
+ toolbarButton[BUTTON_QUERY] = new JButton("Query", ClientHelper
+ .getIcon("query.png"));
+ toolbarButton[BUTTON_QUERY].setEnabled(false);
+ toolbarButton[BUTTON_QUERY].addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ new QueryFrame(model);
+ }
+ });
+
+ toolBar.add(toolbarButton[BUTTON_QUERY]);
+
+ toolBar.addSeparator();
+
+ toolbarButton[BUTTON_CREATE_DOCUMENT] = new JButton("Create Document",
+ ClientHelper.getIcon("newdocument.png"));
+ toolbarButton[BUTTON_CREATE_DOCUMENT].setEnabled(false);
+ toolbarButton[BUTTON_CREATE_DOCUMENT]
+ .addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ new CreateDocumentDialog(thisFrame, model);
+ }
+ });
+
+ toolBar.add(toolbarButton[BUTTON_CREATE_DOCUMENT]);
+
+ toolbarButton[BUTTON_CREATE_FOLDER] = new JButton("Create Folder",
+ ClientHelper.getIcon("newfolder.png"));
+ toolbarButton[BUTTON_CREATE_FOLDER].setEnabled(false);
+ toolbarButton[BUTTON_CREATE_FOLDER]
+ .addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ new CreateFolderDialog(thisFrame, model);
+ }
+ });
+
+ toolBar.add(toolbarButton[BUTTON_CREATE_FOLDER]);
+
+ toolBar.addSeparator();
+
+ toolbarButton[BUTTON_LOG] = new JButton("Log", ClientHelper
+ .getIcon("log.png"));
+ toolbarButton[BUTTON_LOG].addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ logFrame.showFrame();
+ }
+ });
+
+ toolBar.add(toolbarButton[BUTTON_LOG]);
+
+ toolbarButton[BUTTON_INFO] = new JButton("Info", ClientHelper
+ .getIcon("info.png"));
+ toolbarButton[BUTTON_INFO].addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ infoDialog.showDialog();
+ }
+ });
+
+ toolBar.add(toolbarButton[BUTTON_INFO]);
+
+ pane.add(toolBar, BorderLayout.PAGE_START);
+
+ folderPanel = new FolderPanel(model);
+ detailsTabs = new DetailsTabs(model);
+
+ JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+ folderPanel, new JScrollPane(detailsTabs));
+
+ pane.add(split, BorderLayout.CENTER);
+
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ pack();
+
+ split.setDividerLocation(500);
+
+ setLocationRelativeTo(null);
+ setVisible(true);
+ }
+
+ private void showLoginForm() {
+ loginDialog.showDialog();
+ if (!loginDialog.isCanceled()) {
+ ClientSession clientSession = loginDialog.getClientSession();
+
+ model.setClientSession(clientSession);
+
+ try {
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ model.loadFolder(clientSession.getSession().getRepositoryInfo()
+ .getRootFolderId(), false);
+ model.loadObject(clientSession.getSession().getRepositoryInfo()
+ .getRootFolderId());
+
+ toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(true);
+ toolbarButton[BUTTON_TYPES].setEnabled(true);
+ toolbarButton[BUTTON_QUERY].setEnabled(model.supportsQuery());
+ toolbarButton[BUTTON_CREATE_DOCUMENT].setEnabled(true);
+ toolbarButton[BUTTON_CREATE_FOLDER].setEnabled(true);
+
+ setTitle(WINDOW_TITLE
+ + " - "
+ + clientSession.getSession().getRepositoryInfo()
+ .getName());
+ } catch (Exception ex) {
+ toolbarButton[BUTTON_REPOSITORY_INFO].setEnabled(false);
+ toolbarButton[BUTTON_TYPES].setEnabled(false);
+ toolbarButton[BUTTON_QUERY].setEnabled(false);
+ toolbarButton[BUTTON_CREATE_DOCUMENT].setEnabled(false);
+ toolbarButton[BUTTON_CREATE_FOLDER].setEnabled(false);
+
+ ClientHelper.showError(null, ex);
+
+ setTitle(WINDOW_TITLE);
+ } finally {
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientFrame.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,111 @@
+/*
+ * 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;
+
+import java.awt.Component;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.GregorianCalendar;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ClientHelper {
+
+ 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) {
+ }
+ }
+ }
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientWriterAppender.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientWriterAppender.java?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientWriterAppender.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientWriterAppender.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+import org.apache.log4j.WriterAppender;
+import org.apache.log4j.spi.LoggingEvent;
+
+public class ClientWriterAppender extends WriterAppender {
+
+ private static JTextArea logTextArea = null;
+
+ public static void setTextArea(JTextArea textArea) {
+ logTextArea = textArea;
+ }
+
+ @Override
+ public void append(LoggingEvent loggingEvent) {
+ if (logTextArea == null) {
+ return;
+ }
+
+ final String message = layout.format(loggingEvent);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ logTextArea.append(message);
+ }
+ });
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/ClientWriterAppender.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateDocumentDialog.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateDocumentDialog.java?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateDocumentDialog.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateDocumentDialog.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,142 @@
+/*
+ * 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;
+
+import java.awt.BorderLayout;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+import org.apache.chemistry.opencmis.swingclient.swing.CreateDialog;
+
+public class CreateDocumentDialog extends CreateDialog {
+
+ private static final long serialVersionUID = 1L;
+
+ private JTextField nameField;
+ private JComboBox typeBox;
+ private JTextField filenameField;
+ private JComboBox versioningStateBox;
+
+ public CreateDocumentDialog(Frame owner, ClientModel model) {
+ super(owner, "Create Document", model);
+ createGUI();
+ }
+
+ private void createGUI() {
+ final CreateDocumentDialog thisDialog = this;
+
+ nameField = new JTextField(60);
+ createRow("Name:", nameField, 0);
+
+ typeBox = new JComboBox(getTypes(BaseTypeId.CMIS_DOCUMENT.value()));
+ typeBox.setSelectedIndex(0);
+ typeBox.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent e) {
+ DocumentTypeDefinition type = (DocumentTypeDefinition) ((ObjectTypeItem) typeBox
+ .getSelectedItem()).getObjectType();
+ if (type.isVersionable()) {
+ versioningStateBox.setSelectedItem(VersioningState.MAJOR);
+ } else {
+ versioningStateBox.setSelectedItem(VersioningState.NONE);
+ }
+ }
+ });
+
+ createRow("Type:", typeBox, 1);
+
+ JPanel filePanel = new JPanel(new BorderLayout());
+
+ filenameField = new JTextField(30);
+ filePanel.add(filenameField, BorderLayout.CENTER);
+
+ JButton browseButton = new JButton("Browse");
+ browseButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ JFileChooser fileChooser = new JFileChooser();
+ int chooseResult = fileChooser.showDialog(filenameField,
+ "Select");
+ if (chooseResult == JFileChooser.APPROVE_OPTION) {
+ if (fileChooser.getSelectedFile().isFile()) {
+ filenameField.setText(fileChooser.getSelectedFile()
+ .getAbsolutePath());
+ if (nameField.getText().trim().length() == 0) {
+ nameField.setText(fileChooser.getSelectedFile()
+ .getName());
+ }
+ }
+ }
+ }
+ });
+ filePanel.add(browseButton, BorderLayout.LINE_END);
+
+ createRow("File:", filePanel, 2);
+
+ versioningStateBox = new JComboBox(new Object[] { VersioningState.NONE,
+ VersioningState.MAJOR, VersioningState.MINOR,
+ VersioningState.CHECKEDOUT });
+ if (((DocumentTypeDefinition) ((ObjectTypeItem) typeBox
+ .getSelectedItem()).getObjectType()).isVersionable()) {
+ versioningStateBox.setSelectedItem(VersioningState.MAJOR);
+ } else {
+ versioningStateBox.setSelectedItem(VersioningState.NONE);
+ }
+ createRow("Versioning State:", versioningStateBox, 3);
+
+ JButton createButton = new JButton("Create Document");
+ createButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ String name = nameField.getText();
+ String type = ((ObjectTypeItem) typeBox.getSelectedItem())
+ .getObjectType().getId();
+ String filename = filenameField.getText();
+
+ try {
+ getClientModel().createDocument(
+ name,
+ type,
+ filename,
+ (VersioningState) versioningStateBox
+ .getSelectedItem());
+ getClientModel().reloadFolder();
+
+ thisDialog.setVisible(false);
+ thisDialog.dispose();
+ } catch (Exception e) {
+ ClientHelper.showError(null, e);
+ }
+ }
+ });
+ createRow("", createButton, 4);
+
+ showDialog();
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateDocumentDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateFolderDialog.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateFolderDialog.java?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateFolderDialog.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateFolderDialog.java Thu Jul 22 11:19:09 2010
@@ -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.swingclient;
+
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JTextField;
+
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+import org.apache.chemistry.opencmis.swingclient.swing.CreateDialog;
+
+public class CreateFolderDialog extends CreateDialog {
+
+ private static final long serialVersionUID = 1L;
+
+ private JTextField nameField;
+ private JComboBox typeBox;
+
+ public CreateFolderDialog(Frame owner, ClientModel model) {
+ super(owner, "Create Folder", model);
+ createGUI();
+ }
+
+ private void createGUI() {
+ final CreateFolderDialog thisDialog = this;
+
+ nameField = new JTextField(60);
+ createRow("Name:", nameField, 0);
+
+ typeBox = new JComboBox(getTypes(BaseTypeId.CMIS_FOLDER.value()));
+ typeBox.setSelectedIndex(0);
+ createRow("Type:", typeBox, 1);
+
+ JButton createButton = new JButton("Create Folder");
+ createButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ String name = nameField.getText();
+ String type = ((ObjectTypeItem) typeBox.getSelectedItem())
+ .getObjectType().getId();
+
+ try {
+ getClientModel().createFolder(name, type);
+ getClientModel().reloadFolder();
+
+ thisDialog.setVisible(false);
+ thisDialog.dispose();
+ } catch (Exception e) {
+ ClientHelper.showError(null, e);
+ }
+ }
+ });
+ createRow("", createButton, 3);
+
+ showDialog();
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/CreateFolderDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderPanel.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderPanel.java?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderPanel.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderPanel.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,158 @@
+/*
+ * 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;
+
+import java.awt.BorderLayout;
+import java.awt.Cursor;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModelEvent;
+import org.apache.chemistry.opencmis.swingclient.model.FolderListener;
+
+public class FolderPanel extends JPanel implements FolderListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private ClientModel model;
+
+ private String parentId;
+
+ private JButton upButton;
+ private JTextField pathField;
+ private JButton goButton;
+ private FolderTable folderTable;
+
+ public FolderPanel(ClientModel model) {
+ super();
+
+ this.model = model;
+ model.addFolderListener(this);
+ createGUI();
+ }
+
+ public void folderLoaded(ClientModelEvent event) {
+ Folder currentFolder = event.getClientModel().getCurrentFolder();
+
+ if (currentFolder != null) {
+ String path = currentFolder.getPath();
+ pathField.setText(path);
+
+ Folder parent = currentFolder.getFolderParent();
+ if (parent == null) {
+ parentId = null;
+ upButton.setEnabled(false);
+ } else {
+ parentId = parent.getId();
+ upButton.setEnabled(true);
+ }
+ } else {
+ pathField.setText("???");
+ parentId = null;
+ upButton.setEnabled(false);
+ }
+ }
+
+ private void createGUI() {
+ setLayout(new BorderLayout());
+
+ JPanel panel = new JPanel();
+ // panel.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 3));
+ panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
+ panel.setBorder(BorderFactory.createEmptyBorder(3, 0, 2, 0));
+
+ upButton = new JButton("up");
+ upButton.setEnabled(false);
+ upButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ try {
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ model.loadFolder(parentId, false);
+ model.loadObject(model.getCurrentFolder().getId());
+ } catch (Exception ex) {
+ ClientHelper.showError(null, ex);
+ return;
+ } finally {
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+ });
+ panel.add(upButton);
+
+ pathField = new JTextField("");
+ pathField.addKeyListener(new KeyListener() {
+ public void keyTyped(KeyEvent e) {
+ }
+
+ public void keyReleased(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ loadFolder();
+ }
+ }
+
+ public void keyPressed(KeyEvent e) {
+ }
+ });
+ panel.add(pathField);
+
+ goButton = new JButton("go");
+ goButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ loadFolder();
+ }
+ });
+ panel.add(goButton);
+
+ add(panel, BorderLayout.PAGE_START);
+
+ folderTable = new FolderTable(model);
+ folderTable.setFillsViewportHeight(true);
+ model.addFolderListener(folderTable);
+
+ add(new JScrollPane(folderTable), BorderLayout.CENTER);
+ }
+
+ private void loadFolder() {
+ try {
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ String id = pathField.getText().trim();
+ if (id.length() == 0) {
+ id = "/";
+ }
+ model.loadFolder(id, id.startsWith("/"));
+ model.loadObject(model.getCurrentFolder().getId());
+ } catch (Exception ex) {
+ ClientHelper.showError(null, ex);
+ return;
+ } finally {
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderPanel.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,235 @@
+/*
+ * 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;
+
+import java.awt.Cursor;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.ImageIcon;
+import javax.swing.JTable;
+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.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModelEvent;
+import org.apache.chemistry.opencmis.swingclient.model.FolderListener;
+
+public class FolderTable extends JTable implements FolderListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String[] COLUMN_NAMES = { "", "Name", "Type",
+ "Content Type", "Size", "Creation Date", "Created by",
+ "Modification Date", "Modified by", "Id" };
+ private static final int[] COLUMN_WIDTHS = { 24, 200, 150, 150, 80, 200,
+ 100, 200, 100, 300 };
+
+ private ClientModel model;
+
+ private Map<BaseTypeId, ImageIcon> icons;
+
+ public FolderTable(final ClientModel model) {
+ super();
+
+ this.model = model;
+
+ setModel(new FolderTableModel());
+
+ 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(COLUMN_WIDTHS[i]);
+ }
+
+ getSelectionModel().addListSelectionListener(
+ new ListSelectionListener() {
+ public void valueChanged(ListSelectionEvent e) {
+ if (e.getValueIsAdjusting()) {
+ return;
+ }
+
+ int row = getSelectedRow();
+ if (row > -1) {
+ String id = model.getCurrentChildren().get(
+ getSelectedRow()).getId();
+
+ try {
+ setCursor(Cursor
+ .getPredefinedCursor(Cursor.WAIT_CURSOR));
+ model.loadObject(id);
+ } catch (Exception ex) {
+ ClientHelper.showError(null, ex);
+ return;
+ } finally {
+ setCursor(Cursor
+ .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+ }
+ });
+
+ addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
+ doAction();
+ }
+ }
+ });
+
+ addKeyListener(new KeyListener() {
+ public void keyTyped(KeyEvent e) {
+ }
+
+ public void keyReleased(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ doAction();
+ }
+ }
+
+ public void keyPressed(KeyEvent e) {
+ }
+ });
+
+ loadIcons();
+ }
+
+ private void loadIcons() {
+ icons = new HashMap<BaseTypeId, ImageIcon>();
+ icons.put(BaseTypeId.CMIS_DOCUMENT, ClientHelper
+ .getIcon("document.png"));
+ icons.put(BaseTypeId.CMIS_FOLDER, ClientHelper.getIcon("folder.png"));
+ icons.put(BaseTypeId.CMIS_RELATIONSHIP, ClientHelper
+ .getIcon("relationship.png"));
+ icons.put(BaseTypeId.CMIS_POLICY, ClientHelper.getIcon("policy.png"));
+ }
+
+ public void folderLoaded(ClientModelEvent event) {
+ event.getClientModel().getCurrentChildren();
+
+ ((FolderTableModel) getModel()).fireTableDataChanged();
+ }
+
+ private void doAction() {
+ int row = getSelectedRow();
+ if ((row > -1) && (row < model.getCurrentChildren().size())) {
+ CmisObject object = model.getCurrentChildren().get(row);
+
+ if (object instanceof Document) {
+ download((Document) object);
+ } else if (object instanceof Folder) {
+ try {
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ model.loadFolder(object.getId(), false);
+ } catch (Exception ex) {
+ ClientHelper.showError(null, ex);
+ return;
+ } finally {
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+ }
+ }
+
+ private void download(Document doc) {
+ ClientHelper.download(this.getParent(), doc, null);
+ }
+
+ class FolderTableModel extends AbstractTableModel {
+
+ 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() {
+ return model.getCurrentChildren().size();
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ CmisObject obj = model.getCurrentChildren().get(rowIndex);
+
+ switch (columnIndex) {
+ case 0:
+ return icons.get(obj.getBaseTypeId());
+ case 1:
+ return obj.getName();
+ case 2:
+ return obj.getType().getId();
+ case 3:
+ if (obj instanceof Document) {
+ return ((Document) obj).getContentStreamMimeType();
+ } else {
+ return null;
+ }
+ case 4:
+ if (obj instanceof Document) {
+ return ((Document) obj).getContentStreamLength();
+ } else {
+ return null;
+ }
+ case 5:
+ return (obj.getCreationDate() == null ? null : ClientHelper
+ .getDateString(obj.getCreationDate()));
+ case 6:
+ return obj.getCreatedBy();
+ case 7:
+ return (obj.getLastModificationDate() == null ? null
+ : ClientHelper.getDateString(obj
+ .getLastModificationDate()));
+ case 8:
+ return obj.getLastModifiedBy();
+ case 9:
+ return obj.getId();
+ }
+
+ return "";
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ if (columnIndex == 0) {
+ return ImageIcon.class;
+ } else if (columnIndex == 4) {
+ return Long.class;
+ }
+
+ return String.class;
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/FolderTable.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,84 @@
+/*
+ * 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;
+
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.TextArea;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import javax.swing.BoxLayout;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+
+public class InfoDialog extends JDialog {
+
+ private static final long serialVersionUID = 1L;
+
+ public InfoDialog(Frame owner) {
+ super(owner, "Info", true);
+ createGUI();
+ }
+
+ private void createGUI() {
+ setPreferredSize(new Dimension(600, 400));
+ setMinimumSize(new Dimension(200, 60));
+
+ setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
+
+ StringBuilder readme = new StringBuilder();
+
+ InputStream stream = getClass().getResourceAsStream("/META-INF/README");
+ if (stream != null) {
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ stream));
+
+ String s = null;
+ while ((s = br.readLine()) != null) {
+ readme.append(s);
+ readme.append('\n');
+ }
+
+ br.close();
+ } catch (Exception e) {
+ }
+ } else {
+ readme.append("CMIS Swing Client");
+ }
+
+ TextArea ta = new TextArea(readme.toString());
+ ta.setEditable(false);
+ add(ta);
+
+ setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ pack();
+ setLocationRelativeTo(null);
+ }
+
+ public void showDialog() {
+ setVisible(true);
+ }
+
+ public void hideDialog() {
+ setVisible(false);
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LogFrame.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LogFrame.java?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LogFrame.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LogFrame.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,101 @@
+/*
+ * 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;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+public class LogFrame extends JFrame {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String WINDOW_TITLE = "CMIS Client Logging";
+
+ private JTextArea logTextArea;
+
+ public LogFrame() {
+ super();
+ createGUI();
+ }
+
+ private void createGUI() {
+ setTitle(WINDOW_TITLE);
+ setPreferredSize(new Dimension(800, 600));
+ setMinimumSize(new Dimension(200, 60));
+
+ setLayout(new BorderLayout());
+
+ logTextArea = new JTextArea();
+ logTextArea.setEditable(false);
+ logTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
+ logTextArea.setLineWrap(true);
+ logTextArea.setWrapStyleWord(true);
+ add(new JScrollPane(logTextArea), BorderLayout.CENTER);
+
+ JPanel inputPanel = new JPanel(new FlowLayout());
+ add(inputPanel, BorderLayout.PAGE_END);
+
+ JButton clearButton = new JButton("Clear");
+ clearButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ logTextArea.setText("");
+ }
+ });
+ inputPanel.add(clearButton);
+
+ String[] levels = new String[] { Level.ALL.toString(), Level.TRACE.toString(), Level.DEBUG.toString(),
+ Level.INFO.toString(), Level.WARN.toString(), Level.ERROR.toString(), Level.FATAL.toString(),
+ Level.OFF.toString() };
+
+ final JComboBox levelBox = new JComboBox(levels);
+ levelBox.setSelectedItem(Logger.getRootLogger().getLevel().toString());
+ levelBox.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ Logger.getRootLogger().setLevel(Level.toLevel(levelBox.getSelectedItem().toString()));
+ }
+ });
+ inputPanel.add(levelBox);
+
+ setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ pack();
+
+ setLocationRelativeTo(null);
+ setVisible(false);
+
+ ClientWriterAppender.setTextArea(logTextArea);
+ }
+
+ public void showFrame() {
+ setVisible(true);
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LogFrame.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java?rev=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,269 @@
+/*
+ * 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;
+
+import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+
+import org.apache.chemistry.opencmis.client.api.Repository;
+import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.swingclient.model.ClientSession;
+
+public class LoginDialog extends JDialog {
+
+ public static final String SYSPROP_URL = "swingclient.url";
+ public static final String SYSPROP_USER = "swingclient.user";
+ public static final String SYSPROP_PASSWORD = "swingclient.password";
+
+ private static final long serialVersionUID = 1L;
+
+ private JTextField urlField;
+ private JRadioButton bindingAtomButton;
+ private JRadioButton bindingWebServicesButton;
+ private JTextField usernameField;
+ private JPasswordField passwordField;
+ private JButton connectButton;
+ private JButton loginButton;
+ private JComboBox repositoryBox;
+
+ private boolean canceled = true;
+
+ private ClientSession clientSession;
+
+ public LoginDialog(Frame owner) {
+ super(owner, "Login", true);
+ createGUI();
+ }
+
+ private void createGUI() {
+ setPreferredSize(new Dimension(500, 250));
+
+ Container pane = getContentPane();
+
+ pane.setLayout(new GridBagLayout());
+
+ urlField = createTextField(pane, "URL:", 1);
+ urlField.setText(System.getProperty(SYSPROP_URL, ""));
+
+ createBindingButtons(pane, 2);
+
+ usernameField = createTextField(pane, "Username:", 3);
+ usernameField.setText(System.getProperty(SYSPROP_USER, ""));
+
+ passwordField = createPasswordField(pane, "Password:", 4);
+ passwordField.setText(System.getProperty(SYSPROP_PASSWORD, ""));
+
+ connectButton = createButton(pane, "Connect", 5);
+
+ createRepositoryBox(pane, 6);
+
+ loginButton = createButton(pane, "Login", 7);
+ loginButton.setEnabled(false);
+
+ connectButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ repositoryBox.removeAllItems();
+
+ try {
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ createClientSession();
+
+ List<Repository> repositories = clientSession
+ .getRepositories();
+ if (repositories.size() > 0) {
+
+ for (Repository repository : repositories) {
+ repositoryBox.addItem(repository.getName() + " ("
+ + repository.getId() + ")");
+ }
+
+ repositoryBox.setEnabled(true);
+ loginButton.setEnabled(true);
+ } else {
+ repositoryBox.setEnabled(false);
+ loginButton.setEnabled(false);
+ }
+ } catch (Exception ex) {
+ repositoryBox.setEnabled(false);
+ loginButton.setEnabled(false);
+
+ ClientHelper.showError(getOwner(), ex);
+ } finally {
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+ });
+
+ loginButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ try {
+ clientSession.createSession(repositoryBox
+ .getSelectedIndex());
+ canceled = false;
+ hideDialog();
+ } catch (Exception ex) {
+ repositoryBox.setEnabled(false);
+ loginButton.setEnabled(false);
+
+ ClientHelper.showError(getOwner(), ex);
+ }
+ }
+ });
+
+ setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ pack();
+ setLocationRelativeTo(null);
+ }
+
+ private JTextField createTextField(Container pane, String label, int row) {
+ JTextField textField = new JTextField(60);
+ JLabel textLabel = new JLabel(label);
+ textLabel.setLabelFor(textField);
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.LINE_START;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.gridx = 0;
+ c.gridy = row;
+ pane.add(textLabel, c);
+ c.gridx = 1;
+ c.ipadx = 400;
+ pane.add(textField, c);
+
+ return textField;
+ }
+
+ private JPasswordField createPasswordField(Container pane, String label,
+ int row) {
+ JPasswordField textField = new JPasswordField(60);
+ JLabel textLabel = new JLabel(label);
+ textLabel.setLabelFor(textField);
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.LINE_START;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.gridx = 0;
+ c.gridy = row;
+ pane.add(textLabel, c);
+ c.gridx = 1;
+ pane.add(textField, c);
+
+ return textField;
+ }
+
+ private void createBindingButtons(Container pane, int row) {
+ JPanel bindingContainer = new JPanel();
+ bindingAtomButton = new JRadioButton("AtomPub", true);
+ bindingWebServicesButton = new JRadioButton("Web Services", false);
+ ButtonGroup bindingGroup = new ButtonGroup();
+ bindingGroup.add(bindingAtomButton);
+ bindingGroup.add(bindingWebServicesButton);
+ bindingContainer.add(bindingAtomButton);
+ bindingContainer.add(bindingWebServicesButton);
+ JLabel bindingLabel = new JLabel("Binding:");
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.LINE_START;
+ c.gridx = 0;
+ c.gridy = row;
+ pane.add(bindingLabel, c);
+ c.gridx = 1;
+ pane.add(bindingContainer, c);
+ }
+
+ private JButton createButton(Container pane, String label, int row) {
+ JButton button = new JButton(label);
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.CENTER;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.gridx = 1;
+ c.gridy = row;
+ pane.add(button, c);
+
+ return button;
+ }
+
+ private void createRepositoryBox(Container pane, int row) {
+ repositoryBox = new JComboBox();
+ repositoryBox.setEnabled(false);
+ JLabel boxLabel = new JLabel("Repository:");
+ boxLabel.setLabelFor(repositoryBox);
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.anchor = GridBagConstraints.LINE_START;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.gridx = 0;
+ c.gridy = row;
+ pane.add(boxLabel, c);
+ c.gridx = 1;
+ pane.add(repositoryBox, c);
+ }
+
+ public void createClientSession() {
+ String url = urlField.getText();
+ BindingType binding = bindingAtomButton.isSelected() ? BindingType.ATOMPUB
+ : BindingType.WEBSERVICES;
+ String username = usernameField.getText();
+ String password = new String(passwordField.getPassword());
+
+ clientSession = new ClientSession(url, binding, username, password);
+ }
+
+ public void showDialog() {
+ clientSession = null;
+ canceled = true;
+
+ repositoryBox.removeAllItems();
+ repositoryBox.setEnabled(false);
+ loginButton.setEnabled(false);
+
+ setVisible(true);
+ }
+
+ public void hideDialog() {
+ setVisible(false);
+ }
+
+ public ClientSession getClientSession() {
+ return clientSession;
+ }
+
+ public boolean isCanceled() {
+ return canceled;
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=966582&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java Thu Jul 22 11:19:09 2010
@@ -0,0 +1,345 @@
+/*
+ * 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;
+
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFormattedTextField;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.text.NumberFormatter;
+
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.QueryResult;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.swingclient.model.ClientModel;
+
+public class QueryFrame extends JFrame {
+
+ 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 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;
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/QueryFrame.java
------------------------------------------------------------------------------
svn:eol-style = native