-
Notifications
You must be signed in to change notification settings - Fork 116
CSSTUDIO-2071 & CSSTUDIO-2081: Add options to copy & append PV names (with descriptions) to Display Runtime & to WidgetInfoDialog
#2998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e306a54
CSSTUDIO-2072 Generalize the class "ContextMenuEntry" to tree-structu…
abrahamwolk c6055af
CSSTUDIO-2072 Add the class "ContextMenuCopySubMenu".
abrahamwolk 8ecb9ee
CSSTUDIO-2072 Add Messages.CopySubMenu.
abrahamwolk 9be0a09
CSSTUDIO-2072 Implement the method ContextMenuCopySubMenu.getSupporte…
abrahamwolk e7927a9
CSSTUDIO-2072 Implement ContextMenuCopySubMenu.getIcon().
abrahamwolk 423e11e
CSSTUDIO-2072 Implement ContextMenuCopySubMenu.getChildren().
abrahamwolk c6ccb0d
CSSTUDIO-2072 Modify the file "ContextMenuEntry" to contain the Copy …
abrahamwolk 2be1c3b
CSSTUDIO-2072 Add functionality to copy and append PV names, optional…
abrahamwolk ab35486
CSSTUDIO-2072 Add "Selection" column to the Widget Info dialog.
abrahamwolk e716aee
CSSTUDIO-2072 Add functionality to copy PV names, and possibly associ…
abrahamwolk 3d0eed9
CSSTUDIO-2072 Fix name: rename 'appendPVAndDescriptionToClipboardCont…
abrahamwolk c760288
CSSTUDIO-2072 Add labels to messages.properties.
abrahamwolk 908ae5d
CSSTUDIO-2072 Add labels to messages.properties.
abrahamwolk e0c401e
Merge branch 'master' into CSSTUDIO-2072-contextMenu
abrahamwolk c9cbe0e
CSSTUDIO-2081 Fix wrongly resolved merge conflict in ContextMenuHelpe…
abrahamwolk ef4a835
CSSTUDIO-2072 Distinguish between singular and plural in labels.
abrahamwolk 7e23399
CSSTUDIO-2072 Change 'd' to 'D'.
abrahamwolk ba114bd
CSSTUDIO-2072 Add button "Copy PV Names" and rename existing button: …
abrahamwolk 3900680
CSSTUDIO-2072 Remove Messages.Selected.
abrahamwolk be2a938
CSSTUDIO-2072 Replace table column header with a checkbox for that ca…
abrahamwolk 2e37d39
CSSTUDIO-2072 Use System.lineSeparator() instead of "\n".
abrahamwolk 692cbf8
CSSTUDIO-2072 Reduce width of column for selecting PV names.
abrahamwolk ca0ccdc
CSSTUDIO-2072 Rename button: "Close" -> "Cancel".
abrahamwolk 505f951
CSSTUDIO-2072 Move the context menu-items for copying and appending P…
abrahamwolk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
351 changes: 335 additions & 16 deletions
351
...fx/src/main/java/org/csstudio/display/builder/representation/javafx/WidgetInfoDialog.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/probe/src/main/java/org/phoebus/applications/probe/ContextMenuAppendPvToClipboard.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package org.phoebus.applications.probe; | ||
|
|
||
| import javafx.scene.image.Image; | ||
| import javafx.scene.input.Clipboard; | ||
| import javafx.scene.input.ClipboardContent; | ||
| import org.phoebus.core.types.ProcessVariable; | ||
| import org.phoebus.framework.selection.Selection; | ||
| import org.phoebus.ui.javafx.ImageCache; | ||
| import org.phoebus.ui.spi.ContextMenuEntry; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class ContextMenuAppendPvToClipboard implements ContextMenuEntry { | ||
| @Override | ||
| public String getName() { | ||
| return Messages.AppendPVNameToClipboard; | ||
| } | ||
|
|
||
| private Image icon = ImageCache.getImage(ImageCache.class, "/icons/copy.png"); | ||
| @Override | ||
| public Image getIcon() { | ||
| return icon; | ||
| } | ||
|
|
||
| @Override | ||
| public Class<?> getSupportedType() { | ||
| return ProcessVariable.class; | ||
| } | ||
|
|
||
| @Override | ||
| public void call(final Selection selection) | ||
| { | ||
| List<ProcessVariable> pvs = selection.getSelections(); | ||
| String pvNamesToAppendToClipboard = pvs.stream().map(ProcessVariable::getName).collect(Collectors.joining(System.lineSeparator())); | ||
|
|
||
| Clipboard clipboard = Clipboard.getSystemClipboard(); | ||
| String newContentInClipboard; | ||
| { | ||
| String existingContentInClipboard; | ||
| if (clipboard.hasString()) { | ||
| existingContentInClipboard = clipboard.getString() + "\n"; | ||
| } else { | ||
| existingContentInClipboard = ""; | ||
| } | ||
| newContentInClipboard = existingContentInClipboard + pvNamesToAppendToClipboard; | ||
| } | ||
| ClipboardContent newContent = new ClipboardContent(); | ||
| newContent.putString(newContentInClipboard); | ||
| clipboard.setContent(newContent); | ||
| } | ||
| } |
205 changes: 205 additions & 0 deletions
205
...in/java/org/phoebus/applications/probe/ContextMenuAppendPvToClipboardWithDescription.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| package org.phoebus.applications.probe; | ||
|
|
||
| import javafx.application.Platform; | ||
| import javafx.scene.control.Alert; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.control.ButtonType; | ||
| import javafx.scene.control.ScrollPane; | ||
| import javafx.scene.control.TextField; | ||
| import javafx.scene.control.Tooltip; | ||
| import javafx.scene.image.Image; | ||
| import javafx.scene.input.Clipboard; | ||
| import javafx.scene.input.ClipboardContent; | ||
| import javafx.scene.input.KeyCode; | ||
| import javafx.scene.layout.ColumnConstraints; | ||
| import javafx.scene.layout.GridPane; | ||
| import javafx.scene.layout.Priority; | ||
| import javafx.scene.layout.Region; | ||
| import javafx.scene.text.Text; | ||
| import javafx.stage.Window; | ||
| import javafx.util.Pair; | ||
| import org.csstudio.display.builder.runtime.app.DisplayRuntimeInstance; | ||
| import org.phoebus.core.types.ProcessVariable; | ||
| import org.phoebus.framework.selection.Selection; | ||
| import org.phoebus.ui.dialog.DialogHelper; | ||
| import org.phoebus.ui.docking.DockItem; | ||
| import org.phoebus.ui.docking.DockPane; | ||
| import org.phoebus.ui.javafx.ImageCache; | ||
| import org.phoebus.ui.spi.ContextMenuEntry; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.concurrent.ExecutionException; | ||
| import java.util.concurrent.FutureTask; | ||
| import java.util.function.BiConsumer; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class ContextMenuAppendPvToClipboardWithDescription implements ContextMenuEntry { | ||
| @Override | ||
| public String getName() { | ||
| return Messages.AppendPVNameToClipboardWithDescription; | ||
| } | ||
|
|
||
| private Image icon = ImageCache.getImage(ImageCache.class, "/icons/copy.png"); | ||
| @Override | ||
| public Image getIcon() { | ||
| return icon; | ||
| } | ||
|
|
||
| @Override | ||
| public Class<?> getSupportedType() { | ||
| return ProcessVariable.class; | ||
| } | ||
|
|
||
| @Override | ||
| public void call(final Selection selection) | ||
| { | ||
| List<ProcessVariable> pvs = selection.getSelections(); | ||
| String pvNamesToAppendToClipboard = pvs.stream().map(ProcessVariable::getName).collect(Collectors.joining(System.lineSeparator())); | ||
|
|
||
| String defaultDescription; | ||
| { | ||
| var activeDockPane = DockPane.getActiveDockPane(); | ||
| var activeDockItem = (DockItem) activeDockPane.getSelectionModel().getSelectedItem(); | ||
| if (activeDockItem.getApplication() instanceof DisplayRuntimeInstance) { | ||
| DisplayRuntimeInstance displayRuntimeInstance = (DisplayRuntimeInstance) activeDockItem.getApplication(); | ||
| defaultDescription = displayRuntimeInstance.getDisplayName(); | ||
| } | ||
| else { | ||
| defaultDescription = ""; | ||
| } | ||
| } | ||
|
|
||
| BiConsumer<String, String> appendPVAndDescriptionToClipboardContinuation = (pvName, description) -> { | ||
| Clipboard clipboard = Clipboard.getSystemClipboard(); | ||
| String newContentInClipboard; | ||
| { | ||
| String existingContentInClipboard; | ||
| if (clipboard.hasString()) { | ||
| existingContentInClipboard = clipboard.getString() + "\n"; | ||
| } else { | ||
| existingContentInClipboard = ""; | ||
| } | ||
| newContentInClipboard = existingContentInClipboard + pvName + "," + description; | ||
| } | ||
| ClipboardContent newContent = new ClipboardContent(); | ||
| newContent.putString(newContentInClipboard); | ||
| clipboard.setContent(newContent); | ||
| }; | ||
|
|
||
| String pvName = pvNamesToAppendToClipboard; | ||
|
|
||
| addDescriptionToPvNameModalDialog(pvName, | ||
| defaultDescription, | ||
| "Append", | ||
| appendPVAndDescriptionToClipboardContinuation); | ||
| } | ||
|
|
||
| public static void addDescriptionToPvNameModalDialog(String pvName, | ||
| String defaultDescription, | ||
| String acceptButtonText, | ||
| BiConsumer continuation) { | ||
| Window windowToPositionTheConfirmationDialogOver = DockPane.getActiveDockPane().getScene().getWindow(); | ||
|
|
||
| ButtonType acceptButtonType = new ButtonType(acceptButtonText); | ||
| ButtonType cancelButtonType = new ButtonType("Cancel"); | ||
|
|
||
| FutureTask<Optional<Pair<String, String>>> displayConfirmationWindow = new FutureTask(() -> { | ||
| Alert prompt = new Alert(Alert.AlertType.NONE); | ||
|
|
||
| prompt.getDialogPane().getButtonTypes().add(cancelButtonType); | ||
| Button cancelButton = (Button) prompt.getDialogPane().lookupButton(cancelButtonType); | ||
| cancelButton.setTooltip(new Tooltip(cancelButton.getText())); | ||
|
|
||
| prompt.getDialogPane().getButtonTypes().add(acceptButtonType); | ||
| Button acceptButton = (Button) prompt.getDialogPane().lookupButton(acceptButtonType); | ||
| acceptButton.setTooltip(new Tooltip(acceptButton.getText())); | ||
|
|
||
| GridPane gridPane = new GridPane(); | ||
| gridPane.setPrefWidth(Double.MAX_VALUE); | ||
| gridPane.setVgap(4); | ||
|
|
||
| ColumnConstraints firstColumnColumnConstraints = new ColumnConstraints(); | ||
| gridPane.getColumnConstraints().add(0, firstColumnColumnConstraints); | ||
| ColumnConstraints secondColumnColumnConstraints = new ColumnConstraints(); | ||
| secondColumnColumnConstraints.setHgrow(Priority.ALWAYS); | ||
| secondColumnColumnConstraints.setFillWidth(true); | ||
| gridPane.getColumnConstraints().add(1, secondColumnColumnConstraints); | ||
|
|
||
| int currentRow = 0; | ||
|
|
||
| Text pvNameLabelText = new Text("PV Name: "); | ||
| pvNameLabelText.setStyle("-fx-font-size: 14; -fx-font-weight: bold; "); | ||
| gridPane.add(pvNameLabelText, 0, currentRow); | ||
|
|
||
| Text pvNameText = new Text(pvName); | ||
| pvNameText.setStyle("-fx-font-size: 14; -fx-font-style: italic; "); | ||
| gridPane.add(pvNameText, 1, currentRow); | ||
| currentRow++; | ||
|
|
||
| Text descriptionLabelText = new Text("Description: "); | ||
| descriptionLabelText.setStyle("-fx-font-size: 14; -fx-font-weight: bold; "); | ||
| gridPane.add(descriptionLabelText, 0, currentRow); | ||
|
|
||
| TextField descriptionText = new TextField(defaultDescription); | ||
| descriptionText.setStyle("-fx-font-size: 14; "); | ||
| descriptionText.setOnKeyPressed(keyEvent -> { | ||
| if (keyEvent.getCode() == KeyCode.ENTER) { | ||
| keyEvent.consume(); | ||
| acceptButton.fire(); | ||
| } | ||
| }); | ||
| gridPane.add(descriptionText, 1, currentRow); | ||
| currentRow++; | ||
|
|
||
| prompt.getDialogPane().setOnKeyPressed(keyEvent -> { | ||
| if (keyEvent.getCode() == KeyCode.ESCAPE) { | ||
| keyEvent.consume(); | ||
| cancelButton.fire(); | ||
| } | ||
| }); | ||
|
|
||
| ScrollPane scrollPane = new ScrollPane(); | ||
| scrollPane.setContent(gridPane); | ||
|
|
||
| prompt.getDialogPane().setContent(gridPane); | ||
|
|
||
| prompt.setHeaderText("Append PV Name with Description to the Clipboard"); | ||
| prompt.setTitle("Append PV Name with Description to the Clipboard"); | ||
|
|
||
| int prefWidth = 500; | ||
| int prefHeight = 150; | ||
| prompt.getDialogPane().setPrefSize(prefWidth, prefHeight); | ||
| prompt.getDialogPane().setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); | ||
| prompt.setResizable(false); | ||
|
|
||
| DialogHelper.positionDialog(prompt, windowToPositionTheConfirmationDialogOver.getScene().getRoot(), -prefWidth/2, -prefHeight/2); | ||
| descriptionText.requestFocus(); | ||
| descriptionText.selectAll(); | ||
|
|
||
| if (prompt.showAndWait().orElse(ButtonType.CANCEL) == acceptButtonType) { | ||
| String description = descriptionText.getText(); | ||
| Pair<String, String> pvNameAndDescription = new Pair<>(pvName, description); | ||
| return Optional.of(pvNameAndDescription); | ||
| } | ||
| else { | ||
| return Optional.empty(); | ||
| } | ||
| }); | ||
|
|
||
| if (Platform.isFxApplicationThread()) { | ||
| displayConfirmationWindow.run(); | ||
| } | ||
| else { | ||
| Platform.runLater(displayConfirmationWindow); | ||
| } | ||
| try { | ||
| Optional<Pair<String, String>> maybePVNameAndDescription = displayConfirmationWindow.get(); | ||
| maybePVNameAndDescription.ifPresent(pair -> continuation.accept(pair.getKey(), pair.getValue())); | ||
| } catch (ExecutionException e) { | ||
| ; // Do nothing. | ||
| } catch (InterruptedException e) { | ||
| ; // Do nothing. | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.