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 9925F92E3 for ; Tue, 28 May 2013 10:27:32 +0000 (UTC) Received: (qmail 25428 invoked by uid 500); 28 May 2013 10:27:31 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 25270 invoked by uid 500); 28 May 2013 10:27:29 -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 25171 invoked by uid 99); 28 May 2013 10:27:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 10:27:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 10:27:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D2CBA2388CBF for ; Tue, 28 May 2013 10:25:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r863441 [24/29] - in /websites/staging/chemistry/trunk/content: ./ java/0.9.0/maven/chemistry-opencmis-workbench/ java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/ java/0.9.0/maven/chemistry-opencmis-workbench/chem... Date: Tue, 28 May 2013 10:25:38 -0000 To: commits@chemistry.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130528102544.D2CBA2388CBF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.html (added) +++ websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/ObjectPanel.html Tue May 28 10:25:36 2013 @@ -0,0 +1,405 @@ + + + + +ObjectPanel 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.details;
+20  
+21  import groovy.ui.Console;
+22  
+23  import java.awt.BorderLayout;
+24  import java.awt.Cursor;
+25  import java.awt.Font;
+26  import java.awt.event.ActionEvent;
+27  import java.awt.event.ActionListener;
+28  import java.io.File;
+29  import java.io.IOException;
+30  import java.io.Writer;
+31  import java.util.ArrayList;
+32  import java.util.Collections;
+33  import java.util.HashMap;
+34  import java.util.HashSet;
+35  import java.util.List;
+36  import java.util.Locale;
+37  import java.util.Map;
+38  import java.util.Set;
+39  
+40  import javax.script.ScriptEngineFactory;
+41  import javax.script.ScriptEngineManager;
+42  import javax.swing.BorderFactory;
+43  import javax.swing.BoxLayout;
+44  import javax.swing.JButton;
+45  import javax.swing.JPanel;
+46  import javax.swing.JTextArea;
+47  import javax.swing.JTextField;
+48  import javax.swing.SwingUtilities;
+49  
+50  import org.apache.chemistry.opencmis.client.api.CmisObject;
+51  import org.apache.chemistry.opencmis.client.api.Document;
+52  import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
+53  import org.apache.chemistry.opencmis.client.api.Folder;
+54  import org.apache.chemistry.opencmis.client.api.SecondaryType;
+55  import org.apache.chemistry.opencmis.client.api.Session;
+56  import org.apache.chemistry.opencmis.client.bindings.spi.LinkAccess;
+57  import org.apache.chemistry.opencmis.tck.CmisTestGroup;
+58  import org.apache.chemistry.opencmis.workbench.ClientHelper;
+59  import org.apache.chemistry.opencmis.workbench.checks.ObjectComplianceTestGroup;
+60  import org.apache.chemistry.opencmis.workbench.checks.SwingReport;
+61  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+62  import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent;
+63  import org.apache.chemistry.opencmis.workbench.model.ObjectListener;
+64  import org.apache.chemistry.opencmis.workbench.swing.InfoPanel;
+65  
+66  public class ObjectPanel extends InfoPanel implements ObjectListener {
+67  
+68      private static final long serialVersionUID = 1L;
+69  
+70      private final Set<String> scriptExtensions;
+71  
+72      private JTextField nameField;
+73      private JTextField idField;
+74      private JTextField typeField;
+75      private JTextField basetypeField;
+76      private InfoList secondaryTypesList;
+77      private JTextField versionLabelField;
+78      private JTextField pwcField;
+79      private JTextField contentUrlField;
+80      private InfoList pathsList;
+81      private InfoList allowableActionsList;
+82      private JPanel buttonPanel;
+83      private JButton refreshButton;
+84      private JButton checkButton;
+85      private JPanel scriptPanel;
+86      private JButton scriptOpenButton;
+87      private JButton scriptRunButton;
+88      private JTextArea scriptOutput;
+89      private JTextAreaWriter scriptOutputWriter;
+90  
+91      public ObjectPanel(ClientModel model) {
+92          super(model);
+93  
+94          model.addObjectListener(this);
+95  
+96          // get all installed script engines
+97          scriptExtensions = new HashSet<String>();
+98          ScriptEngineManager mgr = new ScriptEngineManager();
+99          for (ScriptEngineFactory sef : mgr.getEngineFactories()) {
+100             scriptExtensions.addAll(sef.getExtensions());
+101         }
+102 
+103         createGUI();
+104     }
+105 
+106     public void objectLoaded(ClientModelEvent event) {
+107         CmisObject object = getClientModel().getCurrentObject();
+108 
+109         if (object == null) {
+110             nameField.setText("");
+111             idField.setText("");
+112             typeField.setText("");
+113             basetypeField.setText("");
+114             secondaryTypesList.removeAll();
+115             versionLabelField.setText("");
+116             pwcField.setText("");
+117             pathsList.removeAll();
+118             contentUrlField.setText("");
+119             allowableActionsList.removeAll();
+120             refreshButton.setEnabled(false);
+121             checkButton.setEnabled(false);
+122             scriptPanel.setVisible(false);
+123         } else {
+124             try {
+125                 nameField.setText(object.getName());
+126                 idField.setText(object.getId());
+127                 typeField.setText(object.getType().getId());
+128                 basetypeField.setText(object.getBaseTypeId().toString());
+129 
+130                 if (object.getSecondaryTypes() != null) {
+131                     List<String> secTypeIds = new ArrayList<String>();
+132                     for (SecondaryType type : object.getSecondaryTypes()) {
+133                         secTypeIds.add(type.getId());
+134                     }
+135                     secondaryTypesList.setList(secTypeIds);
+136                 } else {
+137                     secondaryTypesList.removeAll();
+138                 }
+139 
+140                 if (object instanceof Document) {
+141                     Document doc = (Document) object;
+142 
+143                     try {
+144                         versionLabelField.setText(doc.getVersionLabel());
+145                     } catch (Exception e) {
+146                         versionLabelField.setText("???");
+147                     }
+148 
+149                     if (doc.isVersionSeriesCheckedOut() == null) {
+150                         pwcField.setText("");
+151                     } else if (doc.isVersionSeriesCheckedOut().booleanValue()) {
+152                         pwcField.setText(doc.getVersionSeriesCheckedOutId());
+153                     } else {
+154                         pwcField.setText("(not checked out)");
+155                     }
+156                 } else {
+157                     pwcField.setText("");
+158                     versionLabelField.setText("");
+159                 }
+160 
+161                 if (object instanceof FileableCmisObject) {
+162                     if (object instanceof Folder) {
+163                         pathsList.setList(Collections.singletonList(((Folder) object).getPath()));
+164                     } else {
+165                         pathsList.setList(Collections.singletonList(""));
+166                         final FileableCmisObject pathObject = (FileableCmisObject) object;
+167                         SwingUtilities.invokeLater(new Runnable() {
+168                             @Override
+169                             public void run() {
+170                                 try {
+171                                     List<String> paths = pathObject.getPaths();
+172                                     if ((paths == null) || (paths.size() == 0)) {
+173                                         pathsList.setList(Collections.singletonList("(unfiled)"));
+174                                     } else {
+175                                         pathsList.setList(paths);
+176                                     }
+177                                 } catch (Exception e) {
+178                                     pathsList.setList(Collections.singletonList("(???)"));
+179                                     // ClientHelper.showError(null, e);
+180                                 }
+181                                 ObjectPanel.this.revalidate();
+182                             }
+183                         });
+184                     }
+185                 } else {
+186                     pathsList.setList(Collections.singletonList("(not filable)"));
+187                 }
+188 
+189                 String docUrl = getDocumentURL(object, getClientModel().getClientSession().getSession());
+190                 if (docUrl != null) {
+191                     contentUrlField.setText(docUrl);
+192                 } else {
+193                     contentUrlField.setText("(not available)");
+194                 }
+195 
+196                 if (object.getAllowableActions() != null) {
+197                     allowableActionsList.setList(object.getAllowableActions().getAllowableActions());
+198                 } else {
+199                     allowableActionsList.setList(Collections.singletonList("(missing)"));
+200                 }
+201 
+202                 refreshButton.setEnabled(true);
+203                 checkButton.setEnabled(true);
+204 
+205                 if (object instanceof Document) {
+206                     String name = object.getName().toLowerCase(Locale.ENGLISH);
+207                     int x = name.lastIndexOf('.');
+208                     if ((x > -1) && (scriptExtensions.contains(name.substring(x + 1)))) {
+209                         scriptPanel.setVisible(true);
+210                         scriptOutput.setVisible(false);
+211                     } else {
+212                         scriptPanel.setVisible(false);
+213                     }
+214                 }
+215             } catch (Exception e) {
+216                 ClientHelper.showError(this, e);
+217             }
+218         }
+219 
+220         revalidate();
+221     }
+222 
+223     private void createGUI() {
+224         setupGUI();
+225 
+226         nameField = addLine("Name:", true);
+227         idField = addId("Id:");
+228         typeField = addLine("Type:");
+229         basetypeField = addLine("Base Type:");
+230         secondaryTypesList = addComponent("Secondary Types:", new InfoList());
+231         pathsList = addComponent("Paths:", new InfoList());
+232         versionLabelField = addLine("Version Label:");
+233         pwcField = addId("PWC:");
+234         contentUrlField = addLink("Content URL:");
+235         allowableActionsList = addComponent("Allowable Actions:", new InfoList());
+236 
+237         buttonPanel = addComponent("", new JPanel(new BorderLayout()));
+238         buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
+239         buttonPanel.setOpaque(false);
+240 
+241         refreshButton = new JButton("Refresh");
+242         refreshButton.setEnabled(false);
+243         buttonPanel.add(refreshButton);
+244         checkButton = new JButton("Check specification compliance");
+245         checkButton.setEnabled(false);
+246         buttonPanel.add(checkButton);
+247 
+248         scriptPanel = addComponent("", new JPanel(new BorderLayout()));
+249         scriptPanel.setOpaque(false);
+250         scriptPanel.setVisible(false);
+251 
+252         JPanel scriptButtonPanel = new JPanel();
+253         scriptButtonPanel.setLayout(new BoxLayout(scriptButtonPanel, BoxLayout.LINE_AXIS));
+254         scriptButtonPanel.setOpaque(false);
+255         scriptPanel.add(scriptButtonPanel, BorderLayout.PAGE_START);
+256         scriptOpenButton = new JButton("Open Script");
+257         scriptButtonPanel.add(scriptOpenButton);
+258         scriptRunButton = new JButton("Run Script");
+259         scriptButtonPanel.add(scriptRunButton);
+260 
+261         scriptOutput = new JTextArea(null, 1, 80);
+262         scriptOutput.setEditable(false);
+263         scriptOutput.setFont(Font.decode("Monospaced"));
+264         scriptOutput.setBorder(BorderFactory.createTitledBorder(""));
+265         scriptOutputWriter = new JTextAreaWriter(scriptOutput);
+266         scriptPanel.add(scriptOutput, BorderLayout.CENTER);
+267 
+268         refreshButton.addActionListener(new ActionListener() {
+269             public void actionPerformed(ActionEvent e) {
+270                 try {
+271                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+272                     getClientModel().reloadObject();
+273                 } catch (Exception ex) {
+274                     ClientHelper.showError(null, ex);
+275                 } finally {
+276                     setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+277                 }
+278             }
+279         });
+280 
+281         checkButton.addActionListener(new ActionListener() {
+282             public void actionPerformed(ActionEvent e) {
+283                 try {
+284                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+285 
+286                     Map<String, String> parameters = new HashMap<String, String>(getClientModel().getClientSession()
+287                             .getSessionParameters());
+288                     String objectId = getClientModel().getCurrentObject().getId();
+289 
+290                     ObjectComplianceTestGroup octg = new ObjectComplianceTestGroup(parameters, objectId);
+291                     octg.run();
+292 
+293                     List<CmisTestGroup> groups = new ArrayList<CmisTestGroup>();
+294                     groups.add(octg);
+295                     SwingReport report = new SwingReport(null, 700, 500);
+296                     report.createReport(parameters, groups, (Writer) null);
+297                 } catch (Exception ex) {
+298                     ClientHelper.showError(null, ex);
+299                 } finally {
+300                     setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+301                 }
+302             }
+303         });
+304 
+305         scriptOpenButton.addActionListener(new ActionListener() {
+306             public void actionPerformed(ActionEvent e) {
+307                 try {
+308                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+309                     Document doc = (Document) getClientModel().getCurrentObject();
+310 
+311                     String name = doc.getName().toLowerCase(Locale.ENGLISH);
+312                     if (name.endsWith(".groovy")) {
+313                         File file = ClientHelper.createTempFileFromDocument(doc, null);
+314                         Console console = ClientHelper.openConsole(ObjectPanel.this, getClientModel(), null);
+315                         if (console != null) {
+316                             console.loadScriptFile(file);
+317                         }
+318                     } else {
+319                         ClientHelper.open(ObjectPanel.this, doc, null);
+320                     }
+321                 } catch (Exception ex) {
+322                     ClientHelper.showError(null, ex);
+323                 } finally {
+324                     setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+325                 }
+326             }
+327         });
+328 
+329         scriptRunButton.addActionListener(new ActionListener() {
+330             public void actionPerformed(ActionEvent e) {
+331                 try {
+332                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+333                     Document doc = (Document) getClientModel().getCurrentObject();
+334                     File file = ClientHelper.createTempFileFromDocument(doc, null);
+335                     String name = doc.getName().toLowerCase(Locale.ENGLISH);
+336                     String ext = name.substring(name.lastIndexOf('.') + 1);
+337 
+338                     scriptOutput.setText("");
+339                     scriptOutput.setVisible(true);
+340                     scriptOutput.invalidate();
+341 
+342                     ClientHelper.runJSR223Script(ObjectPanel.this, getClientModel(), file, ext, scriptOutputWriter);
+343                 } catch (Exception ex) {
+344                     ClientHelper.showError(null, ex);
+345                 } finally {
+346                     setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+347                 }
+348             }
+349         });
+350 
+351     }
+352 
+353     public String getDocumentURL(final CmisObject document, final Session session) {
+354         if (!(document instanceof Document)) {
+355             return null;
+356         }
+357 
+358         if (session.getBinding().getObjectService() instanceof LinkAccess) {
+359             return ((LinkAccess) session.getBinding().getObjectService()).loadContentLink(session.getRepositoryInfo()
+360                     .getId(), document.getId());
+361         }
+362 
+363         return null;
+364     }
+365 
+366     private static class JTextAreaWriter extends Writer {
+367         private final JTextArea textArea;
+368 
+369         public JTextAreaWriter(JTextArea textArea) {
+370             this.textArea = textArea;
+371         }
+372 
+373         @Override
+374         public void write(final char[] cbuf, final int off, final int len) throws IOException {
+375             final String s = new String(cbuf, off, len);
+376             SwingUtilities.invokeLater(new Runnable() {
+377                 public void run() {
+378                     textArea.append(s);
+379                 }
+380             });
+381         }
+382 
+383         @Override
+384         public void flush() throws IOException {
+385         }
+386 
+387         @Override
+388         public void close() throws IOException {
+389         }
+390     }
+391 }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/PolicyTable.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/PolicyTable.html (added) +++ websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/PolicyTable.html Tue May 28 10:25:36 2013 @@ -0,0 +1,98 @@ + + + + +PolicyTable 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.details;
+20  
+21  import java.awt.event.MouseEvent;
+22  
+23  import org.apache.chemistry.opencmis.client.api.ObjectId;
+24  import org.apache.chemistry.opencmis.client.api.Policy;
+25  import org.apache.chemistry.opencmis.workbench.ClientHelper;
+26  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+27  
+28  public class PolicyTable extends AbstractDetailsTable {
+29  
+30      private static final long serialVersionUID = 1L;
+31  
+32      private static final String[] COLUMN_NAMES = { "Name", "Id" };
+33      private static final int[] COLUMN_WIDTHS = { 200, 400 };
+34  
+35      public PolicyTable(ClientModel model) {
+36          super();
+37          init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+38      }
+39  
+40      @Override
+41      public void singleClickAction(MouseEvent e, int rowIndex, int colIndex) {
+42          if (getColumnClass(colIndex) != ObjectId.class) {
+43              return;
+44          }
+45  
+46          try {
+47              getClientModel().loadObject(
+48                      getObject().getPolicies().get(getRowSorter().convertRowIndexToModel(rowIndex)).getId());
+49              setTab(0);
+50          } catch (Exception ex) {
+51              ClientHelper.showError(this, ex);
+52          }
+53      }
+54  
+55      public int getDetailRowCount() {
+56          if (getObject().getPolicies() == null) {
+57              return 0;
+58          }
+59  
+60          return getObject().getPolicies().size();
+61      }
+62  
+63      public Object getDetailValueAt(int rowIndex, int columnIndex) {
+64          Policy policy = getObject().getPolicies().get(rowIndex);
+65  
+66          switch (columnIndex) {
+67          case 0:
+68              return policy.getName();
+69          case 1:
+70              return policy;
+71          }
+72  
+73          return null;
+74      }
+75  
+76      @Override
+77      public Class<?> getDetailColumClass(int columnIndex) {
+78          if (columnIndex == 1) {
+79              return ObjectId.class;
+80          }
+81  
+82          return super.getDetailColumClass(columnIndex);
+83      }
+84  }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/PropertyTable.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/PropertyTable.html (added) +++ websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/PropertyTable.html Tue May 28 10:25:36 2013 @@ -0,0 +1,95 @@ + + + + +PropertyTable 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.details;
+20  
+21  import java.awt.event.MouseEvent;
+22  import java.util.Collection;
+23  
+24  import org.apache.chemistry.opencmis.client.api.Property;
+25  import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+26  import org.apache.chemistry.opencmis.commons.enums.Action;
+27  import org.apache.chemistry.opencmis.workbench.PropertyEditorFrame;
+28  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+29  
+30  public class PropertyTable extends AbstractDetailsTable {
+31  
+32      private static final long serialVersionUID = 1L;
+33  
+34      private static final String[] COLUMN_NAMES = { "Name", "Id", "Type", "Value" };
+35      private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 300 };
+36  
+37      public PropertyTable(ClientModel model) {
+38          super();
+39          init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+40      }
+41  
+42      @Override
+43      public void doubleClickAction(MouseEvent e, int rowIndex) {
+44          AllowableActions aa = getObject().getAllowableActions();
+45  
+46          if ((aa == null) || (aa.getAllowableActions() == null)
+47                  || aa.getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES)) {
+48              new PropertyEditorFrame(getClientModel(), getObject());
+49          }
+50      }
+51  
+52      public int getDetailRowCount() {
+53          return getObject().getProperties().size();
+54      }
+55  
+56      public Object getDetailValueAt(int rowIndex, int columnIndex) {
+57          Property<?> property = getObject().getProperties().get(rowIndex);
+58  
+59          switch (columnIndex) {
+60          case 0:
+61              return property.getDefinition().getDisplayName();
+62          case 1:
+63              return property.getId();
+64          case 2:
+65              return property.getDefinition().getPropertyType().value();
+66          case 3:
+67              return property.getValues();
+68          }
+69  
+70          return null;
+71      }
+72  
+73      @Override
+74      public Class<?> getDetailColumClass(int columnIndex) {
+75          if (columnIndex == 3) {
+76              return Collection.class;
+77          }
+78  
+79          return super.getDetailColumClass(columnIndex);
+80      }
+81  }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/RelationshipTable.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/RelationshipTable.html (added) +++ websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-workbench/chemistry-opencmis-workbench/xref/org/apache/chemistry/opencmis/workbench/details/RelationshipTable.html Tue May 28 10:25:36 2013 @@ -0,0 +1,110 @@ + + + + +RelationshipTable 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.details;
+20  
+21  import java.awt.event.MouseEvent;
+22  
+23  import org.apache.chemistry.opencmis.client.api.ObjectId;
+24  import org.apache.chemistry.opencmis.client.api.Relationship;
+25  import org.apache.chemistry.opencmis.workbench.ClientHelper;
+26  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+27  
+28  public class RelationshipTable extends AbstractDetailsTable {
+29  
+30      private static final long serialVersionUID = 1L;
+31  
+32      private static final String[] COLUMN_NAMES = { "Name", "Type", "Relationship Id", "Source", "Target" };
+33      private static final int[] COLUMN_WIDTHS = { 200, 200, 200, 200, 200 };
+34  
+35      public RelationshipTable(ClientModel model) {
+36          super();
+37          init(model, COLUMN_NAMES, COLUMN_WIDTHS);
+38      }
+39  
+40      @Override
+41      public void singleClickAction(MouseEvent e, int rowIndex, int colIndex) {
+42          if (getColumnClass(colIndex) != ObjectId.class) {
+43              return;
+44          }
+45  
+46          ObjectId id = (ObjectId) getValueAt(rowIndex, colIndex);
+47          if ((id == null) || (id.getId() == null)) {
+48              return;
+49          }
+50  
+51          try {
+52              getClientModel().loadObject(id.getId());
+53              setTab(0);
+54          } catch (Exception ex) {
+55              ClientHelper.showError(this, ex);
+56          }
+57      }
+58  
+59      @Override
+60      public int getDetailRowCount() {
+61          if (getObject().getRelationships() == null) {
+62              return 0;
+63          }
+64  
+65          return getObject().getRelationships().size();
+66      }
+67  
+68      @Override
+69      public Object getDetailValueAt(int rowIndex, int columnIndex) {
+70          Relationship relationship = getObject().getRelationships().get(rowIndex);
+71  
+72          switch (columnIndex) {
+73          case 0:
+74              return relationship.getName();
+75          case 1:
+76              return relationship.getType().getId();
+77          case 2:
+78              return relationship;
+79          case 3:
+80              return relationship.getSourceId();
+81          case 4:
+82              return relationship.getTarget();
+83          }
+84  
+85          return null;
+86      }
+87  
+88      @Override
+89      public Class<?> getDetailColumClass(int columnIndex) {
+90          if ((columnIndex == 2) || (columnIndex == 3) || (columnIndex == 4)) {
+91              return ObjectId.class;
+92          }
+93  
+94          return super.getDetailColumClass(columnIndex);
+95      }
+96  }
+
+
+ +