public GooglePlusController(final GooglePlusDialog view) { this.view = Preconditions.checkNotNull(view, "Required parameter view must be specified."); view.getGenerateButton() .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Credential credential = authorize( view.getClientId().getText(), view.getClientSecret().getText(), Arrays.asList(view.getScopes().getText().split(";"))); setCredentialData(credential); } catch (IOException e1) { JOptionPane.showMessageDialog( view, "Failed to get Accesstoke:\n" + e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } }); view.getCloseButton() .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { view.closeDialog(); } }); }
protected void setCredentialData(Credential credential) { view.getAccesstoken().setText(credential.getAccessToken()); view.getRefreshtoken().setText(credential.getRefreshToken()); view.getExpires() .setText( new Date(credential.getExpiresInSeconds() * 1000L + System.currentTimeMillis()) .toString()); }
public void run() { if (null != view) { view.showDialog(); } }