Commit 15bf6201 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Improvements for code peek (popup position, more types supported)


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 82bf039d
......@@ -119,6 +119,11 @@ public class Ttcn3SourceViewControl implements IInformationControl {
myshell.setBackground(background);
}
@Override
public void setFocus() {
myshell.setFocus();
}
@Override
public void dispose() {
// TODO Auto-generated method stub
......@@ -143,18 +148,12 @@ public class Ttcn3SourceViewControl implements IInformationControl {
}
@Override
public boolean isFocusControl() {
// TODO Auto-generated method stub
return false;
}
@Override
public void setFocus() {
myshell.setFocus();
}
@Override
public void addFocusListener(FocusListener listener) {
// TODO Auto-generated method stub
......
......@@ -14,17 +14,21 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.titan.designer.AST.Assignment;
import org.eclipse.titan.designer.AST.Location;
import org.eclipse.titan.designer.AST.Module;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
import org.eclipse.titan.designer.consoles.TITANDebugConsole;
import org.eclipse.titan.designer.declarationsearch.Declaration;
......@@ -127,8 +131,13 @@ public class PeekDeclaration extends AbstractHandler implements IEditorActionDel
return;
}
final Assignment ass = decl.getAssignment();
if (ass instanceof Def_Type) {
final Assignment ass = decl.getAssignment();
Location codeLoc = null;
if (ass instanceof Def_Type || ass instanceof Def_Function ||
ass instanceof Def_Testcase) {
codeLoc = ass.getLocation();
}
if (codeLoc != null) {
Shell shell = targetEditor.getSite().getShell();
if (targetEditor instanceof ITextEditor)
{
......@@ -142,14 +151,17 @@ public class PeekDeclaration extends AbstractHandler implements IEditorActionDel
if (control instanceof StyledText) {
final StyledText text = (StyledText)control;
final Point caretRel = text.getLocationAtOffset(text.getCaretOffset());
final Point caretAbs = shell.toDisplay(caretRel);
con.setLocation(caretAbs);
Point caretLocation = text.getLocationAtOffset(text.getCaretOffset());
Point displayLocation = text.toDisplay(caretLocation);
final Font textFont= JFaceResources.getFont(org.eclipse.jdt.ui.PreferenceConstants.EDITOR_TEXT_FONT);
final FontData fontData[] = textFont.getFontData();
displayLocation.y += (fontData[0].getHeight() * 2);
con.setLocation(displayLocation);
}
Location loc = ass.getLocation();
StringBuilder code = new StringBuilder();
try {
for (int i = loc.getOffset(); i <= loc.getEndOffset(); i++) {
for (int i = codeLoc.getOffset(); i <= codeLoc.getEndOffset(); i++) {
char c = document.getChar(i);
code.append(c);
}
......
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