Package org.joshy.sketch.actions

Source Code of org.joshy.sketch.actions.SAction

package org.joshy.sketch.actions;

import org.joshy.gfx.event.ChangedEvent;
import org.joshy.gfx.event.EventBus;

/**
* Created by IntelliJ IDEA.
* User: joshmarinacci
* Date: Apr 6, 2010
* Time: 7:45:20 PM
* To change this template use File | Settings | File Templates.
*
* The base class for all actions, which are encapsulated behavior that can be
* attached to UI controls.
*/
public abstract class SAction {
    private boolean enabled = true;

    public CharSequence getDisplayName() {
        return "unknown saction";
    }
    public abstract void execute() throws Exception;
    public boolean isEnabled() {
        return enabled;
    }
    public void setEnabled(boolean enabled) {
        boolean old = isEnabled();
        this.enabled = enabled;
        if(this.enabled != old) {
            fireChange(old,this.enabled);
        }
    }

    private void fireChange(boolean old, boolean enabled) {
        EventBus.getSystem().publish(new ChangedEvent(ChangedEvent.BooleanChanged,enabled,this));
    }
}
TOP

Related Classes of org.joshy.sketch.actions.SAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.