Search in sources :

Example 1 with DefaultScope

use of org.eclipse.core.runtime.preferences.DefaultScope in project liferay-ide by liferay.

the class WorkflowDefinitionValidator method validate.

@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    if (resource.getType() != IResource.FILE) {
        return null;
    }
    ValidationResult result = new ValidationResult();
    IFile workflowDefinitionXml = (IFile) resource;
    if (workflowDefinitionXml.isAccessible() && CoreUtil.isLiferayProject(resource.getProject())) {
        IScopeContext[] scopes = { new InstanceScope(), new DefaultScope() };
        ProjectScope projectScope = new ProjectScope(workflowDefinitionXml.getProject());
        boolean useProjectSettings = projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(ProjectCore.USE_PROJECT_SETTINGS, false);
        if (useProjectSettings) {
            scopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
        }
        try {
            Map<String, Object>[] problems = detectProblems(workflowDefinitionXml, scopes);
            for (int i = 0; i < problems.length; i++) {
                Object messageValue = problems[i].get(IMarker.MESSAGE);
                ValidatorMessage message = ValidatorMessage.create(messageValue.toString(), resource);
                message.setType(MARKER_TYPE);
                message.setAttributes(problems[i]);
                result.add(message);
            }
            if (ListUtil.isNotEmpty(problems)) {
                IResource[] resources = { workflowDefinitionXml };
                result.setDependsOn(resources);
            }
        } catch (Exception e) {
            KaleoCore.logError(e);
        }
    }
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IFile(org.eclipse.core.resources.IFile) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) ValidationResult(org.eclipse.wst.validation.ValidationResult) ValidatorMessage(org.eclipse.wst.validation.ValidatorMessage) CoreException(org.eclipse.core.runtime.CoreException) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) Map(java.util.Map) IResource(org.eclipse.core.resources.IResource)

Example 2 with DefaultScope

use of org.eclipse.core.runtime.preferences.DefaultScope in project m2e-nar by maven-nar.

the class AbstractTestBuild method setUp.

@SuppressWarnings("deprecation")
@Before
public void setUp() throws Exception {
    workspace = ResourcesPlugin.getWorkspace();
    // Turn off auto building
    IWorkspaceDescription description = workspace.getDescription();
    description.setAutoBuilding(false);
    workspace.setDescription(description);
    // Turn off index updating
    IEclipsePreferences store = new DefaultScope().getNode(IMavenConstants.PLUGIN_ID);
    store.putBoolean(MavenPreferenceConstants.P_UPDATE_INDEXES, false);
    mavenConfiguration = MavenPlugin.getMavenConfiguration();
    if (settingsFile != null) {
        oldUserSettingsFile = mavenConfiguration.getUserSettingsFile();
        File settings = new File(settingsFile).getCanonicalFile();
        if (settings.canRead()) {
            String userSettingsFile = settings.getAbsolutePath();
            System.out.println("Setting user settings file: " + userSettingsFile);
            mavenConfiguration.setUserSettingsFile(userSettingsFile);
        } else {
            fail("User settings file cannot be read: " + settings);
        }
    }
    cleanWorkspace();
    waitForJobs();
}
Also used : IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) File(java.io.File) Before(org.junit.Before)

Example 3 with DefaultScope

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

the class PreferenceInitializer method initializeDefaultPreferences.

public void initializeDefaultPreferences() {
    Preferences preferences = new DefaultScope().getNode(SyncResourcesCore.PLUGIN_ID);
    preferences.putInt(PreferenceConstants.LOCAL_RESOURCE_ADDITION, PreferenceConstants.COMMIT_VALUE);
    preferences.putInt(PreferenceConstants.LOCAL_RESOURCE_CHANGE, PreferenceConstants.COMMIT_VALUE);
    preferences.putInt(PreferenceConstants.LOCAL_RESOURCE_DELETION, PreferenceConstants.COMMIT_VALUE);
    preferences.putInt(PreferenceConstants.REMOTE_RESOURCE_ADDITION, PreferenceConstants.COMMIT_VALUE);
    preferences.putInt(PreferenceConstants.REMOTE_RESOURCE_CHANGE, PreferenceConstants.COMMIT_VALUE);
    preferences.putInt(PreferenceConstants.REMOTE_RESOURCE_DELETION, PreferenceConstants.COMMIT_VALUE);
}
Also used : DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) Preferences(org.osgi.service.prefs.Preferences)

Example 4 with DefaultScope

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

the class HTMLAttributeValidator method getExcludedAttributeNames.

private Set getExcludedAttributeNames(IProject project) {
    IScopeContext[] fLookupOrder = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
    if (project != null) {
        ProjectScope projectScope = new ProjectScope(project);
        if (projectScope.getNode(HTMLCorePlugin.getDefault().getBundle().getSymbolicName()).getBoolean(HTMLCorePreferenceNames.USE_PROJECT_SETTINGS, false))
            fLookupOrder = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
    }
    Set result = new HashSet();
    if (fPreferenceService.getBoolean(HTMLCorePlugin.getDefault().getBundle().getSymbolicName(), HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES, HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES_DEFAULT, fLookupOrder)) {
        String ignoreList = fPreferenceService.getString(HTMLCorePlugin.getDefault().getBundle().getSymbolicName(), HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE, HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE_DEFAULT, fLookupOrder);
        if (ignoreList.trim().length() == 0)
            return result;
        // $NON-NLS-1$
        String[] names = ignoreList.split(",");
        for (int i = 0; names != null && i < names.length; i++) {
            String name = names[i] == null ? null : names[i].trim();
            if (name != null && name.length() > 0)
                result.add(name.toLowerCase());
        }
    }
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) Set(java.util.Set) HashSet(java.util.HashSet) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) HashSet(java.util.HashSet)

