public static Comparator<ScriptDTO> nameComparator() { return (o1, o2) -> o1.getScriptName().compareToIgnoreCase(o2.getScriptName()); }
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] "); } } }
scriptDTOBuilder = new ScriptDTO.Builder(scriptDTOFromJsonFile); if (StringUtils.isBlank(scriptDTOFromJsonFile.getScriptName())) { scriptDTOBuilder.withScriptName(scriptDirectory.getName());
Button verbButton = new Button(verb.getScriptName()); verbButton.getStyleClass().addAll("toolButton"); verbButton.setStyle("-fx-background-image: url('" + verb.getIcon() + "');");
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()); }
/** * 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; }); }
/** * 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); } }