use of org.phoenicis.repository.types.Repository in project POL-POM-5 by PhoenicisOrg.
the class FilesystemJsonRepositoryLocationLoader method loadRepositoryLocations.
@Override
public List<RepositoryLocation<? extends Repository>> loadRepositoryLocations() {
List<RepositoryLocation<? extends Repository>> result = new ArrayList<>();
File repositoryListFile = new File(repositoryListPath);
if (repositoryListFile.exists()) {
try {
result = this.objectMapper.readValue(new File(repositoryListPath), TypeFactory.defaultInstance().constructParametricType(List.class, RepositoryLocation.class));
} catch (IOException e) {
LOGGER.error("Couldn't load repository location list", e);
}
} else {
try {
result.add(new GitRepositoryLocation.Builder().withGitRepositoryUri(new URL("https://github.com/PhoenicisOrg/Scripts").toURI()).withBranch("master").build());
result.add(new ClasspathRepositoryLocation("/org/phoenicis/repository"));
} catch (URISyntaxException | MalformedURLException e) {
LOGGER.error("Couldn't create default repository location list", e);
}
}
return result;
}
use of org.phoenicis.repository.types.Repository in project phoenicis by PhoenicisOrg.
the class DragableRepositoryListCell method changed.
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) {
setOnDragDetected(event -> {
if (getItem() == null) {
return;
}
Dragboard dragboard = startDragAndDrop(TransferMode.MOVE);
ClipboardContent content = new ClipboardContent();
content.putString(Integer.toString(getIndex()));
dragboard.setContent(content);
event.consume();
});
setOnDragOver(event -> {
event.acceptTransferModes(TransferMode.MOVE);
event.consume();
});
setOnDragEntered(event -> {
setOpacity(0.3);
});
setOnDragExited(event -> {
setOpacity(1);
});
setOnDragDropped(event -> {
if (getItem() == null) {
return;
}
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasString()) {
ObservableList<RepositoryLocation<? extends Repository>> items = getListView().getItems();
int draggedIdx = Integer.parseInt(db.getString());
int thisIdx = items.indexOf(getItem());
RepositoryLocation<? extends Repository> draggedItem = items.get(draggedIdx);
items.set(draggedIdx, getItem());
items.set(thisIdx, draggedItem);
List<RepositoryLocation<? extends Repository>> itemscopy = new ArrayList<>(getListView().getItems());
getListView().getItems().setAll(itemscopy);
success = true;
}
event.setDropCompleted(success);
event.consume();
});
setOnDragDone(event -> {
onDragDone.accept(getItem(), newValue);
event.consume();
});
}
use of org.phoenicis.repository.types.Repository in project phoenicis by PhoenicisOrg.
the class RepositoriesPanel method populateRepositoryGrid.
private void populateRepositoryGrid() {
this.title = new TextWithStyle(tr("Repositories Settings"), "title");
this.repositoryGrid = new GridPane();
this.repositoryGrid.getStyleClass().add("grid");
this.repositoryText = new TextWithStyle(tr("Repository:"), "captionTitle");
this.repositoryLayout = new VBox();
this.repositoryLayout.setSpacing(5);
this.repositoryListView = new ListView<>(repositories);
this.repositoryListView.setPrefHeight(0);
this.repositoryListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
this.repositoryListView.setEditable(true);
this.repositoryListView.setCellFactory(param -> new DragableRepositoryListCell((repositoryUrl, toIndex) -> {
this.repositoryManager.moveRepository(repositoryUrl, toIndex.intValue());
this.save();
}));
this.repositoryButtonLayout = new HBox();
this.repositoryButtonLayout.setSpacing(5);
this.addButton = new Button();
this.addButton.setText(tr("Add"));
this.addButton.setOnAction((ActionEvent event) -> {
AddRepositoryDialog dialog = new AddRepositoryDialog();
dialog.initOwner(this.getParent().getScene().getWindow());
Optional<RepositoryLocation<? extends Repository>> successResult = dialog.showAndWait();
successResult.ifPresent(repositoryLocation -> {
repositories.add(repositoryLocation);
this.save();
repositoryManager.addRepositories(0, repositoryLocation);
});
});
this.removeButton = new Button();
this.removeButton.setText(tr("Remove"));
this.removeButton.setOnAction((ActionEvent event) -> {
RepositoryLocation<? extends Repository>[] toRemove = repositoryListView.getSelectionModel().getSelectedItems().toArray(new RepositoryLocation[0]);
repositories.removeAll(toRemove);
this.save();
repositoryManager.removeRepositories(toRemove);
});
this.repositoryButtonLayout.getChildren().addAll(addButton, removeButton);
this.repositoryLayout.getChildren().addAll(repositoryListView, repositoryButtonLayout);
VBox.setVgrow(repositoryListView, Priority.ALWAYS);
this.repositoryGrid.add(repositoryText, 0, 0);
this.repositoryGrid.add(repositoryLayout, 1, 0);
GridPane.setHgrow(repositoryLayout, Priority.ALWAYS);
GridPane.setVgrow(repositoryLayout, Priority.ALWAYS);
GridPane.setValignment(repositoryText, VPos.TOP);
}
use of org.phoenicis.repository.types.Repository in project POL-POM-5 by PlayOnLinux.
the class RepositoriesPanelSkin method initialise.
/**
* {@inheritDoc}
*/
@Override
public void initialise() {
final Text title = new Text(tr("Repository Settings"));
title.getStyleClass().add("title");
final TableView<RepositoryLocation<? extends Repository>> repositoryLocationTable = createRepositoryLocationTable();
VBox.setVgrow(repositoryLocationTable, Priority.ALWAYS);
final HBox repositoryButtons = createRepositoryButtons(repositoryLocationTable);
final HBox refreshContainer = createRefreshButtonContainer();
final VBox container = new VBox(title, repositoryLocationTable, repositoryButtons, refreshContainer);
container.getStyleClass().addAll("settings-tab", "repositories-panel");
getChildren().addAll(container);
}
use of org.phoenicis.repository.types.Repository in project POL-POM-5 by PlayOnLinux.
the class RepositoriesPanelSkin method createRepositoryButtons.
/**
* Creates a new container for the repository buttons.
* These buttons consist of:
* - an add button
* - a delete button
* - a restore defaults button
*
* @param repositoryLocationTable The repository location table
* @return A new container for the repository buttons
*/
private HBox createRepositoryButtons(TableView<RepositoryLocation<? extends Repository>> repositoryLocationTable) {
final Button addButton = new Button(tr("Add"));
addButton.getStyleClass().add("repositories-add");
addButton.setOnAction((ActionEvent event) -> {
final AddRepositoryDialog dialog = new AddRepositoryDialog();
dialog.initOwner(getControl().getScene().getWindow());
final Optional<RepositoryLocation<? extends Repository>> successResult = dialog.showAndWait();
successResult.ifPresent(repositoryLocation -> getControl().getRepositoryLocations().add(0, repositoryLocation));
});
final Button removeButton = new Button(tr("Remove"));
removeButton.getStyleClass().add("repositories-remove");
removeButton.setOnAction((ActionEvent event) -> {
final List<RepositoryLocation<? extends Repository>> toRemove = repositoryLocationTable.getSelectionModel().getSelectedItems();
getControl().getRepositoryLocations().removeAll(toRemove);
});
final Button restoreDefault = new Button(tr("Restore defaults"));
restoreDefault.getStyleClass().add("repositories-restore");
restoreDefault.setOnAction(event -> {
final SimpleConfirmDialog dialog = SimpleConfirmDialog.builder().withTitle(tr("Restore default repositories")).withMessage(tr("Are you sure you want to restore the default repositories?")).withYesCallback(() -> Platform.runLater(() -> getControl().getRepositoryLocations().setAll(getControl().getRepositoryLocationLoader().getDefaultRepositoryLocations()))).withOwner(getControl().getScene().getWindow()).withResizable(true).build();
dialog.showAndCallback();
});
final HBox container = new HBox(addButton, removeButton, restoreDefault);
container.getStyleClass().add("repositories-buttons-container");
return container;
}
Aggregations