Commit 8a06cb20 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Fixed Ttcn3SourceViewControl style; event listener for editor change


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent f5c517ff
......@@ -15,6 +15,7 @@ import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlExtension2;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
......@@ -27,12 +28,15 @@ import org.eclipse.swt.graphics.Rectangle;
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.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.titan.designer.editors.ColorManager;
import org.eclipse.titan.designer.editors.ttcn3editor.CodeScanner;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
/**
* A custom TTCN3 source viewer control for the TTCN3 editor
......@@ -66,7 +70,7 @@ public class Ttcn3SourceViewControl implements IInformationControl, IInformation
if (myshell != null) {
return;
}
myshell = new Shell(parent, SWT.ON_TOP | SWT.TOOL | SWT.LEFT_TO_RIGHT | SWT.RESIZE);
myshell = new Shell(parent, SWT.TOOL | SWT.LEFT_TO_RIGHT | SWT.RESIZE);
Composite composite = myshell;
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 10;
......@@ -81,6 +85,10 @@ public class Ttcn3SourceViewControl implements IInformationControl, IInformation
gridData = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
viewer.setLayoutData(gridData);
viewer.setFont(textFont);
/**
* event listener for ESC
*/
myshell.addListener(SWT.Traverse, new Listener() {
public void handleEvent(Event event) {
switch (event.detail) {
......@@ -92,6 +100,17 @@ public class Ttcn3SourceViewControl implements IInformationControl, IInformation
}
}
});
/**
* event listener for editor change
*/
ISelectionService selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
selection.addPostSelectionListener(new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
dispose();
}
});
}
@Override
......@@ -104,7 +123,7 @@ public class Ttcn3SourceViewControl implements IInformationControl, IInformation
/*
* We may need to strip some leading tabs/spaces from all lines except the first one
*
* This is because whitespaces are typically missing for the first line, and all the other
* This is because whitespaces are typically missing for the first line but all the other
* lines are indented
*/
String[] lines = information.split("\n");
......@@ -216,7 +235,9 @@ public class Ttcn3SourceViewControl implements IInformationControl, IInformation
@Override
public void dispose() {
instance = null;
myshell.dispose();
if (myshell != null && ! myshell.isDisposed()) {
myshell.dispose();
}
myshell = null;
}
......
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