### Eclipse Workspace Patch 1.0
#P org.eclipse.pde.core
Index: src/org/eclipse/pde/internal/core/PluginModelManager.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginModelManager.java,v
retrieving revision 1.117
diff -u -r1.117 PluginModelManager.java
--- src/org/eclipse/pde/internal/core/PluginModelManager.java 19 Oct 2007 19:28:09 -0000 1.117
+++ src/org/eclipse/pde/internal/core/PluginModelManager.java 30 Oct 2007 11:42:17 -0000
@@ -388,7 +388,10 @@
*/
private synchronized void initializeTable() {
if (fEntries != null) return;
- fEntries = Collections.synchronizedMap(new TreeMap());
+
+ // Cannot assign to fEntries here - will create a race condition with isInitialized()
+
+ Map entries = Collections.synchronizedMap(new TreeMap());
// Create a state that contains all bundles from the target and workspace
// If a workspace bundle has the same symbolic name as a target bundle,
@@ -405,7 +408,7 @@
fExternalManager.initializeModels(fState.getTargetModels());
// add target models to the master table
- boolean statechanged = addToTable(fExternalManager.getAllModels());
+ boolean statechanged = addToTable(entries, fExternalManager.getAllModels());
// a state is combined only if the workspace plug-ins have not changed
// since the last shutdown of the workbench
@@ -414,7 +417,7 @@
// initialize the workspace models from the cached state
fWorkspaceManager.initializeModels(models);
// add workspace models to the master table
- addToTable(models);
+ addToTable(entries, models);
// resolve the state incrementally if some target models
// were removed
if (statechanged)
@@ -425,7 +428,7 @@
IPluginModelBase[] models = fWorkspaceManager.getPluginModels();
// add workspace plug-ins to the master table
- addToTable(models);
+ addToTable(entries, models);
// add workspace plug-ins to the state
// and remove their target counterparts from the state.
@@ -440,6 +443,8 @@
// flush the extension registry cache since workspace data (BundleDescription id's) have changed.
PDECore.getDefault().getExtensionsRegistry().targetReloaded();
}
+
+ fEntries = entries;
}
/**
@@ -449,17 +454,17 @@
*
* @return true
if changes were made to the state; false
otherwise
*/
- private boolean addToTable(IPluginModelBase[] models) {
+ private boolean addToTable(Map entries, IPluginModelBase[] models) {
boolean stateChanged = false;
for (int i = 0; i < models.length; i++) {
String id = models[i].getPluginBase().getId();
if (id == null)
continue;
- LocalModelEntry entry = (LocalModelEntry)fEntries.get(id);
+ LocalModelEntry entry = (LocalModelEntry)entries.get(id);
// create a new entry for the given ID if none already exists
if (entry == null) {
entry = new LocalModelEntry(id);
- fEntries.put(id, entry);
+ entries.put(id, entry);
}
// add the model to the entry
entry.addModel(models[i]);
#P org.eclipse.pde.ui
Index: src/org/eclipse/pde/internal/ui/views/plugins/PluginsContentProvider.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/plugins/PluginsContentProvider.java,v
retrieving revision 1.4
diff -u -r1.4 PluginsContentProvider.java
--- src/org/eclipse/pde/internal/ui/views/plugins/PluginsContentProvider.java 8 Jun 2007 16:43:38 -0000 1.4
+++ src/org/eclipse/pde/internal/ui/views/plugins/PluginsContentProvider.java 30 Oct 2007 11:42:29 -0000
@@ -13,6 +13,12 @@
import java.io.File;
import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJarEntryResource;
import org.eclipse.jdt.core.IPackageFragment;
@@ -26,6 +32,7 @@
import org.eclipse.pde.internal.core.ModelFileAdapter;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PluginModelManager;
+import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
public class PluginsContentProvider extends DefaultContentProvider
@@ -47,13 +54,75 @@
fView.updateTitle(newInput);
}
+ /**
+ * Initialise the PDE's Plug-in Model Manager in the background, ensuring
+ * that the view it refreshed once complete.
+ *
+ * @param modelMgr
+ * The PDE Plug-in Model Manager.
+ */
+ private void initialisePDEInBackground(PluginModelManager modelMgr) {
+
+ Job initJob = new Job(PDEUIMessages.PluginsView_PDEInitialise_taskName) {
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask(PDEUIMessages.PluginsView_PDEInitialise_taskName, 1);
+
+ // Initialise the PDE
+ PluginModelManager manager;
+ manager = PDECore.getDefault().getModelManager();
+ manager.isEmpty();
+
+ monitor.done();
+
+ return Status.OK_STATUS;
+ }
+ };
+ initJob.setPriority(Job.SHORT);
+ initJob.addJobChangeListener(new IJobChangeListener() {
+
+ public void aboutToRun(IJobChangeEvent event) {
+ }
+
+ public void awake(IJobChangeEvent event) {
+ }
+
+ public void done(IJobChangeEvent event) {
+ fView.refreshView();
+ }
+
+ public void running(IJobChangeEvent event) {
+ }
+
+ public void scheduled(IJobChangeEvent event) {
+ }
+
+ public void sleeping(IJobChangeEvent event) {
+ }
+ });
+ initJob.schedule();
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof PluginModelManager) {
- return ((PluginModelManager) parentElement).getAllModels();
+
+ PluginModelManager modelMgr = (PluginModelManager) parentElement;
+
+ if( ! modelMgr.isInitialized() ) {
+
+ // If the PDE isn't initialised, fire off the init in the
+ // background and show loading information instead
+ // of the real plug-in information
+
+ initialisePDEInBackground(modelMgr);
+
+ return new String[] {PDEUIMessages.PluginsView_PDEInitialise_loading};
+ }
+
+ return modelMgr.getAllModels();
}
if (parentElement instanceof IPluginModelBase) {
IPluginModelBase model = (IPluginModelBase)parentElement;
Index: src/org/eclipse/pde/internal/ui/views/plugins/PluginsView.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/plugins/PluginsView.java,v
retrieving revision 1.10
diff -u -r1.10 PluginsView.java
--- src/org/eclipse/pde/internal/ui/views/plugins/PluginsView.java 21 May 2007 15:41:42 -0000 1.10
+++ src/org/eclipse/pde/internal/ui/views/plugins/PluginsView.java 30 Oct 2007 11:42:29 -0000
@@ -866,8 +866,19 @@
}
private void updateContentDescription() {
- String total = Integer.toString(PluginRegistry.getAllModels().length);
- String visible = Integer.toString(fTreeViewer.getTree().getItemCount());
+
+ // defaults to be shown if the PDE isn't initialised
+ String total = PDEUIMessages.PluginsView_TotalPlugins_unknown;
+ String visible = "0";
+
+ PluginModelManager manager;
+ manager = PDECore.getDefault().getModelManager();
+ if( manager.isInitialized() ) {
+ // Only show the correct values if the PDE is already initialised
+ // (N.B. PluginRegistry.getAllModels() would call the init if allowed to execute)
+ total = Integer.toString(PluginRegistry.getAllModels().length);
+ visible = Integer.toString(fTreeViewer.getTree().getItemCount());
+ }
setContentDescription(NLS.bind(PDEUIMessages.PluginsView_description, visible, total));
}
@@ -898,6 +909,26 @@
}
});
}
+
+ /**
+ * Refresh the view
+ */
+ void refreshView() {
+ if (fTreeViewer == null || fTreeViewer.getTree().isDisposed()) {
+ return;
+ }
+
+ // Make sure we're on the correct thread
+ fTreeViewer.getTree().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (fTreeViewer.getTree().isDisposed()) {
+ return;
+ }
+ fTreeViewer.refresh();
+ updateContentDescription();
+ }
+ });
+ }
private IPluginModelBase[] getModels(ModelEntry entry) {
return (entry.hasWorkspaceModels())
Index: src/org/eclipse/pde/internal/ui/pderesources.properties
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v
retrieving revision 1.932
diff -u -r1.932 pderesources.properties
--- src/org/eclipse/pde/internal/ui/pderesources.properties 16 Oct 2007 17:00:46 -0000 1.932
+++ src/org/eclipse/pde/internal/ui/pderesources.properties 30 Oct 2007 11:42:29 -0000
@@ -1377,6 +1377,9 @@
# Select all is part of a submenu "Select" hence the label is not "Select all"
PluginsView_SelectAllAction_label = &All
+PluginsView_TotalPlugins_unknown=
+PluginsView_PDEInitialise_loading=Loading...
+PluginsView_PDEInitialise_taskName=Initialise PDE
PluginSection_open=Open
PluginsView_unableToOpen = Unable to open external editor: {0}
Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v
retrieving revision 1.334
diff -u -r1.334 PDEUIMessages.java
--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 16 Oct 2007 17:00:46 -0000 1.334
+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 30 Oct 2007 11:42:24 -0000
@@ -1813,6 +1813,11 @@
public static String PluginsView_CollapseAllAction_tooltip;
public static String PluginsView_SelectAllAction_label;
+ public static String PluginsView_TotalPlugins_unknown;
+ public static String PluginsView_PDEInitialise_loading;
+ public static String PluginsView_PDEInitialise_taskName;
+
+
public static String PluginSection_open;
public static String PluginsView_unableToOpen;
public static String PluginWorkingSet_setName;