/** Returns commands which are stored in the current workspace. */ List<CommandImpl> getCommands() { final WorkspaceImpl workspace = appContext.getWorkspace(); final WorkspaceConfigImpl workspaceConfig = workspace.getConfig(); return workspaceConfig.getCommands(); }
private void addMachines() { String defaultEnvironmentName = appContext.getWorkspace().getConfig().getDefaultEnv(); EnvironmentImpl defaultEnvironment = appContext.getWorkspace().getConfig().getEnvironments().get(defaultEnvironmentName); if (defaultEnvironment == null) { return; } Map<String, MachineConfigImpl> machines = defaultEnvironment.getMachines(); for (final String machineName : machines.keySet()) { MachineConfigImpl machineConfig = machines.get(machineName); view.addMachine(machineName); } }
private void showInstallers() { String defaultEnvironmentName = appContext.getWorkspace().getConfig().getDefaultEnv(); EnvironmentImpl defaultEnvironment = appContext.getWorkspace().getConfig().getEnvironments().get(defaultEnvironmentName); if (defaultEnvironment == null) { return; } Map<String, MachineConfigImpl> machines = defaultEnvironment.getMachines(); for (final String machineName : machines.keySet()) { MachineConfigImpl machineConfig = machines.get(machineName); for (String installerId : machineConfig.getInstallers()) { String installerName = installernames.get(installerId); if (installerName == null) { installerName = ""; } String installerDescription = installerDescriptions.get(installerId); if (installerDescription == null) { installerDescription = ""; } view.addInstaller(machineName, installerId, installerName, installerDescription); } } }
/** {@inheritDoc} */ @Override public Promise<String> expand() { return promises.resolve(appContext.getWorkspace().getConfig().getName()); } }
private CommandImpl getWorkspaceCommandByName(String name) { for (Command command : appContext.getWorkspace().getConfig().getCommands()) { if (command.getName().equals(name)) { return new CommandImpl(command); // wrap model interface into implementation, workaround } } return null; }
@Override public void onWorkspaceRunning(WorkspaceRunningEvent event) { if (arrow != null) { arrow.setAttribute( "href", constant.openDashboardUrlWorkspace(appContext.getWorkspace().getConfig().getName())); } }
@Override public void onDownloadOutput(OutputConsole console) { String id = consoleCommands.get(console); String fileName = appContext.getWorkspace().getNamespace() + "-" + appContext.getWorkspace().getConfig().getName() + " " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ".log"; download(fileName, getText(id)); }
@Override public void onDownloadWorkspaceOutput(DownloadWorkspaceOutputEvent event) { Optional<MachineImpl> devMachine = wsAgentServerUtil.getWsAgentServerMachine(); if (!devMachine.isPresent()) { return; } WorkspaceImpl workspace = appContext.getWorkspace(); String fileName = workspace.getNamespace() + "-" + workspace.getConfig().getName() + " " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ".log"; download(fileName, getText(devMachine.get().getName())); }
@Override public Path getProjectsRoot() { // default root (backward compatible solution) Path projectsRoot = Path.valueOf("/projects"); if (workspace != null && workspace.getStatus().equals(WorkspaceStatus.RUNNING)) { String machineName = wsAgentServerUtilProvider.get().getWsAgentServerMachine().get().getName(); String activeEnv = workspace.getRuntime().getActiveEnv(); EnvironmentImpl environment = workspace.getConfig().getEnvironments().get(activeEnv); VolumeImpl vol = null; if (environment != null) { vol = environment.getMachines().get(machineName).getVolume("projects"); } // if voulme exists return its path, otherwise use backward compatible path (/projects) if (vol != null) { projectsRoot = Path.valueOf(vol.getPath()); } } Log.debug( AppContextImpl.class, "Project Root: " + projectsRoot + " workspace: " + workspace.getConfig().getName()); return projectsRoot; }
@Override public void showPanel() { showWorkspaceStatusPanel(); addMachines(); showInstallers(); if (WorkspaceStatus.RUNNING == appContext.getWorkspace().getStatus()) { view.showWorkspaceStarted(); Map<String, MachineImpl> runtimeMachines = appContext.getWorkspace().getRuntime().getMachines(); for (String machineName : runtimeMachines.keySet()) { view.setMachineRunning(machineName); } String defaultEnvironmentName = appContext.getWorkspace().getConfig().getDefaultEnv(); EnvironmentImpl defaultEnvironment = appContext.getWorkspace().getConfig().getEnvironments().get(defaultEnvironmentName); if (defaultEnvironment == null) { return; } Map<String, MachineConfigImpl> environmentMachines = defaultEnvironment.getMachines(); for (final String machineName : environmentMachines.keySet()) { MachineConfigImpl machineConfig = environmentMachines.get(machineName); for (String installerId : machineConfig.getInstallers()) { view.setInstallerRunning(machineName, installerId); } } } }
public WorkspaceImpl(WorkspaceImpl workspace) { this( workspace.getId(), workspace.getNamespace(), workspace.getConfig(), workspace.getRuntime(), workspace.getAttributes(), workspace.isTemporary(), workspace.getStatus(), workspace.getLinks(), workspace.getRuntime() != null ? workspace.getRuntime().getMachineToken() : null); }
final String workspaceName = appContext.getWorkspace().getConfig().getName(); Promise<SshPairDto> sshPairDtoPromise = sshServiceClient.getPair("workspace", appContext.getWorkspaceId());
if (!errorMessage.isEmpty()) { WorkspaceImpl currentWorkspace = appContext.getWorkspace(); String workspaceName = currentWorkspace.getConfig().getName();
/** Start the current workspace with a default environment. */ Promise<Void> startWorkspace() { WorkspaceImpl workspace = appContext.getWorkspace(); String defEnvName = workspace.getConfig().getDefaultEnv(); return workspaceServiceClient .startById(workspace.getId(), defEnvName) .then( ws -> { ((AppContextImpl) appContext).setWorkspace(ws); eventBus.fireEvent(new WorkspaceStartingEvent()); }) .then((Function<WorkspaceImpl, Void>) arg -> null) .catchError( error -> { dialogFactory .createMessageDialog(messages.startWsErrorTitle(), error.getMessage(), null) .show(); wsStatusNotification.setError(STARTING_WORKSPACE_RUNTIME); startWorkspaceNotification.show(); }); }
constant.openDashboardUrlWorkspace(appContext.getWorkspace().getConfig().getName())); arrow.setAttribute("target", "_blank");