This project has retired. For details please refer to its Attic page.
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.Cursor;
22  import java.awt.event.MouseEvent;
23  import java.util.Collection;
24  
25  import org.apache.chemistry.opencmis.client.api.Property;
26  import org.apache.chemistry.opencmis.commons.data.AllowableActions;
27  import org.apache.chemistry.opencmis.commons.enums.Action;
28  import org.apache.chemistry.opencmis.workbench.ClientHelper;
29  import org.apache.chemistry.opencmis.workbench.PropertyEditorFrame;
30  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
31  
32  public class PropertyTable extends AbstractDetailsTable {
33  
34      private static final long serialVersionUID = 1L;
35  
36      private static final String[] COLUMN_NAMES = { "Name", "Id", "Type", "Value" };
37      private static final int[] COLUMN_WIDTHS = { 200, 200, 80, 300 };
38  
39      public PropertyTable(ClientModel model) {
40          super();
41          init(model, COLUMN_NAMES, COLUMN_WIDTHS);
42      }
43  
44      @Override
45      public void doubleClickAction(MouseEvent e, int rowIndex) {
46          AllowableActions aa = getObject().getAllowableActions();
47  
48          if ((aa == null) || (aa.getAllowableActions() == null)
49                  || aa.getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES)) {
50              new PropertyEditorFrame(getClientModel(), getObject());
51          }
52      }
53  
54      public int getDetailRowCount() {
55          return getObject().getProperties().size();
56      }
57  
58      public Object getDetailValueAt(int rowIndex, int columnIndex) {
59          Property<?> property = getObject().getProperties().get(rowIndex);
60  
61          switch (columnIndex) {
62          case 0:
63              return property.getDefinition().getDisplayName();
64          case 1:
65              return property.getId();
66          case 2:
67              return property.getDefinition().getPropertyType().value();
68          case 3:
69              return property.getValues();
70          }
71  
72          return null;
73      }
74  
75      @Override
76      public Class<?> getDetailColumClass(int columnIndex) {
77          if (columnIndex == 3) {
78              return Collection.class;
79          }
80  
81          return super.getDetailColumClass(columnIndex);
82      }
83  }