Skip to content

Commit

Permalink
Add save&restore context menu item to copy resource URL to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
georgweiss committed Oct 11, 2024
1 parent 9faac47 commit 7f131d2
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class Messages {
public static String copyOrMoveNotAllowedBody;
public static String copyOrMoveNotAllowedHeader;
public static String copyUniqueIdToClipboard;
public static String copyUniqueIdAsResourceToClipboard;

public static String createNewTagDialogHeader;
public static String createNewTagDialogTitle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public abstract class ContextMenuBase extends ContextMenu {

protected MenuItem deleteNodesMenuItem;
protected MenuItem copyUniqueIdToClipboardMenuItem;
protected MenuItem copyUniqueIdAsResourceUrlToClipboardMenuItem;

protected MenuItem loginMenuItem;
private static final String loginAppName = "credentials_management";
Expand Down Expand Up @@ -88,6 +89,11 @@ public ContextMenuBase(SaveAndRestoreController saveAndRestoreController) {
copyUniqueIdToClipboardMenuItem.setOnAction(ae -> saveAndRestoreController.copyUniqueNodeIdToClipboard());
copyUniqueIdToClipboardMenuItem.disableProperty().bind(multipleNodesSelectedProperty);

copyUniqueIdAsResourceUrlToClipboardMenuItem =
new MenuItem(Messages.copyUniqueIdAsResourceToClipboard, ImageCache.getImageView(ImageCache.class, "/icons/copy.png"));
copyUniqueIdAsResourceUrlToClipboardMenuItem.setOnAction(ae -> saveAndRestoreController.copyUniqueNodeIdAsResourceUrlToClipboard());
copyUniqueIdAsResourceUrlToClipboardMenuItem.disableProperty().bind(multipleNodesSelectedProperty);

loginMenuItem = new MenuItem(Messages.login, ImageCache.getImageView(ImageCache.class, "/icons/credentials.png"));
loginMenuItem.setOnAction(ae -> {
ApplicationService.createInstance(loginAppName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public ContextMenuCompositeSnapshot(SaveAndRestoreController saveAndRestoreContr
copyMenuItem,
deleteNodesMenuItem,
copyUniqueIdToClipboardMenuItem,
copyUniqueIdAsResourceUrlToClipboardMenuItem,
tagWithComment);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public ContextMenuConfiguration(SaveAndRestoreController saveAndRestoreControlle
pasteMenuItem,
deleteNodesMenuItem,
copyUniqueIdToClipboardMenuItem,
copyUniqueIdAsResourceUrlToClipboardMenuItem,
exportConfigurationMenuItem,
importSnapshotMenuItem);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public ContextMenuSnapshot(SaveAndRestoreController saveAndRestoreController) {
tagWithComment,
copyMenuItem,
copyUniqueIdToClipboardMenuItem,
copyUniqueIdAsResourceUrlToClipboardMenuItem,
exportSnapshotMenuItem);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,26 @@ protected void renameNode() {
renameNode(node.getValue(), existingSiblingNodes);
}

/**
* Puts the unique node id on the clipboard as text
*/
protected void copyUniqueNodeIdToClipboard() {
Node node = browserSelectionModel.getSelectedItem().getValue();
ClipboardContent content = new ClipboardContent();
content.putString(node.getUniqueId());
Clipboard.getSystemClipboard().setContent(content);
}

/**
* Puts the unique node id as a resource URL on the clipboard as text
*/
protected void copyUniqueNodeIdAsResourceUrlToClipboard() {
Node node = browserSelectionModel.getSelectedItem().getValue();
ClipboardContent content = new ClipboardContent();
content.putString("file:/" + node.getUniqueId() + "?app=" + SaveAndRestoreApplication.NAME);
Clipboard.getSystemClipboard().setContent(content);
}

/**
* Renames the selected node. A check is made to ensure that user cannot specify a name
* that is the same as any of its sibling nodes if they are of the same {@link Node} type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ contextMenuTagAsGolden=Add Golden tag
contextMenuTagsWithComment=Tags with comment
copyOrMoveNotAllowedBody=Selection cannot be moved/copied to the specified target node.
copyOrMoveNotAllowedHeader=Cannot move or copy selection.
copyUniqueIdToClipboard=Copy unique id to clipboard
copyUniqueIdToClipboard=Copy id to clipboard
copyUniqueIdAsResourceToClipboard=Copy id as resource URL to clipboard
createdBy=Created By
createCompositeSnapshotFailed=Failed to create composite snapshot
createConfigurationFailed=Failed to create configuration
Expand Down

0 comments on commit 7f131d2

Please sign in to comment.