This project has retired. For details please refer to its Attic page.
RenditionTable 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.Rendition;
24  import org.apache.chemistry.opencmis.workbench.ClientHelper;
25  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
26  
27  public class RenditionTable extends AbstractDetailsTable {
28  
29      private static final long serialVersionUID = 1L;
30  
31      private static final String[] COLUMN_NAMES = { "Title", "Kind", "MIME Type", "Size", "Stream Id" };
32      private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 80, 200 };
33  
34      public RenditionTable(ClientModel model) {
35          super();
36          init(model, COLUMN_NAMES, COLUMN_WIDTHS);
37      }
38  
39      @Override
40      public void doubleClickAction(MouseEvent e, int rowIndex) {
41          String streamId = getObject().getRenditions().get(getRowSorter().convertRowIndexToModel(rowIndex)).getStreamId();
42  
43          if (e.isShiftDown()) {
44              ClientHelper.download(this.getParent(), getObject(), streamId);
45          } else {
46              ClientHelper.open(this.getParent(), getObject(), streamId);
47          }
48      }
49  
50      @Override
51      public int getDetailRowCount() {
52          if (getObject().getRenditions() == null) {
53              return 0;
54          }
55  
56          return getObject().getRenditions().size();
57      }
58  
59      @Override
60      public Object getDetailValueAt(int rowIndex, int columnIndex) {
61          Rendition rendition = getObject().getRenditions().get(rowIndex);
62  
63          switch (columnIndex) {
64          case 0:
65              return rendition.getTitle();
66          case 1:
67              return rendition.getKind();
68          case 2:
69              return rendition.getMimeType();
70          case 3:
71              return rendition.getLength();
72          case 4:
73              return rendition.getStreamId();
74          }
75  
76          return null;
77      }
78  }