Example 5 with DefaultScope

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

the class HTMLAttributeValidationQuickFixProcessor method computeQuickAssistProposals.

/*
	 * @see org.eclipse.jface.text.quickassist.IQuickAssistProcessor#computeQuickAssistProposals(org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext)
	 */
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
    ISourceViewer viewer = invocationContext.getSourceViewer();
    int documentOffset = invocationContext.getOffset();
    int length = viewer != null ? viewer.getSelectedRange().y : 0;
    IAnnotationModel model = viewer.getAnnotationModel();
    if (model == null)
        return null;
    List proposals = new ArrayList();
    if (model instanceof IAnnotationModelExtension2) {
        Iterator iter = ((IAnnotationModelExtension2) model).getAnnotationIterator(documentOffset, length, true, true);
        while (iter.hasNext()) {
            Annotation anno = (Annotation) iter.next();
            if (canFix(anno)) {
                int offset = -1;
                if (anno instanceof TemporaryAnnotation) {
                    offset = ((TemporaryAnnotation) anno).getPosition().getOffset();
                } else if (anno instanceof MarkerAnnotation) {
                    offset = ((MarkerAnnotation) anno).getMarker().getAttribute(IMarker.CHAR_START, -1);
                }
                if (offset == -1)
                    continue;
                IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
                if (!(node instanceof Element))
                    continue;
                Object adapter = (node instanceof IAdaptable ? ((IAdaptable) node).getAdapter(IResource.class) : null);
                IProject project = (adapter instanceof IResource ? ((IResource) adapter).getProject() : null);
                IScopeContext[] fLookupOrder = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
                if (project != null) {
                    ProjectScope projectScope = new ProjectScope(project);
                    if (projectScope.getNode(getPreferenceNodeQualifier()).getBoolean(getProjectSettingsKey(), false))
                        fLookupOrder = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
                }
                boolean ignore = fPreferenceService.getBoolean(getPreferenceNodeQualifier(), HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES, HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES_DEFAULT, fLookupOrder);
                String ignoreList = fPreferenceService.getString(getPreferenceNodeQualifier(), HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE, HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE_DEFAULT, fLookupOrder);
                Set result = new HashSet();
                if (ignoreList.trim().length() > 0) {
                    // $NON-NLS-1$
                    String[] names = ignoreList.split(",");
                    for (int i = 0; names != null && i < names.length; i++) {
                        String name = names[i] == null ? null : names[i].trim();
                        if (name != null && name.length() > 0)
                            result.add(name.toLowerCase());
                    }
                }
                String name = getAttributeName(node, offset);
                if (name == null)
                    continue;
                // If ignore == false. then show a quick fix anyway (due to allow to turn 'ignore' option on)
                if (!ignore || shouldShowQuickFix(result, name.toLowerCase())) {
                    IgnoreAttributeNameCompletionProposal p = new IgnoreAttributeNameCompletionProposal(name.toLowerCase(), offset, NLS.bind(HTMLUIMessages.DoNotValidateAttribute, name), HTMLUIMessages.DoNotValidateAttributeAddInfo, node);
                    if (!proposals.contains(p))
                        proposals.add(p);
                }
                int dashIndex = name.indexOf('-');
                while (dashIndex != -1) {
                    StringBuffer namePattern = new StringBuffer(name.substring(0, dashIndex + 1)).append('*');
                    // a more common pattern is already created
                    if (ignore && result.contains(namePattern.toString().toLowerCase()))
                        break;
                    IgnoreAttributeNameCompletionProposal p = new IgnoreAttributeNameCompletionProposal(namePattern.toString().toLowerCase(), offset, NLS.bind(HTMLUIMessages.DoNotValidateAllAttributes, namePattern.toString()), HTMLUIMessages.DoNotValidateAllAttributesAddInfo, node);
                    if (!proposals.contains(p))
                        proposals.add(p);
                    dashIndex = name.indexOf('-', dashIndex + 1);
                }
            }
        }
    }
    if (proposals.isEmpty())
        return null;
    return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IAdaptable(org.eclipse.core.runtime.IAdaptable) HashSet(java.util.HashSet) Set(java.util.Set) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) Iterator(java.util.Iterator) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) Annotation(org.eclipse.jface.text.source.Annotation) MarkerAnnotation(org.eclipse.ui.texteditor.MarkerAnnotation) TemporaryAnnotation(org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation) IProject(org.eclipse.core.resources.IProject) IAnnotationModelExtension2(org.eclipse.jface.text.source.IAnnotationModelExtension2) MarkerAnnotation(org.eclipse.ui.texteditor.MarkerAnnotation) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) TemporaryAnnotation(org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation) IResource(org.eclipse.core.resources.IResource)

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