This project has retired. For details please refer to its
Attic page.
AddObjectToFolderPanel xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.workbench.actions;
2021import java.awt.BorderLayout;
22import java.awt.Color;
2324import javax.swing.JCheckBox;
25import javax.swing.JLabel;
26import javax.swing.JPanel;
27import javax.swing.JTextField;
2829import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
30import org.apache.chemistry.opencmis.client.api.ObjectId;
31import org.apache.chemistry.opencmis.commons.enums.Action;
32import org.apache.chemistry.opencmis.workbench.model.ClientModel;
33import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
3435publicclassAddObjectToFolderPanelextendsActionPanel {
3637privatestaticfinallong serialVersionUID = 1L;
3839private JTextField folderField;
40private JCheckBox allVersionsBox;
4142publicAddObjectToFolderPanel(ClientModel model) {
43super("Add Object To Folder", "Add", model);
44 }
4546 @Override
47protectedvoid createActionComponents() {
48 JPanel folderPanel = new JPanel(new BorderLayout());
49 folderPanel.setBackground(Color.WHITE);
5051 folderPanel.add(new JLabel("Folder Id:"), BorderLayout.LINE_START);
5253 folderField = new JTextField(30);
54 folderPanel.add(folderField, BorderLayout.CENTER);
5556 addActionComponent(folderPanel);
5758 allVersionsBox = new JCheckBox("add all versions", true);
59 addActionComponent(allVersionsBox);
60 }
6162 @Override
63publicboolean isAllowed() {
64if (getObject() == null || !(getObject() instanceof FileableCmisObject)) {
65return false;
66 }
6768if ((getObject().getAllowableActions() == null)
69 || (getObject().getAllowableActions().getAllowableActions() == null)) {
70returntrue;
71 }
7273return getObject().getAllowableActions().getAllowableActions().contains(Action.CAN_ADD_OBJECT_TO_FOLDER);
74 }
7576 @Override
77publicboolean doAction() throws Exception {
78 ObjectId folderId = getClientModel().getClientSession().getSession().createObjectId(folderField.getText());
79 ((FileableCmisObject) getObject()).addToFolder(folderId, allVersionsBox.isSelected());
80returntrue;
81 }
82 }