public ProjectConfiguration getProjectConfigurationWithoutMigrate(IProject project) throws InvocationTargetException { ProjectConfiguration prjp = null; try { prjp = (ProjectConfiguration) project.getSessionProperty(USER_PREFERENCE); if (prjp == null || !prjp.getResource().exists()) { prjp = new ProjectConfiguration(project); prjp.getVersion(); // initialize the configuration's version attribute prjp.load(); // initialize this instance from the stored values prjp.passivate(); // store this instance as a property on the IResource } return prjp; } catch (CoreException exc) { throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{project.getName()})); } }
/** * This constructor should be used in all cases except for the Properties page's values. */ protected ProjectConfiguration(IProject project) throws InvocationTargetException { // The extractProjectValidators method extracts just this project's validators from the // global list. super(project, extractProjectValidators(convertToArray(ValidationRegistryReader.getReader().getAllValidators()), project)); // Can't put the call to load() and passivate() in the ValidationConfiguration constructor // due // to the order of initialization. // 1. First the ValidationConfiguration constructor is called, and that loads the stored // values. // 2. Then this class's <init> method is called, and that initializes the "override" field // to the default, // which may be different than the stored value. }
/** * This constructor is provided only for the Properties page, so that the page can store values * without persisting them (i.e., if the user presses Cancel then nothing needs to be done.) */ public ProjectConfiguration(ProjectConfiguration original) throws InvocationTargetException { super(); original.copyTo(this); }
/** * Checks if validator is enabled according in Validation preferences * * @param vmd * @return */ static boolean isBatchValidatorPreferenceEnabled(IFile file) { if (file == null) { return true; } boolean enabled = true; ProjectConfiguration configuration = getProjectConfiguration(file); if (configuration != null) { org.eclipse.wst.validation.internal.ValidatorMetaData metadata = ValidationRegistryReader.getReader().getValidatorMetaData(JSPBatchValidator.class.getName()); if (configuration != null && metadata != null) { if (!configuration.isBuildEnabled(metadata) && !configuration.isManualEnabled(metadata)) enabled = false; } } return enabled; }
protected void loadPreference() throws InvocationTargetException { IProject project = (IProject) getResource(); IScopeContext projectContext = new ProjectScope(project); final IEclipsePreferences prefs = projectContext.getNode(ValidationPlugin.PLUGIN_ID); if (prefs != null) { String storedConfig = prefs.get(USER_PREFERENCE,"default_value"); deserialize(storedConfig); String storedManualConfig = prefs.get(USER_MANUAL_PREFERENCE,"default_value"); deserializeManual(storedManualConfig); String storedBuildConfig = prefs.get(USER_BUILD_PREFERENCE,"default_value"); deserializeBuild(storedBuildConfig); String storedDelegatesConfiguration = prefs.get(DELEGATES_PREFERENCE,"default_value"); deserializeDelegates(storedDelegatesConfiguration); } } }
/** * Return true if the given project has the current level of metadata, false otherwise. */ public boolean isMigrated(IProject project) throws InvocationTargetException { if (project == null) { return false; } try { if (project.isAccessible()) { ProjectConfiguration prjp = (ProjectConfiguration) project.getSessionProperty(USER_PREFERENCE); if (prjp != null) { return prjp.isVersionCurrent(); } String serializedPrjp = project.getPersistentProperty(USER_PREFERENCE); if (serializedPrjp != null) { prjp = new ProjectConfiguration(project); prjp.getVersion(); // initialize the configuration's // version attribute return prjp.isVersionCurrent(); } } } catch (CoreException exc) { throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{project.getName()})); } return false; }
protected boolean isDelegateValidatorEnabled(IFile file) { boolean enabled = true; try { ProjectConfiguration configuration = ConfigurationManager.getManager().getProjectConfiguration(file.getProject()); ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(VALIDATOR_CLASS); if (configuration.isBuildEnabled(vmd) || configuration.isManualEnabled(vmd)) enabled = true; else enabled = false; } catch (InvocationTargetException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); } return enabled; } }
protected boolean isDelegateValidatorEnabled(IFile file) { boolean enabled = true; try { ProjectConfiguration configuration = ConfigurationManager.getManager().getProjectConfiguration(file.getProject()); ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(VALIDATOR_CLASS); if (configuration.isBuildEnabled(vmd) || configuration.isManualEnabled(vmd)) { enabled = true; } else { enabled = false; } } catch (InvocationTargetException e) { Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); } return enabled; } }
public ProjectConfiguration getProjectConfiguration(IProject project) throws InvocationTargetException { ProjectConfiguration prjp = null; try { prjp = (ProjectConfiguration) project.getSessionProperty(USER_PREFERENCE); if (prjp == null || !prjp.getResource().exists()) { prjp = new ProjectConfiguration(project); prjp.getVersion(); // initialize the configuration's version attribute prjp.load(); // initialize this instance from the stored values prjp.passivate(); // store this instance as a property on the IResource } return prjp; } catch (CoreException exc) { throw new InvocationTargetException(exc, ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_RETRIEVE, new String[]{project.getName()})); } }