Skip to content

Commit

Permalink
CSSTUDIO-2007 Add version of getDockItemWithInput() that returns any …
Browse files Browse the repository at this point in the history
…DockItemWithInput whose input is the specified input. Improve check by not requiring that the application be the same.
  • Loading branch information
abrahamwolk committed Aug 11, 2023
1 parent ed2f318 commit 2b5a13b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ else if (response == ButtonType.NO)
}

URI newInput = ResourceParser.getURI(actual_file.get());
DockItemWithInput existingInstanceWithInput = DockStage.getDockItemWithInput(getApplication().getAppDescriptor().getName(), newInput);
DockItemWithInput existingInstanceWithInput = DockStage.getDockItemWithInput(newInput);
if (existingInstanceWithInput == null || (input != null && newInput.getPath().equals(input.getPath()))) {
// Update input
setInput(newInput);
Expand All @@ -440,7 +440,7 @@ else if (response == ButtonType.NO)
dialog.setTitle(Messages.SaveAsFileAlreadyOpen_title);
String headerText = MessageFormat.format(Messages.SaveAsFileAlreadyOpen_header, filename);
dialog.setHeaderText(headerText);
String contentText = MessageFormat.format(Messages.SaveAsFileAlreadyOpen_content, getApplication().getAppDescriptor().getDisplayName(), filename);
String contentText = MessageFormat.format(Messages.SaveAsFileAlreadyOpen_content, existingInstanceWithInput.getApplication().getAppDescriptor().getDisplayName(), filename);
dialog.setContentText(contentText);
int width = 550;
int height = 200;
Expand Down
19 changes: 19 additions & 0 deletions core/ui/src/main/java/org/phoebus/ui/docking/DockStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,25 @@ public static DockItemWithInput getDockItemWithInput(final String application_na
return null;
}

/** Locate DockItemWithInput with input
* @param input Input, must not be <code>null</code>
* @return {@link DockItemWithInput} or <code>null</code> if not found
*/
public static DockItemWithInput getDockItemWithInput(URI input)
{
Objects.requireNonNull(input);
for (Stage stage : getDockStages())
for (DockPane pane : getDockPanes(stage))
for (DockItem tab : pane.getDockItems())
if (tab instanceof DockItemWithInput)
{
DockItemWithInput item = (DockItemWithInput) tab;
if (input.equals(item.getInput()))
return item;
}
return null;
}

/** Locate any 'fixed' {@link DockPane}s and un-fix them
* @param stage Stage where to clear 'fixed' panes
*/
Expand Down

0 comments on commit 2b5a13b

Please sign in to comment.