This project has retired. For details please refer to its Attic page.
ACLTable 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.commons.data.Ace;
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.AclEditorFrame;
29  import org.apache.chemistry.opencmis.workbench.ClientHelper;
30  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
31  
32  public class ACLTable extends AbstractDetailsTable {
33  
34      private static final long serialVersionUID = 1L;
35  
36      private static final String[] COLUMN_NAMES = { "Principal", "Permissions", "Direct" };
37      private static final int[] COLUMN_WIDTHS = { 200, 400, 50 };
38  
39      public ACLTable(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_APPLY_ACL)) {
50              new AclEditorFrame(getClientModel(), getObject());
51  
52              try {
53                  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
54                  getClientModel().reloadObject();
55                  getClientModel().reloadFolder();
56              } catch (Exception ex) {
57                  ClientHelper.showError(null, ex);
58              } finally {
59                  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
60              }
61          }
62      }
63  
64      public int getDetailRowCount() {
65          if ((getObject().getAcl() == null) || (getObject().getAcl().getAces() == null)) {
66              return 0;
67          }
68  
69          return getObject().getAcl().getAces().size();
70      }
71  
72      public Object getDetailValueAt(int rowIndex, int columnIndex) {
73          Ace ace = getObject().getAcl().getAces().get(rowIndex);
74  
75          switch (columnIndex) {
76          case 0:
77              return ace.getPrincipalId();
78          case 1:
79              return ace.getPermissions();
80          case 2:
81              return ace.isDirect();
82          }
83  
84          return null;
85      }
86  
87      @Override
88      public Class<?> getDetailColumClass(int columnIndex) {
89          if (columnIndex == 1) {
90              return Collection.class;
91          } else if (columnIndex == 2) {
92              return Boolean.class;
93          }
94  
95          return super.getDetailColumClass(columnIndex);
96      }
97  }