use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.
the class DefaultEditMenuItemConfiguration method jumpToEndOfCurrentClipMenuItem.
@Bean
@Order(1907)
public SelectableMenuContribution jumpToEndOfCurrentClipMenuItem(UiTimelineManager uiTimelineManager, TimelineManagerAccessor timelineManager, SelectedNodeRepository selectedNodeRepository) {
KeyCodeCombination combination = hotKeyRepository.registerOrGetHotKey("jumpToClipEnd", new KeyCodeCombination(KeyCode.PERIOD, KeyCombination.CONTROL_DOWN), "Jump to end of selected clip").getCombination();
return new DefaultMenuContribution(List.of(EDIT_ROOT, JUMP_ROOT, "Jump to end of selected clip"), event -> {
Optional<String> primaryClip = selectedNodeRepository.getPrimarySelectedClip();
if (primaryClip.isPresent()) {
Optional<TimelineClip> clip = timelineManager.findClipById(primaryClip.get());
uiTimelineManager.jumpAbsolute(clip.get().getInterval().getEndPosition().getSeconds());
}
}, combination);
}
use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.
the class DefaultEditMenuItemConfiguration method selectClipsUnderPlayheadMenuItem.
@Bean
@Order(1803)
public SelectableMenuContribution selectClipsUnderPlayheadMenuItem(SelectedNodeRepository selectedNodeRepository, TimelineManagerAccessor timelineManager, UiTimelineManager uiTimelineManager) {
return new DefaultMenuContribution(List.of(EDIT_ROOT, SELECT_ROOT, "Clips under playhead"), event -> {
TimelinePosition position = uiTimelineManager.getCurrentPosition();
List<String> newSelectedClips = timelineManager.getAllClipIds().stream().flatMap(a -> timelineManager.findClipById(a).stream()).filter(a -> a.getInterval().intersects(TimelineInterval.ofPoint(position))).map(a -> a.getId()).collect(Collectors.toList());
selectedNodeRepository.addSelectedClips(newSelectedClips);
});
}
use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.
the class DefaultEditMenuItemConfiguration method selectClipsToLeftContextMenuItem.
@Bean
@Order(1801)
public SelectableMenuContribution selectClipsToLeftContextMenuItem(SelectedNodeRepository selectedNodeRepository, TimelineManagerAccessor timelineManager, TimelineState state) {
return new DefaultMenuContribution(List.of(EDIT_ROOT, SELECT_ROOT, "Clips to _left"), event -> {
TimelinePosition playbackPosition = state.getPlaybackPosition();
selectedNodeRepository.clearAllSelectedItems();
List<String> clipsIds = new ArrayList<>();
for (var channel : timelineManager.getChannels()) {
for (var clip : channel.getAllClips()) {
if (!clip.getInterval().getStartPosition().isGreaterThan(playbackPosition)) {
clipsIds.add(clip.getId());
}
}
}
selectedNodeRepository.addSelectedClips(clipsIds);
});
}
use of com.helospark.tactview.ui.javafx.menu.DefaultMenuContribution in project tactview by helospark.
the class DefaultWindowMenuItemConfiguration method loadLayoutMenuItem.
@Bean
@Order(3998)
public SelectableMenuContribution loadLayoutMenuItem(MessagingService messagingService, AlertDialogFactory alertDialogFactory) {
return new DefaultMenuContribution(List.of(WINDOW_MENU_ITEM, "Load layout"), e -> {
try {
FileChooser fileChooser = new FileChooser();
fileChooser.setSelectedExtensionFilter(new ExtensionFilter("TactView layout file", TACTVIEW_LAYOUT_EXTENSION));
fileChooser.setTitle("Open Layout");
File file = fileChooser.showOpenDialog(JavaFXUiMain.STAGE);
if (file != null) {
try (var inputStream = new FileInputStream(file)) {
DetachableTabPaneLoadModel result = objectMapper.readValue(inputStream, DetachableTabPaneLoadModel.class);
dockableTabRepository.loadAndSetModelToParent(result);
}
}
} catch (Exception e1) {
alertDialogFactory.showExceptionDialog("Unable to load layout", e1);
LOGGER.error("Unable to load layout", e1);
}
});
}
Aggregations