1 /*
2  * CopyPlotToClipboardWebDialog.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.workbench.exportplot.clipboard;
16 
17 import org.rstudio.core.client.resources.ImageResource2x;
18 import org.rstudio.core.client.widget.DecorativeImage;
19 import org.rstudio.core.client.widget.OperationWithInput;
20 import org.rstudio.core.client.widget.ThemedButton;
21 import org.rstudio.studio.client.workbench.exportplot.ExportPlotDialog;
22 import org.rstudio.studio.client.workbench.exportplot.ExportPlotPreviewer;
23 import org.rstudio.studio.client.workbench.exportplot.ExportPlotResources;
24 import org.rstudio.studio.client.workbench.exportplot.model.ExportPlotOptions;
25 
26 import com.google.gwt.event.dom.client.ClickEvent;
27 import com.google.gwt.event.dom.client.ClickHandler;
28 import com.google.gwt.user.client.ui.HorizontalPanel;
29 import com.google.gwt.user.client.ui.Label;
30 
31 public class CopyPlotToClipboardWebDialog extends ExportPlotDialog
32 {
CopyPlotToClipboardWebDialog( final ExportPlotOptions options, ExportPlotPreviewer previewer, final OperationWithInput<ExportPlotOptions> onClose)33    public CopyPlotToClipboardWebDialog(
34                             final ExportPlotOptions options,
35                             ExportPlotPreviewer previewer,
36                             final OperationWithInput<ExportPlotOptions> onClose)
37    {
38       super(options, previewer);
39 
40       setText("Copy Plot to Clipboard");
41 
42       ExportPlotResources resources = ExportPlotResources.INSTANCE;
43 
44       ThemedButton closeButton = new ThemedButton("Close",
45             new ClickHandler() {
46          public void onClick(ClickEvent event)
47          {
48             // save options
49             onClose.execute(getCurrentOptions(options));
50 
51             // close dialog
52             closeDialog();
53          }
54       });
55       addCancelButton(closeButton);
56 
57 
58       HorizontalPanel infoPanel = new HorizontalPanel();
59 
60       DecorativeImage rightMouseImage = new DecorativeImage(new ImageResource2x(resources.rightMouse2x()));
61       infoPanel.add(rightMouseImage);
62 
63       Label label = new Label("Right click on the plot image above to " +
64                               "copy to the clipboard.");
65       label.setStylePrimaryName(resources.styles().rightClickCopyLabel());
66       infoPanel.add(label);
67 
68       addLeftWidget(infoPanel);
69 
70    }
71 
72 }
73