Search in sources :

Example 21 with DefaultScope

use of org.eclipse.core.runtime.preferences.DefaultScope in project eclipse-integration-commons by spring-projects.

the class Activator method start.

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    new DefaultScope().getNode(PLUGIN_ID).putBoolean(PROPERTY_CONFIGURATOR_PROCESSED, false);
    try {
        IExtension extension = Platform.getExtensionRegistry().getExtension("org.eclipse.equinox.p2.engine.actions", "org.springsource.ide.eclipse.commons.configure");
        configurationActionRegistered = extension != null;
        if (!configurationActionRegistered) {
            getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Registeration of configure action failed. This may cause extension install to fail."));
        }
    } catch (Throwable t) {
        getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Registeration of configure action failed. This may cause extension install to fail.", t));
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IExtension(org.eclipse.core.runtime.IExtension) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Example 22 with DefaultScope

use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.

the class JSPActionValidator 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() };
        }
    }
    fSeverityMissingRequiredAttribute = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_MISSING_REQUIRED_ATTRIBUTE);
    fSeverityNonEmptyInlineTag = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_NON_EMPTY_INLINE_TAG);
    fSeverityUnknownAttribute = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_UNKNOWN_ATTRIBUTE);
    fSeverityUnexpectedRuntimeExpression = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_UNEXPECTED_RTEXPRVALUE);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Example 23 with DefaultScope

use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.

the class JSPELValidator 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() };
        }
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Example 24 with DefaultScope

use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.

the class TLDValidator method validate.

public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    if (resource.getType() != IResource.FILE)
        return null;
    ValidationResult result = new ValidationResult();
    IFile file = (IFile) resource;
    if (file.isAccessible()) {
        // TAGX
        if (fTagXexts.contains(file.getFileExtension()) || fTagXnames.contains(file.getName())) {
            monitor.beginTask("", 4);
            org.eclipse.wst.xml.core.internal.validation.eclipse.Validator xmlValidator = new org.eclipse.wst.xml.core.internal.validation.eclipse.Validator();
            ValidationResult result3 = new MarkupValidator().validate(resource, kind, state, new SubProgressMonitor(monitor, 1));
            if (monitor.isCanceled())
                return result;
            ValidationResult result2 = xmlValidator.validate(resource, kind, state, new SubProgressMonitor(monitor, 1));
            if (monitor.isCanceled())
                return result;
            ValidationResult result1 = new JSPActionValidator().validate(resource, kind, state, new SubProgressMonitor(monitor, 1));
            List messages = new ArrayList(result1.getReporter(new NullProgressMonitor()).getMessages());
            messages.addAll(result2.getReporter(new NullProgressMonitor()).getMessages());
            messages.addAll(result3.getReporter(new NullProgressMonitor()).getMessages());
            messages.addAll(new JSPDirectiveValidator().validate(resource, kind, state, new SubProgressMonitor(monitor, 1)).getReporter(new NullProgressMonitor()).getMessages());
            for (int i = 0; i < messages.size(); i++) {
                IMessage message = (IMessage) messages.get(i);
                if (message.getText() != null && message.getText().length() > 0) {
                    ValidatorMessage vmessage = ValidatorMessage.create(message.getText(), resource);
                    if (message.getAttributes() != null) {
                        Map attrs = message.getAttributes();
                        Iterator it = attrs.entrySet().iterator();
                        while (it.hasNext()) {
                            Map.Entry entry = (Map.Entry) it.next();
                            if (!(entry.getValue() instanceof String || entry.getValue() instanceof Integer || entry.getValue() instanceof Boolean)) {
                                it.remove();
                            }
                        }
                        vmessage.setAttributes(attrs);
                    }
                    vmessage.setAttribute(IMarker.LINE_NUMBER, message.getLineNumber());
                    vmessage.setAttribute(IMarker.MESSAGE, message.getText());
                    if (message.getOffset() > -1) {
                        vmessage.setAttribute(IMarker.CHAR_START, message.getOffset());
                        vmessage.setAttribute(IMarker.CHAR_END, message.getOffset() + message.getLength());
                    }
                    int severity = 0;
                    switch(message.getSeverity()) {
                        case IMessage.HIGH_SEVERITY:
                            severity = IMarker.SEVERITY_ERROR;
                            break;
                        case IMessage.NORMAL_SEVERITY:
                            severity = IMarker.SEVERITY_WARNING;
                            break;
                        case IMessage.LOW_SEVERITY:
                            severity = IMarker.SEVERITY_INFO;
                            break;
                    }
                    vmessage.setAttribute(IMarker.SEVERITY, severity);
                    vmessage.setType(MARKER_TYPE);
                    result.add(vmessage);
                }
            }
            monitor.done();
        } else // TLD
        {
            try {
                final IJavaProject javaProject = JavaCore.create(file.getProject());
                if (javaProject.exists()) {
                    IScopeContext[] scopes = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
                    ProjectScope projectScope = new ProjectScope(file.getProject());
                    if (projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false)) {
                        scopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
                    }
                    Map[] problems = detectProblems(javaProject, file, scopes);
                    for (int i = 0; i < problems.length; i++) {
                        ValidatorMessage message = ValidatorMessage.create(problems[i].get(IMarker.MESSAGE).toString(), resource);
                        message.setType(MARKER_TYPE);
                        message.setAttributes(problems[i]);
                        result.add(message);
                    }
                }
            } catch (Exception e) {
                Logger.logException(e);
            }
        }
    }
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) ValidationResult(org.eclipse.wst.validation.ValidationResult) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) Iterator(java.util.Iterator) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) IMessage(org.eclipse.wst.validation.internal.provisional.core.IMessage) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) ValidatorMessage(org.eclipse.wst.validation.ValidatorMessage) JavaModelException(org.eclipse.jdt.core.JavaModelException) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) IJavaProject(org.eclipse.jdt.core.IJavaProject) HashMap(java.util.HashMap) Map(java.util.Map) MarkupValidator(org.eclipse.wst.xml.core.internal.validation.MarkupValidator) AbstractValidator(org.eclipse.wst.validation.AbstractValidator) MarkupValidator(org.eclipse.wst.xml.core.internal.validation.MarkupValidator)

