Search in sources :

Example 1 with ClipMovedCommand

use of com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand in project tactview by helospark.

the class MoveByUnitService method moveByOneUnit.

public void moveByOneUnit(Direction direction) {
    List<String> selectedClipIds = selectedNodeRepository.getSelectedClipIds();
    if (selectedClipIds.size() > 0) {
        String firstClipId = selectedClipIds.get(0);
        TimelinePosition startPosition = timelineManagerAccessor.findClipById(firstClipId).get().getInterval().getStartPosition();
        if (direction.equals(Direction.LEFT) || direction.equals(Direction.RIGHT)) {
            String channelId = timelineManagerAccessor.findChannelForClipId(firstClipId).get().getId();
            TimelinePosition newPosition = direction.equals(Direction.LEFT) ? startPosition.subtract(projectRepository.getFrameTime()) : startPosition.add(projectRepository.getFrameTime());
            ClipMovedCommand clipMovedCommand = ClipMovedCommand.builder().withAdditionalClipIds(selectedClipIds).withClipId(firstClipId).withEnableJumpingToSpecialPosition(false).withIsRevertable(true).withMoreMoveExpected(false).withNewPosition(newPosition).withNewChannelId(channelId).withOriginalChannelId(channelId).withPreviousPosition(startPosition).withTimelineManager(timelineManagerAccessor).build();
            commandInterpreter.sendWithResult(clipMovedCommand).join();
        } else {
            String channelId = timelineManagerAccessor.findChannelForClipId(firstClipId).get().getId();
            Integer channelIndex = timelineManagerAccessor.findChannelIndexForClipId(firstClipId).get();
            Integer newChannelIndex = direction.equals(Direction.DOWN) ? channelIndex + 1 : channelIndex - 1;
            Optional<TimelineChannel> newChannel = timelineManagerAccessor.findChannelOnIndex(newChannelIndex);
            if (newChannel.isPresent()) {
                ClipMovedCommand clipMovedCommand = ClipMovedCommand.builder().withAdditionalClipIds(selectedClipIds).withClipId(firstClipId).withEnableJumpingToSpecialPosition(false).withIsRevertable(true).withMoreMoveExpected(false).withNewPosition(startPosition).withNewChannelId(newChannel.get().getId()).withOriginalChannelId(channelId).withPreviousPosition(startPosition).withTimelineManager(timelineManagerAccessor).build();
                commandInterpreter.sendWithResult(clipMovedCommand).join();
            }
        }
    }
}
Also used : TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) ClipMovedCommand(com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition)

Example 2 with ClipMovedCommand

use of com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand in project tactview by helospark.

the class MoveToContextMenuChainItem method createMoveToPositionMenuItem.

private MenuItem createMoveToPositionMenuItem(ClipContextMenuChainItemRequest request) {
    MenuItem moveToPositionMenuItem = new MenuItem("to position");
    moveToPositionMenuItem.setOnAction(e -> {
        String currentPosition = request.getPrimaryClip().getInterval().getStartPosition().getSeconds().setScale(4).toString();
        TextInputDialog dialog = new TextInputDialog(currentPosition);
        dialog.setTitle("New position");
        dialog.setHeaderText("Enter new position in seconds:");
        dialog.setContentText("Position:");
        stylesheetAdderService.addStyleSheets(dialog.getDialogPane(), "stylesheet.css");
        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            String originalChannelId = timelineManagerAccessor.findChannelForClipId(request.getPrimaryClip().getId()).get().getId();
            ClipMovedCommand clipMovedCommand = ClipMovedCommand.builder().withAdditionalClipIds(request.getAllClips().stream().map(a -> a.getId()).collect(Collectors.toList())).withClipId(request.getPrimaryClip().getId()).withEnableJumpingToSpecialPosition(false).withIsRevertable(true).withMoreMoveExpected(false).withNewPosition(new TimelinePosition(new BigDecimal(result.get()))).withNewChannelId(originalChannelId).withOriginalChannelId(originalChannelId).withPreviousPosition(request.getPrimaryClip().getInterval().getStartPosition()).withTimelineManager(timelineManagerAccessor).build();
            ClipMovedCommand commandResult = commandInterpreter.sendWithResult(clipMovedCommand).join();
            if (!commandResult.wasOperationSuccessful()) {
                Alert alert = alertDialogFactory.createSimpleAlertWithTitleAndContent(AlertType.ERROR, "Cannot move clip at that position", "Cannot move clip at that position");
                alert.showAndWait();
            }
        }
    });
    return moveToPositionMenuItem;
}
Also used : ClipMovedCommand(com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Alert(javafx.scene.control.Alert) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) BigDecimal(java.math.BigDecimal) TextInputDialog(javafx.scene.control.TextInputDialog)

Example 3 with ClipMovedCommand

use of com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand in project tactview by helospark.

the class MoveToContextMenuChainItem method createMoveToRightMenuItem.

