/** * Returns {@code Optional} with the {@link Constants#SERVER_WS_AGENT_HTTP_REFERENCE wsagent/http} * server. * * @return {@code Optional} with the {@link Constants#SERVER_WS_AGENT_HTTP_REFERENCE wsagent/http} * server if the current workspace has a runtime and there is a machine with such server, * otherwise an empty {@code Optional} */ public Optional<ServerImpl> getWsAgentHttpServer() { return getServerByRef(getWsAgentHttpServerReference()); }
/** {@inheritDoc} */ @Override protected void dispatch(WorkspaceReadyHandler handler) { handler.onWorkspaceReady(this); } }
/** * Returns {@code Optional} with the {@link Constants#SERVER_WS_AGENT_WEBSOCKET_REFERENCE * wsagent/ws} server. * * @return {@code Optional} with the {@link Constants#SERVER_WS_AGENT_WEBSOCKET_REFERENCE * wsagent/ws} server if the current workspace has a runtime and there is a machine with such * server, otherwise an empty {@code Optional} */ public Optional<ServerImpl> getWsAgentWebSocketServer() { return getServerByRef(getWsAgentWebSocketServerReference()); }
@Inject public AppStateTracker( EventBus eventBus, AppContext appContext, AppStateSyncWriter appStateSyncWriter, AppStateManager appStateManager, AppStateBackwardCompatibility appStateBackwardCompatibility) { this.eventBus = eventBus; this.appContext = appContext; this.appStateSyncWriter = appStateSyncWriter; this.appStateManager = appStateManager; this.appStateBackwardCompatibility = appStateBackwardCompatibility; eventBus.addHandler(WorkspaceReadyEvent.getType(), this::onWorkspaceReady); }
@VisibleForTesting Optional<ServerImpl> getServerByRef(String ref) { Optional<RuntimeImpl> runtimeOpt = getWorkspaceRuntime(); if (runtimeOpt.isPresent()) { for (MachineImpl machine : runtimeOpt.get().getMachines().values()) { ServerImpl server = machine.getServers().get(ref); if (server != null) { return Optional.of(server); } } } return Optional.empty(); }
/** * Checks whether the provided {@link MachineImpl} contains the {@link * Constants#SERVER_WS_AGENT_HTTP_REFERENCE wsagent/http} server. * * @param machine {@link MachineImpl} to check * @return {@code true} if the given machine contains the {@link * Constants#SERVER_WS_AGENT_HTTP_REFERENCE wsagent/http} server server, otherwise {@code * false} */ public boolean containsWsAgentHttpServer(MachineImpl machine) { return machine.getServers().keySet().contains(getWsAgentHttpServerReference()); }
@Override public void onTerminalAgentServerRunning(TerminalAgentServerRunningEvent event) { // open terminal automatically for dev-machine only Optional<MachineImpl> devMachine = wsAgentServerUtil.getWsAgentServerMachine(); if (devMachine.isPresent() && event.getMachineName().equals(devMachine.get().getName())) { provideMachineNode(event.getMachineName(), true, false); TerminalOptionsJso options = TerminalOptionsJso.create(); newTerminal(options, false, false); } }
/** * Adds command node to process tree and displays command output * * @param outputConsole the console for command output */ public void addCommandOutput(OutputConsole outputConsole) { Optional<MachineImpl> devMachine = wsAgentServerUtil.getWsAgentServerMachine(); devMachine.ifPresent(machine -> addCommandOutput(machine.getName(), outputConsole, true)); }
/** * Returns {@code Optional} with a machine which contains the "wsagent" server. * * @return {@code Optional} with the machine which contains the "wsagent" server if the current * workspace has a runtime and there is such machine, otherwise an empty {@code Optional} */ public Optional<MachineImpl> getWsAgentServerMachine() { return getWorkspaceRuntime() .flatMap( runtime -> runtime .getMachines() .values() .stream() .filter(this::containsWsAgentHttpServer) .findAny()); }
@NotNull @Override public Promise<String> expand() { String value = ""; Optional<MachineImpl> devMachine = wsAgentServerUtil.getWsAgentServerMachine(); if (devMachine.isPresent()) { String hostName = devMachine.get().getAttributes().get("config.hostname"); if (hostName != null) { value = hostName; } } return Promises.resolve(value); } }
/** * Returns a top-level URL of the GWT Code Server which is declared in the machine that contains * the "wsagent" server. * * @return {@code Optional} with a top-level URL of the GWT Code Server or an empty {@code * Optional} if none */ private Optional<String> getInternalCodeServerURL() { Optional<MachineImpl> wsAgentServerMachineOpt = wsAgentServerUtil.getWsAgentServerMachine(); if (wsAgentServerMachineOpt.isPresent()) { MachineImpl wsAgentServerMachine = wsAgentServerMachineOpt.get(); Optional<ServerImpl> codeServerOpt = wsAgentServerMachine.getServerByName(INT_CODE_SERVER_REF); if (codeServerOpt.isPresent()) { ServerImpl codeServer = codeServerOpt.get(); String codeServerUrl = codeServer.getUrl(); if (!isNullOrEmpty(codeServerUrl)) { return codeServerUrl.endsWith("/") ? Optional.of(codeServerUrl) : Optional.of(codeServerUrl + '/'); } } } return Optional.empty(); }
private void registerMacros() { final Optional<MachineImpl> devMachine = wsAgentServerUtil.getWsAgentServerMachine(); if (devMachine.isPresent()) { macros.clear(); for (Map.Entry<String, ? extends Server> entry : devMachine.get().getServers().entrySet()) { macros.add(new ServerAddressMacro(entry.getKey(), entry.getValue().getUrl())); } macroRegistryProvider.get().register(macros); } }
private void handleWsAgentStatus() { wsAgentServerUtil .getWsAgentHttpServer() .ifPresent( server -> { if (server.getStatus() == STOPPED) { show(); } }); }
@Override public String getWsAgentServerApiEndpoint() { Optional<ServerImpl> server = wsAgentServerUtilProvider.get().getWsAgentHttpServer(); if (server.isPresent()) { return server.get().getUrl(); } throw new RuntimeException("wsagent server doesn't exist"); }
@Inject public JavaLanguageExtensionServiceClient( RequestTransmitter requestTransmitter, RequestHandlerConfigurator configurator, RequestTransmitter transmitter, AppContext appContext, EventBus eventBus) { this.requestTransmitter = requestTransmitter; this.configurator = configurator; this.transmitter = transmitter; this.appContext = appContext; eventBus.addHandler(WorkspaceReadyEvent.getType(), e -> subscribe()); }
/** Selects dev machine. */ private void selectDevMachine() { Optional<MachineImpl> devMachine = wsAgentServerUtil.getWsAgentServerMachine(); if (!devMachine.isPresent()) { return; } for (ProcessTreeNode processTreeNode : machineNodes.values()) { if (processTreeNode.getType() == MACHINE_NODE) { String machineName = (String) processTreeNode.getData(); if (machineName.equals(devMachine.get().getName())) { view.selectNode(processTreeNode); notifyTreeNodeSelected(processTreeNode); return; } } } }
@Inject public FileWatcherExcludesOperation( EventBus eventBus, PromiseProvider promises, RequestTransmitter requestTransmitter) { this.promises = promises; this.requestTransmitter = requestTransmitter; eventBus.addHandler(WindowActionEvent.TYPE, this); eventBus.addHandler(WorkspaceReadyEvent.getType(), event -> subscribe()); }
@Inject public InitialProjectImporter( ImportProjectNotificationSubscriberFactory subscriberFactory, AppContext appContext, OAuth2AuthenticatorRegistry oAuth2AuthenticatorRegistry, ProjectImportOutputJsonRpcNotifier subscriber, NotificationManager notificationManager, CoreLocalizationConstant locale, AskCredentialsDialog askCredentialsDialog, DialogFactory dialogFactory, PromiseProvider promises, EventBus eventBus) { super(appContext, subscriberFactory); this.oAuth2AuthenticatorRegistry = oAuth2AuthenticatorRegistry; this.subscriber = subscriber; this.notificationManager = notificationManager; this.locale = locale; this.askCredentialsDialog = askCredentialsDialog; this.dialogFactory = dialogFactory; this.promises = promises; eventBus.addHandler(WorkspaceReadyEvent.getType(), e -> importProjects()); }
@Inject public JavaCompilerPreferencePresenter( JavaLocalizationConstant locale, EventBus eventBus, ErrorWarningsView view, PropertyWidgetFactory propertyFactory, @JavaCompilerPreferenceManager PreferencesManager preferencesManager) { super(locale.compilerSetup(), CATEGORY); this.view = view; this.propertyFactory = propertyFactory; this.preferencesManager = preferencesManager; this.widgets = new HashMap<>(); eventBus.addHandler(WorkspaceReadyEvent.getType(), e -> updateErrorWarningsPanel()); fillUpOptions(); }
/** Accepts factory if it is present in context of application */ public void process() { final FactoryImpl factory; if ((factory = appContext.getFactory()) == null) { return; } eventBus.addHandler( WorkspaceReadyEvent.getType(), e -> { if (isImportingStarted) { return; } isImportingStarted = true; notification = notificationManager.notify( localizationConstant.cloningSource(), StatusNotification.Status.PROGRESS, NOT_EMERGE_MODE); performOnAppLoadedActions(factory); startImporting(factory); }); }