1 /*
2  * RStudioAPIShowDialogEvent.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 
16 package org.rstudio.studio.client.common.rstudioapi.events;
17 
18 import com.google.gwt.core.client.JavaScriptObject;
19 import com.google.gwt.event.shared.EventHandler;
20 import com.google.gwt.event.shared.GwtEvent;
21 
22 public class RStudioAPIShowDialogEvent extends GwtEvent<RStudioAPIShowDialogEvent.Handler>
23 {
24    public static class Data extends JavaScriptObject
25    {
Data()26       protected Data()
27       {
28       }
29 
getMessage()30       public final native String getMessage() /*-{
31          return this.message;
32       }-*/;
33 
getTitle()34       public final native String getTitle() /*-{
35          return this.title;
36       }-*/;
37 
getDialogIcon()38       public final native int getDialogIcon() /*-{
39          return this.dialogIcon;
40       }-*/;
41 
getPrompt()42       public final native boolean getPrompt() /*-{
43          return this.prompt || false;
44       }-*/;
45 
getPromptDefault()46       public final native String getPromptDefault() /*-{
47          return this["default"];
48       }-*/;
49 
getOK()50       public final native String getOK() /*-{
51          return this.ok;
52       }-*/;
53 
getCancel()54       public final native String getCancel() /*-{
55          return this.cancel;
56       }-*/;
57 
getUrl()58       public final native String getUrl() /*-{
59          return this.url;
60       }-*/;
61    }
62 
63    public interface Handler extends EventHandler
64    {
onRStudioAPIShowDialogEvent(RStudioAPIShowDialogEvent event)65       void onRStudioAPIShowDialogEvent(RStudioAPIShowDialogEvent event);
66    }
67 
RStudioAPIShowDialogEvent(Data data)68    public RStudioAPIShowDialogEvent(Data data)
69    {
70       data_ = data;
71    }
72 
getMessage()73    public String getMessage()
74    {
75       return data_.getMessage();
76    }
77 
getTitle()78    public String getTitle()
79    {
80       return data_.getTitle();
81    }
82 
getDialogIcon()83    public int getDialogIcon()
84    {
85       return data_.getDialogIcon();
86    }
87 
getPrompt()88    public boolean getPrompt()
89    {
90       return data_.getPrompt();
91    }
92 
getPromptDefault()93    public String getPromptDefault()
94    {
95       return data_.getPromptDefault();
96    }
97 
getOK()98    public String getOK()
99    {
100       return data_.getOK();
101    }
102 
getCancel()103    public String getCancel()
104    {
105       return data_.getCancel();
106    }
107 
getUrl()108    public String getUrl()
109    {
110       return data_.getUrl();
111    }
112 
113    @Override
getAssociatedType()114    public Type<Handler> getAssociatedType()
115    {
116       return TYPE;
117    }
118 
119    @Override
dispatch(Handler handler)120    protected void dispatch(Handler handler)
121    {
122       handler.onRStudioAPIShowDialogEvent(this);
123    }
124 
125    private final Data data_;
126 
127    public static final Type<Handler> TYPE = new Type<>();
128 }
129