This project has retired. For details please refer to its
Attic page.
MovePanel 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.JLabel;
25import javax.swing.JPanel;
26import javax.swing.JTextField;
2728import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
29import org.apache.chemistry.opencmis.client.api.ObjectId;
30import org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl;
31import org.apache.chemistry.opencmis.commons.enums.Action;
32import org.apache.chemistry.opencmis.workbench.model.ClientModel;
33import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
3435publicclassMovePanelextendsActionPanel {
3637privatestaticfinallong serialVersionUID = 1L;
3839private JTextField targetFolderField;
4041publicMovePanel(ClientModel model) {
42super("Move Object", "Move", model);
43 }
4445 @Override
46protectedvoid createActionComponents() {
47 JPanel targetFolderPanel = new JPanel(new BorderLayout());
48 targetFolderPanel.setBackground(Color.WHITE);
4950 targetFolderPanel.add(new JLabel("Target Folder Id:"), BorderLayout.LINE_START);
5152 targetFolderField = new JTextField(30);
53 targetFolderPanel.add(targetFolderField, BorderLayout.CENTER);
5455 addActionComponent(targetFolderPanel);
56 }
5758 @Override
59publicboolean isAllowed() {
60if ((getObject() == null) || !(getObject() instanceof FileableCmisObject)) {
61return false;
62 }
6364if ((getObject().getAllowableActions() == null)
65 || (getObject().getAllowableActions().getAllowableActions() == null)) {
66returntrue;
67 }
6869return getObject().getAllowableActions().getAllowableActions().contains(Action.CAN_MOVE_OBJECT);
70 }
7172 @Override
73publicboolean doAction() throws Exception {
74 ObjectId targetFolderId = new ObjectIdImpl(targetFolderField.getText());
75 ((FileableCmisObject) getObject()).move(getClientModel().getCurrentFolder(), targetFolderId);
76returntrue;
77 }
78 }