You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2011/05/09 21:14:28 UTC

svn commit: r1101154 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: actions/ApplyPolicyPanel.java actions/RemovePolicyPanel.java details/ActionsPanel.java

Author: fmui
Date: Mon May  9 19:14:28 2011
New Revision: 1101154

URL: http://svn.apache.org/viewvc?rev=1101154&view=rev
Log:
Workbench: added apply and remove policy action panels

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java   (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java?rev=1101154&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java Mon May  9 19:14:28 2011
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.workbench.actions;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl;
+import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
+
+public class ApplyPolicyPanel extends ActionPanel {
+
+    private static final long serialVersionUID = 1L;
+
+    private JTextField policyField;
+
+    public ApplyPolicyPanel(ClientModel model) {
+        super("Apply Policy", "Apply Policy", model);
+    }
+
+    @Override
+    protected void createActionComponents() {
+        JPanel policyIdPanel = new JPanel(new BorderLayout());
+        policyIdPanel.setBackground(Color.WHITE);
+
+        policyIdPanel.add(new JLabel("Policy Id:"), BorderLayout.LINE_START);
+
+        policyField = new JTextField(30);
+        policyIdPanel.add(policyField, BorderLayout.CENTER);
+
+        addActionComponent(policyIdPanel);
+    }
+
+    @Override
+    public boolean isAllowed() {
+        if (getObject() == null) {
+            return false;
+        }
+
+        if ((getObject().getAllowableActions() == null)
+                || (getObject().getAllowableActions().getAllowableActions() == null)) {
+            return true;
+        }
+
+        return getObject().getAllowableActions().getAllowableActions().contains(Action.CAN_APPLY_POLICY);
+    }
+
+    @Override
+    public void doAction() throws Exception {
+        getObject().applyPolicy(new ObjectIdImpl(policyField.getText()));
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/ApplyPolicyPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java?rev=1101154&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java Mon May  9 19:14:28 2011
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.workbench.actions;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl;
+import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.workbench.model.ClientModel;
+import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
+
+public class RemovePolicyPanel extends ActionPanel {
+
+    private static final long serialVersionUID = 1L;
+
+    private JTextField policyField;
+
+    public RemovePolicyPanel(ClientModel model) {
+        super("Remove Policy", "Remove Policy", model);
+    }
+
+    @Override
+    protected void createActionComponents() {
+        JPanel policyIdPanel = new JPanel(new BorderLayout());
+        policyIdPanel.setBackground(Color.WHITE);
+
+        policyIdPanel.add(new JLabel("Policy Id:"), BorderLayout.LINE_START);
+
+        policyField = new JTextField(30);
+        policyIdPanel.add(policyField, BorderLayout.CENTER);
+
+        addActionComponent(policyIdPanel);
+    }
+
+    @Override
+    public boolean isAllowed() {
+        if (getObject() == null) {
+            return false;
+        }
+
+        if ((getObject().getAllowableActions() == null)
+                || (getObject().getAllowableActions().getAllowableActions() == null)) {
+            return true;
+        }
+
+        return getObject().getAllowableActions().getAllowableActions().contains(Action.CAN_REMOVE_POLICY);
+    }
+
+    @Override
+    public void doAction() throws Exception {
+        getObject().removePolicy(new ObjectIdImpl(policyField.getText()));
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/RemovePolicyPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java?rev=1101154&r1=1101153&r2=1101154&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/details/ActionsPanel.java Mon May  9 19:14:28 2011
@@ -23,6 +23,7 @@ import javax.swing.BoxLayout;
 import javax.swing.JPanel;
 
 import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.workbench.actions.ApplyPolicyPanel;
 import org.apache.chemistry.opencmis.workbench.actions.CancelCheckOutPanel;
 import org.apache.chemistry.opencmis.workbench.actions.CheckInPanel;
 import org.apache.chemistry.opencmis.workbench.actions.CheckOutPanel;
@@ -31,6 +32,7 @@ import org.apache.chemistry.opencmis.wor
 import org.apache.chemistry.opencmis.workbench.actions.DeleteTreePanel;
 import org.apache.chemistry.opencmis.workbench.actions.MovePanel;
 import org.apache.chemistry.opencmis.workbench.actions.PropertyUpdatePanel;
+import org.apache.chemistry.opencmis.workbench.actions.RemovePolicyPanel;
 import org.apache.chemistry.opencmis.workbench.actions.SetContentStreamPanel;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.model.ClientModelEvent;
@@ -51,6 +53,8 @@ public class ActionsPanel extends JPanel
     private CheckInPanel checkInPanel;
     private SetContentStreamPanel setContentStreamPanel;
     private DeleteContentStreamPanel deleteContentStreamPanel;
+    private ApplyPolicyPanel applyPolicyPanel;
+    private RemovePolicyPanel removePolicyPanel;
 
     public ActionsPanel(ClientModel model) {
         super();
@@ -90,6 +94,12 @@ public class ActionsPanel extends JPanel
 
         deleteContentStreamPanel.setObject(object);
         deleteContentStreamPanel.setVisible(deleteContentStreamPanel.isAllowed());
+
+        applyPolicyPanel.setObject(object);
+        applyPolicyPanel.setVisible(applyPolicyPanel.isAllowed());
+
+        removePolicyPanel.setObject(object);
+        removePolicyPanel.setVisible(removePolicyPanel.isAllowed());
     }
 
     private void createGUI() {
@@ -122,5 +132,11 @@ public class ActionsPanel extends JPanel
 
         deleteContentStreamPanel = new DeleteContentStreamPanel(model);
         add(deleteContentStreamPanel);
+
+        applyPolicyPanel = new ApplyPolicyPanel(model);
+        add(applyPolicyPanel);
+
+        removePolicyPanel = new RemovePolicyPanel(model);
+        add(removePolicyPanel);
     }
 }