Package org.codemap.mapview.action

Source Code of org.codemap.mapview.action.CommandAction

package org.codemap.mapview.action;

import org.codemap.commands.Command;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;

public abstract class CommandAction extends Action {

    private Command command;

    public CommandAction(String text, int style, ActionStore actionStore) {
        super(text, style);
        ImageDescriptor img = getImage();
        if (img != null) {
            setImageDescriptor(img);           
        }
        actionStore.put(this);
    }

    protected abstract ImageDescriptor getImage();

    public void setCommand(Command c) {
        command = c;
        setChecked(c.isEnabled());
    }

    @Override
    public void run() {
        super.run();
        command.setEnabled(isChecked());
    }
}
TOP

Related Classes of org.codemap.mapview.action.CommandAction

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.