Search in sources :

Example 11 with Repository

use of org.phoenicis.repository.types.Repository in project phoenicis 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 12 with Repository

use of org.phoenicis.repository.types.Repository in project phoenicis 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;
}
Also used : Repository(org.phoenicis.repository.types.Repository) MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) File(java.io.File) GitRepositoryLocation(org.phoenicis.repository.location.GitRepositoryLocation) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) ClasspathRepositoryLocation(org.phoenicis.repository.location.ClasspathRepositoryLocation) URL(java.net.URL) ClasspathRepositoryLocation(org.phoenicis.repository.location.ClasspathRepositoryLocation)

Example 13 with Repository

use of org.phoenicis.repository.types.Repository in project phoenicis 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)

Example 14 with Repository

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

the class RepositoriesPanelSkin method createRepositoryLocationTable.

/**
 * Creates a {@link TableView} containing the {@link RepositoryLocation} objects
 *
 * @return A {@link TableView} containing the {@link RepositoryLocation} objects
 */
private TableView<RepositoryLocation<? extends Repository>> createRepositoryLocationTable() {
    final TableView<RepositoryLocation<? extends Repository>> repositoryLocationTable = new TableView<>();
    repositoryLocationTable.getStyleClass().add("repositories-table");
    // add the priority column
    repositoryLocationTable.getColumns().add(createColumn(tr("Priority"), repositoryLocation -> getControl().getRepositoryLocations().indexOf(repositoryLocation) + 1));
    // add the repository name column
    repositoryLocationTable.getColumns().add(createColumn(tr("Repository name"), RepositoryLocation::toDisplayString));
    repositoryLocationTable.setRowFactory(tv -> {
        final TableRow<RepositoryLocation<? extends Repository>> row = new TableRow<>();
        row.getStyleClass().add("repository-row");
        final Tooltip repositoryLocationTooltip = new Tooltip(tr("Move the repository up or down to change its priority"));
        // ensure that the tooltip is only shown for non empty rows
        row.emptyProperty().addListener((Observable invalidation) -> {
            if (row.isEmpty()) {
                Tooltip.uninstall(row, repositoryLocationTooltip);
            } else {
                Tooltip.install(row, repositoryLocationTooltip);
            }
        });
        row.setOnDragDetected(event -> {
            if (!row.isEmpty()) {
                final int index = row.getIndex();
                final Dragboard dragboard = row.startDragAndDrop(TransferMode.MOVE);
                // create a preview image
                final RepositoryLocation<? extends Repository> repositoryLocation = getControl().getRepositoryLocations().get(index);
                dragboard.setDragView(createPreviewImage(repositoryLocation));
                // save the dragged repository index
                final ClipboardContent content = new ClipboardContent();
                content.put(repositoryLocationFormat, index);
                dragboard.setContent(content);
                event.consume();
            }
        });
        row.setOnDragOver(event -> {
            final Dragboard dragboard = event.getDragboard();
            if (dragboard.hasContent(repositoryLocationFormat) && row.getIndex() != (Integer) dragboard.getContent(repositoryLocationFormat)) {
                event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
                event.consume();
            }
        });
        row.setOnDragDropped(event -> {
            final Dragboard dragboard = event.getDragboard();
            if (dragboard.hasContent(repositoryLocationFormat)) {
                final int draggedIndex = (Integer) dragboard.getContent(repositoryLocationFormat);
                final List<RepositoryLocation<? extends Repository>> workingCopy = new ArrayList<>(getControl().getRepositoryLocations());
                final RepositoryLocation<? extends Repository> draggedRepositoryLocation = workingCopy.remove(draggedIndex);
                final int dropIndex = row.isEmpty() ? workingCopy.size() : row.getIndex();
                workingCopy.add(dropIndex, draggedRepositoryLocation);
                getControl().getRepositoryLocations().setAll(workingCopy);
                event.setDropCompleted(true);
                event.consume();
            }
        });
        return row;
    });
    Bindings.bindContent(repositoryLocationTable.getItems(), getControl().getRepositoryLocations());
    return repositoryLocationTable;
}
Also used : Scene(javafx.scene.Scene) Repository(org.phoenicis.repository.types.Repository) javafx.scene.control(javafx.scene.control) SnapshotParameters(javafx.scene.SnapshotParameters) VBox(javafx.scene.layout.VBox) Bindings(javafx.beans.binding.Bindings) Function(java.util.function.Function) TransferMode(javafx.scene.input.TransferMode) RepositoriesPanel(org.phoenicis.javafx.components.setting.control.RepositoriesPanel) ArrayList(java.util.ArrayList) Dragboard(javafx.scene.input.Dragboard) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) SkinBase(org.phoenicis.javafx.components.common.skin.SkinBase) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) Group(javafx.scene.Group) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) Priority(javafx.scene.layout.Priority) ActionEvent(javafx.event.ActionEvent) AddRepositoryDialog(org.phoenicis.javafx.views.mainwindow.settings.addrepository.AddRepositoryDialog) List(java.util.List) DataFormat(javafx.scene.input.DataFormat) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SimpleConfirmDialog(org.phoenicis.javafx.dialogs.SimpleConfirmDialog) Optional(java.util.Optional) ClipboardContent(javafx.scene.input.ClipboardContent) Image(javafx.scene.image.Image) ClipboardContent(javafx.scene.input.ClipboardContent) ArrayList(java.util.ArrayList) RepositoryLocation(org.phoenicis.repository.location.RepositoryLocation) Observable(javafx.beans.Observable) Repository(org.phoenicis.repository.types.Repository) Dragboard(javafx.scene.input.Dragboard)

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