Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2AC4817AAC for ; Mon, 6 Apr 2015 17:20:10 +0000 (UTC) Received: (qmail 82180 invoked by uid 500); 6 Apr 2015 17:20:03 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 82018 invoked by uid 500); 6 Apr 2015 17:20:03 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 81273 invoked by uid 99); 6 Apr 2015 17:20:03 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 17:20:03 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 42B7CAC0E2E for ; Mon, 6 Apr 2015 17:20:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1671614 [13/31] - in /chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench: ./ chemistry-opencmis-workbench/ chemistry-opencmis-workbench/css/ chemistry-opencmis-workbench/images/ chemistry-opencmis-workbench/images/... Date: Mon, 06 Apr 2015 17:20:01 -0000 To: commits@chemistry.apache.org From: gabriele@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150406172003.42B7CAC0E2E@hades.apache.org> Added: chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/FolderTable.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/FolderTable.html?rev=1671614&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/FolderTable.html (added) +++ chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/FolderTable.html Mon Apr 6 17:19:59 2015 @@ -0,0 +1,406 @@ + + + + +FolderTable xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.workbench;
+20  
+21  import java.awt.Cursor;
+22  import java.awt.datatransfer.DataFlavor;
+23  import java.awt.datatransfer.Transferable;
+24  import java.awt.datatransfer.UnsupportedFlavorException;
+25  import java.awt.event.ActionEvent;
+26  import java.awt.event.ActionListener;
+27  import java.awt.event.KeyEvent;
+28  import java.awt.event.KeyListener;
+29  import java.awt.event.MouseAdapter;
+30  import java.awt.event.MouseEvent;
+31  import java.io.File;
+32  import java.io.IOException;
+33  import java.util.Collections;
+34  import java.util.GregorianCalendar;
+35  import java.util.HashMap;
+36  import java.util.List;
+37  import java.util.Map;
+38  
+39  import javax.swing.DropMode;
+40  import javax.swing.ImageIcon;
+41  import javax.swing.JComponent;
+42  import javax.swing.JMenuItem;
+43  import javax.swing.JPopupMenu;
+44  import javax.swing.JTable;
+45  import javax.swing.ListSelectionModel;
+46  import javax.swing.SwingUtilities;
+47  import javax.swing.TransferHandler;
+48  import javax.swing.event.ListSelectionEvent;
+49  import javax.swing.event.ListSelectionListener;
+50  import javax.swing.table.AbstractTableModel;
+51  import javax.swing.table.TableColumn;
+52  
+53  import org.apache.chemistry.opencmis.client.api.CmisObject;
+54  import org.apache.chemistry.opencmis.client.api.Document;
+55  import org.apache.chemistry.opencmis.client.api.Folder;
+56  import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+57  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+58  import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent;
+59  import org.apache.chemistry.opencmis.workbench.model.FolderListener;
+60  import org.apache.chemistry.opencmis.workbench.swing.GregorianCalendarRenderer;
+61  
+62  public class FolderTable extends JTable implements FolderListener {
+63  
+64      private static final long serialVersionUID = 1L;
+65  
+66      private static final String[] COLUMN_NAMES = { "", "Name", "Type", "Content Type", "Size", "Creation Date",
+67              "Created by", "Modification Date", "Modified by", "Id" };
+68      private static final int[] COLUMN_WIDTHS = { 24, 200, 150, 150, 80, 180, 100, 180, 100, 300 };
+69      public static final int ID_COLUMN = 9;
+70  
+71      private final ClientModel model;
+72  
+73      private Map<BaseTypeId, ImageIcon> icons;
+74      private ImageIcon checkedOutIcon;
+75      private ImageIcon pwcIcon;
+76  
+77      public FolderTable(final ClientModel model) {
+78          super();
+79  
+80          this.model = model;
+81  
+82          setModel(new FolderTableModel());
+83  
+84          setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+85          setAutoResizeMode(AUTO_RESIZE_OFF);
+86          setAutoCreateRowSorter(true);
+87  
+88          setDefaultRenderer(GregorianCalendar.class, new GregorianCalendarRenderer());
+89          setTransferHandler(new FolderTransferHandler());
+90          setDragEnabled(true);
+91          setDropMode(DropMode.INSERT);
+92  
+93          for (int i = 0; i < COLUMN_WIDTHS.length; i++) {
+94              TableColumn column = getColumnModel().getColumn(i);
+95              column.setPreferredWidth(COLUMN_WIDTHS[i]);
+96          }
+97  
+98          final JPopupMenu popup = new JPopupMenu();
+99          JMenuItem menuItem = new JMenuItem("Copy to clipboard");
+100         popup.add(menuItem);
+101 
+102         menuItem.addActionListener(new ActionListener() {
+103             public void actionPerformed(ActionEvent e) {
+104                 ClientHelper.copyTableToClipboard(FolderTable.this);
+105             }
+106         });
+107 
+108         getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+109             public void valueChanged(ListSelectionEvent e) {
+110                 if (e.getValueIsAdjusting()) {
+111                     return;
+112                 }
+113 
+114                 int row = getSelectedRow();
+115                 if (row > -1) {
+116                     String id = getModel().getValueAt(getRowSorter().convertRowIndexToModel(row), ID_COLUMN).toString();
+117 
+118                     try {
+119                         setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+120                         model.loadObject(id);
+121                     } catch (Exception ex) {
+122                         ClientHelper.showError(null, ex);
+123                         return;
+124                     } finally {
+125                         setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+126                     }
+127                 }
+128             }
+129         });
+130 
+131         addMouseListener(new MouseAdapter() {
+132             public void mouseClicked(MouseEvent e) {
+133                 if (e.getClickCount() == 2) {
+134                     doAction(e.isShiftDown());
+135                 }
+136             }
+137 
+138             public void mousePressed(MouseEvent e) {
+139                 maybeShowPopup(e);
+140             }
+141 
+142             public void mouseReleased(MouseEvent e) {
+143                 maybeShowPopup(e);
+144             }
+145 
+146             private void maybeShowPopup(MouseEvent e) {
+147                 if (e.isPopupTrigger()) {
+148                     popup.show(e.getComponent(), e.getX(), e.getY());
+149                 }
+150             }
+151         });
+152 
+153         addKeyListener(new KeyListener() {
+154             public void keyTyped(KeyEvent e) {
+155             }
+156 
+157             public void keyReleased(KeyEvent e) {
+158                 if (e.getKeyCode() == KeyEvent.VK_SPACE) {
+159                     doAction(e.isShiftDown());
+160                 }
+161             }
+162 
+163             public void keyPressed(KeyEvent e) {
+164             }
+165         });
+166 
+167         loadIcons();
+168     }
+169 
+170     private void loadIcons() {
+171         icons = new HashMap<BaseTypeId, ImageIcon>();
+172         icons.put(BaseTypeId.CMIS_DOCUMENT, ClientHelper.getIcon("document.png"));
+173         icons.put(BaseTypeId.CMIS_FOLDER, ClientHelper.getIcon("folder.png"));
+174         icons.put(BaseTypeId.CMIS_RELATIONSHIP, ClientHelper.getIcon("relationship.png"));
+175         icons.put(BaseTypeId.CMIS_POLICY, ClientHelper.getIcon("policy.png"));
+176         icons.put(BaseTypeId.CMIS_ITEM, ClientHelper.getIcon("item.png"));
+177 
+178         checkedOutIcon = ClientHelper.getIcon("checkedout.png");
+179         pwcIcon = ClientHelper.getIcon("pwc.png");
+180     }
+181 
+182     public void folderLoaded(final ClientModelEvent event) {
+183         SwingUtilities.invokeLater(new Runnable() {
+184             public void run() {
+185                 event.getClientModel().getCurrentChildren();
+186                 ((FolderTableModel) getModel()).fireTableDataChanged();
+187             }
+188         });
+189     }
+190 
+191     private void doAction(boolean alternate) {
+192         int row = getSelectedRow();
+193         if ((row > -1) && (row < model.getCurrentChildren().size())) {
+194             String id = getModel().getValueAt(getRowSorter().convertRowIndexToModel(row), ID_COLUMN).toString();
+195             CmisObject object = model.getFromCurrentChildren(id);
+196 
+197             if (object instanceof Document) {
+198                 if (alternate) {
+199                     ClientHelper.download(this.getParent(), (Document) object, null);
+200                 } else {
+201                     ClientHelper.open(this.getParent(), (Document) object, null);
+202                 }
+203             } else if (object instanceof Folder) {
+204                 try {
+205                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+206                     model.loadFolder(object.getId(), false);
+207                 } catch (Exception ex) {
+208                     ClientHelper.showError(null, ex);
+209                     return;
+210                 } finally {
+211                     setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+212                 }
+213             }
+214         }
+215     }
+216 
+217     class FolderTableModel extends AbstractTableModel {
+218 
+219         private static final long serialVersionUID = 1L;
+220 
+221         public String getColumnName(int columnIndex) {
+222             return COLUMN_NAMES[columnIndex];
+223         }
+224 
+225         public int getColumnCount() {
+226             return COLUMN_NAMES.length;
+227         }
+228 
+229         public int getRowCount() {
+230             return model.getCurrentChildren().size();
+231         }
+232 
+233         public Object getValueAt(int rowIndex, int columnIndex) {
+234             CmisObject obj = model.getCurrentChildren().get(rowIndex);
+235 
+236             switch (columnIndex) {
+237             case 0:
+238                 if (obj instanceof Document) {
+239                     Document doc = (Document) obj;
+240                     if (Boolean.TRUE.equals(doc.isVersionSeriesCheckedOut())) {
+241                         if (doc.getId().equals(doc.getVersionSeriesCheckedOutId())) {
+242                             return pwcIcon;
+243                         } else {
+244                             return checkedOutIcon;
+245                         }
+246                     } else {
+247                         return icons.get(BaseTypeId.CMIS_DOCUMENT);
+248                     }
+249                 }
+250                 return icons.get(obj.getBaseTypeId());
+251             case 1:
+252                 return obj.getName();
+253             case 2:
+254                 return obj.getType().getId();
+255             case 3:
+256                 if (obj instanceof Document) {
+257                     return ((Document) obj).getContentStreamMimeType();
+258                 } else {
+259                     return null;
+260                 }
+261             case 4:
+262                 if (obj instanceof Document) {
+263                     return ((Document) obj).getContentStreamLength();
+264                 } else {
+265                     return null;
+266                 }
+267             case 5:
+268                 return obj.getCreationDate();
+269             case 6:
+270                 return obj.getCreatedBy();
+271             case 7:
+272                 return obj.getLastModificationDate();
+273             case 8:
+274                 return obj.getLastModifiedBy();
+275             case ID_COLUMN:
+276                 return obj.getId();
+277             default:
+278             }
+279 
+280             return "";
+281         }
+282 
+283         @Override
+284         public Class<?> getColumnClass(int columnIndex) {
+285             switch (columnIndex) {
+286             case 0:
+287                 return ImageIcon.class;
+288             case 4:
+289                 return Long.class;
+290             case 5:
+291             case 7:
+292                 return GregorianCalendar.class;
+293             default:
+294             }
+295 
+296             return String.class;
+297         }
+298     }
+299 
+300     class FolderTransferHandler extends TransferHandler {
+301 
+302         private static final long serialVersionUID = 1L;
+303 
+304         public FolderTransferHandler() {
+305             super();
+306         }
+307 
+308         @Override
+309         public boolean canImport(TransferSupport support) {
+310             if (!support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+311                 return false;
+312             }
+313 
+314             if (!support.isDrop()) {
+315                 return false;
+316             }
+317 
+318             return true;
+319         }
+320 
+321         @SuppressWarnings("unchecked")
+322         @Override
+323         public boolean importData(TransferSupport support) {
+324             if (!canImport(support)) {
+325                 return false;
+326             }
+327 
+328             File file = null;
+329             try {
+330                 List<File> fileList = (List<File>) support.getTransferable().getTransferData(
+331                         DataFlavor.javaFileListFlavor);
+332 
+333                 if ((fileList == null) || (fileList.size() != 1) || (fileList.get(0) == null)
+334                         || !fileList.get(0).isFile()) {
+335                     return false;
+336                 }
+337 
+338                 file = fileList.get(0);
+339             } catch (Exception ex) {
+340                 ClientHelper.showError(null, ex);
+341                 return false;
+342             }
+343 
+344             new CreateDocumentDialog(null, model, file);
+345 
+346             return true;
+347         }
+348 
+349         @Override
+350         public int getSourceActions(JComponent c) {
+351             return COPY;
+352         }
+353 
+354         @Override
+355         protected Transferable createTransferable(JComponent c) {
+356             int row = getSelectedRow();
+357             if ((row > -1) && (row < model.getCurrentChildren().size())) {
+358                 String id = getValueAt(row, ID_COLUMN).toString();
+359                 CmisObject object = model.getFromCurrentChildren(id);
+360 
+361                 if (object instanceof Document) {
+362                     Document doc = (Document) object;
+363 
+364                     File tempFile = null;
+365                     try {
+366                         tempFile = ClientHelper.createTempFileFromDocument(doc, null);
+367                     } catch (Exception e) {
+368                         ClientHelper.showError(null, e);
+369                     }
+370 
+371                     final File tempTransFile = tempFile;
+372 
+373                     return new Transferable() {
+374                         public boolean isDataFlavorSupported(DataFlavor flavor) {
+375                             return flavor == DataFlavor.javaFileListFlavor;
+376                         }
+377 
+378                         public DataFlavor[] getTransferDataFlavors() {
+379                             return new DataFlavor[] { DataFlavor.javaFileListFlavor };
+380                         }
+381 
+382                         public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
+383                             return Collections.singletonList(tempTransFile);
+384                         }
+385                     };
+386                 }
+387             }
+388 
+389             return null;
+390         }
+391     }
+392 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/InfoDialog.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/InfoDialog.html?rev=1671614&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/InfoDialog.html (added) +++ chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/InfoDialog.html Mon Apr 6 17:19:59 2015 @@ -0,0 +1,135 @@ + + + + +InfoDialog xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.workbench;
+20  
+21  import java.awt.Dimension;
+22  import java.awt.FlowLayout;
+23  import java.awt.Font;
+24  import java.awt.Frame;
+25  import java.io.IOException;
+26  import java.io.InputStream;
+27  import java.util.Properties;
+28  import java.util.TreeSet;
+29  
+30  import javax.swing.BorderFactory;
+31  import javax.swing.BoxLayout;
+32  import javax.swing.JDialog;
+33  import javax.swing.JFrame;
+34  import javax.swing.JLabel;
+35  import javax.swing.JPanel;
+36  import javax.swing.JScrollPane;
+37  import javax.swing.JTextArea;
+38  import javax.swing.UIManager;
+39  
+40  import org.apache.chemistry.opencmis.commons.impl.IOUtils;
+41  
+42  public class InfoDialog extends JDialog {
+43  
+44      private static final long serialVersionUID = 1L;
+45  
+46      public InfoDialog(Frame owner) {
+47          super(owner, "Info", true);
+48          createGUI();
+49      }
+50  
+51      private void createGUI() {
+52          setPreferredSize(new Dimension(800, 500));
+53          setMinimumSize(new Dimension(600, 400));
+54  
+55          setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
+56  
+57          JPanel topPanel = new JPanel(new FlowLayout());
+58  
+59          JLabel cmisLogo = new JLabel(ClientHelper.getIcon("icon.png"));
+60          topPanel.add(cmisLogo);
+61  
+62          Font labelFont = UIManager.getFont("Label.font");
+63          Font titleFont = labelFont.deriveFont(Font.BOLD, labelFont.getSize2D() * 2f);
+64  
+65          JLabel titleLabel = new JLabel("CMIS Workbench");
+66          titleLabel.setFont(titleFont);
+67          topPanel.add(titleLabel);
+68  
+69          add(topPanel);
+70  
+71          StringBuilder readme = new StringBuilder();
+72  
+73          readme.append(loadText("/META-INF/README-cmis-workbench.txt", "CMIS Workbench"));
+74          readme.append("\n---------------------------------------------------------\n");
+75  
+76          readme.append("\nCurrent System Properties:\n\n");
+77  
+78          Properties sysProps = System.getProperties();
+79          for (Object key : new TreeSet<Object>(sysProps.keySet())) {
+80              readme.append(key).append(" = ").append(sysProps.get(key)).append('\n');
+81          }
+82  
+83          readme.append("\n---------------------------------------------------------\n");
+84          readme.append(loadText("/META-INF/build-timestamp.txt", ""));
+85  
+86          JTextArea ta = new JTextArea(readme.toString());
+87          ta.setEditable(false);
+88          ta.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
+89          JScrollPane readmePane = new JScrollPane(ta);
+90          readmePane.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
+91  
+92          add(readmePane);
+93  
+94          ClientHelper.installEscapeBinding(this, getRootPane(), false);
+95  
+96          setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+97          pack();
+98          setLocationRelativeTo(null);
+99      }
+100 
+101     public void showDialog() {
+102         setVisible(true);
+103     }
+104 
+105     public void hideDialog() {
+106         setVisible(false);
+107     }
+108 
+109     private String loadText(String file, String defaultText) {
+110         InputStream stream = getClass().getResourceAsStream(file);
+111         if (stream != null) {
+112             try {
+113                 return IOUtils.readAllLines(stream);
+114             } catch (IOException e) {
+115                 return defaultText;
+116             }
+117         }
+118 
+119         return defaultText;
+120     }
+121 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/LogFrame.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/LogFrame.html?rev=1671614&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/LogFrame.html (added) +++ chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/LogFrame.html Mon Apr 6 17:19:59 2015 @@ -0,0 +1,117 @@ + + + + +LogFrame xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.workbench;
+20  
+21  import java.awt.BorderLayout;
+22  import java.awt.Dimension;
+23  import java.awt.FlowLayout;
+24  import java.awt.Font;
+25  import java.awt.event.ActionEvent;
+26  import java.awt.event.ActionListener;
+27  
+28  import javax.swing.JButton;
+29  import javax.swing.JComboBox;
+30  import javax.swing.JFrame;
+31  import javax.swing.JPanel;
+32  import javax.swing.JScrollPane;
+33  import javax.swing.JTextArea;
+34  
+35  import org.apache.log4j.Level;
+36  import org.apache.log4j.Logger;
+37  
+38  public class LogFrame extends JFrame {
+39  
+40      private static final long serialVersionUID = 1L;
+41  
+42      private static final String WINDOW_TITLE = "CMIS Client Logging";
+43  
+44      private JTextArea logTextArea;
+45  
+46      public LogFrame() {
+47          super();
+48          createGUI();
+49      }
+50  
+51      private void createGUI() {
+52          setTitle(WINDOW_TITLE);
+53          setPreferredSize(new Dimension(800, 600));
+54          setMinimumSize(new Dimension(200, 60));
+55  
+56          setLayout(new BorderLayout());
+57  
+58          logTextArea = new JTextArea();
+59          logTextArea.setEditable(false);
+60          logTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
+61          logTextArea.setLineWrap(true);
+62          logTextArea.setWrapStyleWord(true);
+63          add(new JScrollPane(logTextArea), BorderLayout.CENTER);
+64  
+65          JPanel inputPanel = new JPanel(new FlowLayout());
+66          add(inputPanel, BorderLayout.PAGE_END);
+67  
+68          JButton clearButton = new JButton("Clear");
+69          clearButton.addActionListener(new ActionListener() {
+70              public void actionPerformed(ActionEvent e) {
+71                  logTextArea.setText("");
+72              }
+73          });
+74          inputPanel.add(clearButton);
+75  
+76          String[] levels = new String[] { Level.ALL.toString(), Level.TRACE.toString(), Level.DEBUG.toString(),
+77                  Level.INFO.toString(), Level.WARN.toString(), Level.ERROR.toString(), Level.FATAL.toString(),
+78                  Level.OFF.toString() };
+79  
+80          final JComboBox levelBox = new JComboBox(levels);
+81          levelBox.setSelectedItem(Logger.getRootLogger().getLevel().toString());
+82          levelBox.addActionListener(new ActionListener() {
+83              public void actionPerformed(ActionEvent e) {
+84                  Logger.getRootLogger().setLevel(Level.toLevel(levelBox.getSelectedItem().toString()));
+85              }
+86          });
+87          inputPanel.add(levelBox);
+88  
+89          ClientHelper.installEscapeBinding(this, getRootPane(), false);
+90  
+91          setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+92          pack();
+93  
+94          setLocationRelativeTo(null);
+95          setVisible(false);
+96  
+97          ClientWriterAppender.setTextArea(logTextArea);
+98      }
+99  
+100     public void showFrame() {
+101         setVisible(true);
+102     }
+103 }
+
+
+ +