Search in sources :

Example 11 with DefaultMenuContribution

use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.

the class DefaultWindowMenuItemConfiguration method saveLayoutMenuItem.

@Bean
@Order(3997)
public SelectableMenuContribution saveLayoutMenuItem(MessagingService messagingService, QuerySaveFilenameService querySaveFilenameService, @Value("${tactview.homedirectory}") String homeDirectory, AlertDialogFactory alertDialogFactory) {
    return new DefaultMenuContribution(List.of(WINDOW_MENU_ITEM, "Save layout"), e -> {
        QuerySaveFileNameRequest request = QuerySaveFileNameRequest.builder().withInitialDirectory(homeDirectory).withTitle("Save layout file").build();
        Optional<String> optionalFileName = querySaveFilenameService.queryUserAboutFileName(request);
        if (optionalFileName.isPresent()) {
            try {
                String fileName = optionalFileName.get();
                if (!fileName.endsWith("." + TACTVIEW_LAYOUT_EXTENSION)) {
                    fileName += ("." + TACTVIEW_LAYOUT_EXTENSION);
                }
                DetachableTabPaneLoadModel data = dockableTabRepository.extractLoadModel();
                String result = objectMapper.writeValueAsString(data);
                try (FileOutputStream fos = new FileOutputStream(new File(fileName))) {
                    fos.write(result.getBytes(StandardCharsets.UTF_8));
                }
            } catch (Exception e1) {
                alertDialogFactory.showExceptionDialog("Unable to save layout", e1);
                LOGGER.error("Unable to save layout", e1);
            }
        }
    });
}
Also used : DefaultMenuContribution(com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution) FileOutputStream(java.io.FileOutputStream) DetachableTabPaneLoadModel(com.helospark.tactview.ui.javafx.tiwulfx.com.panemu.tiwulfx.control.DetachableTabPaneLoadModel) File(java.io.File) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) QuerySaveFileNameRequest(com.helospark.tactview.ui.javafx.save.QuerySaveFilenameService.QuerySaveFileNameRequest) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Example 12 with DefaultMenuContribution

use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.

the class DefaultEditMenuItemConfiguration method addChapterMenuItem.

