1 /* 2 * ContextDepthChangedEvent.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.views.environment.events; 16 17 import org.rstudio.studio.client.workbench.views.environment.model.CallFrame; 18 import org.rstudio.studio.client.workbench.views.environment.model.EnvironmentContextData; 19 import org.rstudio.studio.client.workbench.views.environment.model.RObject; 20 21 import com.google.gwt.core.client.JsArray; 22 import com.google.gwt.event.shared.EventHandler; 23 import com.google.gwt.event.shared.GwtEvent; 24 25 public class ContextDepthChangedEvent extends 26 GwtEvent<ContextDepthChangedEvent.Handler> 27 { 28 public interface Handler extends EventHandler 29 { onContextDepthChanged(ContextDepthChangedEvent event)30 void onContextDepthChanged(ContextDepthChangedEvent event); 31 } 32 33 // This event is fired both as an event dispatched from the server and as 34 // an event from the client to set up state after requesting it from the 35 // server. The serverInitiated flag distinguishes between these states. ContextDepthChangedEvent(EnvironmentContextData data, boolean serverInitiated)36 public ContextDepthChangedEvent(EnvironmentContextData data, 37 boolean serverInitiated) 38 { 39 contextData_ = data; 40 serverInitiated_ = serverInitiated; 41 } 42 getContextDepth()43 public int getContextDepth() 44 { 45 return contextData_.contextDepth(); 46 } 47 getEnvironmentList()48 public JsArray<RObject> getEnvironmentList() 49 { 50 return contextData_.environmentList(); 51 } 52 getCallFrames()53 public JsArray<CallFrame> getCallFrames() 54 { 55 return contextData_.callFrames(); 56 } 57 getFunctionName()58 public String getFunctionName() 59 { 60 return contextData_.functionName(); 61 } 62 getFunctionCode()63 public String getFunctionCode() 64 { 65 return contextData_.functionCode(); 66 } 67 useProvidedSource()68 public boolean useProvidedSource() 69 { 70 return contextData_.useProvidedSource(); 71 } 72 getEnvironmentName()73 public String getEnvironmentName() 74 { 75 return contextData_.environmentName(); 76 } 77 getFunctionEnvName()78 public String getFunctionEnvName() 79 { 80 return contextData_.functionEnvName(); 81 } 82 environmentIsLocal()83 public boolean environmentIsLocal() 84 { 85 return contextData_.environmentIsLocal(); 86 } 87 environmentMonitoring()88 public boolean environmentMonitoring() 89 { 90 return contextData_.environmentMonitoring(); 91 } 92 isServerInitiated()93 public boolean isServerInitiated() 94 { 95 return serverInitiated_; 96 } 97 98 @Override getAssociatedType()99 public Type<Handler> getAssociatedType() 100 { 101 return TYPE; 102 } 103 104 @Override dispatch(Handler handler)105 protected void dispatch(Handler handler) 106 { 107 handler.onContextDepthChanged(this); 108 } 109 110 public static final Type<Handler> TYPE = new Type<>(); 111 private final EnvironmentContextData contextData_; 112 private final boolean serverInitiated_; 113 } 114