List of usage examples for org.eclipse.jface.preference IPreferenceStore isDefault
boolean isDefault(String name);
From source file:gov.redhawk.ui.port.nxmplot.preferences.Preference.java
License:Open Source License
public boolean isDefault(IPreferenceStore store) { return store.isDefault(getName()); }
From source file:isabelle.eclipse.ui.preferences.OverlayPreferenceStore.java
License:Open Source License
/** * Propagates the given overlay key from the orgin to the target preference store. * * @param orgin the source preference store * @param key the overlay key/*from ww w . j av a 2 s . c o m*/ * @param target the preference store to which the key is propagated */ private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { if (orgin.isDefault(key.fKey)) { if (!target.isDefault(key.fKey)) target.setToDefault(key.fKey); return; } TypeDescriptor d = key.fDescriptor; if (BOOLEAN == d) { boolean originValue = orgin.getBoolean(key.fKey); boolean targetValue = target.getBoolean(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (DOUBLE == d) { double originValue = orgin.getDouble(key.fKey); double targetValue = target.getDouble(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (FLOAT == d) { float originValue = orgin.getFloat(key.fKey); float targetValue = target.getFloat(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (INT == d) { int originValue = orgin.getInt(key.fKey); int targetValue = target.getInt(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (LONG == d) { long originValue = orgin.getLong(key.fKey); long targetValue = target.getLong(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (STRING == d) { String originValue = orgin.getString(key.fKey); String targetValue = target.getString(key.fKey); if (targetValue != null && originValue != null && !targetValue.equals(originValue)) target.setValue(key.fKey, originValue); } }
From source file:melnorme.lang.ide.ui.editor.JavaSourceViewer_Mod.java
License:Open Source License
/** * Creates a color from the information stored in the given preference store. * Returns <code>null</code> if there is no such information available. * * @param store the store to read from// ww w . j a va 2 s . co m * @param key the key used for the lookup in the preference store * @param display the display used create the color * @return the created color according to the specification in the preference store * @since 3.0 */ protected Color createColor(IPreferenceStore store, String key, Display display) { RGB rgb = null; if (store.contains(key)) { if (store.isDefault(key)) rgb = PreferenceConverter.getDefaultColor(store, key); else rgb = PreferenceConverter.getColor(store, key); if (rgb != null) return new Color(display, rgb); } return null; }
From source file:melnorme.lang.ide.ui.editor.ViewerColorUpdater.java
License:Open Source License
protected Color createColor(IPreferenceStore store, String key, Display display) { RGB rgb = null;/*from w ww. j a v a 2s.com*/ if (store.contains(key)) { if (store.isDefault(key)) { rgb = PreferenceConverter.getDefaultColor(store, key); } else { rgb = PreferenceConverter.getColor(store, key); } if (rgb != null) return new Color(display, rgb); } return null; }
From source file:melnorme.util.swt.jface.preference.OverlayPreferenceStore.java
License:Open Source License
protected void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { if (orgin.isDefault(key.fKey)) { if (!target.isDefault(key.fKey)) target.setToDefault(key.fKey); return;//w ww . j a v a2 s .c o m } TypeDescriptor d = key.fDescriptor; if (BOOLEAN == d) { boolean originValue = orgin.getBoolean(key.fKey); boolean targetValue = target.getBoolean(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (DOUBLE == d) { double originValue = orgin.getDouble(key.fKey); double targetValue = target.getDouble(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (FLOAT == d) { float originValue = orgin.getFloat(key.fKey); float targetValue = target.getFloat(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (INT == d) { int originValue = orgin.getInt(key.fKey); int targetValue = target.getInt(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (LONG == d) { long originValue = orgin.getLong(key.fKey); long targetValue = target.getLong(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (STRING == d) { String originValue = orgin.getString(key.fKey); String targetValue = target.getString(key.fKey); if (targetValue != null && originValue != null && !targetValue.equals(originValue)) target.setValue(key.fKey, originValue); } }
From source file:net.certiv.fluentmark.editor.FluentSourceViewer.java
License:Open Source License
/** * Creates a color from the information stored in the given preference delta. Returns * <code>null</code> if there is no such information available. TODO: move or fix store.getColor * * @param delta the delta to read from/*from w ww . j a va 2s . c o m*/ * @param key the key used for the lookup in the preference delta * @param display the display used create the color * @return the created color according to the specification in the preference delta */ public Color createColor(IPreferenceStore store, String key, Display display) { RGB rgb = null; if (store.contains(key)) { if (store.isDefault(key)) { rgb = PreferenceConverter.getDefaultColor(store, key); } else { rgb = PreferenceConverter.getColor(store, key); } if (rgb != null) return new Color(display, rgb); } return null; }
From source file:net.certiv.fluentmark.preferences.OverlayPreferenceStore.java
License:Open Source License
/** * Propagates the given overlay key from the origin to the target preference store. * * @param origin the source preference store * @param key the overlay key/* www . ja va2 s . c o m*/ * @param target the preference store to which the key is propagated */ private void propagateProperty(IPreferenceStore origin, OverlayKey key, IPreferenceStore target) { if (origin.isDefault(key.fKey)) { if (!target.isDefault(key.fKey)) target.setToDefault(key.fKey); return; } TypeDescriptor d = key.fDescriptor; if (BOOLEAN == d) { boolean originValue = origin.getBoolean(key.fKey); boolean targetValue = target.getBoolean(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (DOUBLE == d) { double originValue = origin.getDouble(key.fKey); double targetValue = target.getDouble(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (FLOAT == d) { float originValue = origin.getFloat(key.fKey); float targetValue = target.getFloat(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (INT == d) { int originValue = origin.getInt(key.fKey); int targetValue = target.getInt(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (LONG == d) { long originValue = origin.getLong(key.fKey); long targetValue = target.getLong(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (STRING == d) { String originValue = origin.getString(key.fKey); String targetValue = target.getString(key.fKey); if (targetValue != null && originValue != null && !targetValue.equals(originValue)) target.setValue(key.fKey, originValue); } }
From source file:net.sf.eclipsensis.editor.text.NSISTextUtility.java
License:Open Source License
private static Color createColor(Map<String, Color> map, IPreferenceStore store, String key, String defaultKey, Display display) {/*from www .j a v a 2 s. co m*/ if (!store.getBoolean(defaultKey)) { if (store.contains(key)) { RGB rgb = null; if (store.isDefault(key)) { rgb = PreferenceConverter.getDefaultColor(store, key); } else { rgb = PreferenceConverter.getColor(store, key); } Color color = new Color(display, rgb); Color oldColor = map.put(key, color); if (oldColor != null) { oldColor.dispose(); } return color; } } return null; }
From source file:net.sf.eclipsensis.installoptions.dialogs.InstallOptionsPreferencePage.java
License:Open Source License
private <T> void loadPreference(Map<String, ? super T> map, String name, TypeConverter<T> converter, T defaultValue) {/* w w w . j a v a 2 s .c o m*/ T o = null; try { IPreferenceStore store = getPreferenceStore(); if (store.contains(name) || store.isDefault(name)) { o = converter.asType(store.getString(name)); } } catch (Exception ex) { o = null; } if (o == null) { o = converter.makeCopy(defaultValue); } map.put(name, o); }
From source file:net.sf.eclipsensis.util.HTMLExporter.java
License:Open Source License
/** * @throws UnsupportedEncodingException//from w w w.j a v a2s . c o m * @throws FileNotFoundException * @throws IOException */ private void writeHead(File file) throws UnsupportedEncodingException, FileNotFoundException, IOException { String charset = null; IDocumentProvider provider = mEditor.getDocumentProvider(); if (provider instanceof IStorageDocumentProvider) { charset = ((IStorageDocumentProvider) provider).getEncoding(mEditor.getEditorInput()); if (charset == null) { charset = ((IStorageDocumentProvider) provider).getDefaultEncoding(); } } if (charset == null) { charset = System.getProperty("file.encoding"); //$NON-NLS-1$ } if (charset != null) { mWriter = new PrintWriter( new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset))); } else { mWriter = new PrintWriter(new BufferedWriter(new FileWriter(file))); } mWriter.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); //$NON-NLS-1$ mWriter.println("<html>"); //$NON-NLS-1$ mWriter.println("<head>"); //$NON-NLS-1$ mWriter.print("<title>"); //$NON-NLS-1$ mWriter.print(NSISEditorUtilities.getPathEditorInput(mEditor).getPath().toOSString()); mWriter.println("</title>"); //$NON-NLS-1$ mWriter.print("<meta http-equiv=\"Content-Type\" content=\"text/html"); //$NON-NLS-1$ if (charset != null) { mWriter.print("; charset="); //$NON-NLS-1$ mWriter.print(charset); } mWriter.println("\">"); //$NON-NLS-1$ mWriter.println("<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">"); //$NON-NLS-1$ mWriter.println("<style type=\"text/css\">"); //$NON-NLS-1$ mWriter.print("body { background-color: #"); //$NON-NLS-1$ mWriter.print(ColorManager.rgbToHex(mStyledText.getBackground().getRGB())); mWriter.println("}"); //$NON-NLS-1$ mWriter.println("pre { display: inline }"); //$NON-NLS-1$ mWriter.println("a { color: #567599; text-decoration: none; }"); //$NON-NLS-1$ mWriter.println("a:hover { background-color: #F4F4F4; color: #303030; text-decoration: underline}"); //$NON-NLS-1$ if (mProjectionEnabled) { mWriter.println( "table.expand { float:right; border: 1px solid #567599; font-size: 1px; cursor: pointer; cursor: hand; }"); //$NON-NLS-1$ mWriter.println("table.expand td { height: 4px; width: 4px; }"); //$NON-NLS-1$ mWriter.println("table.expand td.top { border-bottom: 1px solid #567599; }"); //$NON-NLS-1$ mWriter.println("table.expand td.right { width: 4px; border-left: 1px solid #567599; }"); //$NON-NLS-1$ mWriter.println( "table.collapse { float:right; border: 1px solid #567599; font-size: 1px; cursor: pointer; cursor: hand; }"); //$NON-NLS-1$ mWriter.println("table.collapse td { height: 4px; width: 4px; }"); //$NON-NLS-1$ mWriter.println("table.collapse td.top { border-bottom: 1px solid #567599; }"); //$NON-NLS-1$ mWriter.println(".hiddenRow { display:none; }"); //$NON-NLS-1$ mWriter.println( "#lineDiv { font-size: 1px; display: none; position: absolute; color: #567599; border-left: solid 1px; border-bottom: solid 1px; width: 1px; height: 1px; }"); //$NON-NLS-1$ } if (mLineNumbersVisible) { StringBuffer buf = new StringBuffer("text-align: right; color: #"); //$NON-NLS-1$ RGB rgb = null; // foreground color IPreferenceStore store = EditorsUI.getPreferenceStore(); String pref = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR; if (store.contains(pref)) { if (store.isDefault(pref)) { rgb = PreferenceConverter.getDefaultColor(store, pref); } else { rgb = PreferenceConverter.getColor(store, pref); } } if (rgb == null) { rgb = new RGB(0, 0, 0); } buf.append(ColorManager.rgbToHex(rgb)); mWriter.print(".lineNum { "); //$NON-NLS-1$ mWriter.print(buf.toString()); mWriter.println(" }"); //$NON-NLS-1$ } mWriter.print(".ruler { background-color: #FFFFFF; text-align: right; border-right: 2px solid #"); //$NON-NLS-1$ mWriter.print( ColorManager.rgbToHex(mShell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB())); mWriter.println(" }"); //$NON-NLS-1$ mWriter.println("</style>"); //$NON-NLS-1$ if (mProjectionEnabled) { mWriter.println("<script type=\"text/javascript\" language=\"javascript\">"); //$NON-NLS-1$ mWriter.println("<!--"); //$NON-NLS-1$ mWriter.println("document.write(\"<style type='text/css'>\");"); //$NON-NLS-1$ mWriter.println("if(navigator.userAgent.toLowerCase().indexOf(\"netscape6\") >= 0) {"); //$NON-NLS-1$ mWriter.println(" document.write(\"table.collapse td.right { width: 4px; }\")"); //$NON-NLS-1$ mWriter.println("}"); //$NON-NLS-1$ mWriter.println("else {"); //$NON-NLS-1$ mWriter.println(" document.write(\"table.collapse td.right { width: 5px; }\")"); //$NON-NLS-1$ mWriter.println("}"); //$NON-NLS-1$ mWriter.println("document.write(\"</style>\");"); //$NON-NLS-1$ mWriter.println("if (!String.prototype.endsWith) {"); //$NON-NLS-1$ mWriter.println(" String.prototype.endsWith = function(suffix) {"); //$NON-NLS-1$ mWriter.println(" var startPos = this.length - suffix.length;"); //$NON-NLS-1$ mWriter.println(" if (startPos < 0) {"); //$NON-NLS-1$ mWriter.println(" return false;"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" return (this.lastIndexOf(suffix, startPos) == startPos);"); //$NON-NLS-1$ mWriter.println(" };"); //$NON-NLS-1$ mWriter.println("}"); //$NON-NLS-1$ mWriter.println("function getObject(name)"); //$NON-NLS-1$ mWriter.println("{"); //$NON-NLS-1$ mWriter.println(" if(document.all) {"); //$NON-NLS-1$ mWriter.println(" return document.all[name];"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" else {"); //$NON-NLS-1$ mWriter.println(" return document.getElementById(name);"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println("}"); //$NON-NLS-1$ mWriter.println("function showLine(trigger,end)"); //$NON-NLS-1$ mWriter.println("{"); //$NON-NLS-1$ mWriter.println(" if(trigger.className != \"expand\") {"); //$NON-NLS-1$ mWriter.println(" var lineDiv = getObject(\"lineDiv\");"); //$NON-NLS-1$ mWriter.println(" var sec = getObject(\"line\"+end);"); //$NON-NLS-1$ mWriter.println(" if(sec && lineDiv) {"); //$NON-NLS-1$ mWriter.println(" var triggerPos = getElementPosition(trigger);"); //$NON-NLS-1$ mWriter.println(" var secPos = getElementPosition(sec);"); //$NON-NLS-1$ mWriter.println(" if(secPos && triggerPos) {"); //$NON-NLS-1$ mWriter.println(" lineDiv.style.left = triggerPos.left+triggerPos.width/2;"); //$NON-NLS-1$ mWriter.println(" lineDiv.style.top = triggerPos.top+triggerPos.height;"); //$NON-NLS-1$ mWriter.println(" lineDiv.style.width = triggerPos.width/2;"); //$NON-NLS-1$ mWriter.println( " lineDiv.style.height = secPos.top+secPos.height/2-(triggerPos.top+triggerPos.height);"); //$NON-NLS-1$ mWriter.println(" lineDiv.style.display = \"block\";"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println("}"); //$NON-NLS-1$ mWriter.println("function hideLine()"); //$NON-NLS-1$ mWriter.println("{"); //$NON-NLS-1$ mWriter.println(" var lineDiv = getObject(\"lineDiv\");"); //$NON-NLS-1$ mWriter.println(" if(lineDiv) {"); //$NON-NLS-1$ mWriter.println(" lineDiv.style.display = \"none\";"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println("}"); //$NON-NLS-1$ mWriter.println("function toggle(trigger,start,end) "); //$NON-NLS-1$ mWriter.println("{"); //$NON-NLS-1$ mWriter.println(" if(trigger) {"); //$NON-NLS-1$ mWriter.println(" var i;"); //$NON-NLS-1$ mWriter.println(" var sec;"); //$NON-NLS-1$ mWriter.println(" var expand;"); //$NON-NLS-1$ mWriter.println(" hideLine();"); //$NON-NLS-1$ mWriter.println(" if(trigger.className == \"expand\") {"); //$NON-NLS-1$ mWriter.println(" expand = true;"); //$NON-NLS-1$ mWriter.println(" trigger.className = \"collapse\";"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" else {"); //$NON-NLS-1$ mWriter.println(" expand = false;"); //$NON-NLS-1$ mWriter.println(" trigger.className = \"expand\";"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" for(i=start; i<= end; i++) {"); //$NON-NLS-1$ mWriter.println(" sec = getObject(\"line\"+i);"); //$NON-NLS-1$ mWriter.println(" if(sec) {"); //$NON-NLS-1$ mWriter.println(" if(expand) {"); //$NON-NLS-1$ mWriter.println(" if(sec.className == \"hiddenRow\") {"); //$NON-NLS-1$ mWriter.println(" sec.className = \"\";"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" else if(sec.className.endsWith(\" hiddenRow\")) {"); //$NON-NLS-1$ mWriter.println( " sec.className = sec.className.substr(0,sec.className.length-\" hiddenRow\".length);"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" else {"); //$NON-NLS-1$ mWriter.println(" if(sec.className == \"\") {"); //$NON-NLS-1$ mWriter.println(" sec.className = \"hiddenRow\";"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" else {"); //$NON-NLS-1$ mWriter.println(" sec.className = sec.className + \" hiddenRow\";"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println("}"); //$NON-NLS-1$ mWriter.println("function getElementPosition(elem){"); //$NON-NLS-1$ mWriter.println(" var offsetLeft = 0;"); //$NON-NLS-1$ mWriter.println(" var offsetTop =0;"); //$NON-NLS-1$ mWriter.println(" var width = elem.offsetWidth;"); //$NON-NLS-1$ mWriter.println(" var height = elem.offsetHeight;"); //$NON-NLS-1$ mWriter.println(" while (elem){"); //$NON-NLS-1$ mWriter.println(" offsetLeft += elem.offsetLeft;"); //$NON-NLS-1$ mWriter.println(" offsetTop += elem.offsetTop;"); //$NON-NLS-1$ mWriter.println(" elem = elem.offsetParent;"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println( " if (navigator.userAgent.indexOf('Mac') != -1 && typeof(document.body.leftMargin) !='undefined'){"); //$NON-NLS-1$ mWriter.println(" offsetLeft += document.body.leftMargin;"); //$NON-NLS-1$ mWriter.println(" offsetTop += document.body.topMargin;"); //$NON-NLS-1$ mWriter.println(" }"); //$NON-NLS-1$ mWriter.println(" return {left:offsetLeft,top:offsetTop, width:width, height: height};"); //$NON-NLS-1$ mWriter.println("}"); //$NON-NLS-1$ mWriter.println("//-->"); //$NON-NLS-1$ mWriter.println("</script>"); //$NON-NLS-1$ } mWriter.println("</head>"); //$NON-NLS-1$ }