Updated the help window to not preserve the previous location on a new

request for the same page
This commit is contained in:
dragonmacher 2025-03-10 19:01:48 -04:00
parent 73d29e3488
commit ef7c79f0c0
4 changed files with 23 additions and 14 deletions

View file

@ -573,7 +573,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
/**
* Returns true if there is a {@link CodeUnit} for the address
* wrapped by this info. If not, then we do not have a valid addreess.
* wrapped by this info. If not, then we do not have a valid address.
*
* @return true if there is a {@link CodeUnit} for the address
* wrapped by this info.

View file

@ -142,7 +142,7 @@ public class DockingHelpBroker extends GHelpBroker {
@Override
public void actionPerformed(ActionEvent e) {
reloadHelpPage(getCurrentURL());
reloadHelpPage(getCurrentURL(), true);
}
};
toolbar.add(new JButton(refreshAction));
@ -150,8 +150,8 @@ public class DockingHelpBroker extends GHelpBroker {
}
@Override // opened access
protected void reloadHelpPage(URL url) {
super.reloadHelpPage(url);
protected void reloadHelpPage(URL url, boolean preserveLocation) {
super.reloadHelpPage(url, preserveLocation);
}
//=================================================================================================

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -462,7 +462,7 @@ public class HelpManager implements HelpService {
// an invokeLater() will work as long as the model loading is
// relatively quick.
//
SystemUtilities.runSwingLater(() -> displayHelp(help, owner));
Swing.runLater(() -> displayHelp(help, owner));
return;
}
@ -596,7 +596,10 @@ public class HelpManager implements HelpService {
return;
}
((DockingHelpBroker) mainHB).reloadHelpPage(validateUrl(helpURL));
// Let the URL dictate where the page scrolls to. If we do not do this, then there is an
// odd effect of having the page load and then jump to a previous location.
boolean preserveLocation = false;
((DockingHelpBroker) mainHB).reloadHelpPage(validateUrl(helpURL), preserveLocation);
}
private URL getURLForID(ID ID) {

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -85,14 +85,14 @@ public class GHelpBroker extends DefaultHelpBroker {
}
/* Perform some shenanigans to force Java Help to reload the given URL */
protected void reloadHelpPage(URL url) {
protected void reloadHelpPage(URL url, boolean preserveLocation) {
clearContentViewer();
showNavigationAid(url);
try {
// Page loading is asynchronous. Listen for the page to be loaded and then restore the
// users current view state.
htmlEditorPane.addPropertyChangeListener(new PageLocationUpdater());
htmlEditorPane.addPropertyChangeListener(new PageLocationUpdater(preserveLocation));
htmlEditorPane.setPage(url);
}
catch (IOException e) {
@ -102,7 +102,7 @@ public class GHelpBroker extends DefaultHelpBroker {
}
private void reloadHelpPage() {
reloadHelpPage(getCurrentURL());
reloadHelpPage(getCurrentURL(), true);
}
public void reload() {
@ -378,8 +378,10 @@ public class GHelpBroker extends DefaultHelpBroker {
private URL url;
private int caretPosition;
private Rectangle viewPosition;
private boolean preserveLocation;
PageLocationUpdater() {
PageLocationUpdater(boolean preserveLocation) {
this.preserveLocation = preserveLocation;
url = getCurrentURL();
caretPosition = htmlEditorPane.getCaretPosition();
viewPosition = htmlEditorPane.getVisibleRect();
@ -399,6 +401,10 @@ public class GHelpBroker extends DefaultHelpBroker {
return; // new page loaded; ignore
}
if (!preserveLocation) {
return;
}
htmlEditorPane.setCaretPosition(caretPosition);
// not sure why this needs to be done later, but setting the caret seems to trigger a
// view updated, so try to run after that