Search in sources :

Example 6 with Repository

use of org.phoenicis.repository.types.Repository in project POL-POM-5 by PlayOnLinux.

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 {
        result.addAll(getDefaultRepositoryLocations());
    }
    return result;
}
Also used : Repository(org.phoenicis.repository.types.Repository) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) GitRepositoryLocation(org.phoenicis.repository.location.GitRepositoryLocation) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) ClasspathRepositoryLocation(org.phoenicis.repository.location.ClasspathRepositoryLocation)

Example 7 with Repository

use of org.phoenicis.repository.types.Repository in project POL-POM-5 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);
}
Also used : Pos(javafx.geometry.Pos) javafx.scene.layout(javafx.scene.layout) Repository(org.phoenicis.repository.types.Repository) javafx.scene.control(javafx.scene.control) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) RepositoryManager(org.phoenicis.repository.RepositoryManager) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) ActionEvent(javafx.event.ActionEvent) AddRepositoryDialog(org.phoenicis.javafx.views.mainwindow.settings.addrepository.AddRepositoryDialog) Insets(javafx.geometry.Insets) SettingsManager(org.phoenicis.settings.SettingsManager) VPos(javafx.geometry.VPos) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) ActionEvent(javafx.event.ActionEvent) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) Repository(org.phoenicis.repository.types.Repository) AddRepositoryDialog(org.phoenicis.javafx.views.mainwindow.settings.addrepository.AddRepositoryDialog)

Example 8 with Repository

use of org.phoenicis.repository.types.Repository in project POL-POM-5 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();
    });
}
Also used : Repository(org.phoenicis.repository.types.Repository) ClipboardContent(javafx.scene.input.ClipboardContent) ArrayList(java.util.ArrayList) Dragboard(javafx.scene.input.Dragboard) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation)

Example 9 with Repository

use of org.phoenicis.repository.types.Repository in project POL-POM-5 by PhoenicisOrg.

the class DragableRepositoryListCell method updateItem.

@Override
protected void updateItem(RepositoryLocation<? extends Repository> item, boolean empty) {
    super.updateItem(item, empty);
    if (!empty) {
        ObservableList<RepositoryLocation<? extends Repository>> repositories = getListView().getItems();
        GridPane itemPane = new GridPane();
        Label indexLabel = new Label(String.valueOf(repositories.size() - repositories.indexOf(item)));
        indexLabel.setPrefWidth(50);
        Label repositoryLocationLabel = new Label(item.toDisplayString());
        itemPane.add(indexLabel, 0, 0);
        itemPane.add(repositoryLocationLabel, 1, 0);
        setGraphic(itemPane);
    } else {
        setGraphic(null);
    }
}
Also used : Repository(org.phoenicis.repository.types.Repository) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation)

Example 10 with Repository

use of org.phoenicis.repository.types.Repository in project POL-POM-5 by PhoenicisOrg.

the class PhoenicisTestsApp method run.

private void run(String[] args) {
    try (final ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(PhoenicisTestsConfiguration.class)) {
        final Repository repository = applicationContext.getBean("mockedRepository", Repository.class);
        this.applicationContext = applicationContext;
        repository.fetchInstallableApplications(repositoryDTO -> {
            repositoryDTO.getTypes().get(0).getCategories().forEach(this::testCategory);
        }, e -> {
            throw new IllegalStateException(e);
        });
        applicationContext.getBean(ControlledThreadPoolExecutorServiceCloser.class).close();
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ControlledThreadPoolExecutorServiceCloser(org.phoenicis.multithreading.ControlledThreadPoolExecutorServiceCloser) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Repository(org.phoenicis.repository.types.Repository)

Aggregations

Repository (org.phoenicis.repository.types.Repository)14 RepositoryLocation (org.phoenicis.repository.location.RepositoryLocation)12 ArrayList (java.util.ArrayList)6 ActionEvent (javafx.event.ActionEvent)4 Text (javafx.scene.text.Text)4 AddRepositoryDialog (org.phoenicis.javafx.views.mainwindow.settings.addrepository.AddRepositoryDialog)4 File (java.io.File)3 IOException (java.io.IOException)3 Optional (java.util.Optional)3 Platform (javafx.application.Platform)3 javafx.scene.control (javafx.scene.control)3 ClipboardContent (javafx.scene.input.ClipboardContent)3 Dragboard (javafx.scene.input.Dragboard)3 HBox (javafx.scene.layout.HBox)3 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)3 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 FXCollections (javafx.collections.FXCollections)2 ObservableList (javafx.collections.ObservableList)2