use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.
the class IgnoreElementNameCompletionProposal method apply.
/*
* @see ICompletionProposal#apply(IDocument)
*/
public void apply(IDocument document) {
Object adapter = (fTarget instanceof IAdaptable ? ((IAdaptable) fTarget).getAdapter(IResource.class) : null);
IProject project = (adapter instanceof IResource ? ((IResource) adapter).getProject() : null);
IScopeContext[] fLookupOrder = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
boolean hasProjectSettings = false;
if (project != null) {
ProjectScope projectScope = new ProjectScope(project);
if (projectScope.getNode(getPreferenceNodeQualifier()).getBoolean(getProjectSettingsKey(), false)) {
hasProjectSettings = true;
fLookupOrder = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
}
}
boolean originalEnableIgnore = fPreferenceService.getBoolean(getPreferenceNodeQualifier(), HTMLCorePreferenceNames.IGNORE_ELEMENT_NAMES, HTMLCorePreferenceNames.IGNORE_ELEMENT_NAMES_DEFAULT, fLookupOrder);
String originalElementNames = fPreferenceService.getString(getPreferenceNodeQualifier(), HTMLCorePreferenceNames.ELEMENT_NAMES_TO_IGNORE, HTMLCorePreferenceNames.ELEMENT_NAMES_TO_IGNORE_DEFAULT, fLookupOrder);
StringBuffer ignoreList = new StringBuffer(originalElementNames);
if (!containsPattern(originalElementNames, fPattern)) {
if (ignoreList.length() > 0)
ignoreList.append(',');
ignoreList.append(fPattern.toLowerCase());
}
fLookupOrder[0].getNode(getPreferenceNodeQualifier()).putBoolean(HTMLCorePreferenceNames.IGNORE_ELEMENT_NAMES, true);
fLookupOrder[0].getNode(getPreferenceNodeQualifier()).put(HTMLCorePreferenceNames.ELEMENT_NAMES_TO_IGNORE, ignoreList.toString());
PreferenceDialog dialog = hasProjectSettings ? PreferencesUtil.createPropertyDialogOn(getShell(), project, HTMLValidationPreferencePage.PROPERTY_PAGE_ID, null, null) : PreferencesUtil.createPreferenceDialogOn(getShell(), HTMLValidationPreferencePage.PREFERENCE_PAGE_ID, null, null);
int result = Window.CANCEL;
if (dialog != null) {
Object page = dialog.getSelectedPage();
if (page instanceof HTMLValidationPreferencePage) {
((HTMLValidationPreferencePage) page).overrideIgnoredElementsOriginValues(originalEnableIgnore, originalElementNames);
}
result = dialog.open();
}
if (Window.CANCEL == result) {
fLookupOrder[0].getNode(getPreferenceNodeQualifier()).putBoolean(HTMLCorePreferenceNames.IGNORE_ELEMENT_NAMES, originalEnableIgnore);
fLookupOrder[0].getNode(getPreferenceNodeQualifier()).put(HTMLCorePreferenceNames.ELEMENT_NAMES_TO_IGNORE, originalElementNames);
for (int i = 0; i < fLookupOrder.length; i++) {
try {
fLookupOrder[i].getNode(getPreferenceNodeQualifier()).flush();
} catch (BackingStoreException e) {
Logger.logException(e);
}
}
}
}
use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.
the class JSPELTranslator method getScopeContexts.
private IScopeContext[] getScopeContexts(IStructuredDocument document) {
IScopeContext[] scopes = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
final IFile file = getFile(document);
if (file != null && file.exists()) {
final IProject project = file.getProject();
if (project.exists()) {
ProjectScope projectScope = new ProjectScope(project);
if (projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false)) {
scopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
}
}
}
return scopes;
}
use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.
the class MainTab method save.
private void save() {
IEclipsePreferences defaultPreferences = new DefaultScope().getNode(TaskTagPreferenceKeys.TASK_TAG_NODE);
String defaultTags = defaultPreferences.get(TaskTagPreferenceKeys.TASK_TAG_TAGS, null);
String defaultPriorities = defaultPreferences.get(TaskTagPreferenceKeys.TASK_TAG_PRIORITIES, null);
StringBuffer buf = new StringBuffer();
for (int i = 0; i < fTaskTags.length; i++) {
if (i > 0) {
// $NON-NLS-1$
buf.append(",");
}
buf.append(fTaskTags[i].getTag());
}
String currentTags = buf.toString();
if (currentTags.equals(defaultTags) && !fPreferencesLookupOrder[0].getName().equals(DefaultScope.SCOPE)) {
if (_debugPreferences) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
System.out.println(getClass().getName() + " removing " + TaskTagPreferenceKeys.TASK_TAG_TAGS + " from scope " + fPreferencesLookupOrder[0].getName() + ":" + fPreferencesLookupOrder[0].getLocation());
}
fPreferencesLookupOrder[0].getNode(TaskTagPreferenceKeys.TASK_TAG_NODE).remove(TaskTagPreferenceKeys.TASK_TAG_TAGS);
} else {
fOwner.requestRedetection();
if (_debugPreferences) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
System.out.println(getClass().getName() + " setting " + TaskTagPreferenceKeys.TASK_TAG_TAGS + " \"" + currentTags + "\" in scope " + fPreferencesLookupOrder[0].getName() + ":" + fPreferencesLookupOrder[0].getLocation());
}
fPreferencesLookupOrder[0].getNode(TaskTagPreferenceKeys.TASK_TAG_NODE).put(TaskTagPreferenceKeys.TASK_TAG_TAGS, currentTags);
}
StringBuffer buf2 = new StringBuffer();
for (int i = 0; i < fTaskTags.length; i++) {
if (i > 0) {
// $NON-NLS-1$
buf2.append(",");
}
buf2.append(String.valueOf(fTaskTags[i].getPriority()));
}
String priorities = buf2.toString();
if (priorities.equals(defaultPriorities) && !fPreferencesLookupOrder[0].getName().equals(DefaultScope.SCOPE)) {
if (_debugPreferences) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
System.out.println(getClass().getName() + " removing " + TaskTagPreferenceKeys.TASK_TAG_PRIORITIES + " from scope " + fPreferencesLookupOrder[0].getName() + ":" + fPreferencesLookupOrder[0].getLocation());
}
fPreferencesLookupOrder[0].getNode(TaskTagPreferenceKeys.TASK_TAG_NODE).remove(TaskTagPreferenceKeys.TASK_TAG_PRIORITIES);
} else {
fOwner.requestRedetection();
if (_debugPreferences) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
System.out.println(getClass().getName() + " setting " + TaskTagPreferenceKeys.TASK_TAG_PRIORITIES + " \"" + priorities + "\" in scope " + fPreferencesLookupOrder[0].getName() + ":" + fPreferencesLookupOrder[0].getLocation());
}
fPreferencesLookupOrder[0].getNode(TaskTagPreferenceKeys.TASK_TAG_NODE).put(TaskTagPreferenceKeys.TASK_TAG_PRIORITIES, priorities);
}
}
use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidator method loadPreferences.
private void loadPreferences(IFile file) {
fScopes = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
fPreferencesService = Platform.getPreferencesService();
if (file != null && file.isAccessible()) {
ProjectScope projectScope = new ProjectScope(file.getProject());
if (projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false)) {
fScopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
}
}
fSeverityIncludeFileMissing = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_INCLUDE_FILE_NOT_FOUND);
fSeverityIncludeFileNotSpecified = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_INCLUDE_NO_FILE_SPECIFIED);
fSeverityTaglibDuplicatePrefixWithDifferentURIs = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_DUPLICATE_PREFIXES_DIFFERENT_URIS);
fSeverityTaglibDuplicatePrefixWithSameURIs = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_DUPLICATE_PREFIXES_SAME_URIS);
fSeverityTaglibMissingPrefix = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_MISSING_PREFIX);
fSeverityTaglibMissingURI = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_MISSING_URI_OR_TAGDIR);
fSeverityTaglibUnresolvableURI = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_UNRESOLVABLE_URI_OR_TAGDIR);
fSeverityTagdirUnresolvableURI = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_UNRESOLVABLE_URI_OR_TAGDIR);
fSeveritySuperClassNotFound = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_PAGE_SUPERCLASS_NOT_FOUND);
fSeverityDuplicateAttributeName = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_ATTRIBUTE_DUPLICATE_NAME);
}
use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.
the class JSPCorePreferenceInitializer method initializeDefaultPreferences.
public void initializeDefaultPreferences() {
IEclipsePreferences node = new DefaultScope().getNode(JSPCorePlugin.getDefault().getBundle().getSymbolicName());
// compiler/validation preferences
node.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
// code generation preferences
// $NON-NLS-1$
node.put(CommonEncodingPreferenceNames.INPUT_CODESET, "");
// $NON-NLS-1$
String defaultEnc = "ISO-8859-1";
// $NON-NLS-1$
String systemEnc = System.getProperty("file.encoding");
if (systemEnc != null) {
// $NON-NLS-1$
defaultEnc = CommonCharsetNames.getPreferredDefaultIanaName(systemEnc, "ISO-8859-1");
}
node.put(CommonEncodingPreferenceNames.OUTPUT_CODESET, defaultEnc);
// $NON-NLS-1$
node.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, "");
// this could be made smarter by actually looking up the content
// type's valid extensions
// $NON-NLS-1$
node.put(JSPCorePreferenceNames.DEFAULT_EXTENSION, "jsp");
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_DUPLICATE_PREFIXES_DIFFERENT_URIS, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_DUPLICATE_PREFIXES_SAME_URIS, ValidationMessage.IGNORE);
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_MISSING_PREFIX, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_MISSING_URI_OR_TAGDIR, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_TAGLIB_UNRESOLVABLE_URI_OR_TAGDIR, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_PAGE_SUPERCLASS_NOT_FOUND, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_INCLUDE_NO_FILE_SPECIFIED, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_INCLUDE_FILE_NOT_FOUND, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_DIRECTIVE_ATTRIBUTE_DUPLICATE_NAME, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_JAVA_LOCAL_VARIABLE_NEVER_USED, ValidationMessage.IGNORE);
node.putInt(JSPCorePreferenceNames.VALIDATION_JAVA_ARGUMENT_IS_NEVER_USED, ValidationMessage.IGNORE);
node.putInt(JSPCorePreferenceNames.VALIDATION_JAVA_NULL_LOCAL_VARIABLE_REFERENCE, ValidationMessage.IGNORE);
node.putInt(JSPCorePreferenceNames.VALIDATION_JAVA_POTENTIAL_NULL_LOCAL_VARIABLE_REFERENCE, ValidationMessage.IGNORE);
node.putInt(JSPCorePreferenceNames.VALIDATION_JAVA_UNUSED_IMPORT, ValidationMessage.IGNORE);
node.putInt(JSPCorePreferenceNames.VALIDATION_EL_SYNTAX, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_EL_LEXER, ValidationMessage.IGNORE);
node.putInt(JSPCorePreferenceNames.VALIDATION_EL_FUNCTION_UNDEFINED, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_MISSING_REQUIRED_ATTRIBUTE, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_UNKNOWN_ATTRIBUTE, ValidationMessage.WARNING);
node.putInt(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_NON_EMPTY_INLINE_TAG, ValidationMessage.WARNING);
node.putInt(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_UNEXPECTED_RTEXPRVALUE, ValidationMessage.WARNING);
node.putInt(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_VALIDATION_MESSAGE, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_NOT_FOUND, ValidationMessage.WARNING);
node.putInt(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_NOT_INSTANTIATED, ValidationMessage.WARNING);
node.putInt(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_RUNTIME_EXCEPTION, ValidationMessage.WARNING);
node.putInt(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TAG_HANDLER_CLASS_NOT_FOUND, ValidationMessage.WARNING);
node.putInt(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USEBEAN_INVALID_ID, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USBEAN_MISSING_TYPE_INFO, ValidationMessage.ERROR);
node.putInt(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USEBEAN_AMBIGUOUS_TYPE_INFO, ValidationMessage.WARNING);
}
Aggregations