List of usage examples for org.eclipse.jface.preference PreferenceStore PreferenceStore
public PreferenceStore(String filename)
From source file:org.cfeclipse.cfml.CFMLPlugin.java
License:Open Source License
/** * This method is called upon plug-in activation. Seems like most startup * stuff should now go here./*from w w w.java2 s.c om*/ */ public void start(BundleContext context) throws Exception { super.start(context); /* * //System.out.println( "Property store file set to " + * CFMLPlugin.getDefault().getStateLocation().toString() + * "/properties.ini" ); */ PropertyConfigurator.configure(CFMLPlugin.getDefault().getBundle().getEntry("/lib/log4j.properties")); this.propertyStore = new PreferenceStore( CFMLPlugin.getDefault().getStateLocation().toString() + "/properties.ini"); String defaultSnippetPath = CFMLPlugin.getDefault().getStateLocation().toString() + "/snippets"; File f = new File(defaultSnippetPath); if (!f.exists()) { f.mkdir(); } try { // load all the syntax dictionaries DictionaryManager.initDictionaries(); // startup the image hovers lazily so plugin starts fast Job job = new WorkspaceJob("Initializing Image Hovers") { public IStatus runInWorkspace(IProgressMonitor monitor) { StartupHandler startupHandler = new StartupHandler(); startupHandler.earlyStartup(); if (monitor.isCanceled()) return Status.CANCEL_STATUS; return Status.OK_STATUS; } }; job.schedule(3000); // startup the image registry in job so doesn't slow down init CFPluginImages.initCFPluginImages(); setupCAM(); setupLastEncMgr(); checkForPluginVersionChange(); } catch (Exception e) { // lots of bad things can happen... e.printStackTrace(System.err); } // EditorPartListener editorListener = new EditorPartListener(); // doesn't seem to be needed and is causing errors. Leaving in case 3.4 // needs it-- if so, rethink // this.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(editorListener); }
From source file:org.cs3.pdt.connector.internal.preferences.PreferenceConfiguration.java
License:Open Source License
private PreferenceStore createStore(String configuration) { PreferenceStore store = new PreferenceStore(getConfigurationFileName(configuration)); String defaultConfiguration = getDefaultConfiguration(configuration); if (defaultConfiguration.equals(PDTConnector.CONFIGURATION_SWI)) { initWithSWIPreferences(store);//w w w. j a v a 2 s . co m } else if (defaultConfiguration.equals(PDTConnector.CONFIGURATION_SWI_LOGTALK)) { initWithSWILogtalkPreferences(store); // } else if (defaultConfiguration.equals(PDTConnector.CONFIGURATION_YAP)) { // initWithYAPPreferences(store); // } else if (defaultConfiguration.equals(PDTConnector.CONFIGURATION_YAP_LOGTALK)) { // initWithYAPLogtalkPreferences(store); } else { Debug.error("Invalid default configuration " + defaultConfiguration + " of " + configuration); } try { store.load(); } catch (IOException e) { } return store; }
From source file:org.cs3.prolog.connector.internal.preferences.PreferenceConfiguration.java
License:Open Source License
private PreferenceStore createStore(String configuration) { PreferenceStore store = new PreferenceStore(getConfigurationFileName(configuration)); String defaultConfiguration = getDefaultConfiguration(configuration); if (defaultConfiguration.equals(PrologRuntimeUI.CONFIGURATION_SWI)) { initWithSWIPreferences(store);/* w w w.j av a 2 s . c o m*/ } else if (defaultConfiguration.equals(PrologRuntimeUI.CONFIGURATION_SWI_LOGTALK)) { initWithSWILogtalkPreferences(store); } else if (defaultConfiguration.equals(PrologRuntimeUI.CONFIGURATION_YAP)) { initWithYAPPreferences(store); } else if (defaultConfiguration.equals(PrologRuntimeUI.CONFIGURATION_YAP_LOGTALK)) { initWithYAPLogtalkPreferences(store); } else { Debug.error("Invalid default configuration " + defaultConfiguration + " of " + configuration); } try { store.load(); } catch (IOException e) { } return store; }
From source file:org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.java
License:Open Source License
/** * Returns the workspace viewer <code>PreferenceStore</code> * * @return the workspace viewer <code>PreferenceStore</code> *///from www . j a v a 2 s . co m public PreferenceStore getWorkspaceViewerPreferenceStore() { if (workspaceViewerPreferenceStore != null) { return workspaceViewerPreferenceStore; } else { // Try to load it IPath path = DiagramUIPlugin.getInstance().getStateLocation(); String id = ViewUtil.getIdStr(getDiagram()); String fileName = path.toString() + "/" + id;//$NON-NLS-1$ java.io.File file = new File(fileName); workspaceViewerPreferenceStore = new PreferenceStore(fileName); if (file.exists()) { // Load it try { workspaceViewerPreferenceStore.load(); } catch (Exception e) { // Create the default addDefaultPreferences(); } } else { // Create it addDefaultPreferences(); } return workspaceViewerPreferenceStore; } }
From source file:org.eclipse.gmf.runtime.diagram.ui.printing.internal.util.PrintHelperUtil.java
License:Open Source License
/** * Returns the workspace viewer <code>PreferenceStore</code> for a given diagram edit part. * //w w w. j ava 2s. c om * @param diagramEP the DiagramEditPart to obtain the preference store for * * @return the <code>PreferenceStore</code> for the given diagram edit part * Could return null if it couldn't be loaded */ private static IPreferenceStore getPreferenceStoreForDiagram(DiagramEditPart diagramEP) { // Try to load it String id = ViewUtil.getIdStr(diagramEP.getDiagramView()); //try and get preferences from the open diagrams first //loadedPreferences will be set to true only if the preferences could // be //successfully loaded IPreferenceStore fPreferences = loadPreferencesFromOpenDiagram(id); if (fPreferences != null) { //loadPreferencesFromOpenDiagram will have set preferences return fPreferences; } IPath path = DiagramUIPlugin.getInstance().getStateLocation(); String fileName = path.toString() + "/" + id;//$NON-NLS-1$ java.io.File file = new File(fileName); fPreferences = new PreferenceStore(fileName); if (file.exists()) { // Load it try { ((PreferenceStore) fPreferences).load(); return fPreferences; } catch (Exception e) { return null; } } return null; //fPreferences couldn't be loaded }
From source file:org.eclipse.help.ui.internal.views.ScopeSet.java
License:Open Source License
public IPreferenceStore getPreferenceStore() { if (preferenceStore == null) { preferenceStore = new PreferenceStore(getFileName(this.name)); try {/*from www . j ava 2 s. c o m*/ File file = new File(getFileName(this.name)); if (file.exists()) { preferenceStore.load(); } } catch (IOException e) { String message = Messages.bind(Messages.ScopeSet_errorLoading, name); HelpUIPlugin.logError(message, e); } } return preferenceStore; }
From source file:org.eclipse.jdt.internal.ui.JavaPlugin.java
License:Open Source License
/** * Returns the preference store for this UI plug-in. * This preference store is used to hold persistent settings for this plug-in in * the context of a workbench. Some of these settings will be user controlled, * whereas others may be internal setting that are never exposed to the user. * <p>/* w w w . j a v a 2s. c om*/ * If an error occurs reading the preference store, an empty preference store is * quietly created, initialized with defaults, and returned. * </p> * <p> * <strong>NOTE:</strong> As of Eclipse 3.1 this method is * no longer referring to the core runtime compatibility layer and so * plug-ins relying on Plugin#initializeDefaultPreferences * will have to access the compatibility layer themselves. * </p> * * @return the preference store */ public IPreferenceStore getPreferenceStore() { // Create the preference store lazily. if (preferenceStore == null) { preferenceStore = new PreferenceStore("test"); } return preferenceStore; }
From source file:org.eclipse.sirius.diagram.ui.part.SiriusDiagramEditor.java
License:Open Source License
/** * Returns the workspace viewer <code>PreferenceStore</code> * //w ww.j ava 2 s. co m * @return the workspace viewer <code>PreferenceStore</code> */ public PreferenceStore getWorkspaceViewerPreferenceStore() { if (workspaceViewerPreferenceStore != null) { return workspaceViewerPreferenceStore; } else { // Try to load it IPath path = DiagramUIPlugin.getPlugin().getStateLocation(); String viewId = SiriusGMFHelper.getViewId(getDiagram()); String fileName = path.toString() + "/" + viewId;//$NON-NLS-1$ java.io.File file = new File(fileName); workspaceViewerPreferenceStore = new PreferenceStore(fileName); if (file.exists()) { // Load it try { workspaceViewerPreferenceStore.load(); } catch (Exception e) { // Create the default addDefaultPreferences(); } } else { // Create it addDefaultPreferences(); } return workspaceViewerPreferenceStore; } }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.print.SiriusDiagramPrintPreviewHelper.java
License:Open Source License
/** * Returns the workspace viewer <code>PreferenceStore</code> for a given * diagram edit part.// ww w .j a v a 2 s . co m * * @param diagramEP * the DiagramEditPart to obtain the preference store for * * @return the <code>PreferenceStore</code> for the given diagram edit part * Could return null if it couldn't be loaded */ private static IPreferenceStore getPreferenceStoreForDiagram(DiagramEditPart diagramEP) { // Try to load it String id = ViewUtil.getIdStr(diagramEP.getDiagramView()); // try and get preferences from the open diagrams first // loadedPreferences will be set to true only if the preferences could // be // successfully loaded IPreferenceStore fPreferences = SiriusDiagramPrintPreviewHelper.loadPreferencesFromOpenDiagram(id); if (fPreferences != null) { // loadPreferencesFromOpenDiagram will have set preferences return fPreferences; } IPath path = DiagramUIPlugin.getInstance().getStateLocation(); String fileName = path.toString() + "/" + id;//$NON-NLS-1$ java.io.File file = new File(fileName); fPreferences = new PreferenceStore(fileName); if (file.exists()) { // Load it try { ((PreferenceStore) fPreferences).load(); return fPreferences; } catch (Exception e) { return null; } } return null; // fPreferences couldn't be loaded }
From source file:org.eclipsetrader.ui.internal.application.Activator.java
License:Open Source License
private void migrateSettings() throws Exception { IPath workspacePath = Platform.getLocation().append(".metadata").append(".plugins") .append("org.eclipse.core.runtime").append(".settings"); File preferencesFile = workspacePath.append("org.eclipsetrader.ui.prefs").toFile(); PreferenceStore preferences = new PreferenceStore(preferencesFile.toString()); if (preferencesFile.exists()) { preferences.load();/*from w w w. j ava 2 s .co m*/ } File legacyPreferencesFile = workspacePath.append("org.eclipsetrader.ui.charts.prefs").toFile(); if (legacyPreferencesFile.exists()) { PreferenceStore legacyPreferences = new PreferenceStore(legacyPreferencesFile.toString()); legacyPreferences.load(); for (String name : legacyPreferences.preferenceNames()) { preferences.putValue(name, legacyPreferences.getString(name)); } legacyPreferencesFile.delete(); } legacyPreferencesFile = workspacePath.append("org.eclipsetrader.ui.trading.prefs").toFile(); if (legacyPreferencesFile.exists()) { PreferenceStore legacyPreferences = new PreferenceStore(legacyPreferencesFile.toString()); legacyPreferences.load(); for (String name : legacyPreferences.preferenceNames()) { preferences.putValue(name, legacyPreferences.getString(name)); } legacyPreferencesFile.delete(); } legacyPreferencesFile = workspacePath.append("org.eclipsetrader.ui.ats.prefs").toFile(); if (legacyPreferencesFile.exists()) { PreferenceStore legacyPreferences = new PreferenceStore(legacyPreferencesFile.toString()); legacyPreferences.load(); for (String name : legacyPreferences.preferenceNames()) { preferences.putValue(name, legacyPreferences.getString(name)); } legacyPreferencesFile.delete(); } if (!preferencesFile.exists()) { preferencesFile.getParentFile().mkdirs(); } preferences.save(); }