Commit 403caf5f authored by Adam Knapp's avatar Adam Knapp
Browse files

Configuration parameter for hover window content (issue #442 #449)


Signed-off-by: Adam Knapp's avatarAdam Knapp <adam.knapp@ericsson.com>
parent 7deb9485
......@@ -202,6 +202,11 @@
id="org.eclipse.titan.designer.editors.ttcn3editor.PeekDeclaration"
name="Peek Declaration">
</command>
<command
defaultHandler="org.eclipse.titan.designer.editors.actions.SwitchHoverWindowContentAction"
id="org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction"
name="Switch hover window content">
</command>
</extension>
<extension
......@@ -617,6 +622,12 @@
id="org.eclipse.titan.designer.editors.ttcn3editor.PeekDeclaration"
label="Peek Declaration">
</command>
<command
commandId="org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction"
icon="icons/titan.gif"
id="org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction"
label="Switch hover window content">
</command>
</menuContribution>
<menuContribution
......@@ -1182,6 +1193,12 @@
id="org.eclipse.titan.designer.editors.ttcn3editor.PeekDeclaration"
name="Peek declaration">
</command>
<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>
</extension>
<extension point="org.eclipse.ui.bindings">
<key commandId="org.eclipse.titan.designer.firstChar"
......@@ -1348,6 +1365,21 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="F9">
</key>
<key
commandId="org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction"
contextId="org.eclipse.titan.designer.editors.ASN1EditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+F2" />
<key
commandId="org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction"
contextId="org.eclipse.titan.designer.editors.TTCN3EditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+F2" />
<key
commandId="org.eclipse.titan.designer.editors.SwitchHoverWindowContentAction"
contextId="org.eclipse.titan.designer.editors.TTCN3PPEditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+F2" />
</extension>
<extension point="org.eclipse.ui.contexts">
<context description="%context.editingText.description.testtest"
......
/******************************************************************************
* Copyright (c) 2000-2021 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
******************************************************************************/
package org.eclipse.titan.designer.editors.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.titan.designer.Activator;
import org.eclipse.titan.designer.preferences.PreferenceConstantValues;
import org.eclipse.titan.designer.preferences.PreferenceConstants;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
/**
* Used to provide hotkey for switching between hover window content types, i.e. code comment and code peek
*
* @author Adam Knapp
* */
public class SwitchHoverWindowContentAction extends AbstractHandler implements IEditorActionDelegate {
private static final String[] HOVER_WINDOW_CONTENT_TYPE = new String[] {
PreferenceConstantValues.HOVER_WINDOW_CONTENT_COMMENT, PreferenceConstantValues.HOVER_WINDOW_CONTENT_PEEK
};
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
switchHoverWindowContent();
return null;
}
@Override
public void run(IAction action) {
switchHoverWindowContent();
}
@Override
public void selectionChanged(IAction action, ISelection selection) {
// Do nothing
}
@Override
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
// Do nothing
}
private void switchHoverWindowContent() {
final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
final String hoverWindowContent = prefStore.getString(PreferenceConstants.HOVER_WINDOW_CONTENT);
int i = 0;
for (; i < HOVER_WINDOW_CONTENT_TYPE.length; i++) {
if (hoverWindowContent.equals(HOVER_WINDOW_CONTENT_TYPE[i])) {
i++;
break;
}
}
if (i == HOVER_WINDOW_CONTENT_TYPE.length) {
i = 0;
}
prefStore.setValue(PreferenceConstants.HOVER_WINDOW_CONTENT, HOVER_WINDOW_CONTENT_TYPE[i]);
}
}
......@@ -292,6 +292,10 @@ public final class PreferenceConstantValues {
public static final String BEFORE_BUILD_CLEAR_CONSOLE = "Clear";
public static final String BEFORE_BUILD_PRINT_CONSOLE_DELIMITERS = "Print delimiter";
// Content of hover window
public static final String HOVER_WINDOW_CONTENT_COMMENT = "comment";
public static final String HOVER_WINDOW_CONTENT_PEEK = "peek";
/** private constructor to disable instantiation */
private PreferenceConstantValues() {
......
......@@ -39,6 +39,7 @@ public final class PreferenceConstants {
public static final String CONTENTASSISTANT_PROPOSAL_SORTING = ProductConstants.PRODUCT_ID_DESIGNER + ".proposalSorting";
public static final String CONTENTASSISTANT_AUTO_ACTIVATION = ProductConstants.PRODUCT_ID_DESIGNER + ".autoActivation";
public static final String CONTENTASSISTANT_AUTO_ACTIVATION_DELAY = ProductConstants.PRODUCT_ID_DESIGNER + ".autoActivationDelay";
public static final String HOVER_WINDOW_CONTENT = ProductConstants.PRODUCT_ID_DESIGNER + ".hoverWindowContent";
//export
public static final String EXPORT_EXCLUDE_WORKING_DIRECTORY_CONTENTS = ProductConstants.PRODUCT_ID_DESIGNER + ".excludeWorkingDirectoryContents";
......
......@@ -65,6 +65,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
preferenceStore.setDefault(PreferenceConstants.CONTENTASSISTANT_PROPOSAL_SORTING, PreferenceConstantValues.SORT_BY_RELEVANCE);
preferenceStore.setDefault(PreferenceConstants.CONTENTASSISTANT_AUTO_ACTIVATION, true);
preferenceStore.setDefault(PreferenceConstants.CONTENTASSISTANT_AUTO_ACTIVATION_DELAY, 100);
preferenceStore.setDefault(PreferenceConstants.HOVER_WINDOW_CONTENT, PreferenceConstantValues.HOVER_WINDOW_CONTENT_COMMENT);
// export
preferenceStore.setDefault(PreferenceConstants.EXPORT_EXCLUDE_WORKING_DIRECTORY_CONTENTS, true);
......
......@@ -37,6 +37,10 @@ public final class ContentAssistPage extends FieldEditorPreferencePage implement
{ PreferenceConstantValues.SORT_BY_RELEVANCE, PreferenceConstantValues.SORT_BY_RELEVANCE },
{ PreferenceConstantValues.SORT_ALPHABETICALLY, PreferenceConstantValues.SORT_ALPHABETICALLY } };
private static final String[][] HOVER_OPTIONS = new String[][] {
{ "code comment", PreferenceConstantValues.HOVER_WINDOW_CONTENT_COMMENT },
{ "code peek", PreferenceConstantValues.HOVER_WINDOW_CONTENT_PEEK } };
private Composite pageComposite;
private Group insertionGroup;
......@@ -50,6 +54,9 @@ public final class ContentAssistPage extends FieldEditorPreferencePage implement
private Composite autoActivationComposite;
private BooleanFieldEditor enableAutoActivation;
private IntegerFieldEditor autoActivationDelay;
private Group hoverWindowContentGroup;
private Composite hoverWindowContentComposite;
private ComboFieldEditor hoverWindowContentCombo;
public ContentAssistPage() {
super(GRID);
......@@ -128,6 +135,22 @@ public final class ContentAssistPage extends FieldEditorPreferencePage implement
autoActivationDelay.setEnabled(doGetPreferenceStore().getBoolean(PreferenceConstants.CONTENTASSISTANT_AUTO_ACTIVATION),
autoActivationComposite);
addField(autoActivationDelay);
hoverWindowContentGroup = new Group(pageComposite, SWT.SHADOW_ETCHED_OUT);
hoverWindowContentGroup.setText("Content of hover window");
hoverWindowContentGroup.setLayout(new GridLayout(2, false));
hoverWindowContentGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
hoverWindowContentComposite = new Composite(hoverWindowContentGroup, SWT.NONE);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
gridData.horizontalIndent = 3;
hoverWindowContentComposite.setLayoutData(gridData);
hoverWindowContentCombo = new ComboFieldEditor(PreferenceConstants.HOVER_WINDOW_CONTENT,
"Hover window content:", HOVER_OPTIONS, hoverWindowContentComposite);
final Label text2 = hoverWindowContentCombo.getLabelControl(hoverWindowContentComposite);
text2.setToolTipText("What do you want to see as hover tooltip");
addField(hoverWindowContentCombo);
}
@Override
......@@ -150,6 +173,9 @@ public final class ContentAssistPage extends FieldEditorPreferencePage implement
autoActivationComposite.dispose();
enableAutoActivation.dispose();
autoActivationDelay.dispose();
hoverWindowContentGroup.dispose();
hoverWindowContentGroup.dispose();
hoverWindowContentCombo.dispose();
super.dispose();
}
......
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