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();
}
}
}
}
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;
}
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;
}
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()));
}
}
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;
}
Aggregations