private MenuItem createMoveToRightMenuItem(ClipContextMenuChainItemRequest request) {
    MenuItem moveToLeftMenuItem = new MenuItem("to furthest right");
    moveToLeftMenuItem.setOnAction(e -> {
        ClipToRightCommand clipMovedCommand = ClipToRightCommand.builder().withAdditionalClipIds(request.getAllClips().stream().map(a -> a.getId()).collect(Collectors.toList())).withClipId(request.getPrimaryClip().getId()).withTimelineManager(timelineManagerAccessor).build();
        ClipToRightCommand commandResult = commandInterpreter.sendWithResult(clipMovedCommand).join();
        if (!commandResult.wasOperationSuccessful()) {
            Alert alert = alertDialogFactory.createSimpleAlertWithTitleAndContent(AlertType.ERROR, "Cannot move clip to right", "Cannot move clip to right");
            alert.showAndWait();
        }
    });
    return moveToLeftMenuItem;
}
Also used : AlertDialogFactory(com.helospark.tactview.ui.javafx.stylesheet.AlertDialogFactory) Component(com.helospark.lightdi.annotation.Component) Alert(javafx.scene.control.Alert) MenuItem(javafx.scene.control.MenuItem) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Collectors(java.util.stream.Collectors) ClipMovedCommand(com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand) Menu(javafx.scene.control.Menu) Order(com.helospark.lightdi.annotation.Order) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) BigDecimal(java.math.BigDecimal) AlertType(javafx.scene.control.Alert.AlertType) StylesheetAdderService(com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) ClipToLeftCommand(com.helospark.tactview.ui.javafx.commands.impl.ClipToLeftCommand) MoveByUnitService(com.helospark.tactview.ui.javafx.commands.impl.service.MoveByUnitService) TextInputDialog(javafx.scene.control.TextInputDialog) ClipToRightCommand(com.helospark.tactview.ui.javafx.commands.impl.ClipToRightCommand) Optional(java.util.Optional) Direction(com.helospark.tactview.ui.javafx.commands.impl.service.MoveByUnitService.Direction) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Alert(javafx.scene.control.Alert) ClipToRightCommand(com.helospark.tactview.ui.javafx.commands.impl.ClipToRightCommand)

Example 4 with ClipMovedCommand

use of com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand in project tactview by helospark.

the class TimelineDragAndDropHandler method moveClip.

public void moveClip(String channelId, boolean revertable, TimelinePosition position) {
    ClipMovedCommand command = createMoveClipCommand(channelId, revertable, position);
    if (command != null) {
        ClipMovedCommand result = commandInterpreter.sendWithResult(command).join();
        dragRepository.currentlyDraggedClip().setHasMovedWithoutRevert(!revertable && (dragRepository.currentlyDraggedClip().getHasMovedWithoutRevert() || result.hasMoved()));
    }
}
Also used : ClipMovedCommand(com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand)

Example 5 with ClipMovedCommand

use of com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand in project tactview by helospark.

the class MoveToContextMenuChainItem method createMoveRelativeMenuItem.

private MenuItem createMoveRelativeMenuItem(ClipContextMenuChainItemRequest request) {
    MenuItem moveToPositionMenuItem = new MenuItem("relative");
    moveToPositionMenuItem.setOnAction(e -> {
        TextInputDialog dialog = new TextInputDialog("0.0");
        dialog.setTitle("Relative move");
        dialog.setHeaderText("Enter relative move in seconds:");
        dialog.setContentText("Relative move:");
        stylesheetAdderService.addStyleSheets(dialog.getDialogPane(), "stylesheet.css");
        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            String originalChannelId = timelineManagerAccessor.findChannelForClipId(request.getPrimaryClip().getId()).get().getId();
            ClipMovedCommand clipMovedCommand = ClipMovedCommand.builder().withAdditionalClipIds(request.getAllClips().stream().map(a -> a.getId()).collect(Collectors.toList())).withClipId(request.getPrimaryClip().getId()).withEnableJumpingToSpecialPosition(false).withIsRevertable(true).withMoreMoveExpected(false).withNewPosition(request.getPrimaryClip().getInterval().getStartPosition().add(new BigDecimal(result.get()))).withNewChannelId(originalChannelId).withOriginalChannelId(originalChannelId).withPreviousPosition(request.getPrimaryClip().getInterval().getStartPosition()).withTimelineManager(timelineManagerAccessor).build();
            ClipMovedCommand commandResult = commandInterpreter.sendWithResult(clipMovedCommand).join();
            if (!commandResult.wasOperationSuccessful()) {
                Alert alert = alertDialogFactory.createSimpleAlertWithTitleAndContent(AlertType.ERROR, "Cannot move clip at that position", "Cannot move clip at that position");
                alert.showAndWait();
            }
        }
    });
    return moveToPositionMenuItem;
}
Also used : ClipMovedCommand(com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Alert(javafx.scene.control.Alert) BigDecimal(java.math.BigDecimal) TextInputDialog(javafx.scene.control.TextInputDialog)

Aggregations

ClipMovedCommand (com.helospark.tactview.ui.javafx.commands.impl.ClipMovedCommand)7 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)5 BigDecimal (java.math.BigDecimal)4 Alert (javafx.scene.control.Alert)4 MenuItem (javafx.scene.control.MenuItem)4 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)4 TextInputDialog (javafx.scene.control.TextInputDialog)4 Component (com.helospark.lightdi.annotation.Component)3 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)3 UiCommandInterpreterService (com.helospark.tactview.ui.javafx.UiCommandInterpreterService)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 Order (com.helospark.lightdi.annotation.Order)2 ClipToLeftCommand (com.helospark.tactview.ui.javafx.commands.impl.ClipToLeftCommand)2 ClipToRightCommand (com.helospark.tactview.ui.javafx.commands.impl.ClipToRightCommand)2 MoveByUnitService (com.helospark.tactview.ui.javafx.commands.impl.service.MoveByUnitService)2 Direction (com.helospark.tactview.ui.javafx.commands.impl.service.MoveByUnitService.Direction)2 AlertDialogFactory (com.helospark.tactview.ui.javafx.stylesheet.AlertDialogFactory)2 StylesheetAdderService (com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService)2 Streams (com.google.common.collect.Streams)1