@Bean
@Order(1950)
public SelectableMenuContribution addChapterMenuItem(AlertDialogFactory dialogFactory, TimelineState timelineState, MarkerRepository chapterRepository) {
    KeyCodeCombination combination = hotKeyRepository.registerOrGetHotKey("addChapter", new KeyCodeCombination(KeyCode.P, KeyCodeCombination.CONTROL_DOWN), "Add chapter").getCombination();
    return new DefaultMenuContribution(List.of(EDIT_ROOT, CHAPTER_ROOT, "Add chapter at current position"), event -> {
        TimelinePosition position = timelineState.getPlaybackPosition();
        Optional<String> result = dialogFactory.showTextInputDialog("Add chapter", "Label of the chapter", "Chapter x");
        if (result.isPresent()) {
            chapterRepository.addChapter(position, result.get());
        }
    }, combination);
}
Also used : DefaultMenuContribution(com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Example 13 with DefaultMenuContribution

use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.

the class DefaultEditMenuItemConfiguration method cutAllAtCurrentPositionMenuItem.

@Bean
@Order(1910)
public SelectableMenuContribution cutAllAtCurrentPositionMenuItem(AlertDialogFactory dialogFactory, TimelineState timelineState, UiCutHandler uiCutHandler) {
    String title = "Cut at current position";
    KeyCodeCombination combination = hotKeyRepository.registerOrGetHotKey("cutAllAtCurrentPosition", new KeyCodeCombination(KeyCode.K, KeyCodeCombination.CONTROL_DOWN), title).getCombination();
    return new DefaultMenuContribution(List.of(EDIT_ROOT, CUT_MENU_ITEM, title), event -> {
        uiCutHandler.cutAllAtCurrentPosition();
    }, combination);
}
Also used : DefaultMenuContribution(com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Example 14 with DefaultMenuContribution

use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.

the class DefaultEditMenuItemConfiguration method cutSelectedUntilCurrent.

@Bean
@Order(1911)
public SelectableMenuContribution cutSelectedUntilCurrent(AlertDialogFactory dialogFactory, TimelineState timelineState, UiCutHandler uiCutHandler) {
    String title = "Set selected startpoint";
    KeyCodeCombination combination = hotKeyRepository.registerOrGetHotKey("cutSelectedUntilCursor", new KeyCodeCombination(KeyCode.I, KeyCodeCombination.CONTROL_DOWN), title).getCombination();
    return new DefaultMenuContribution(List.of(EDIT_ROOT, CUT_MENU_ITEM, title), event -> {
        uiCutHandler.cutSelectedUntilCursor(true);
    }, combination);
}
Also used : DefaultMenuContribution(com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Example 15 with DefaultMenuContribution

use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.

the class DefaultEditMenuItemConfiguration method exportAsYoutubeChapterMenuItem.

@Bean
@Order(1952)
public SelectableMenuContribution exportAsYoutubeChapterMenuItem(MarkerRepository chapterRepository, AlertDialogFactory alertDialogFactory) {
    return new DefaultMenuContribution(List.of(EDIT_ROOT, CHAPTER_ROOT, "Show as Youtube chapter"), event -> {
        String result = "";
        String errors = "";
        int numberOfChapters = 0;
        TimelinePosition previousPosition = null;
        if (chapterRepository.getMarkers().get(TimelinePosition.ofZero()) == null) {
            result += "00:00 Intro\n";
            errors += "[WARN] No chapter is defined in position 00:00, added intro chapter at 0\n";
            previousPosition = TimelinePosition.ofZero();
            ++numberOfChapters;
        }
        for (var chapter : chapterRepository.getMarkers().entrySet()) {
            long allSeconds = chapter.getKey().getSeconds().longValue();
            long minutes = allSeconds / 60;
            long seconds = allSeconds % 60;
            result += (String.format("%02d:%02d %s\n", minutes, seconds, chapter.getValue()));
            ++numberOfChapters;
            if (previousPosition != null && chapter.getKey().subtract(previousPosition).isLessThan(10)) {
                errors += "[ERROR] Chapter at " + minutes + ":" + seconds + " is less than 10s from previous chapter which is unaccaptable by YouTube\n";
            }
            previousPosition = chapter.getKey();
        }
        if (numberOfChapters < 3) {
            errors += "[ERROR] Minimum 3 chapters needed by YouTube";
        }
        alertDialogFactory.showTextDialog("Youtube chapters", "Copy the below in your description to add chapters to Youtube", errors, result);
    });
}
Also used : DefaultMenuContribution(com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Aggregations

Bean (com.helospark.lightdi.annotation.Bean)19 Order (com.helospark.lightdi.annotation.Order)19 DefaultMenuContribution (com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution)19 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)14 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)9 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)3 ArrayList (java.util.ArrayList)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 GeneralMarker (com.helospark.tactview.core.timeline.marker.markers.GeneralMarker)2 InpointMarker (com.helospark.tactview.core.timeline.marker.markers.InpointMarker)2 OutpointMarker (com.helospark.tactview.core.timeline.marker.markers.OutpointMarker)2 DetachableTabPaneLoadModel (com.helospark.tactview.ui.javafx.tiwulfx.com.panemu.tiwulfx.control.DetachableTabPaneLoadModel)2 File (java.io.File)2 Configuration (com.helospark.lightdi.annotation.Configuration)1 ProjectRepository (com.helospark.tactview.core.repository.ProjectRepository)1 LinkClipRepository (com.helospark.tactview.core.timeline.LinkClipRepository)1 TimelineInterval (com.helospark.tactview.core.timeline.TimelineInterval)1 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)1 MarkerRepository (com.helospark.tactview.core.timeline.marker.MarkerRepository)1 ExposedDescriptorDescriptor (com.helospark.tactview.core.timeline.subtimeline.ExposedDescriptorDescriptor)1