Search in sources :

Example 16 with Bean

use of com.helospark.lightdi.annotation.Bean in project tactview by helospark.

the class DefaultFileMenuItemConfiguration method exitContributionMenuItem.

@Bean
@Order(200)
public SelectableMenuContribution exitContributionMenuItem(ExitWithSaveService exitWithSaveService) {
    KeyCodeCombination combination = hotKeyRepository.registerOrGetHotKey("quit", new KeyCodeCombination(KeyCode.Q, KeyCodeCombination.CONTROL_DOWN), "Exit").getCombination();
    return new DefaultMenuContribution(List.of(FILE_ROOT, "E_xit"), event -> {
        exitWithSaveService.optionallySaveAndThenRun(() -> {
            Platform.exit();
            System.exit(0);
        });
    }, 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 17 with Bean

use of com.helospark.lightdi.annotation.Bean in project tactview by helospark.

the class DefaultViewMenuItemConfiguration method fullScreenWindowContributionMenuItem.

@Bean
@Order(1800)
public SelectableMenuContribution fullScreenWindowContributionMenuItem(MessagingService messagingService) {
    return new DefaultMenuContribution(List.of(VIEW_ROOT, "Full screen"), e -> {
        stage.setFullScreen(true);
        stage.setFullScreenExitHint("Hit escape to exit fullscreen");
        stage.setFullScreenExitKeyCombination(new KeyCodeCombination(KeyCode.ESCAPE));
    });
}
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 18 with Bean

use of com.helospark.lightdi.annotation.Bean 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 19 with Bean

use of com.helospark.lightdi.annotation.Bean in project tactview by helospark.

the class StandardEffectContextMenuChainItemConfiguration method moveDownItem.

@Bean
@Order(91)
public EffectContextMenuChainItem moveDownItem(UiCommandInterpreterService commandInterpreter, TimelineManagerAccessor timelineManager) {
    return alwaysSupportedContextMenuItem(request -> {
        MenuItem moveDownClip = new MenuItem("Move down");
        int index = timelineManager.findEffectChannel(request.getEffect().getId());
        int numberOfEffectChannels = timelineManager.getNumberOfEffectChannels(request.getEffect().getId()) - 1;
        System.out.println("Down index: " + index + " " + numberOfEffectChannels);
        if (index >= numberOfEffectChannels) {
            moveDownClip.setDisable(true);
        } else {
            moveDownClip.setOnAction(e -> commandInterpreter.sendWithResult(new MoveEffectToChannelCommand(timelineManager, request.getEffect().getId(), index + 1)));
        }
        return moveDownClip;
    });
}
Also used : MoveEffectToChannelCommand(com.helospark.tactview.ui.javafx.commands.impl.MoveEffectToChannelCommand) MenuItem(javafx.scene.control.MenuItem) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Example 20 with Bean

use of com.helospark.lightdi.annotation.Bean in project tactview by helospark.

the class StandardEffectContextMenuChainItemConfiguration method maximizeMenuItem.

@Bean
@Order(120)
public EffectContextMenuChainItem maximizeMenuItem(ExtendsClipToMaximizeLengthService extendsClipToMaximizeLengthService, TimelineManagerAccessor timelineManager) {
    return alwaysSupportedContextMenuItem(request -> {
        MenuItem maximizeClipMenuItem = new MenuItem("Maximize");
        timelineManager.findClipForEffect(request.getEffect().getId()).ifPresent(clip -> {
            maximizeClipMenuItem.setOnAction(e -> extendsClipToMaximizeLengthService.extendEffectToClipSize(clip.getId(), request.getEffect()));
        });
        return maximizeClipMenuItem;
    });
}
Also used : MenuItem(javafx.scene.control.MenuItem) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Aggregations

Bean (com.helospark.lightdi.annotation.Bean)43 Order (com.helospark.lightdi.annotation.Order)36 DefaultMenuContribution (com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution)19 MenuItem (javafx.scene.control.MenuItem)17 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)14 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)13 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)6 Configuration (com.helospark.lightdi.annotation.Configuration)5 ProjectRepository (com.helospark.tactview.core.repository.ProjectRepository)4 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)4 VisualTimelineClip (com.helospark.tactview.core.timeline.VisualTimelineClip)4 EffectFactory (com.helospark.tactview.core.timeline.effect.EffectFactory)4 UiCommandInterpreterService (com.helospark.tactview.ui.javafx.UiCommandInterpreterService)4 CopyPasteRepository (com.helospark.tactview.ui.javafx.repository.CopyPasteRepository)4 SelectedNodeRepository (com.helospark.tactview.ui.javafx.repository.SelectedNodeRepository)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Qualifier (com.helospark.lightdi.annotation.Qualifier)3 EffectFactoryChain (com.helospark.tactview.core.timeline.EffectFactoryChain)3 KeyframeSupportingDoubleInterpolator (com.helospark.tactview.core.timeline.effect.interpolation.interpolator.KeyframeSupportingDoubleInterpolator)3