public Builder(ScriptDTO scriptDTO) { this.withTypeId(scriptDTO.getTypeId()) .withCategoryId(scriptDTO.getCategoryId()) .withApplicationId(scriptDTO.getApplicationId()) .withId(scriptDTO.getId()) .withScriptName(scriptDTO.getScriptName()) .withScript(scriptDTO.getScript()) .withCompatibleOperatingSystems(scriptDTO.getCompatibleOperatingSystems()) .withTestingOperatingSystems(scriptDTO.getTestingOperatingSystems()) .withFree(scriptDTO.isFree()) .withRequiresPatch(scriptDTO.requiresPatch) .withIcon(scriptDTO.getIcon()); }
private void testScript(CategoryDTO categoryDTO, ApplicationDTO applicationDTO, ScriptDTO scriptDTO) { final ScriptInterpreter scriptInterpreter = applicationContext.getBean("nashornInterprpeter", ScriptInterpreter.class); System.out.print("| |-- " + scriptDTO.getScriptName()); try { scriptInterpreter.runScript(scriptDTO.getScript(), e -> { throw new TestException(e); }); System.out.println(" [OK] "); } catch (TestException e) { e.printStackTrace(); System.out.println(" [KO] "); } } }
executeBuilder.append(String.format("TYPE_ID=\"%s\";\n", script.getTypeId())); executeBuilder.append(String.format("CATEGORY_ID=\"%s\";\n", script.getCategoryId())); executeBuilder.append(String.format("APPLICATION_ID=\"%s\";\n", script.getApplicationId())); executeBuilder.append(String.format("SCRIPT_ID=\"%s\";\n", script.getId())); executeBuilder.append(script.getScript()); executeBuilder.append("\n");
Button verbButton = new Button(verb.getScriptName()); verbButton.getStyleClass().addAll("toolButton"); verbButton.setStyle("-fx-background-image: url('" + verb.getIcon() + "');"); verbButton.setOnMouseClicked(event -> { this.lockAll(); this.verbsManager.installVerb(container.getEngine().toLowerCase(), container.getName(), verb.getId(), this::unlockAll, e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder()
result &= script.isFree(); result &= !script.isRequiresPatch(); result &= CollectionUtils.isEmpty(script.getTestingOperatingSystems()); result &= Optional.ofNullable(script.getCompatibleOperatingSystems()) .map(compatibleOperatingSystems -> compatibleOperatingSystems .contains(operatingSystemFetcher.fetchCurrentOperationSystem()))
public String getScript(List<String> path) { final ScriptDTO script = repositoryManager.getScript(path); if (script == null) { throw new ScriptException("Script not found: " + path); } return script.getScript(); }
public static Comparator<ScriptDTO> nameComparator() { return (o1, o2) -> o1.getScriptName().compareToIgnoreCase(o2.getScriptName()); }
/** * fetches the ScriptDTO for a given path (e.g. ["Applications", "Development", "Notepad++", "Online"]) * @param path path in the JS namespace * @return ScriptDTO */ default ScriptDTO getScript(List<String> path) { final String wantedId = path.get(3); final ApplicationDTO applicationDTO = getApplication(path); if (applicationDTO != null) { for (ScriptDTO scriptDTO : applicationDTO.getScripts()) { if (wantedId.equals(scriptDTO.getId())) { return scriptDTO; } } } LOGGER.error(String.format("Could not find ScriptDTO with ID \"%s\"", wantedId)); return null; }
/** * Refreshes the shown scripts. * When this method is called it begins by clearing the <code>scriptGrid</code>. * Afterwards this method refills it. */ private void updateScripts(final GridPane scriptGrid) { scriptGrid.getChildren().clear(); for (int i = 0; i < filteredScripts.size(); i++) { ScriptDTO script = filteredScripts.get(i); final Label scriptName = new Label(script.getScriptName()); GridPane.setHgrow(scriptName, Priority.ALWAYS); if (getControl().isShowScriptSource()) { final Tooltip tooltip = new Tooltip(tr("Source: {0}", script.getScriptSource())); Tooltip.install(scriptName, tooltip); } final Button installButton = new Button(tr("Install")); installButton.setOnMouseClicked(evt -> { try { installScript(script); } catch (IllegalArgumentException e) { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error while trying to download the installer")) .withException(e) .build(); errorDialog.showAndWait(); } }); scriptGrid.addRow(i, scriptName, installButton); } }
/** * 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; }); }
@Option @LongSwitch("install") @ShortSwitch("i") @AllAvailableArguments public void installApp(List<String> arguments) { final String typeName = arguments.get(0); final String categoryName = arguments.get(1); final String appName = arguments.get(2); final String scriptName = arguments.get(3); final ScriptDTO scriptDTO = repositoryManager .getScript(Arrays.asList(typeName, categoryName, appName, scriptName)); scriptInterpreter.runScript(scriptDTO.getScript(), Throwable::printStackTrace); }
scriptDTOBuilder = new ScriptDTO.Builder(scriptDTOFromJsonFile); if (StringUtils.isBlank(scriptDTOFromJsonFile.getScriptName())) { scriptDTOBuilder.withScriptName(scriptDirectory.getName());
if (applicationDTO.getId().equals("settings")) { for (ScriptDTO scriptDTO : applicationDTO.getScripts()) { script.append("include([\"engines\", \"" + engineId + "\", \"settings\", \"" + scriptDTO.getId() + "\"]);\n"); script.append("if (!(\"" + engineId + "\" in settings))\n");