1 /* 2 * GlobalDisplay.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.common; 16 17 import com.google.gwt.user.client.Command; 18 19 import org.rstudio.core.client.MessageDisplay; 20 import org.rstudio.core.client.Point; 21 import org.rstudio.core.client.dom.WindowEx; 22 import org.rstudio.core.client.widget.*; 23 24 public abstract class GlobalDisplay extends MessageDisplay 25 { 26 public static class NewWindowOptions 27 { NewWindowOptions()28 public NewWindowOptions() 29 { 30 } 31 getName()32 public String getName() 33 { 34 return name_; 35 } 36 setName(String name)37 public void setName(String name) 38 { 39 this.name_ = name; 40 } 41 isFocus()42 public boolean isFocus() 43 { 44 return focus_; 45 } 46 setFocus(boolean focus)47 public void setFocus(boolean focus) 48 { 49 this.focus_ = focus; 50 } 51 getCallback()52 public OperationWithInput<WindowEx> getCallback() 53 { 54 return callback_; 55 } 56 setCallback(OperationWithInput<WindowEx> callback)57 public void setCallback(OperationWithInput<WindowEx> callback) 58 { 59 this.callback_ = callback; 60 } 61 setPosition(Point pos)62 public void setPosition(Point pos) 63 { 64 position_ = pos; 65 } 66 getPosition()67 public Point getPosition() 68 { 69 return position_; 70 } 71 72 // only applicable in desktop mode--by default windows will not load 73 // non-local content setAllowExternalNavigation(boolean allow)74 public void setAllowExternalNavigation(boolean allow) 75 { 76 allowExternalNavigation_ = allow; 77 } 78 allowExternalNavigation()79 public boolean allowExternalNavigation() 80 { 81 return allowExternalNavigation_; 82 } 83 84 // only applicable in desktop mode--by default windows showing web content 85 // get a basic web navigation toolbar setShowDesktopToolbar(boolean show)86 public void setShowDesktopToolbar(boolean show) 87 { 88 showDesktopToolbar_ = show; 89 } 90 showDesktopToolbar()91 public boolean showDesktopToolbar() 92 { 93 return showDesktopToolbar_; 94 } 95 setAppendClientId(boolean append)96 public void setAppendClientId(boolean append) 97 { 98 appendClientId_ = append; 99 } 100 appendClientId()101 public boolean appendClientId() 102 { 103 return appendClientId_; 104 } 105 106 private Point position_ = null; 107 private String name_ = "_blank"; 108 private boolean focus_ = true; 109 private OperationWithInput<WindowEx> callback_; 110 private boolean allowExternalNavigation_ = false; 111 private boolean showDesktopToolbar_ = true; 112 private boolean appendClientId_ = false; 113 } 114 openWindow(String url)115 public abstract void openWindow(String url); openWindow(String url, NewWindowOptions options)116 public abstract void openWindow(String url, NewWindowOptions options); 117 openProgressWindow(String name, String message, OperationWithInput<WindowEx> openOperation)118 public abstract void openProgressWindow(String name, 119 String message, 120 OperationWithInput<WindowEx> openOperation); 121 openMinimalWindow(String url, int width, int height)122 public abstract void openMinimalWindow(String url, int width, int height); 123 openMinimalWindow(String url, boolean showLocation, int width, int height)124 public abstract void openMinimalWindow(String url, 125 boolean showLocation, 126 int width, 127 int height); 128 openMinimalWindow(String url, boolean showLocation, int width, int height, NewWindowOptions options)129 public abstract void openMinimalWindow(String url, 130 boolean showLocation, 131 int width, 132 int height, 133 NewWindowOptions options); 134 openWebMinimalWindow(String url, boolean showLocation, int width, int height, NewWindowOptions options)135 public abstract void openWebMinimalWindow(String url, 136 boolean showLocation, 137 int width, 138 int height, 139 NewWindowOptions options); 140 141 openSatelliteWindow(String name, int width, int height)142 public abstract void openSatelliteWindow(String name, int width, int height); 143 openSatelliteWindow(String name, int width, int height, NewWindowOptions options)144 public abstract void openSatelliteWindow(String name, int width, int height, 145 NewWindowOptions options); 146 bringWindowToFront(String name)147 public abstract void bringWindowToFront(String name); 148 showHtmlFile(String path)149 public abstract void showHtmlFile(String path); 150 showWordDoc(String path)151 public abstract void showWordDoc(String path); 152 showPptPresentation(String path)153 public abstract void showPptPresentation(String path); 154 openRStudioLink(String linkName)155 public void openRStudioLink(String linkName) 156 { 157 openRStudioLink(linkName, true); 158 } 159 openRStudioLink(String linkName, boolean includeVersionInfo)160 public abstract void openRStudioLink(String linkName, 161 boolean includeVersionInfo); 162 163 /** 164 * Shows a non-modal progress message. Execute the returned command 165 * to dismiss. 166 */ showProgress(String message)167 public abstract Command showProgress(String message); 168 showLicenseWarningBar(boolean severe, String message)169 public abstract void showLicenseWarningBar(boolean severe, String message); showWarningBar(boolean severe, String message)170 public abstract void showWarningBar(boolean severe, String message); hideWarningBar()171 public abstract void hideWarningBar(); 172 getProgressIndicator(String errorCaption)173 public abstract ProgressIndicator getProgressIndicator(String errorCaption); 174 }