Package floobits.dialogs

Source Code of floobits.dialogs.CreateAccount$LinkAccountAction

package floobits.dialogs;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import floobits.common.interfaces.IContext;
import floobits.FloobitsPlugin;
import floobits.impl.ContextImpl;
import floobits.utilities.Flog;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.event.ActionEvent;

public class CreateAccount extends DialogWrapper {
    private JPanel jPanel;
    protected Project project;


    private class CreateAccountAction extends DialogWrapper.DialogWrapperAction {

        protected CreateAccountAction() {
            super("Create a Floobits account");
        }

        @Override
        protected void doAction(ActionEvent e) {
            Flog.info("Creating account from button press");
            doOKAction();
        }
    }


    private class LinkAccountAction extends DialogWrapper.DialogWrapperAction {

        protected LinkAccountAction() {
            super("I already have an account");
        }

        @Override
        protected void doAction(ActionEvent e) {
            Flog.info("Linking account from button press");
            doCancelAction();
        }
    }


    public CreateAccount(Project project) {
        super(project, true);
        this.project = project;
        jPanel = new JPanel();
        init();
        this.setTitle("No Floobits Account Detected");
        JLabel label = new JLabel("You need a Floobits account! If you don't have one we will create one for you.");
        jPanel.add(label);
    }

    @Override
    public void createDefaultActions () {
        super.createDefaultActions();
        myOKAction = new CreateAccountAction();
        myCancelAction = new LinkAccountAction();
    }

    @Nullable
    @Override
    public JComponent createCenterPanel() {
        return jPanel;
    }

    @Override
    public void doCancelAction() {
        super.doCancelAction();
        IContext context;
        if (project == null) {
            context = new ContextImpl(null);
        } else {
            context = FloobitsPlugin.getInstance(project).context;
        }
        context.linkEditor();
    }

    @Override
    protected void doOKAction() {
        super.doOKAction();
        IContext context;
        if (project == null) {
            context = new ContextImpl(null);
        } else {
            context = FloobitsPlugin.getInstance(project).context;
        }
        context.createAccount();
    }
}
TOP

Related Classes of floobits.dialogs.CreateAccount$LinkAccountAction

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.