This project has retired. For details please refer to its Attic page.
ActionsPanel 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 javax.swing.BorderFactory;
22  import javax.swing.BoxLayout;
23  import javax.swing.JPanel;
24  
25  import org.apache.chemistry.opencmis.client.api.CmisObject;
26  import org.apache.chemistry.opencmis.workbench.actions.AclUpdatePanel;
27  import org.apache.chemistry.opencmis.workbench.actions.AddObjectToFolderPanel;
28  import org.apache.chemistry.opencmis.workbench.actions.ApplyPolicyPanel;
29  import org.apache.chemistry.opencmis.workbench.actions.CancelCheckOutPanel;
30  import org.apache.chemistry.opencmis.workbench.actions.CheckInPanel;
31  import org.apache.chemistry.opencmis.workbench.actions.CheckOutPanel;
32  import org.apache.chemistry.opencmis.workbench.actions.DeleteContentStreamPanel;
33  import org.apache.chemistry.opencmis.workbench.actions.DeletePanel;
34  import org.apache.chemistry.opencmis.workbench.actions.DeleteTreePanel;
35  import org.apache.chemistry.opencmis.workbench.actions.MovePanel;
36  import org.apache.chemistry.opencmis.workbench.actions.PropertyUpdatePanel;
37  import org.apache.chemistry.opencmis.workbench.actions.RemoveObjectFromFolderPanel;
38  import org.apache.chemistry.opencmis.workbench.actions.RemovePolicyPanel;
39  import org.apache.chemistry.opencmis.workbench.actions.SetContentStreamPanel;
40  import org.apache.chemistry.opencmis.workbench.model.ClientModel;
41  import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent;
42  import org.apache.chemistry.opencmis.workbench.model.ObjectListener;
43  
44  public class ActionsPanel extends JPanel implements ObjectListener {
45  
46      private static final long serialVersionUID = 1L;
47  
48      private final ClientModel model;
49  
50      private PropertyUpdatePanel propertyUpdatePanel;
51      private DeletePanel deletePanel;
52      private DeleteTreePanel deleteTreePanel;
53      private MovePanel movePanel;
54      private CheckOutPanel checkOutPanel;
55      private CancelCheckOutPanel cancelCheckOutPanel;
56      private CheckInPanel checkInPanel;
57      private SetContentStreamPanel setContentStreamPanel;
58      private DeleteContentStreamPanel deleteContentStreamPanel;
59      private AddObjectToFolderPanel addObjectToFolderPanel;
60      private RemoveObjectFromFolderPanel removeObjectFromFolderPanel;
61      private AclUpdatePanel aclUpdatePanel;
62      private ApplyPolicyPanel applyPolicyPanel;
63      private RemovePolicyPanel removePolicyPanel;
64  
65      public ActionsPanel(ClientModel model) {
66          super();
67  
68          this.model = model;
69          model.addObjectListener(this);
70  
71          createGUI();
72      }
73  
74      public void objectLoaded(ClientModelEvent event) {
75          CmisObject object = model.getCurrentObject();
76  
77          propertyUpdatePanel.setObject(object);
78          propertyUpdatePanel.setVisible(propertyUpdatePanel.isAllowed());
79  
80          deletePanel.setObject(object);
81          deletePanel.setVisible(deletePanel.isAllowed());
82  
83          deleteTreePanel.setObject(object);
84          deleteTreePanel.setVisible(deleteTreePanel.isAllowed());
85  
86          movePanel.setObject(object);
87          movePanel.setVisible(movePanel.isAllowed());
88  
89          checkOutPanel.setObject(object);
90          checkOutPanel.setVisible(checkOutPanel.isAllowed());
91  
92          cancelCheckOutPanel.setObject(object);
93          cancelCheckOutPanel.setVisible(cancelCheckOutPanel.isAllowed());
94  
95          checkInPanel.setObject(object);
96          checkInPanel.setVisible(checkInPanel.isAllowed());
97  
98          setContentStreamPanel.setObject(object);
99          setContentStreamPanel.setVisible(setContentStreamPanel.isAllowed());
100 
101         deleteContentStreamPanel.setObject(object);
102         deleteContentStreamPanel.setVisible(deleteContentStreamPanel.isAllowed());
103 
104         addObjectToFolderPanel.setObject(object);
105         addObjectToFolderPanel.setVisible(addObjectToFolderPanel.isAllowed());
106 
107         removeObjectFromFolderPanel.setObject(object);
108         removeObjectFromFolderPanel.setVisible(removeObjectFromFolderPanel.isAllowed());
109 
110         aclUpdatePanel.setObject(object);
111         aclUpdatePanel.setVisible(aclUpdatePanel.isAllowed());
112 
113         applyPolicyPanel.setObject(object);
114         applyPolicyPanel.setVisible(applyPolicyPanel.isAllowed());
115 
116         removePolicyPanel.setObject(object);
117         removePolicyPanel.setVisible(removePolicyPanel.isAllowed());
118     }
119 
120     private void createGUI() {
121         setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
122         setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
123 
124         propertyUpdatePanel = new PropertyUpdatePanel(model);
125         add(propertyUpdatePanel);
126 
127         deletePanel = new DeletePanel(model);
128         add(deletePanel);
129 
130         deleteTreePanel = new DeleteTreePanel(model);
131         add(deleteTreePanel);
132 
133         movePanel = new MovePanel(model);
134         add(movePanel);
135 
136         checkOutPanel = new CheckOutPanel(model);
137         add(checkOutPanel);
138 
139         cancelCheckOutPanel = new CancelCheckOutPanel(model);
140         add(cancelCheckOutPanel);
141 
142         checkInPanel = new CheckInPanel(model);
143         add(checkInPanel);
144 
145         setContentStreamPanel = new SetContentStreamPanel(model);
146         add(setContentStreamPanel);
147 
148         deleteContentStreamPanel = new DeleteContentStreamPanel(model);
149         add(deleteContentStreamPanel);
150 
151         addObjectToFolderPanel = new AddObjectToFolderPanel(model);
152         add(addObjectToFolderPanel);
153 
154         removeObjectFromFolderPanel = new RemoveObjectFromFolderPanel(model);
155         add(removeObjectFromFolderPanel);
156 
157         applyPolicyPanel = new ApplyPolicyPanel(model);
158         add(applyPolicyPanel);
159 
160         aclUpdatePanel = new AclUpdatePanel(model);
161         add(aclUpdatePanel);
162 
163         removePolicyPanel = new RemovePolicyPanel(model);
164         add(removePolicyPanel);
165     }
166 }