use of org.phoenicis.containers.dto.ContainerDTO in project phoenicis by PhoenicisOrg.
the class WinePrefixContainerController method runInContainer.
public void runInContainer(ContainerDTO container, String command, Runnable doneCallback, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Engines\", \"" + container.getEngine() + "\", \"Engine\", \"Object\"]);", ignored -> interactiveScriptSession.eval("new " + container.getEngine() + "()", output -> {
final ScriptObjectMirror wine = (ScriptObjectMirror) output;
wine.callMember("prefix", container.getName());
wine.callMember("run", command);
wine.callMember("wait");
doneCallback.run();
}, errorCallback), errorCallback);
}
use of org.phoenicis.containers.dto.ContainerDTO in project POL-POM-5 by PlayOnLinux.
the class ContainerVerbsPanelSkin method createVerbManagementButtons.
/**
* Creates a container with the buttons for the verb selection management. These buttons consist of:
* - a button to install all selected verbs
* - a button to clear/reset the selection
*
* @param verbs The {@link GridPane} containing the visual verb installation components
* @return A container with the buttons for the verb selection management
*/
private HBox createVerbManagementButtons(final GridPane verbs) {
final Button installButton = new Button(tr("Install selected"));
installButton.disableProperty().bind(getControl().lockVerbsProperty());
installButton.setOnAction(event -> {
getControl().setLockVerbs(true);
final ContainerDTO container = getControl().getContainer();
// find the ids of all selected verbs
final List<ScriptDTO> installationVerbs = verbs.getChildren().stream().filter(element -> element instanceof CheckBox && ((CheckBox) element).isSelected()).map(GridPane::getRowIndex).map(getControl().getVerbScripts()::get).collect(Collectors.toList());
final List<String> verbNames = installationVerbs.stream().map(ScriptDTO::getScriptName).collect(Collectors.toList());
final ListConfirmDialog confirmDialog = ListConfirmDialog.builder().withTitle(tr("Install Verbs")).withMessage(tr("Are you sure you want to install the following Verbs:")).withConfirmItems(verbNames).withOwner(getControl().getScene().getWindow()).withYesCallback(() -> {
final List<String> verbIds = installationVerbs.stream().map(ScriptDTO::getId).collect(Collectors.toList());
// install the selected verbs
getControl().getVerbsManager().installVerbs(container.getEngine().toLowerCase(), container.getName(), verbIds, () -> getControl().setLockVerbs(false), e -> Platform.runLater(() -> {
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error installing Verbs")).withException(e).build();
errorDialog.showAndWait();
}));
}).build();
confirmDialog.showAndCallback();
// after the dialog has been closed unlock the verb buttons
getControl().setLockVerbs(false);
});
final Button clearButton = new Button(tr("Clear selection"));
clearButton.disableProperty().bind(getControl().lockVerbsProperty());
clearButton.setOnAction(event -> verbs.getChildren().stream().filter(element -> element instanceof CheckBox).map(element -> (CheckBox) element).forEach(verbCheckBox -> verbCheckBox.setSelected(false)));
return new HBox(installButton, clearButton);
}
use of org.phoenicis.containers.dto.ContainerDTO in project POL-POM-5 by PlayOnLinux.
the class ContainerToolsPanelSkin method createToolsContainer.
/**
* Creates the container for the tool buttons
*
* @return The container with the tool buttons
*/
private TilePane createToolsContainer() {
final TilePane toolsContainer = new TilePane();
final Button runExecutable = new Button(tr("Run executable"));
runExecutable.getStyleClass().addAll("toolButton", "runExecutable");
runExecutable.setOnMouseClicked(event -> {
getControl().setLockTools(true);
final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(tr("Choose executable..."));
// open in container directory if it exists
final File containerDir = new File(getControl().getContainer().getPath());
if (containerDir.canRead()) {
fileChooser.setInitialDirectory(containerDir);
}
final File file = fileChooser.showOpenDialog(getControl().getScene().getWindow());
if (file != null) {
final ContainerDTO container = getControl().getContainer();
final String engineId = container.getEngine().toLowerCase();
getControl().getEnginesManager().getEngine(engineId, engine -> {
engine.setWorkingContainer(container.getName());
engine.run(file.getAbsolutePath(), new String[0], container.getPath(), false, true, new HashMap<>());
getControl().setLockTools(false);
}, exception -> Platform.runLater(() -> {
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error")).withOwner(getControl().getScene().getWindow()).withException(exception).build();
errorDialog.showAndWait();
}));
} else {
// unlock if file chooser is closed
getControl().setLockTools(false);
}
});
toolsContainer.getChildren().add(runExecutable);
return toolsContainer;
}
use of org.phoenicis.containers.dto.ContainerDTO in project POL-POM-5 by PlayOnLinux.
the class ContainersFeaturePanelSkin method updateEngineTools.
/**
* Applies the engine tools belonging to the currently selected container to the given
* {@link ContainerInformationPanel}
*
* @param containerInformationPanel The information panel showing the details for the currently selected container
*/
private void updateEngineTools(final ContainerInformationPanel containerInformationPanel) {
final ObservableMap<String, ApplicationDTO> engineTools = getControl().getEngineTools();
final ContainerDTO container = containerInformationPanel.getContainer();
if (container != null && engineTools.containsKey(container.getEngine().toLowerCase())) {
containerInformationPanel.setEngineTools(engineTools.get(container.getEngine().toLowerCase()));
} else {
containerInformationPanel.setEngineTools(null);
}
}
use of org.phoenicis.containers.dto.ContainerDTO in project POL-POM-5 by PlayOnLinux.
the class ContainersFeaturePanelSkin method createContent.
/**
* {@inheritDoc}
*/
@Override
public ObjectExpression<Node> createContent() {
/*
* initialize the container lists by:
* 1. sorting the containers by their name
* 2. filtering the containers
*/
final FilteredList<ContainerDTO> filteredContainers = ConcatenatedList.create(new MappedList<>(getControl().getCategories().sorted(Comparator.comparing(ContainerCategoryDTO::getName)), ContainerCategoryDTO::getContainers)).sorted(Comparator.comparing(ContainerDTO::getName)).filtered(getControl().getFilter()::filter);
filteredContainers.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty()));
final ObservableList<ListWidgetElement<ContainerDTO>> listWidgetEntries = new MappedList<>(filteredContainers, ListWidgetElement::create);
final CombinedListWidget<ContainerDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
// bind direction: controller property -> skin property
getControl().selectedContainerProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
combinedListWidget.select(newValue);
} else {
combinedListWidget.deselect();
}
});
// bind direction: skin property -> controller properties
combinedListWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
final ContainerDTO selectedItem = newValue.getItem();
getControl().setSelectedContainer(selectedItem);
getControl().setOpenedDetailsPanel(new ContainerInformation(selectedItem));
} else {
getControl().setSelectedContainer(null);
getControl().setOpenedDetailsPanel(new None());
}
});
return new SimpleObjectProperty<>(combinedListWidget);
}
Aggregations