Commit b34a7d32 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Syntax highlighting preferences preview code styling


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 8bfed157
......@@ -12,11 +12,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelectionChangedListener;
......@@ -26,6 +30,7 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
......@@ -38,6 +43,8 @@ import org.eclipse.titan.designer.preferences.PreferenceConstants;
import org.eclipse.titan.designer.preferences.PreferenceInitializer;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.osgi.service.prefs.Preferences;
/**
* This preference page hold the controls and functionality related to syntax
......@@ -473,8 +480,16 @@ public final class SyntaxHighlightPage extends PreferencePage implements IWorkbe
textViewer = new StyledText(colorEditorsComposite, SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
textViewer.setEditable(false);
textViewer.setLayoutData(wordsGridData);
textViewer.setBackground(getShell().getBackground());
textViewer.setFont(getFont());
Preferences preferences = InstanceScope.INSTANCE.getNode("org.eclipse.ui.editors");
String bgColor = preferences.get("AbstractTextEditor.Color.Background", null);
if (bgColor == null) {
preferences = DefaultScope.INSTANCE.getNode("org.eclipse.ui.editors");
bgColor = preferences.get("AbstractTextEditor.Color.Background", null);
}
if (bgColor != null) {
textViewer.setBackground(new Color(PlatformUI.getWorkbench().getDisplay(), StringConverter.asRGB(bgColor)));
}
textViewer.setFont(JFaceResources.getTextFont());
addTemplateText(PreferenceConstants.COLOR_COMMENTS, "/**\n"
+ " * @desc Demo module\n"
+ " * @status deprecated\n"
......@@ -510,6 +525,7 @@ public final class SyntaxHighlightPage extends PreferencePage implements IWorkbe
addTemplateText(PreferenceConstants.COLOR_AST_VARIABLE, "c2");
addTemplateText(PreferenceConstants.COLOR_NORMAL_TEXT, "\n");
addTemplateText(PreferenceConstants.COLOR_NORMAL_TEXT, "}\n");
updateStyleRanges();
}
private void createSemanticHighlightingCheckbox(final Composite parent) {
......
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