This project has retired. For details please refer to its
Attic page.
DeleteTreePanel 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.util.List;
2223import javax.swing.JCheckBox;
24import javax.swing.JComboBox;
25import javax.swing.JOptionPane;
2627import org.apache.chemistry.opencmis.client.api.Folder;
28import org.apache.chemistry.opencmis.commons.enums.Action;
29import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
30import org.apache.chemistry.opencmis.workbench.model.ClientModel;
31import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
3233publicclassDeleteTreePanelextendsActionPanel {
3435privatestaticfinallong serialVersionUID = 1L;
3637private JCheckBox allVersionsBox;
38private JComboBox unfileObjectsBox;
39private JCheckBox continueOnFailureBox;
4041publicDeleteTreePanel(ClientModel model) {
42super("Delete Tree", "Delete", model);
43 }
4445 @Override
46protectedvoid createActionComponents() {
47 allVersionsBox = new JCheckBox("delete all versions", true);
48 addActionComponent(allVersionsBox);
4950 unfileObjectsBox = new JComboBox(new Object[] { UnfileObject.DELETE, UnfileObject.DELETESINGLEFILED,
51 UnfileObject.UNFILE });
52 unfileObjectsBox.setSelectedIndex(0);
53 addActionComponent(unfileObjectsBox);
5455 continueOnFailureBox = new JCheckBox("continue on failure", true);
56 addActionComponent(allVersionsBox);
57 }
5859 @Override
60publicboolean isAllowed() {
61if ((getObject() == null) || !(getObject() instanceof Folder)) {
62return false;
63 }
6465if ((getObject().getAllowableActions() == null)
66 || (getObject().getAllowableActions().getAllowableActions() == null)) {
67returntrue;
68 }
6970return getObject().getAllowableActions().getAllowableActions().contains(Action.CAN_DELETE_TREE);
71 }
7273 @Override
74publicboolean doAction() throws Exception {
75 List<String> ids = ((Folder) getObject()).deleteTree(allVersionsBox.isSelected(),
76 (UnfileObject) unfileObjectsBox.getSelectedItem(), continueOnFailureBox.isSelected());
7778if (ids != null && !ids.isEmpty()) {
79 StringBuilder sb = new StringBuilder(
80"Delete tree failed! At least the following objects could not be deleted:\n");
8182for (String id : ids) {
83 sb.append('\n');
84 sb.append(id);
85 }
8687 JOptionPane.showMessageDialog(this, sb.toString(), "Delete Tree", JOptionPane.ERROR_MESSAGE);
88 }
89return false;
90 }
91 }