use of org.eclipse.wst.html.ui.internal.preferences.ui.HTMLValidationPreferencePage 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.wst.html.ui.internal.preferences.ui.HTMLValidationPreferencePage in project webtools.sourceediting by eclipse.
the class IgnoreAttributeNameCompletionProposal 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_ATTRIBUTE_NAMES, HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES_DEFAULT, fLookupOrder);
String originalAttributeNames = fPreferenceService.getString(getPreferenceNodeQualifier(), HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE, HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE_DEFAULT, fLookupOrder);
StringBuffer ignoreList = new StringBuffer(originalAttributeNames);
if (!containsPattern(originalAttributeNames, fPattern)) {
if (ignoreList.length() > 0)
ignoreList.append(',');
ignoreList.append(fPattern.toLowerCase());
}
fLookupOrder[0].getNode(getPreferenceNodeQualifier()).putBoolean(HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES, true);
fLookupOrder[0].getNode(getPreferenceNodeQualifier()).put(HTMLCorePreferenceNames.ATTRIBUTE_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).overrideIgnoredAttributesOriginValues(originalEnableIgnore, originalAttributeNames);
}
result = dialog.open();
}
if (Window.CANCEL == result) {
fLookupOrder[0].getNode(getPreferenceNodeQualifier()).putBoolean(HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES, originalEnableIgnore);
fLookupOrder[0].getNode(getPreferenceNodeQualifier()).put(HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE, originalAttributeNames);
for (int i = 0; i < fLookupOrder.length; i++) {
try {
fLookupOrder[i].getNode(getPreferenceNodeQualifier()).flush();
} catch (BackingStoreException e) {
Logger.logException(e);
}
}
}
}
Aggregations