protected void copyTo(GlobalConfiguration gp) throws InvocationTargetException { super.copyTo(gp); // Need to have a distinct method for this child class (i.e., the parameter // is not a ValidationConfiguration) because if this initialization is // called as part of ValidationConfiguration's constructor, then the value of // this field is overwritten. Fields of this class are initialized to the // default after the ValidationConfiguration parent is created. gp.setCanProjectsOverride(canProjectsOverride()); gp.setSaveAutomatically(getSaveAutomatically()); }
/** * This constructor is provided only for the Preference 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 GlobalConfiguration(GlobalConfiguration original) throws InvocationTargetException { super(); original.copyTo(this); }
public void resetToDefault() throws InvocationTargetException { setDisableAllValidation(getDisableValidationDefault()); setEnabledValidators(getEnabledValidatorsDefault()); setEnabledManualValidators(getManualEnabledValidators()); setEnabledBuildValidators(getBuildEnabledValidators()); setCanProjectsOverride(getCanProjectsOverrideDefault()); setSaveAutomatically(getSaveAutomaticallyDefault()); setDefaultDelegates(getValidators()); }
/** * @see org.eclipse.wst.validation.internal.operations.internal.attribute.ValidationConfiguration#serialize() */ public String serialize() throws InvocationTargetException { StringBuffer buffer = new StringBuffer(); buffer.append(ConfigurationConstants.SAVE_AUTOMATICALLY_SETTING); buffer.append(String.valueOf(getSaveAutomatically())); buffer.append(ConfigurationConstants.PREF_PROJECTS_CAN_OVERRIDE); buffer.append(String.valueOf(canProjectsOverride())); buffer.append(super.serialize()); return buffer.toString(); }
/** * 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()})); } }
public void resetToDefaultForProjectDescriptionChange() throws InvocationTargetException { // The default values of the project is whatever the preference values are GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration(); setEnabledManualValidators(gp.getManualEnabledValidators()); setEnabledBuildValidators(gp.getBuildEnabledValidators()); setDelegatingValidators(gp.getDelegatingValidators()); }
/** * 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; }
private ValidatorMetaData[] getStateOfProjectLevelValidatorsFromGlobal(ProjectConfiguration prjp) throws InvocationTargetException { List enabledGlobalValidatorsForProject = new ArrayList(); GlobalConfiguration gf = ConfigurationManager.getManager().getGlobalConfiguration(); List allProjectValidator = getAllValidatorUniqueNames(prjp.getValidators()); ValidatorMetaData[] vmd = gf.getBuildEnabledValidators(); for(int i = 0; i < vmd.length; i++) { if(allProjectValidator.contains(vmd[i].getValidatorUniqueName())) { enabledGlobalValidatorsForProject.add(vmd[i]); } } return (ValidatorMetaData[]) enabledGlobalValidatorsForProject.toArray(new ValidatorMetaData[enabledGlobalValidatorsForProject.size()]); }
/** * This constructor should be used in all cases except for the Preference page's values. */ public GlobalConfiguration(IWorkspaceRoot root) throws InvocationTargetException { super(root, convertToArray(ValidationRegistryReader.getReader().getAllValidators())); // 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. }
public void enableValidator(String validatorId) { try { ValidatorMetaData vmd = ValidationRegistryReader.getReader() .getValidatorMetaData(validatorId); GlobalConfiguration gf = ConfigurationManager.getManager() .getGlobalConfiguration(); gf.enableSingleValidator(vmd); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void disableValidator(String validatorId){ try { ValidatorMetaData vmd = ValidationRegistryReader.getReader() .getValidatorMetaData(validatorId); GlobalConfiguration gf = ConfigurationManager.getManager() .getGlobalConfiguration(); gf.disableSingleValidator(vmd); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public Map getDelegatingValidators() throws InvocationTargetException { if (useGlobalPreference()) { return ConfigurationManager.getManager().getGlobalConfiguration().getDelegatingValidators(); } return super.getDelegatingValidators(); }
public ValidatorDelegateDescriptor getDelegateDescriptor(ValidatorMetaData vmd) throws InvocationTargetException { if (useGlobalPreference()) { return ConfigurationManager.getManager().getGlobalConfiguration().getDelegateDescriptor(vmd); } return super.getDelegateDescriptor(vmd); }
/** * Return the ValidationConfiguration to use, whether global or project. */ public boolean useGlobalPreference() { try { GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration(); if (gp == null) { return false; } if (!gp.canProjectsOverride()) { // If project's can't override the global, use the global return true; } // If the project overrides, then don't use the global. // If the project does not override, use the global. return !_doesProjectOverride; } catch (InvocationTargetException exc) { Logger logger = ValidationPlugin.getPlugin().getMsgLogger(); if (logger.isLoggingLevel(Level.SEVERE)) { LogEntry entry = ValidationPlugin.getLogEntry(); entry.setSourceIdentifier("ProjectConfiguration.userGlobalPreference"); //$NON-NLS-1$ entry.setTargetException(exc); logger.write(Level.SEVERE, entry); } return false; } }
public void resetToDefault() throws InvocationTargetException { // The default values of the project is whatever the preference values are GlobalConfiguration gp = ConfigurationManager.getManager().getGlobalConfiguration(); setEnabledManualValidators(gp.getManualEnabledValidators()); setEnabledBuildValidators(gp.getBuildEnabledValidators()); setDelegatingValidators(gp.getDelegatingValidators()); // except for this field, which is unique to the project preferences setDoesProjectOverride(getDoesProjectOverrideDefault()); }
public ValidatorMetaData[] getBuildEnabledValidators() throws InvocationTargetException { if (useGlobalPreference()) { return extractProjectValidators(ConfigurationManager.getManager().getGlobalConfiguration().getBuildEnabledValidators(), getResource()); } return super.getBuildEnabledValidators(); }