Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html /
 
 package org.eclipse.xtext.ui.editor.syntaxcoloring;
import  org.eclipse.jface.preference.ColorFieldEditor;
import  org.eclipse.jface.preference.FontFieldEditor;
import  org.eclipse.jface.preference.IPreferenceStore;
import  org.eclipse.jface.text.TextAttribute;
import  org.eclipse.swt.SWT;

Author(s):
Dennis H´┐Żbner - Initial contribution and API
	public TokenTypeDefDetailsPart(IPreferenceStore preferenceStore) {
		super(preferenceStore);
	}
	protected void createFieldEditors() {
		{
			// Foreground
			// Background
			addField(new ColorFieldEditor(."Background",
			// Style
			// TODO extract a FontStyleCheckBoxGroupFieldEditor
"Italic", String.valueOf(SWT.ITALIC) }, { "Bold", String.valueOf(SWT.BOLD) },
"Underline", String.valueOf(TextAttribute.UNDERLINE) },
"Strike through", String.valueOf(TextAttribute.STRIKETHROUGH) }, }, getFieldEditorParent(), true) {
				protected String calculateResult(String[][] settings) {
					int result = SWT.NORMAL;
					for (int i = 0; i < settings.lengthi++) {
						String[] row = settings[i];
						String value = row[1];
						String checked = row[2];
						if (Boolean.valueOf(checked)) {
							result += Integer.valueOf(value);
						}
					}
					return String.valueOf(result);
				}
				protected boolean isSelected(String fieldNameString valueToSet) {
					int value = SWT.NORMAL;
					try {
						value = Integer.valueOf(valueToSet);
					}
					catch (NumberFormatException nfe) {
						// ignore preference value
						return false;
					}
					if (value == SWT.NORMAL)
						return false;
					if (fieldName.equals("Italic"))
						return (value & SWT.ITALIC) == SWT.ITALIC;
					else if (fieldName.equals("Bold"))
						return (value & SWT.BOLD) == SWT.BOLD;
					else if (fieldName.equals("Underline"))
						return (value & TextAttribute.UNDERLINE) == TextAttribute.UNDERLINE;
					else if (fieldName.equals("Strike through"))
						return (value & TextAttribute.STRIKETHROUGH) == TextAttribute.STRIKETHROUGH;
					return false;
				}
			});
			// Font
		}
	}
New to GrepCode? Check out our FAQ X