Ejemplo n.º 1
0
  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();
              }
            });
  }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
0
 public void run() {
   if (null != view) {
     view.showDialog();
   }
 }