[395009] file org.eclipse.wst.sse.core.prefs contains workspace project names which have no place there
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/TaglibIndex.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/TaglibIndex.java index 8ff14e5..96bb2fd 100644 --- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/TaglibIndex.java +++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/TaglibIndex.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 IBM Corporation and others. + * Copyright (c) 2005, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,6 +34,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.jobs.ILock; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jdt.core.ElementChangedEvent; @@ -624,6 +625,8 @@ /** symbolic name for OSGI framework */ private final static String OSGI_FRAMEWORK_ID = "org.eclipse.osgi"; //$NON-NLS-1$ + private final static QualifiedName STATE_NAME = new QualifiedName("org.eclipse.jst.jsp.core", TaglibIndex.class.getName()); + private TaglibIndex() { super(); } @@ -644,7 +647,11 @@ * Only consider a crash if a value exists and is DIRTY (not a * new workspace) */ - if (DIRTY.equalsIgnoreCase(getState())) { + String savedState = getState(); + if (savedState == null) { + removeIndexes(false); + } + else if (DIRTY.equalsIgnoreCase(savedState)) { Logger.log(Logger.ERROR, "A workspace crash was detected. The previous session did not exit normally. Not using saved taglib indexes."); //$NON-NLS-3$ removeIndexes(false); } @@ -773,8 +780,14 @@ } private String getState() { - String state = JSPCorePlugin.getDefault().getPluginPreferences().getString(TaglibIndex.class.getName()); - return state; + try { + String state = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(STATE_NAME); + return state; + } + catch (CoreException e) { + Logger.logException(e); + } + return DIRTY; } private IPath getTaglibIndexStateLocation() { @@ -952,8 +965,12 @@ private void setState(String state) { if (!state.equals(getState())) { - JSPCorePlugin.getDefault().getPluginPreferences().setValue(TaglibIndex.class.getName(), state); - JSPCorePlugin.getDefault().savePluginPreferences(); + try { + ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(STATE_NAME, state); + } + catch (CoreException e) { + Logger.logException(e); + } } }
diff --git a/bundles/org.eclipse.wst.sse.core/build.properties b/bundles/org.eclipse.wst.sse.core/build.properties index 37541b2..f46fe9f 100644 --- a/bundles/org.eclipse.wst.sse.core/build.properties +++ b/bundles/org.eclipse.wst.sse.core/build.properties
@@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2001, 2006 IBM Corporation and others. +# Copyright (c) 2001, 2012 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -26,7 +26,6 @@ temp.folder/** src.includes = schema/,\ doc/,\ - component.xml,\ DevTimeSupport/ output.. = bin/ src.excludes = DevTimeSupport/build.xml,\
diff --git a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningJob.java b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningJob.java index 92fda63..8e35e2e 100644 --- a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningJob.java +++ b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningJob.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2010 IBM Corporation and others. + * Copyright (c) 2001, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,6 +13,8 @@ package org.eclipse.wst.sse.core.internal.tasks; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; import org.eclipse.core.resources.IProject; @@ -20,10 +22,12 @@ import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.Job; @@ -44,6 +48,7 @@ static final int JOB_DELAY_DELTA = 1000; private static final int JOB_DELAY_PROJECT = 5000; static final String TASK_TAG_PROJECTS_ALREADY_SCANNED = "task-tag-projects-already-scanned"; //$NON-NLS-1$ + static final QualifiedName QTASK_TAG_PROJECTS_ALREADY_SCANNED = new QualifiedName(SSECorePlugin.ID, TASK_TAG_PROJECTS_ALREADY_SCANNED); private List fQueue = null; /** symbolic name for OSGI framework */ @@ -55,14 +60,18 @@ setPriority(Job.DECORATE); setSystem(true); setUser(false); - - SSECorePlugin.getDefault().getPluginPreferences().setDefault(TASK_TAG_PROJECTS_ALREADY_SCANNED, ""); //$NON-NLS-1$ } synchronized void addProjectDelta(IResourceDelta delta) { IResource projectResource = delta.getResource(); if (projectResource.getType() == IResource.PROJECT) { + if (!projectResource.isAccessible()) { + String[] projectsPreviouslyScanned = getScannedProjects(); + HashSet updatedProjects = new HashSet(Arrays.asList(projectsPreviouslyScanned)); + updatedProjects.remove(projectResource.getName()); + setScannedProjects((String[]) updatedProjects.toArray(new String[updatedProjects.size()])); + } if (isEnabledOnProject((IProject) projectResource)) { fQueue.add(delta); if (Logger.DEBUG_TASKSJOB) { @@ -126,7 +135,7 @@ } private boolean projectHasNotBeenFullyScanned(IResource project) { - String[] projectsScanned = StringUtils.unpack(SSECorePlugin.getDefault().getPluginPreferences().getString(TASK_TAG_PROJECTS_ALREADY_SCANNED)); + String[] projectsScanned = getScannedProjects(); boolean shouldScan = true; String name = project.getName(); @@ -150,7 +159,7 @@ if (frameworkIsShuttingDown()) return Status.CANCEL_STATUS; - cleanupRememberedProjectList(TASK_TAG_PROJECTS_ALREADY_SCANNED); + cleanupRememberedProjectList(); IStatus status = null; List currentQueue = retrieveQueue(); @@ -185,12 +194,17 @@ } else if (o instanceof IProject) { WorkspaceTaskScanner.getInstance().scan((IProject) o, scanMonitor); - if(!scanMonitor.isCanceled() ) { - String[] projectsPreviouslyScanned = StringUtils.unpack(SSECorePlugin.getDefault().getPluginPreferences().getString(TASK_TAG_PROJECTS_ALREADY_SCANNED)); - String[] updatedProjects = new String[projectsPreviouslyScanned.length + 1]; - updatedProjects[projectsPreviouslyScanned.length] = ((IResource) o).getName(); - System.arraycopy(projectsPreviouslyScanned, 0, updatedProjects, 0, projectsPreviouslyScanned.length); - SSECorePlugin.getDefault().getPluginPreferences().setValue(TASK_TAG_PROJECTS_ALREADY_SCANNED, StringUtils.pack(updatedProjects)); + if (!scanMonitor.isCanceled()) { + String[] projectsPreviouslyScanned = getScannedProjects(); + HashSet updatedProjects = new HashSet(Arrays.asList(projectsPreviouslyScanned)); + updatedProjects.add(((IProject) o).getName()); + setScannedProjects((String[]) updatedProjects.toArray(new String[updatedProjects.size()])); + } + if (!((IProject) o).isAccessible()) { + String[] projectsPreviouslyScanned = getScannedProjects(); + HashSet updatedProjects = new HashSet(Arrays.asList(projectsPreviouslyScanned)); + updatedProjects.remove(((IProject) o).getName()); + setScannedProjects((String[]) updatedProjects.toArray(new String[updatedProjects.size()])); } } } @@ -220,8 +234,8 @@ return status; } - private void cleanupRememberedProjectList(String preferenceName) { - String[] rememberedProjectNames = StringUtils.unpack(SSECorePlugin.getDefault().getPluginPreferences().getString(preferenceName)); + private void cleanupRememberedProjectList() { + String[] rememberedProjectNames = getScannedProjects(); IResource[] workspaceProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); String[] projectNames = new String[workspaceProjects.length]; for (int i = 0; i < projectNames.length; i++) { @@ -240,12 +254,36 @@ projectNamesToRemember.add(rememberedProjectNames[i]); } else if (Logger.DEBUG_TASKSJOB) { - System.out.println("Removing " + rememberedProjectNames[i] + " removed from " + preferenceName); //$NON-NLS-1$ //$NON-NLS-2$ + System.out.println("Removing " + rememberedProjectNames[i] + " removed from " + TASK_TAG_PROJECTS_ALREADY_SCANNED); //$NON-NLS-1$ //$NON-NLS-2$ } } if (projectNamesToRemember.size() != rememberedProjectNames.length) { - SSECorePlugin.getDefault().getPluginPreferences().setValue(preferenceName, StringUtils.pack((String[]) projectNamesToRemember.toArray(new String[projectNamesToRemember.size()]))); + setScannedProjects((String[]) projectNamesToRemember.toArray(new String[projectNamesToRemember.size()])); + } + } + + static String[] getScannedProjects() { + String rawValue = null; + try { + rawValue = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(QTASK_TAG_PROJECTS_ALREADY_SCANNED); + } + catch (CoreException e) { + Logger.logException(e); + } + if (rawValue != null) + return StringUtils.unpack(rawValue); + return new String[0]; + } + + static void setScannedProjects(String[] projectNames) { + if (Logger.DEBUG_TASKSJOB) + System.out.println("Task scanned projects set to " + StringUtils.pack(projectNames)); //$NON-NLS-1$ + try { + ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(QTASK_TAG_PROJECTS_ALREADY_SCANNED, StringUtils.pack(projectNames)); + } + catch (CoreException e) { + Logger.logException(e); } } }
diff --git a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningScheduler.java b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningScheduler.java index 6095a6d..6c32086 100644 --- a/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningScheduler.java +++ b/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/TaskScanningScheduler.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2007 IBM Corporation and others. + * Copyright (c) 2001, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,8 +24,6 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.wst.sse.core.internal.Logger; -import org.eclipse.wst.sse.core.internal.SSECorePlugin; -import org.eclipse.wst.sse.core.utils.StringUtils; public class TaskScanningScheduler { class ListenerVisitor implements IResourceChangeListener, IResourceDeltaVisitor { @@ -65,20 +63,19 @@ private static TaskScanningScheduler scheduler; public static void refresh() { - SSECorePlugin.getDefault().getPluginPreferences().setValue(TaskScanningJob.TASK_TAG_PROJECTS_ALREADY_SCANNED, ""); //$NON-NLS-1$ + TaskScanningJob.setScannedProjects(new String[0]); scheduler.enqueue(ResourcesPlugin.getWorkspace().getRoot()); } public static void refresh(IProject project) { - String[] projectNames = StringUtils.unpack(SSECorePlugin.getDefault().getPluginPreferences().getString(TaskScanningJob.TASK_TAG_PROJECTS_ALREADY_SCANNED)); //$NON-NLS-1$ + String[] projectNames = TaskScanningJob.getScannedProjects(); List freshProjectList = new ArrayList(); for (int i = 0; i < projectNames.length; i++) { if (!projectNames[i].equals(project.getName())) { freshProjectList.add(projectNames[i]); } } - String freshProjects = StringUtils.pack((String[]) freshProjectList.toArray(new String[freshProjectList.size()])); - SSECorePlugin.getDefault().getPluginPreferences().setValue(TaskScanningJob.TASK_TAG_PROJECTS_ALREADY_SCANNED, freshProjects); //$NON-NLS-1$ + TaskScanningJob.setScannedProjects((String[]) freshProjectList.toArray(new String[freshProjectList.size()])); scheduler.enqueue(project); }