-
Notifications
You must be signed in to change notification settings - Fork 117
Improve layout management and fix layout issue #3250
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -325,8 +325,7 @@ private void possiblySelectIniFile(CopyOnWriteArrayList<String> application_para | |
| String errorMessage = errorTitleAndErrorMessage.getValue(); | ||
|
|
||
| logger.log(Level.SEVERE, errorMessage); | ||
|
|
||
| Dialog errorDialog = new Alert(AlertType.ERROR); | ||
| Alert errorDialog = new Alert(AlertType.ERROR); | ||
| errorDialog.setTitle(errorTitle); | ||
| errorDialog.setHeaderText(errorTitle); | ||
| errorDialog.setContentText(errorMessage + "\n\n" + Messages.PhoebusWillQuit); | ||
|
|
@@ -348,7 +347,7 @@ private void possiblySelectIniFile(CopyOnWriteArrayList<String> application_para | |
| ObservableList<File> iniFilesInDirectory_ObservableList = FXCollections.observableArrayList(iniFilesInDirectory_List); | ||
|
|
||
| if (iniFilesInDirectory_List.size() > 0) { | ||
| Dialog<File> iniFileSelectionDialog = new Dialog(); | ||
| Dialog<File> iniFileSelectionDialog = new Dialog<>(); | ||
| iniFileSelectionDialog.setTitle(Messages.SelectPhoebusConfiguration); | ||
| iniFileSelectionDialog.setHeaderText(Messages.SelectPhoebusConfiguration); | ||
| iniFileSelectionDialog.setGraphic(null); | ||
|
|
@@ -357,7 +356,7 @@ private void possiblySelectIniFile(CopyOnWriteArrayList<String> application_para | |
| iniFileSelectionDialog.setHeight(400); | ||
| iniFileSelectionDialog.setResizable(false); | ||
|
|
||
| ListView listView = new ListView(iniFilesInDirectory_ObservableList); | ||
| ListView<File> listView = new ListView<>(iniFilesInDirectory_ObservableList); | ||
| listView.getSelectionModel().select(0); | ||
|
|
||
| Runnable setReturnValueAndCloseDialog = () -> { | ||
|
|
@@ -419,20 +418,20 @@ private void possiblySelectIniFile(CopyOnWriteArrayList<String> application_para | |
| PropertyPreferenceLoader.load(selectedFile_FileInputStream); | ||
| } | ||
| } catch (Exception exception) { | ||
| displayErrorMessageAndQuit.accept(new Pair(Messages.ErrorLoadingPhoebusConfiguration, Messages.ErrorLoadingPhoebusConfiguration + " '" + selectedFile.getAbsolutePath() + "': " + exception.getMessage())); | ||
| displayErrorMessageAndQuit.accept(new Pair<>(Messages.ErrorLoadingPhoebusConfiguration, Messages.ErrorLoadingPhoebusConfiguration + " '" + selectedFile.getAbsolutePath() + "': " + exception.getMessage())); | ||
| } | ||
| } catch (FileNotFoundException e) { | ||
| displayErrorMessageAndQuit.accept(new Pair(Messages.ErrorLoadingPhoebusConfiguration, Messages.ErrorLoadingPhoebusConfiguration + " '" + selectedFile.getAbsolutePath() + "': " + Messages.FileDoesNotExist)); | ||
| displayErrorMessageAndQuit.accept(new Pair<>(Messages.ErrorLoadingPhoebusConfiguration, Messages.ErrorLoadingPhoebusConfiguration + " '" + selectedFile.getAbsolutePath() + "': " + Messages.FileDoesNotExist)); | ||
| } | ||
| } else { | ||
| // Selecting a configuration was cancelled either by pressing the "X"-button or by pressing the ESC-key. | ||
| stop(); | ||
| } | ||
| } else { | ||
| displayErrorMessageAndQuit.accept(new Pair(Messages.ErrorDuringEvalutationOfTheFlagSelectSettings, Messages.ErrorDuringEvalutationOfTheFlagSelectSettings + ": " + MessageFormat.format(Messages.TheDirectoryDoesNotContainConfigurationFiles, iniFilesLocation_String))); | ||
| displayErrorMessageAndQuit.accept(new Pair<>(Messages.ErrorDuringEvalutationOfTheFlagSelectSettings, Messages.ErrorDuringEvalutationOfTheFlagSelectSettings + ": " + MessageFormat.format(Messages.TheDirectoryDoesNotContainConfigurationFiles, iniFilesLocation_String))); | ||
| } | ||
| } else { | ||
| displayErrorMessageAndQuit.accept(new Pair(Messages.ErrorDuringEvalutationOfTheFlagSelectSettings, Messages.ErrorDuringEvalutationOfTheFlagSelectSettings + ": " + MessageFormat.format(Messages.TheArgumentIsNotADirectory, iniFilesLocation_String))); | ||
| displayErrorMessageAndQuit.accept(new Pair<>(Messages.ErrorDuringEvalutationOfTheFlagSelectSettings, Messages.ErrorDuringEvalutationOfTheFlagSelectSettings + ": " + MessageFormat.format(Messages.TheArgumentIsNotADirectory, iniFilesLocation_String))); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -561,7 +560,28 @@ private void startUI(final MementoTree memento, final JobMonitor monitor) throws | |
| Preferences.ui_monitor_period, TimeUnit.MILLISECONDS); | ||
|
|
||
| closeAllTabsMenuItem.acceleratorProperty().setValue(closeAllTabsKeyCombination); | ||
|
|
||
|
|
||
| //Load a custom layout at start if layout_default is defined in preferences | ||
| String layoutFileName = Preferences.layout_default; | ||
| if(layoutFileName != null && !layoutFileName.isBlank()) { | ||
| layoutFileName = !layoutFileName.endsWith(".memento")? layoutFileName + ".memento" :layoutFileName; | ||
| String layout_dir = Preferences.layout_dir; | ||
| File parentFolder = null; | ||
| File user = Locations.user(); | ||
| if(layout_dir != null && !layout_dir.isBlank() && !layout_dir.contains("$(")) { | ||
| parentFolder = new File(user, layout_dir); | ||
| } | ||
| if(parentFolder == null) { | ||
| parentFolder = user; | ||
| } | ||
| File layoutFile = new File(parentFolder,layoutFileName ); | ||
| if(layoutFile.exists()) { | ||
| startLayoutReplacement(layoutFile); | ||
| } | ||
| else { | ||
| logger.log(Level.WARNING, "Layout file " + layoutFileName + " is not found"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -778,8 +798,9 @@ void createLoadLayoutsMenu() { | |
| } | ||
|
|
||
| // Get every momento file from the configured layout | ||
| if (Preferences.layout_dir != null && !Preferences.layout_dir.isBlank()) { | ||
| final File layoutDir = new File(Preferences.layout_dir); | ||
| String layout_dir = Preferences.layout_dir; | ||
| if (layout_dir != null && !layout_dir.isBlank() && !layout_dir.contains("$(")) { | ||
| final File layoutDir = new File(Locations.user(), layout_dir); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @katysaintin This introduced a change in the semantics of the option Could you change the option
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was changed to support defining layout_dir using $(user.home) but we should continue to support absolute paths. @katysaintin can you update the above so the |
||
| if (layoutDir.exists()) { | ||
| final File[] systemLayoutFiles = layoutDir.listFiles(); | ||
| if (systemLayoutFiles != null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import org.phoebus.framework.autocomplete.ProposalService; | ||
| import org.phoebus.framework.jobs.JobManager; | ||
| import org.phoebus.framework.workbench.Locations; | ||
| import org.phoebus.ui.Preferences; | ||
| import org.phoebus.ui.autocomplete.AutocompleteMenu; | ||
| import org.phoebus.ui.dialog.DialogHelper; | ||
| import org.phoebus.ui.docking.DockItem; | ||
|
|
@@ -156,7 +157,23 @@ private static void positionDialog(final Dialog<?> dialog, Stage stage) | |
| private static boolean saveState(List<Stage> stagesToSave, final String layout) | ||
| { | ||
| final String memento_filename = layout + ".memento"; | ||
| final File memento_file = new File(Locations.user(), memento_filename); | ||
| //Take in account layout dir and add Layout folder in the path | ||
| String layout_dir = Preferences.layout_dir; | ||
| File user = Locations.user(); | ||
| File parentFolder = null; | ||
| if(layout_dir != null && !layout_dir.isEmpty() && !layout_dir.contains("$(")) { | ||
| parentFolder = new File(user , layout_dir); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to also change (or make backwards-compatible) the save-functionality, to use Before the changes in this pull request, layouts were loaded from both
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello, just to be sure, for the modifications :
Is that right ? That's means that layout_dir can be absolute or relative ? I check that ASAP. Thank you for the review . Katy
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that would restore the old behavior.
I think saving a layout should save it to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think it would be best if the implemented functionality is backwards-compatible, so that, by default,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hello, sorry I was busy today, I will do the correction tomorrow, (French hour). Katy
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello, see modifications in PR #3300 |
||
| if(!parentFolder.exists()) { | ||
| parentFolder.mkdir(); | ||
| } | ||
| } | ||
|
|
||
| if(parentFolder == null) { | ||
| parentFolder = user; | ||
| } | ||
|
|
||
| final File memento_file = new File(parentFolder, memento_filename); | ||
|
|
||
| // File.exists() is blocking in nature. | ||
| // To combat this the phoebus application maintains a list of *.memento files that are in the default directory. | ||
| // Check if the file name is in the list, and confirm a file overwrite with the user. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some
# ...comments...to the preference settings, something that explains these because that all ends up in the online help and https://control-system-studio.readthedocs.io/en/latest/preference_properties.htmlThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course, comments added .