private void updateVerbs(RepositoryDTO repositoryDTO) { this.verbsManager.fetchAvailableVerbs(repositoryDTO, verbs -> this.verbs = verbs); }
private void updateEngineTools(RepositoryDTO repositoryDTO) { this.engineToolsManager.fetchAvailableEngineTools(repositoryDTO, engineTools -> this.engineTools = engineTools); } }
/** * fetches the available versions of a certain engine * @param engineId engine ID (e.g. "wine") * @param callback callback which will be executed with the fetched engine versions * @param errorCallback callback which will be executed if an error occurs */ public void fetchAvailableVersions(String engineId, Consumer<List<EngineSubCategoryDTO>> callback, Consumer<Exception> errorCallback) { this.getEngine(engineId, engine -> callback.accept(unSerialize(engine.getAvailableVersions())), errorCallback); }
final String engineId = engineCategoryDTO.getName().toLowerCase(); this.enginesManager.fetchAvailableVersions(engineId, versions -> { this.versionsCache.put(engineId, versions); .withTitle(tr("Install {0}", engineDTO.getVersion())) .withMessage(tr("Are you sure you want to install {0}?", engineDTO.getVersion())) .withOwner(enginesView.getContent().getScene().getWindow()) .withResizable(true) .withYesCallback(() -> this.enginesManager.getEngine(engineDTO.getId(), engine -> { engine.install(engineDTO.getSubCategory(), engineDTO.getVersion()); this.versionsCache.remove(engineDTO.getId()); this.forceViewUpdate(); }, e -> Platform.runLater(() -> { .withTitle(tr("Delete {0}", engineDTO.getVersion())) .withMessage(tr("Are you sure you want to delete {0}?", engineDTO.getVersion())) .withOwner(enginesView.getContent().getScene().getWindow()) .withResizable(true) .withYesCallback(() -> this.enginesManager.getEngine(engineDTO.getId(), engine -> { engine.delete(engineDTO.getSubCategory(), engineDTO.getVersion()); this.versionsCache.remove(engineDTO.getId()); this.forceViewUpdate(); }, e -> Platform.runLater(() -> { if (this.enginesView.isSelected() && this.firstViewSelection) {
private void populateView(RepositoryDTO repositoryDTO, Map<String, Engine> engines) { this.repositoryCache = repositoryDTO; this.enginesCache = engines; // show a waiting screen until the engines are loaded Platform.runLater(enginesView::showWait); // fetch all categories consisting of engines that are contained in the repository final List<CategoryDTO> categoryDTOS = repositoryDTO.getTypes().stream() .filter(type -> type.getId().equals("engines")) .flatMap(type -> type.getCategories().stream()) .collect(Collectors.toList()); Platform.runLater(() -> { // generate the necessary css for the engine categories setDefaultEngineIcons(categoryDTOS); }); // fetch the engine categories objects contained in the engine categories final Queue<EngineCategoryDTO> engineCategories = new ArrayDeque<>( enginesManager.getAvailableEngines(categoryDTOS)); // insert the missing engine subcategories into the engine categories fetchEngineSubcategories(engineCategories, ImmutableMap.of(), subcategoryMap -> { final List<EngineCategoryDTO> categories = subcategoryMap.entrySet().stream() .map(entry -> new EngineCategoryDTO.Builder(entry.getKey()) .withSubCategories(entry.getValue()) .build()) .collect(Collectors.toList()); Platform.runLater(() -> { // update the view enginesView.populate(categories, engines); }); }); }
public void runInContainer(ContainerDTO container, String command, Runnable doneCallback, Consumer<Exception> errorCallback) { // TODO: better way to get engine ID final String engineId = container.getEngine().toLowerCase(); this.enginesManager.getEngine(engineId, engine -> { engine.setWorkingContainer(container.getName()); engine.run(command, new String[0], container.getPath(), false, true, new HashMap<>()); doneCallback.run(); }, errorCallback); } }
private void populate(List<EngineSetting> engineSettings) { final VBox displayPane = new VBox(); displayPane.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS); final GridPane displayContentPane = new GridPane(); displayContentPane.getStyleClass().add("grid"); int row = 0; for (EngineSetting setting : engineSettings) { final ComboBox<String> comboBox = new ComboBox<>(); comboBox.setMaxWidth(Double.MAX_VALUE); ObservableList<String> items = FXCollections.observableArrayList(setting.getOptions()); comboBox.setItems(items); comboBox.setValue(setting.getCurrentOption(this.container.getName())); comboBox.valueProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> { this.lockAll(); setting.setOption(this.container.getName(), items.indexOf(newValue)); this.unlockAll(); })); displayContentPane.add(new TextWithStyle(setting.getText(), CAPTION_TITLE_CSS_CLASS), 0, row); displayContentPane.add(comboBox, 1, row); lockableElements.add(comboBox); ++row; } Region spacer = new Region(); GridPane.setHgrow(spacer, Priority.ALWAYS); displayContentPane.add(spacer, 2, 0); displayPane.getChildren().addAll(displayContentPane); this.setContent(displayPane); }
@Bean public ContainersController containersController() { return new ContainersController(viewsConfiguration.viewContainers(), containersConfiguration.backgroundContainersManager(), containersConfiguration.containerEngineController(), repositoryConfiguration.repositoryManager(), enginesConfiguration.engineSettingsManager(), enginesConfiguration.verbsManager(), enginesConfiguration.engineToolsManager()); }
@Bean public ContainerEngineController containerEngineController() { return new ContainerEngineController(enginesConfiguration.enginesSource()); } }
@Bean public EngineToolsManager engineToolsManager() { return new EngineToolsManager(scriptsConfiguration.scriptInterpreter()); } }
@Bean public EngineSettingsManager engineSettingsManager() { return new EngineSettingsManager(scriptsConfiguration.scriptInterpreter()); }
@Bean public VerbsManager verbsManager() { return new VerbsManager(scriptsConfiguration.scriptInterpreter()); }
/** * fetches the available engine settings * @param repositoryDTO * @param callback * @param errorCallback callback which will be executed if an error occurs */ public void fetchAvailableEngineSettings(RepositoryDTO repositoryDTO, Consumer<Map<String, List<EngineSetting>>> callback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval(this.createFetchScript(repositoryDTO), output -> callback.accept((Map<String, List<EngineSetting>>) output), errorCallback); }
@Bean public EnginesManager enginesSource() { return new EnginesManager(scriptsConfiguration.scriptInterpreter(), phoenicisGlobalConfiguration.objectMapper()); }
/** * fetches the available engines * @param repositoryDTO * @param callback * @param errorCallback callback which will be executed if an error occurs */ public void fetchAvailableEngines(RepositoryDTO repositoryDTO, Consumer<Map<String, Engine>> callback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval(this.createFetchScript(repositoryDTO), output -> callback.accept((Map<String, Engine>) output), errorCallback); }
/** * runs a tool in a given container * @param engineId ID of the engine which provides the tool (e.g. "Wine") * @param container name of the container * @param toolId ID of the tool * @param doneCallback callback executed after the script ran * @param errorCallback callback executed in case of an error */ public void runTool(String engineId, String container, String toolId, Runnable doneCallback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval( "include([\"engines\", \"" + engineId + "\", \"tools\", \"" + toolId + "\"]);", ignored -> interactiveScriptSession.eval("new Tool()", output -> { final EngineTool toolObject = (EngineTool) output; toolObject.run(container); doneCallback.run(); }, errorCallback), errorCallback); }
/** * installs a Verb in a given container * @param engineId ID of the engine which provides the Verb (e.g. "Wine") * @param container name of the container * @param verbId ID of the Verb * @param doneCallback callback executed after the script ran * @param errorCallback callback executed in case of an error */ public void installVerb(String engineId, String container, String verbId, Runnable doneCallback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval( "include([\"engines\", \"" + engineId + "\", \"verbs\", \"" + verbId + "\"]);", ignored -> interactiveScriptSession.eval("new Verb()", output -> { final Verb verbObject = (Verb) output; verbObject.install(container); doneCallback.run(); }, errorCallback), errorCallback); }
private void updateEngineSettings(RepositoryDTO repositoryDTO) { this.engineSettingsManager.fetchAvailableEngineSettings(repositoryDTO, engineSettings -> Platform.runLater(() -> this.engineSettings = engineSettings), e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Loading engine tools failed.")) .withException(e) .withOwner(this.containersView.getContent().getScene().getWindow()) .build(); errorDialog.showAndWait(); })); }
/** * Constructor * * @param control The control belonging to the skin */ public ContainerEngineToolsPanelSkin(ContainerEngineToolsPanel control) { super(control); // map the tool scripts to a tool button this.toolButtons = new MappedList<>(control.getEngineToolScripts(), tool -> { final Button toolButton = new Button(tool.getScriptName()); toolButton.getStyleClass().addAll("toolButton"); toolButton.setStyle("-fx-background-image: url('" + tool.getIcon() + "');"); toolButton.disableProperty().bind(getControl().lockToolsProperty()); toolButton.setOnMouseClicked(event -> { getControl().setLockTools(true); final ContainerDTO container = getControl().getContainer(); // TODO: find a better way to get the engine ID getControl().getEngineToolsManager().runTool(container.getEngine().toLowerCase(), container.getName(), tool.getId(), () -> getControl().setLockTools(false), e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error")) .withException(e) .build(); errorDialog.showAndWait(); })); }); return toolButton; }); }
@Bean public EnginesController enginesController() { return new EnginesController(viewsConfiguration.viewEngines(), repositoryConfiguration.repositoryManager(), enginesConfiguration.enginesSource(), themeConfiguration.themeManager()); }