1 20 21 package org.apache.directory.ldapstudio.browser.common; 22 23 24 import java.util.ArrayList ; 25 import java.util.Collection ; 26 27 import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants; 28 import org.apache.directory.ldapstudio.browser.core.model.schema.AttributeValueProviderRelation; 29 import org.apache.directory.ldapstudio.browser.core.model.schema.SyntaxValueProviderRelation; 30 import org.apache.directory.ldapstudio.valueeditors.ValueEditorManager; 31 import org.apache.directory.ldapstudio.valueeditors.ValueEditorManager.ValueEditorExtension; 32 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 33 import org.eclipse.jface.preference.IPreferenceStore; 34 import org.eclipse.jface.preference.PreferenceConverter; 35 import org.eclipse.swt.SWT; 36 import org.eclipse.swt.graphics.FontData; 37 import org.eclipse.swt.graphics.RGB; 38 import org.eclipse.swt.widgets.Display; 39 40 41 47 public class BrowserCommonPreferencesInitializer extends AbstractPreferenceInitializer 48 { 49 52 public void initializeDefaultPreferences() 53 { 54 55 IPreferenceStore store = BrowserCommonActivator.getDefault().getPreferenceStore(); 56 57 store.setDefault( BrowserCommonConstants.PREFERENCE_COUNT_LIMIT, 1000 ); 59 store.setDefault( BrowserCommonConstants.PREFERENCE_TIME_LIMIT, 0 ); 60 61 RGB rgbBlack = Display.getDefault().getSystemColor( SWT.COLOR_BLACK ).getRGB(); 63 RGB rgbRed = Display.getDefault().getSystemColor( SWT.COLOR_RED ).getRGB(); 64 RGB rgbYellow = Display.getDefault().getSystemColor( SWT.COLOR_YELLOW ).getRGB(); 65 FontData[] fontData = Display.getDefault().getSystemFont().getFontData(); 66 FontData fontDataNormal = new FontData( fontData[0].getName(), fontData[0].getHeight(), SWT.NORMAL ); 67 FontData fontDataItalic = new FontData( fontData[0].getName(), fontData[0].getHeight(), SWT.ITALIC ); 68 FontData fontDataBold = new FontData( fontData[0].getName(), fontData[0].getHeight(), SWT.BOLD ); 69 FontData fontDataBoldItalic = new FontData( fontData[0].getName(), fontData[0].getHeight(), SWT.BOLD 70 | SWT.ITALIC ); 71 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_OBJECTCLASS_COLOR, rgbBlack ); 73 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_OBJECTCLASS_FONT, fontDataBoldItalic ); 74 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_MUSTATTRIBUTE_COLOR, rgbBlack ); 75 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_MUSTATTRIBUTE_FONT, fontDataBold ); 76 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_MAYATTRIBUTE_COLOR, rgbBlack ); 77 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_MAYATTRIBUTE_FONT, fontDataNormal ); 78 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_OPERATIONALATTRIBUTE_COLOR, rgbBlack ); 79 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_OPERATIONALATTRIBUTE_FONT, fontDataItalic ); 80 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_WARNING_FONT, fontDataBoldItalic ); 82 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_WARNING_COLOR, rgbYellow ); 83 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_ERROR_FONT, fontDataBoldItalic ); 84 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_ERROR_COLOR, rgbRed ); 85 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_QUICKFILTER_FONT, fontDataBold ); 87 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_QUICKFILTER_BACKGROUND_COLOR, rgbYellow ); 88 PreferenceConverter.setDefault( store, BrowserCommonConstants.PREFERENCE_QUICKFILTER_FOREGROUND_COLOR, rgbBlack ); 89 90 store.setDefault( BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES, false ); 92 93 Collection <AttributeValueProviderRelation> avprs = new ArrayList <AttributeValueProviderRelation>(); 95 Collection <SyntaxValueProviderRelation> svprs = new ArrayList <SyntaxValueProviderRelation>(); 96 Collection <ValueEditorExtension> valueEditorProxys = ValueEditorManager.getValueEditorProxys(); 97 for ( ValueEditorExtension proxy : valueEditorProxys ) 98 { 99 for ( String attributeType : proxy.attributeTypes ) 100 { 101 AttributeValueProviderRelation avpr = new AttributeValueProviderRelation( attributeType, 102 proxy.className ); 103 avprs.add( avpr ); 104 } 105 for ( String syntaxOid : proxy.syntaxOids ) 106 { 107 SyntaxValueProviderRelation svpr = new SyntaxValueProviderRelation( syntaxOid, proxy.className ); 108 svprs.add( svpr ); 109 } 110 } 111 BrowserCommonActivator.getDefault().getValueEditorsPreferences().setDefaultAttributeValueProviderRelations( 112 avprs.toArray( new AttributeValueProviderRelation[0] ) ); 113 BrowserCommonActivator.getDefault().getValueEditorsPreferences().setDefaultSyntaxValueProviderRelations( 114 svprs.toArray( new SyntaxValueProviderRelation[0] ) ); 115 116 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_EXPAND_BASE_ENTRIES, false ); 118 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_ENABLE_FOLDING, true ); 119 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_FOLDING_SIZE, 100 ); 120 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_ENTRY_LABEL, BrowserCommonConstants.SHOW_RDN ); 121 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_ENTRY_ABBREVIATE, true ); 122 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_ENTRY_ABBREVIATE_MAX_LENGTH, 50 ); 123 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SEARCH_RESULT_LABEL, BrowserCommonConstants.SHOW_DN ); 124 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SEARCH_RESULT_ABBREVIATE, true ); 125 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SEARCH_RESULT_ABBREVIATE_MAX_LENGTH, 50 ); 126 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIT, true ); 127 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_SEARCHES, true ); 128 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_BOOKMARKS, true ); 129 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIRECTORY_META_ENTRIES, false ); 130 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SORT_BY, BrowserCoreConstants.SORT_BY_RDN_VALUE ); 131 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SORT_ORDER, BrowserCoreConstants.SORT_ORDER_ASCENDING ); 132 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_SORT_LIMIT, 10000 ); 133 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_LEAF_ENTRIES_FIRST, true ); 134 store.setDefault( BrowserCommonConstants.PREFERENCE_BROWSER_META_ENTRIES_LAST, true ); 135 136 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_ENABLE_FOLDING, true ); 138 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_FOLDING_THRESHOLD, 10 ); 139 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OBJECTCLASS_ATTRIBUTES, true ); 140 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_MUST_ATTRIBUTES, true ); 141 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_MAY_ATTRIBUTES, true ); 142 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES, false ); 143 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_OBJECTCLASS_AND_MUST_ATTRIBUTES_FIRST, true ); 144 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_OPERATIONAL_ATTRIBUTES_LAST, true ); 145 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_DEFAULT_SORT_BY, 146 BrowserCoreConstants.SORT_BY_ATTRIBUTE_DESCRIPTION ); 147 store.setDefault( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_DEFAULT_SORT_ORDER, 148 BrowserCoreConstants.SORT_ORDER_ASCENDING ); 149 150 151 152 store.setDefault( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_ATTRIBUTEDELIMITER, "\t" ); 154 store.setDefault( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_VALUEDELIMITER, "|" ); 155 store.setDefault( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_QUOTECHARACTER, "\"" ); 156 store 157 .setDefault( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_LINESEPARATOR, BrowserCoreConstants.LINE_SEPARATOR ); 158 store.setDefault( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_BINARYENCODING, 159 BrowserCoreConstants.BINARYENCODING_IGNORE ); 160 } 161 162 } 163 | Popular Tags |