Package floobits.actions

Source Code of floobits.actions.IsJoinedAction

package floobits.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import floobits.common.interfaces.IContext;
import floobits.FloobitsPlugin;
import floobits.common.API;
import floobits.common.EditorEventHandler;
import floobits.common.protocol.handlers.FlooHandler;
import floobits.utilities.Flog;

public abstract class IsJoinedAction extends RequiresAccountAction {

    public abstract void actionPerformed(AnActionEvent e, EditorEventHandler editorEventHandler);

    @Override
    public void actionPerformedHasAccount(AnActionEvent e) {
        FloobitsPlugin floobitsPlugin;
        FlooHandler flooHandler;
        IContext context = null;
        try {
            floobitsPlugin = FloobitsPlugin.getInstance(e.getProject());
            if (floobitsPlugin == null) {
                Flog.log("no floobits plugin, aborting.");
                return;
            }
            context = floobitsPlugin.context;
            flooHandler = context.getFlooHandler();
            if (flooHandler == null) {
                return;
            }
            actionPerformed(e, flooHandler.editorEventHandler);
        } catch (Throwable throwable) {
            API.uploadCrash(context, throwable);
        }
    }

    @Override
    public void update(AnActionEvent e) {
        super.update(e);
        FloobitsPlugin floobitsPlugin = FloobitsPlugin.getInstance(e.getProject());
        if (floobitsPlugin == null) {
            return;
        }
        e.getPresentation().setEnabled(isEnabled(floobitsPlugin));
    }

    protected boolean isEnabled(FloobitsPlugin floobitsPlugin) {
        return floobitsPlugin.context.isJoined();
    }
}
TOP

Related Classes of floobits.actions.IsJoinedAction

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.