/*
 * Copyright 2002-2004 the original author or authors.
 * 
 * Licensed 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.springframework.richclient.command.support;

import java.beans.PropertyChangeListener;
import java.util.Map;

import org.springframework.binding.value.ValueModel;
import org.springframework.binding.value.support.ValueHolder;
import org.springframework.richclient.command.GuardedActionCommandExecutor;
import org.springframework.richclient.command.ParameterizableActionCommandExecutor;

/**
 * @author Keith Donald
 */
public class AbstractActionCommandExecutor implements ParameterizableActionCommandExecutor,
        GuardedActionCommandExecutor {

    private ValueModel enabled = new ValueHolder(Boolean.FALSE);

    public boolean isEnabled() {
        return ((Boolean)enabled.getValue()).booleanValue();
    }

    public void setEnabled(boolean enabled) {
        this.enabled.setValue(Boolean.valueOf(enabled));
    }

    public void addEnabledListener(PropertyChangeListener listener) {
        enabled.addValueChangeListener(listener);
    }

    public void removeEnabledListener(PropertyChangeListener listener) {
        enabled.removeValueChangeListener(listener);
    }

    public void execute(Map parameters) {
        execute();
    }

    public void execute() {
    }

}
@@ -1008,16 +1008,81 @@
 xecutor;
+%0Aimport org.springframework.richclient.core.SecurityControllable;
 %0A%0A/**%0A *
@@ -1235,16 +1235,38 @@
 Executor
+, SecurityControllable
  %7B%0A%0A    
@@ -1336,146 +1336,2529 @@
    p
-ublic boolean isEnabled() %7B%0A        return ((Boolean)enabled.getValue()).booleanValue();%0A    %7D%0A%0A    public void setEnabled(boolean enabled
+rivate boolean authorized = true;%0A    private boolean maskedEnabledState = false;%0A    private String securityControllerId = null;%0A%0A    /**%0A     * Set the Id of the security controller that should manage this object.%0A     * @param controllerId Id (bean name) of the security controller%0A     */%0A    public void setSecurityControllerId(String controllerId) %7B%0A        this.securityControllerId = controllerId;%0A    %7D%0A%0A    /**%0A     * Get the id (bean name) of the security controller that should manage this object.%0A     * @return controller id%0A     */%0A    public String getSecurityControllerId() %7B%0A        return securityControllerId;%0A    %7D%0A%0A    /**%0A     * Set the authorized state.  Setting authorized to false will override any call%0A     * to %7B@link #setEnabled(boolean)%7D.  As long as this object is unauthorized,%0A     * it can not be enabled.%0A     * @param authorized Pass %3Ccode%3Etrue%3C/code%3E if the object is to be authorized%0A     */%0A    public void setAuthorized( boolean authorized ) %7B%0A%0A        if( isAuthorized() != authorized ) %7B%0A            %0A            this.authorized = authorized;%0A%0A            // We need to apply a change to our enabled state depending on our%0A            // new authorized state.%0A            if( authorized ) %7B%0A                // install the last requested enabled state%0A                setEnabled(maskedEnabledState);%0A            %7D else %7B%0A                // Record the current enabled state and then disable%0A                maskedEnabledState = isEnabled();%0A                internalSetEnabled(false);%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Get the authorized state.%0A     * @return authorized%0A     */%0A    public boolean isAuthorized() %7B%0A        return authorized;%0A    %7D%0A%0A    public boolean isEnabled() %7B%0A        return ((Boolean)enabled.getValue()).booleanValue();%0A    %7D%0A%0A    /**%0A     * Set the enabled state of this command.  Note that if we are currently not%0A     * authorized, then the new value will just be recorded and no change in the%0A     * current enabled state will be made.%0A     * @param enabled state%0A     */%0A    public void setEnabled(boolean enabled) %7B%0A        maskedEnabledState = enabled;%0A        if( isAuthorized() ) %7B%0A            internalSetEnabled( enabled );%0A        %7D%0A    %7D%0A%0A    /**%0A     * Internal method to set the enabled state.  This is needed so that calls%0A     * made to the public setEnabled and this method can be handled differently.%0A     * @param enabled state%0A     * @see #setAuthorized(boolean)%0A     */%0A    protected void internalSetEnabled( boolean enabled 
 ) %7B%0A

Implement SecurityControllable