1 /*
2  * AutoGlassAttacher.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.ui.LayoutPanel;
18 import org.rstudio.core.client.widget.GlassAttacher;
19 import org.rstudio.core.client.widget.events.GlassVisibilityEvent;
20 import org.rstudio.studio.client.RStudioGinjector;
21 import org.rstudio.studio.client.application.events.EventBus;
22 
23 public class AutoGlassAttacher extends GlassAttacher
24 {
AutoGlassAttacher(LayoutPanel panel)25    public AutoGlassAttacher(LayoutPanel panel)
26    {
27       super(panel);
28 
29       EventBus eventBus = RStudioGinjector.INSTANCE.getEventBus();
30       eventBus.addHandler(GlassVisibilityEvent.TYPE, glassVisibilityEvent ->
31       {
32          setGlass(glassVisibilityEvent.isShow());
33       });
34       setGlass(false);
35    }
36 }
37