GT-3179 - Help - addressed missing help for tool options; fixed bug that

caused help find dialog to be stuck behind Tool Options dialog; fixed
bug that caused the Help Find Dialog keybinding to trigger an exception
This commit is contained in:
dragonmacher 2019-10-04 15:43:13 -04:00
parent ea953ce924
commit 66198876e5
28 changed files with 296 additions and 151 deletions

View file

@ -1780,12 +1780,14 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
2) A component provider's code
3) A dialog provider's code
4) A background thread
5) The help window
It seems like the parent should be the active window for 1-2.
Case 3 should probably use the window of the dialog provider.
Case 4 should probably use the main tool frame, since the user may be
moving between windows while the thread is working. So, rather than using the
active window, we can default to the tool's frame.
Case 5 should use the help window.
We have not yet solidified how we should parent. This documentation is meant to
move us towards clarity as we find Use Cases that don't make sense. (Once we
@ -1828,7 +1830,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
Component c = parent;
while (c != null) {
if (c instanceof Frame) {
if (c instanceof Window) {
return (Window) c;
}
c = c.getParent();

View file

@ -175,7 +175,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
for (ActionData actionData : actions) {
if (actionData.isMyProvider(localContext)) {
hasLocalActionsForKeyBinding = true;
if (actionData.action.isEnabledForContext(localContext)) {
if (isValidAndEnabled(actionData, localContext)) {
list.add(new ExecutableKeyActionAdapter(actionData.action, localContext));
}
}
@ -199,7 +199,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
(ComponentBasedDockingAction) actionData.action;
if (componentAction.isValidComponentContext(localContext)) {
hasLocalActionsForKeyBinding = true;
if (actionData.action.isEnabledForContext(localContext)) {
if (isValidAndEnabled(actionData, localContext)) {
list.add(new ExecutableKeyActionAdapter(actionData.action, localContext));
}
}
@ -219,21 +219,22 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
// When looking for context matches, we prefer local context, even though this
// is a 'global' action. This allows more specific context to be used when
// available
if (actionData.action.isValidContext(localContext)) {
if (actionData.action.isEnabledForContext(localContext)) {
list.add(new ExecutableKeyActionAdapter(actionData.action, localContext));
}
if (isValidAndEnabled(actionData, localContext)) {
list.add(new ExecutableKeyActionAdapter(actionData.action, localContext));
}
else if (actionData.action.isValidGlobalContext(globalContext)) {
if (actionData.action.isEnabledForContext(globalContext)) {
list.add(new ExecutableKeyActionAdapter(actionData.action, globalContext));
}
else if (isValidAndEnabled(actionData, globalContext)) {
list.add(new ExecutableKeyActionAdapter(actionData.action, globalContext));
}
}
}
return list;
}
private boolean isValidAndEnabled(ActionData actionData, ActionContext localContext) {
DockingActionIf a = actionData.action;
return a.isValidContext(localContext) && a.isEnabledForContext(localContext);
}
@Override
public boolean isReservedKeybindingPrecedence() {
return false; // MultipleKeyActions can never be reserved

View file

@ -142,8 +142,9 @@ public class ToolActions implements DockingToolActions, PropertyChangeListener {
}
KeyStroke ks = action.getKeyBinding();
String description = "Keybinding for " + action.getFullName();
keyBindingOptions.registerOption(action.getFullName(), OptionType.KEYSTROKE_TYPE, ks, null,
null);
description);
KeyStroke newKs = keyBindingOptions.getKeyStroke(action.getFullName(), ks);
if (!Objects.equals(ks, newKs)) {
action.setUnvalidatedKeyBindingData(new KeyBindingData(newKs));
@ -175,8 +176,9 @@ public class ToolActions implements DockingToolActions, PropertyChangeListener {
private void registerStub(SharedStubKeyBindingAction stub, KeyStroke defaultKeyStroke) {
stub.addPropertyChangeListener(this);
String description = "Keybinding for Stub action: " + stub.getFullName();
keyBindingOptions.registerOption(stub.getFullName(), OptionType.KEYSTROKE_TYPE,
defaultKeyStroke, null, null);
defaultKeyStroke, null, description);
keyBindingsManager.addAction(null, stub);
}

View file

@ -319,14 +319,15 @@ public class OptionsPanel extends JPanel {
return; // not sure this can happen
}
HelpService help = Help.getHelpService();
HelpLocation location = options.getOptionsHelpLocation();
if (location == null) {
// The tree node may or may not have help. The leaf options should all have help.
return;
help.clearHelp(this);
}
else {
help.registerHelp(this, location);
}
HelpService help = Help.getHelpService();
help.registerHelp(this, location);
}
private OptionsEditor getOptionsEditor(OptionsTreeNode node) {