/** * Return true if the global preferences are at the current level of metadata, false otherwise. */ public boolean isGlobalMigrated() throws InvocationTargetException { IWorkspaceRoot root = ValidationConfiguration.getRoot(); if (root == null) { return false; } try { GlobalConfiguration gp = (GlobalConfiguration) root.getSessionProperty(USER_PREFERENCE); if (gp != null) { return gp.isVersionCurrent(); } String serializedPrjp = root.getPersistentProperty(USER_PREFERENCE); if (serializedPrjp != null) { gp = new GlobalConfiguration(root); gp.getVersion(); // initialize the configuration's version attribute return gp.isVersionCurrent(); } } catch (CoreException exc) { throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{root.getName()})); } return false; }
/** * This method returns the global preferences for the workspace. */ public GlobalConfiguration getGlobalConfiguration() throws InvocationTargetException { IWorkspaceRoot root = ValidationConfiguration.getRoot(); GlobalConfiguration gp = null; try { gp = (GlobalConfiguration) root.getSessionProperty(USER_PREFERENCE); if (gp == null) { gp = new GlobalConfiguration(root); Preferences prefs = ValidationPlugin.getPlugin().getPluginPreferences(); if( prefs != null ){ prefs.addPropertyChangeListener(gp); } gp.getVersion(); // initialize the configuration's version attribute gp.load(); // initialize this instance from the stored values gp.passivate(); // store this instance as a property on the IResource } return gp; } catch (CoreException exc) { throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{root.getName()})); } }