Example 25 with DefaultScope

use of org.eclipse.core.runtime.preferences.DefaultScope in project webtools.sourceediting by eclipse.

the class TagContentSettingsPropertyPage method createContents.

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(GridDataFactory.fillDefaults());
    composite.setLayout(new GridLayout(2, true));
    Object adapter = getElement().getAdapter(IFile.class);
    if (adapter == null) {
        adapter = getElement().getAdapter(IResource.class);
    }
    if (adapter != null && adapter instanceof IResource) {
        String preferenceKey = TagModelQuery.createPreferenceKey(((IResource) adapter).getFullPath());
        new DefaultScope().getNode(JSPCorePlugin.getDefault().getBundle().getSymbolicName()).put(preferenceKey, fValues[0]);
        ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(((IResource) adapter).getProject()), JSPCorePlugin.getDefault().getBundle().getSymbolicName());
        String[][] entryNamesAndValues = new String[][] { { fDisplayTypes[0], fValues[0] }, { fDisplayTypes[1], fValues[1] } };
        fComboFieldEditor = new ComboFieldEditor(preferenceKey, JSPUIMessages.JSPFContentSettingsPropertyPage_2, entryNamesAndValues, composite);
        fComboFieldEditor.fillIntoGrid(composite, 2);
        fComboFieldEditor.setPreferenceStore(store);
        fComboFieldEditor.load();
        // let the page save for us if needed
        setPreferenceStore(store);
    }
    return composite;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor) IResource(org.eclipse.core.resources.IResource) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Aggregations

DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)44 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)24 ProjectScope (org.eclipse.core.resources.ProjectScope)17 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)16 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)15 IProject (org.eclipse.core.resources.IProject)7 IResource (org.eclipse.core.resources.IResource)6 HashSet (java.util.HashSet)4 Set (java.util.Set)4 IFile (org.eclipse.core.resources.IFile)4 IAdaptable (org.eclipse.core.runtime.IAdaptable)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 BackingStoreException (org.osgi.service.prefs.BackingStoreException)3 IOException (java.io.IOException)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)2 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)2