1 /*
2  * RSConnectCloudAccount.java
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 package org.rstudio.studio.client.rsconnect.ui;
16 
17 import com.google.gwt.core.client.GWT;
18 import com.google.gwt.event.dom.client.KeyUpEvent;
19 import com.google.gwt.event.dom.client.KeyUpHandler;
20 import com.google.gwt.resources.client.CssResource;
21 import com.google.gwt.uibinder.client.UiBinder;
22 import com.google.gwt.uibinder.client.UiField;
23 import com.google.gwt.user.client.Command;
24 import com.google.gwt.user.client.ui.Composite;
25 import com.google.gwt.user.client.ui.TextArea;
26 import com.google.gwt.user.client.ui.Widget;
27 
28 public class RSConnectCloudAccount extends Composite
29 {
30    private static RSConnectCloudAccountUiBinder uiBinder = GWT
31          .create(RSConnectCloudAccountUiBinder.class);
32 
33    interface RSConnectCloudAccountUiBinder extends
34          UiBinder<Widget, RSConnectCloudAccount>
35    {
36    }
37 
38    interface ConnectStyle extends CssResource
39    {
spaced()40       String spaced();
41    }
42 
RSConnectCloudAccount()43    public RSConnectCloudAccount()
44    {
45       initWidget(uiBinder.createAndBindUi(this));
46       accountInfo.addKeyUpHandler(new KeyUpHandler()
47       {
48          @Override
49          public void onKeyUp(KeyUpEvent event)
50          {
51             if (onAccountInfoChanged_ != null)
52             {
53                onAccountInfoChanged_.execute();
54             }
55          }
56       });
57    }
58 
focus()59    public void focus()
60    {
61       accountInfo.setFocus(true);
62    }
63 
setOnAccountInfoChanged(Command cmd)64    public void setOnAccountInfoChanged(Command cmd)
65    {
66       onAccountInfoChanged_ = cmd;
67    }
68 
getAccountInfo()69    public String getAccountInfo()
70    {
71       return accountInfo.getText();
72    }
73 
getStyle()74    public ConnectStyle getStyle()
75    {
76       return style;
77    }
78 
79    @UiField TextArea accountInfo;
80    @UiField ConnectStyle style;
81 
82    private Command onAccountInfoChanged_;
83 }
84