Commit 82bf039d authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Styling for code peek window


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent e2eb6a21
......@@ -7,6 +7,8 @@
******************************************************************************/
package org.eclipse.titan.designer.editors.controls;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
......@@ -18,10 +20,12 @@ import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
......@@ -42,14 +46,20 @@ public class Ttcn3SourceViewControl implements IInformationControl {
myshell = new Shell(parent, SWT.ON_TOP | SWT.TOOL | SWT.LEFT_TO_RIGHT | SWT.RESIZE);
Composite composite = myshell;
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginHeight = 10;
layout.marginWidth = 10;
composite.setLayout(layout);
setSize(600, 400);
final Display display = myshell.getDisplay();
//setBackgroundColor(display.getSystemColor(SWT.COLOR_YELLOW));
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
composite.setLayoutData(gridData);
viewer = new SourceViewer(composite, null, 0);
viewer = new SourceViewer(composite, null, SWT.V_SCROLL | SWT.H_SCROLL);
viewer.setEditable(false);
Font textFont= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
StyledText styledText = viewer.getTextWidget();
styledText.setFont(textFont);
StyledText st = viewer.getTextWidget();
gridData = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
st.setLayoutData(gridData);
......@@ -96,8 +106,7 @@ public class Ttcn3SourceViewControl implements IInformationControl {
@Override
public void setSize(int width, int height) {
//myshell.setSize(width, height);
myshell.setSize(200, 200);
myshell.setSize(width, height);
}
@Override
......@@ -105,6 +114,11 @@ public class Ttcn3SourceViewControl implements IInformationControl {
myshell.setLocation(location);
}
@Override
public void setBackgroundColor(Color background) {
myshell.setBackground(background);
}
@Override
public void dispose() {
// TODO Auto-generated method stub
......@@ -129,12 +143,7 @@ public class Ttcn3SourceViewControl implements IInformationControl {
}
@Override
public void setBackgroundColor(Color background) {
// TODO Auto-generated method stub
}
@Override
public boolean isFocusControl() {
// TODO Auto-generated method stub
......
......@@ -17,6 +17,10 @@ import org.eclipse.jface.action.IAction;
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.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;
......@@ -134,6 +138,14 @@ public class PeekDeclaration extends AbstractHandler implements IEditorActionDel
IDocument document = provider.getDocument(input);
Ttcn3SourceViewControl con = new Ttcn3SourceViewControl(shell);
Control control = targetEditor.getAdapter(Control.class);
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);
}
Location loc = ass.getLocation();
StringBuilder code = new StringBuilder();
try {
......
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