List of usage examples for org.eclipse.jface.preference IPreferenceStore setValue
void setValue(String name, boolean value);
From source file:com.google.dart.tools.ui.internal.preferences.DartKeyBindingPersistence.java
License:Open Source License
/** * Read a key binding file in the format created by {@code writeFile()}. * /*from w w w . j av a 2s. c o m*/ * @param file The File of key bindings * @throws CoreException if there is a problem reading or parsing the file */ public void readFile(File file, String encoding) throws CoreException { Reader reader = null; try { reader = new FileReader(file); readFrom(reader); } catch (IOException ex) { throw createException(ex, ex.getMessage()); } finally { if (reader != null) { try { reader.close(); } catch (IOException ex) { DartToolsPlugin.log(ex); } } } try { String bindString = FileUtilities.getContents(file, encoding); IPreferenceStore prefs = DartToolsPlugin.getDefault().getPreferenceStore(); prefs.setValue(CUSTOM_KEY_BINDING_STRING, bindString); } catch (IOException ex) { DartToolsPlugin.log(ex); } }
From source file:com.google.dart.tools.ui.internal.preferences.DartKeyBindingPersistence.java
License:Open Source License
/** * Remove all custom key bindings and restore default bindings. *///from www . jav a 2 s . c o m public void resetBindings() throws CoreException { IPreferenceStore prefs = DartToolsPlugin.getDefault().getPreferenceStore(); prefs.setValue(CUSTOM_KEY_BINDING_STRING, ""); bindingService.readRegistryAndPreferences(commandService); initBindingManager(); // deletes all USER bindings try { bindingService.savePreferences(bindingManager.getActiveScheme(), bindingManager.getBindings()); } catch (IOException e) { throw createException(e, DESERIALIZATION_PROBLEM); } }
From source file:com.google.dart.tools.ui.internal.preferences.FontPreferencePage.java
License:Open Source License
private void persistFont(String fontKey, FontData[] fontData) { IPreferenceStore workbenchPrefStore = WorkbenchPlugin.getDefault().getPreferenceStore(); IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); ITheme theme = themeManager.getCurrentTheme(); FontRegistry registry = theme.getFontRegistry(); registry.put(fontKey, fontData);/*from w w w .j a v a 2 s . com*/ String key = ThemeElementHelper.createPreferenceKey(theme, fontKey); String fdString = PreferenceConverter.getStoredRepresentation(fontData); String storeString = workbenchPrefStore.getString(key); if (!fdString.equals(storeString)) { workbenchPrefStore.setValue(key, fdString); } }
From source file:com.google.dart.tools.ui.internal.preferences.FontPreferencePage.java
License:Open Source License
@SuppressWarnings("unused") private void scaleFontNamed(String name, int size) { IPreferenceStore workbenchPrefStore = WorkbenchPlugin.getDefault().getPreferenceStore(); IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); ITheme theme = themeManager.getCurrentTheme(); FontRegistry registry = theme.getFontRegistry(); FontData[] fds = registry.getFontData(name); FontData data = new FontData(fds[0].getName(), size, fds[0].getStyle()); registry.put(name, new FontData[] { data }); String key = ThemeElementHelper.createPreferenceKey(theme, name); String fdString = PreferenceConverter.getStoredRepresentation(new FontData[] { data }); String storeString = workbenchPrefStore.getString(key); if (!fdString.equals(storeString)) { workbenchPrefStore.setValue(key, fdString); }//from ww w. java2 s .c om }
From source file:com.google.dart.tools.ui.internal.text.dart.DartAutoIndentStrategyTest.java
License:Open Source License
public void test_useTabs() throws Exception { // We have 1000 and one listener for preferences that expect that we run them in UI. // Just make them happy... Display.getDefault().syncExec(new Runnable() { @Override//w w w.j a v a2s . co m public void run() { IPreferenceStore preferenceStore = DartToolsPlugin.getDefault().getPreferenceStore(); try { preferenceStore.setValue(USE_SPACES, false); preferenceStore.setValue(TAB_CHAR, "tab"); assertSmartInsertAfterNewLine(createSource(// "main() {!", "}"), createSource(// "main() {", "\t!", "}")); } finally { preferenceStore.setToDefault(USE_SPACES); preferenceStore.setToDefault(TAB_CHAR); } } }); }
From source file:com.google.dart.tools.ui.themes.ColorThemeTest.java
License:Open Source License
public void testThemeChange() throws Exception { // Creating the theme manager reads all theme files (22 at present), parses the xml, and // initializes the object model. Then it reads all the mapping files, parses the xml, and // initializes the object model for them, too. There are currently 7 mappings but some may // be deleted. Basically, this test exercises most of the theme manager code. ColorThemeManager colorThemeManager = new ColorThemeManager(); IPreferenceStore store = PreferenceConstants.getPreferenceStore(); PreferenceConstants.initializeDefaultValues(store); openTestEditor(""); IPreferenceStore prefs = testEditor.getPreferences(); Display display = testEditor.getViewer().getTextWidget().getDisplay(); Color ebg = DartUI.getEditorBackground(prefs, display); Color efg = DartUI.getEditorForeground(prefs, display); assertNull(ebg);/* www. ja v a 2 s. c o m*/ assertNull(efg); List<String> themeNames = getThemeList(colorThemeManager); assertNotNull(themeNames); assertFalse(themeNames.isEmpty()); String selectedThemeName = themeNames.get(4); assertEquals("Havenjark", selectedThemeName); store.setValue("colorTheme", selectedThemeName); // change the world to match the new theme colorThemeManager.applyTheme(selectedThemeName); // verify that the open editor got updated with new colors ebg = DartUI.getEditorBackground(prefs, display); efg = DartUI.getEditorForeground(prefs, display); assertNotNull(ebg); assertNotNull(efg); assertTrue(ebg.toString().indexOf("45, 54, 57") > 0); assertTrue(efg.toString().indexOf("192, 182, 168") > 0); }
From source file:com.google.gdt.eclipse.designer.core.builders.CompilationParticipantTest.java
License:Open Source License
/** * Invalid "source" class, but no GWT marker, because we disable compilation participant. *//*from w w w.j a v a 2 s . c om*/ public void test_noMarker_AWTClass() throws Exception { IFile sourceFile; { IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); preferenceStore.setValue(Constants.P_BUILDER_CHECK_CLIENT_CLASSPATH, false); try { sourceFile = setFileContentSrc("test/client/MyComposite.java", getSourceDQ("package test.client;", "import com.google.gwt.user.client.ui.Composite;", "public class MyComposite extends Composite {", " public MyComposite() {", " java.awt.Image image = null;", " }", "}")); waitForAutoBuild(); } finally { preferenceStore.setToDefault(Constants.P_BUILDER_CHECK_CLIENT_CLASSPATH); } } // no markers expected IMarker[] markers = GTestUtils.getMyMarkers(sourceFile); assertThat(markers).hasSize(0); }
From source file:com.google.gdt.eclipse.designer.core.model.widgets.WidgetTest.java
License:Open Source License
/** * Test for automatic renaming GWT widgets on "text" property change. * <p>/*from w w w .j a va2 s . co m*/ * http://fogbugz.instantiations.com/fogbugz/default.php?42832 */ public void test_renameOnTextPropertyChange() throws Exception { RootPanelInfo frame = parseJavaInfo("public class Test implements EntryPoint {", " public void onModuleLoad() {", " RootPanel rootPanel = RootPanel.get();", " {", " Button button = new Button();", " rootPanel.add(button);", " }", " }", "}"); frame.refresh(); WidgetInfo button = frame.getChildrenWidgets().get(0); // IPreferenceStore preferences = GwtToolkitDescription.INSTANCE.getPreferences(); preferences.setValue(IPreferenceConstants.P_VARIABLE_TEXT_MODE, IPreferenceConstants.V_VARIABLE_TEXT_MODE_ALWAYS); preferences.setValue(IPreferenceConstants.P_VARIABLE_TEXT_TEMPLATE, "${text}${class_name}"); button.getPropertyByTitle("html").setValue("Some text"); assertEditor("public class Test implements EntryPoint {", " public void onModuleLoad() {", " RootPanel rootPanel = RootPanel.get();", " {", " Button someTextButton = new Button();", " someTextButton.setHTML('Some text');", " rootPanel.add(someTextButton);", " }", " }", "}"); }
From source file:com.google.gdt.eclipse.designer.gxt.actions.ConfigureExtGwtAction.java
License:Open Source License
/** * @return the folder with "gwt.jar" file, or <code>null</code> if user cancelled selection. *///from w w w .j ava2 s . com private static String getLibraryLocation() { IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); String libraryLocation = preferenceStore.getString(LOCATION_KEY); while (true) { DirectoryDialog directoryDialog = new DirectoryDialog(DesignerPlugin.getShell()); directoryDialog.setText("Ext GWT Location"); directoryDialog.setMessage("Choose folder with extracted Ext GWT, it should have gxt.jar file.\n" + "You can download it from http://www.extjs.com/products/gxt/"); directoryDialog.setFilterPath(libraryLocation); libraryLocation = directoryDialog.open(); // cancel if (libraryLocation == null) { return null; } // check for "gxt.jar" file { String jarPath = ConfigureExtGwtOperation.getJarPath(libraryLocation); File file = new File(jarPath); if (!file.exists() || !file.isFile()) { MessageDialog.openError(null, "Invalid folder", "No gxt.jar file in choosen folder."); continue; } } // check for "resources" directory { File file = new File(libraryLocation + "/resources"); if (!file.exists() || !file.isDirectory()) { MessageDialog.openError(null, "Invalid folder", "No 'resources' directory in choosen folder.\n" + "Just gxt.jar file is not enough, we need also images and CSS files."); continue; } } // OK preferenceStore.setValue(LOCATION_KEY, libraryLocation); return libraryLocation; } }
From source file:com.google.gdt.eclipse.designer.smart.actions.ConfigureSmartGwtAction.java
License:Open Source License
/** * @return the folder with "gwt.jar" file, or <code>null</code> if user cancelled selection. *///from w w w . ja va 2 s .co m private static String getLibraryLocation() { IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); String libraryLocation = preferenceStore.getString(LOCATION_KEY); while (true) { DirectoryDialog directoryDialog = new DirectoryDialog(DesignerPlugin.getShell()); directoryDialog.setText("Smart GWT Location"); directoryDialog.setMessage("Choose folder with extracted SmartGWT, it should have smartgwt.jar file.\n" + "You can download it from http://code.google.com/p/smartgwt/"); directoryDialog.setFilterPath(libraryLocation); libraryLocation = directoryDialog.open(); // cancel if (libraryLocation == null) { return null; } // check for "gxt.jar" file { File file = new File(libraryLocation + "/smartgwt.jar"); if (!file.exists() || !file.isFile()) { MessageDialog.openError(null, "Invalid folder", "No smartgwt.jar file in choosen folder."); continue; } } // OK preferenceStore.setValue(LOCATION_KEY, libraryLocation); return libraryLocation; } }