Commit b4e8d9ac authored by Adam Knapp's avatar Adam Knapp
Browse files

Add dynamic query of key binding (issue #442 #449)


Signed-off-by: Adam Knapp's avatarAdam Knapp <adam.knapp@ericsson.com>
parent 0fb5f39c
......@@ -1179,26 +1179,23 @@
description="Toggle Comment"
id="org.eclipse.titan.designer.editors.configeditor.ToggleComment"
name="Toggle Comment" />
<category id="org.eclipse.titan.designer.editors.TITANCommands"
name="TITAN Commands" />
<command
categoryId="org.eclipse.titan.designer.editors.TITANCommands"
<command categoryId="org.eclipse.titan.designer.editors.TITANCommands"
description="Shows the source of the declaration in a popup"
id="org.eclipse.titan.designer.editors.ttcn3editor.OpenDeclaration"
name="Peek Declaration">
</command>
<command
categoryId="org.eclipse.titan.designer.editors.TITANCommands"
<command categoryId="org.eclipse.titan.designer.editors.TITANCommands"
description="Peeks a declaration"
id="org.eclipse.titan.designer.editors.ttcn3editor.PeekDeclaration"
name="Peek declaration">
</command>
<command
categoryId="org.eclipse.titan.designer.editors.TITANCommands"
<command categoryId="org.eclipse.titan.designer.editors.TITANCommands"
description="Switch between the content types of hover window"
id="org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction"
name="Switch hover window content">
</command>
<category id="org.eclipse.titan.designer.editors.TITANCommands"
name="TITAN Commands" />
</extension>
<extension point="org.eclipse.ui.bindings">
<key commandId="org.eclipse.titan.designer.firstChar"
......@@ -1363,8 +1360,7 @@
commandId="org.eclipse.titan.designer.editors.ttcn3editor.PeekDeclaration"
contextId="org.eclipse.titan.designer.editors.TTCN3EditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="F9">
</key>
sequence="F9" />
<key
commandId="org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction"
contextId="org.eclipse.titan.designer.editors.ASN1EditorScope"
......
......@@ -25,6 +25,7 @@ import org.eclipse.ui.IEditorPart;
* @author Adam Knapp
* */
public class SwitchHoverWindowContentAction extends AbstractHandler implements IEditorActionDelegate {
private static final String COMMAND_ID = "org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction";
private static final String[] HOVER_WINDOW_CONTENT_TYPE = new String[] {
PreferenceConstantValues.HOVER_WINDOW_CONTENT_COMMENT, PreferenceConstantValues.HOVER_WINDOW_CONTENT_PEEK
};
......@@ -35,6 +36,10 @@ public class SwitchHoverWindowContentAction extends AbstractHandler implements I
return null;
}
public static String getCommandId() {
return COMMAND_ID;
}
@Override
public void run(IAction action) {
switchHoverWindowContent();
......
......@@ -16,7 +16,10 @@ import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.titan.designer.editors.actions.SwitchHoverWindowContentAction;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.keys.IBindingService;
/**
* Control for handling ttcn3 source editor hovers
......@@ -66,7 +69,15 @@ public class Ttcn3HoverInfoControl extends AbstractInformationControl implements
viewer.setEditable(false);
viewer.setBackground(fShell.getBackground());
if (isRich) {
setStatusText("Press Ctrl+F2 for code view mode");
String keyBinding= null;
IBindingService bindingService= PlatformUI.getWorkbench().getAdapter(IBindingService.class);
if (bindingService != null) {
keyBinding = bindingService.getBestActiveBindingFormattedFor(SwitchHoverWindowContentAction.getCommandId());
}
if (keyBinding == null) {
keyBinding = "<unbound>";
}
setStatusText("Press " + keyBinding + " for code view mode");
} else {
setStatusText("Hover to focus");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment