package org.vietabroader.controller;

import org.vietabroader.model.GlobalState;
import org.vietabroader.model.VASpreadsheet;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SpreadsheetConnectController implements Controller {

    private JButton btnConnect;
    private JTextField txtConnect;
    private static final Logger logger = LoggerFactory.getLogger(SpreadsheetConnectController.class);

    public SpreadsheetConnectController setConnectButton(JButton btn) {
        btnConnect = btn;
        return this;
    }

    public SpreadsheetConnectController setTextSpreadsheetID(JTextField txt) {
        txtConnect = txt;
        return this;
    }

    @Override
    public void control() {
        btnConnect.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                GlobalState currentState = GlobalState.getInstance();
                try {
                    VASpreadsheet spreadsheet = new VASpreadsheet(txtConnect.getText());
                    spreadsheet.connect();

                    currentState.setStatus(GlobalState.Status.CONNECTED);
                    currentState.setSpreadsheet(spreadsheet);

                    logger.info("Sheet " + spreadsheet.getSpreadsheetTitle() + "connected");
                } catch (Exception ex) {
                    currentState.setStatus(GlobalState.Status.SIGNED_IN);
                    ex.printStackTrace();
                }
            }
        });
    }
}

@@ -1017,24 +1017,168 @@
 Instance();%0A
+                if (currentState.getStatus() == GlobalState.Status.SIGNED_IN %7C%7C currentState.getStatus() == GlobalState.Status.CONNECTED) %7B%0A    
             
@@ -1187,16 +1187,20 @@
   try %7B%0A
+    
         
@@ -1300,16 +1300,20 @@
         
+ 
+   
 spreadsh
@@ -1324,24 +1324,28 @@
 connect();%0A%0A
+    
             
@@ -1418,32 +1418,36 @@
                 
+    
 currentState.set
@@ -1493,16 +1493,20 @@
         
+  
+  
 logger.i
@@ -1570,16 +1570,20 @@
 cted%22);%0A
+    
         
@@ -1627,32 +1627,36 @@
                 
+    
 currentState.set
@@ -1713,16 +1713,20 @@
         
+  
+  
 ex.print
@@ -1735,24 +1735,46 @@
 ackTrace();%0A
+                    %7D%0A
             

Add the check for status