This project has retired. For details please refer to its
Attic page.
RemovePolicyPanel 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.runtime.ObjectIdImpl;
29import org.apache.chemistry.opencmis.commons.enums.Action;
30import org.apache.chemistry.opencmis.workbench.model.ClientModel;
31import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
3233publicclassRemovePolicyPanelextendsActionPanel {
3435privatestaticfinallong serialVersionUID = 1L;
3637private JTextField policyField;
3839publicRemovePolicyPanel(ClientModel model) {
40super("Remove Policy", "Remove Policy", model);
41 }
4243 @Override
44protectedvoid createActionComponents() {
45 JPanel policyIdPanel = new JPanel(new BorderLayout());
46 policyIdPanel.setBackground(Color.WHITE);
4748 policyIdPanel.add(new JLabel("Policy Id:"), BorderLayout.LINE_START);
4950 policyField = new JTextField(30);
51 policyIdPanel.add(policyField, BorderLayout.CENTER);
5253 addActionComponent(policyIdPanel);
54 }
5556 @Override
57publicboolean isAllowed() {
58if (getObject() == null) {
59return false;
60 }
6162if ((getObject().getAllowableActions() == null)
63 || (getObject().getAllowableActions().getAllowableActions() == null)) {
64returntrue;
65 }
6667return getObject().getAllowableActions().getAllowableActions().contains(Action.CAN_REMOVE_POLICY);
68 }
6970 @Override
71publicboolean doAction() throws Exception {
72 getObject().removePolicy(new ObjectIdImpl(policyField.getText()));
73returntrue;
74 }
75 }