Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2014-02-27 05:25:10 +0000
committerEike Stepper2014-02-27 08:44:35 +0000
commit3faf7b521e5fc2db25794aa7ecd9759d73caeef4 (patch)
tree03312402d503c9f86a4d567fae54c5714aa0f59f
parent99354fc1fb5ea09d39c1693ce58a9ee628ce0f81 (diff)
downloadcdo-3faf7b521e5fc2db25794aa7ecd9759d73caeef4.tar.gz
cdo-3faf7b521e5fc2db25794aa7ecd9759d73caeef4.tar.xz
cdo-3faf7b521e5fc2db25794aa7ecd9759d73caeef4.zip
[428897] [Oomph] Add an analysis and repair tool for bundle pools
https://bugs.eclipse.org/bugs/show_bug.cgi?id=428897
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactArchive.gifbin603 -> 0 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactArchiveDamaged.gifbin608 -> 0 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactBinary.gif (renamed from plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFile.gif)bin616 -> 616 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactBinaryDamaged.gif (renamed from plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFileDamaged.gif)bin624 -> 624 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFeature.gifbin0 -> 585 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFeatureDamaged.gifbin0 -> 604 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFolder.gifbin596 -> 0 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFolderDamaged.gifbin613 -> 0 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactPlugin.gifbin0 -> 327 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactPluginDamaged.gifbin0 -> 363 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePool.gifbin594 -> 596 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePoolDamaged.gifbin609 -> 613 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/repository.gifbin0 -> 353 bytes
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AbstractSetupDialog.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AdditionalURIPrompterDialog.java105
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolAnalyzer.java373
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolComposite.java548
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolDialog.java2
18 files changed, 669 insertions, 361 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactArchive.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactArchive.gif
deleted file mode 100644
index c026f01780..0000000000
--- a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactArchive.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactArchiveDamaged.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactArchiveDamaged.gif
deleted file mode 100644
index 020df7010c..0000000000
--- a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactArchiveDamaged.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFile.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactBinary.gif
index 17633ae457..17633ae457 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFile.gif
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactBinary.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFileDamaged.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactBinaryDamaged.gif
index 84609b1d5b..84609b1d5b 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFileDamaged.gif
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactBinaryDamaged.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFeature.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFeature.gif
new file mode 100644
index 0000000000..8706680c79
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFeature.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFeatureDamaged.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFeatureDamaged.gif
new file mode 100644
index 0000000000..bc6400fa4a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFeatureDamaged.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFolder.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFolder.gif
deleted file mode 100644
index e7c4e9a23f..0000000000
--- a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFolder.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFolderDamaged.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFolderDamaged.gif
deleted file mode 100644
index bffe9d811f..0000000000
--- a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactFolderDamaged.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactPlugin.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactPlugin.gif
new file mode 100644
index 0000000000..b4cc50fc45
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactPlugin.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactPluginDamaged.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactPluginDamaged.gif
new file mode 100644
index 0000000000..5a715e7279
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/artifactPluginDamaged.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePool.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePool.gif
index 86e915eb60..e7c4e9a23f 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePool.gif
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePool.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePoolDamaged.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePoolDamaged.gif
index eb664243ba..bffe9d811f 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePoolDamaged.gif
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/bundlePoolDamaged.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/repository.gif b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/repository.gif
new file mode 100644
index 0000000000..962062c376
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/icons/obj16/repository.gif
Binary files differ
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AbstractSetupDialog.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AbstractSetupDialog.java
index 13b9cbfbdf..666692e852 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AbstractSetupDialog.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AbstractSetupDialog.java
@@ -83,7 +83,7 @@ public abstract class AbstractSetupDialog extends TitleAreaDialog
protected AbstractSetupDialog(Shell parentShell, String title, int width, int height)
{
- this(parentShell, title, width, height, Activator.getDefault().getBundle());
+ this(parentShell, title, width, height, Activator.getDefault() == null ? null : Activator.getDefault().getBundle());
}
public String getTitle()
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AdditionalURIPrompterDialog.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AdditionalURIPrompterDialog.java
new file mode 100644
index 0000000000..03d790a938
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/AdditionalURIPrompterDialog.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2004-2014 Eike Stepper (Berlin, Germany) 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.internal.setup.ui;
+
+import org.eclipse.emf.cdo.releng.internal.setup.ui.BundlePoolAnalyzer.Artifact;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public final class AdditionalURIPrompterDialog extends AbstractSetupDialog
+{
+ private List<Artifact> artifacts;
+
+ private Table artifactTable;
+
+ private Table repositoryTable;
+
+ private Composite artifactComposite;
+
+ private Composite repositoryComposite;
+
+ public AdditionalURIPrompterDialog(Shell parentShell, List<Artifact> artifacts)
+ {
+ super(parentShell, "Bundle Pool Management", 400, 500);
+ setShellStyle(SWT.TITLE | SWT.MAX | SWT.RESIZE | SWT.BORDER | SWT.APPLICATION_MODAL);
+ this.artifacts = artifacts;
+ }
+
+ @Override
+ protected String getDefaultMessage()
+ {
+ return "Some artifacts could not be downloaded from the repositories listed in the profiles.\n"
+ + "Select additional repositories and try again.";
+ }
+
+ @Override
+ protected void createUI(Composite parent)
+ {
+ GridLayout gridLayout = (GridLayout)parent.getLayout();
+ gridLayout.marginWidth = 10;
+ gridLayout.marginHeight = 10;
+
+ SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
+ sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+
+ artifactComposite = new Composite(sashForm, SWT.NONE);
+ GridLayout gl_artifactComposite = new GridLayout(1, false);
+ gl_artifactComposite.marginWidth = 0;
+ gl_artifactComposite.marginHeight = 0;
+ artifactComposite.setLayout(gl_artifactComposite);
+
+ Label artifactLabel = new Label(artifactComposite, SWT.NONE);
+ artifactLabel.setBounds(0, 0, 55, 15);
+ artifactLabel.setText("Remaining Artifacts:");
+
+ TableViewer artifactViewer = new TableViewer(artifactComposite, SWT.BORDER | SWT.FULL_SELECTION);
+ artifactTable = artifactViewer.getTable();
+ artifactTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ artifactViewer.setLabelProvider(new BundlePoolComposite.TableLabelProvider(parent.getDisplay()));
+ artifactViewer.setContentProvider(new ArrayContentProvider());
+ artifactViewer.setInput(artifacts);
+
+ repositoryComposite = new Composite(sashForm, SWT.NONE);
+ GridLayout gl_repositoryComposite = new GridLayout(1, false);
+ gl_repositoryComposite.marginWidth = 0;
+ gl_repositoryComposite.marginHeight = 0;
+ repositoryComposite.setLayout(gl_repositoryComposite);
+
+ Label repositoryLabel = new Label(repositoryComposite, SWT.NONE);
+ repositoryLabel.setBounds(0, 0, 55, 15);
+ repositoryLabel.setText("Additional Repositories:");
+
+ CheckboxTableViewer repositoryViewer = CheckboxTableViewer.newCheckList(repositoryComposite, SWT.BORDER
+ | SWT.FULL_SELECTION);
+ repositoryTable = repositoryViewer.getTable();
+ repositoryTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ repositoryViewer.setLabelProvider(new BundlePoolComposite.TableLabelProvider(parent.getDisplay()));
+ repositoryViewer.setContentProvider(new ArrayContentProvider());
+ repositoryViewer.setInput(artifacts.get(0).getBundlePool().getRepositoryURIs());
+
+ sashForm.setWeights(new int[] { 1, 2 });
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolAnalyzer.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolAnalyzer.java
index a43ca618ed..4ba02f0de6 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolAnalyzer.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolAnalyzer.java
@@ -19,6 +19,7 @@ import org.eclipse.net4j.util.om.monitor.SubMonitor;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
@@ -37,7 +38,7 @@ import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -48,6 +49,7 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.zip.ZipEntry;
@@ -59,7 +61,7 @@ import java.util.zip.ZipInputStream;
*/
public final class BundlePoolAnalyzer
{
- private final Listener listener;
+ private final Handler handler;
private final Map<File, BundlePool> bundlePools = new HashMap<File, BundlePool>();
@@ -67,9 +69,9 @@ public final class BundlePoolAnalyzer
private Set<URI> repositoryURIs;
- public BundlePoolAnalyzer(Listener listener)
+ public BundlePoolAnalyzer(Handler handler)
{
- this.listener = listener;
+ this.handler = handler;
IProfileRegistry profileRegistry = P2.getProfileRegistry();
for (IProfile p2Profile : profileRegistry.getProfiles())
@@ -91,7 +93,7 @@ public final class BundlePoolAnalyzer
}
}
- listener.analyzerChanged(this);
+ handler.analyzerChanged(this);
for (BundlePool bundlePool : bundlePools.values())
{
@@ -151,7 +153,7 @@ public final class BundlePoolAnalyzer
/**
* @author Eike Stepper
*/
- public interface Listener
+ public interface Handler
{
public void analyzerChanged(BundlePoolAnalyzer analyzer);
@@ -179,9 +181,15 @@ public final class BundlePoolAnalyzer
private final Set<Artifact> unusedArtifacts = new HashSet<Artifact>();
- private final Set<Artifact> damagedArchives = new HashSet<Artifact>();
+ private final Set<Artifact> damagedArtifacts = new HashSet<Artifact>();
- private int damagedArchivesPercent;
+ private int damagedArtifactsPercent;
+
+ private Artifact[] artifactsArray;
+
+ private Artifact[] unusedArtifactsArray;
+
+ private Artifact[] damagedArtifactsArray;
public BundlePool(BundlePoolAnalyzer agent, File location)
{
@@ -189,19 +197,6 @@ public final class BundlePoolAnalyzer
this.location = location;
}
- public IFileArtifactRepository getP2BundlePool(IProgressMonitor monitor)
- {
- try
- {
- IArtifactRepositoryManager repositoryManager = P2.getArtifactRepositoryManager();
- return (IFileArtifactRepository)repositoryManager.loadRepository(location.toURI(), monitor);
- }
- catch (ProvisionException ex)
- {
- throw new IllegalStateException(ex);
- }
- }
-
public BundlePoolAnalyzer getAnalyzer()
{
return analyzer;
@@ -245,9 +240,13 @@ public final class BundlePoolAnalyzer
{
synchronized (this)
{
- Artifact[] array = artifacts.values().toArray(new Artifact[artifacts.size()]);
- Arrays.sort(array);
- return array;
+ if (artifactsArray == null)
+ {
+ artifactsArray = artifacts.values().toArray(new Artifact[artifacts.size()]);
+ Arrays.sort(artifactsArray);
+ }
+
+ return artifactsArray;
}
}
@@ -269,39 +268,43 @@ public final class BundlePoolAnalyzer
public Artifact[] getUnusedArtifacts()
{
- Artifact[] array;
synchronized (this)
{
- array = unusedArtifacts.toArray(new Artifact[unusedArtifacts.size()]);
- }
+ if (unusedArtifactsArray == null)
+ {
+ unusedArtifactsArray = unusedArtifacts.toArray(new Artifact[unusedArtifacts.size()]);
+ Arrays.sort(unusedArtifactsArray);
+ }
- Arrays.sort(array);
- return array;
+ return unusedArtifactsArray;
+ }
}
- public int getDamagedArchivesPercent()
+ public int getDamagedArtifactsPercent()
{
- return damagedArchivesPercent;
+ return damagedArtifactsPercent;
}
- public int getDamagedArchivesCount()
+ public int getDamagedArtifactsCount()
{
- synchronized (damagedArchives)
+ synchronized (damagedArtifacts)
{
- return damagedArchives.size();
+ return damagedArtifacts.size();
}
}
- public Artifact[] getDamagedArchives()
+ public Artifact[] getDamagedArtifacts()
{
- Artifact[] array;
synchronized (this)
{
- array = damagedArchives.toArray(new Artifact[damagedArchives.size()]);
- }
+ if (damagedArtifactsArray == null)
+ {
+ damagedArtifactsArray = damagedArtifacts.toArray(new Artifact[damagedArtifacts.size()]);
+ Arrays.sort(damagedArtifactsArray);
+ }
- Arrays.sort(array);
- return array;
+ return damagedArtifactsArray;
+ }
}
public int compareTo(BundlePool o)
@@ -315,6 +318,19 @@ public final class BundlePoolAnalyzer
return location.toString();
}
+ IFileArtifactRepository getP2BundlePool(IProgressMonitor monitor)
+ {
+ try
+ {
+ IArtifactRepositoryManager repositoryManager = P2.getArtifactRepositoryManager();
+ return (IFileArtifactRepository)repositoryManager.loadRepository(location.toURI(), monitor);
+ }
+ catch (ProvisionException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ }
+
Profile addProfile(IProfile p2Profile, String installFolder)
{
Profile profile = new Profile(this, p2Profile, installFolder == null ? null : new File(installFolder));
@@ -347,21 +363,30 @@ public final class BundlePoolAnalyzer
private void analyze(IProgressMonitor monitor)
{
+ Random random = new Random(System.currentTimeMillis());
+
IFileArtifactRepository p2BundlePool = getP2BundlePool(monitor);
for (IArtifactKey key : p2BundlePool.query(ArtifactKeyQuery.ALL_KEYS, monitor))
{
checkCancelation(monitor);
File file = p2BundlePool.getArtifactFile(key);
+
Artifact artifact = new Artifact(this, key, file);
synchronized (this)
{
artifacts.put(key, artifact);
+ artifactsArray = null;
+ }
+
+ if (random.nextInt(100) < 2)
+ {
+ analyzer.handler.bundlePoolChanged(this, false, false);
}
}
- analyzer.listener.bundlePoolChanged(this, true, false);
+ analyzer.handler.bundlePoolChanged(this, true, false);
for (Profile profile : getProfiles())
{
@@ -369,8 +394,10 @@ public final class BundlePoolAnalyzer
profile.analyze(monitor);
}
+ analyzer.handler.analyzerChanged(analyzer);
+
analyzeUnusedArtifacts(monitor);
- analyzeDamagedArchives(monitor);
+ analyzeDamagedArtifacts(monitor);
}
private void analyzeUnusedArtifacts(IProgressMonitor monitor)
@@ -383,13 +410,14 @@ public final class BundlePoolAnalyzer
synchronized (this)
{
unusedArtifacts.add(artifact);
+ unusedArtifactsArray = null;
}
- analyzer.listener.bundlePoolChanged(this, false, false);
+ analyzer.handler.bundlePoolChanged(this, false, false);
}
}
- analyzer.listener.bundlePoolChanged(this, true, false);
+ analyzer.handler.bundlePoolChanged(this, true, false);
}
private boolean analyzeUnusedArtifact(Artifact artifact, IProgressMonitor monitor)
@@ -406,7 +434,7 @@ public final class BundlePoolAnalyzer
return true;
}
- private void analyzeDamagedArchives(IProgressMonitor monitor)
+ private void analyzeDamagedArtifacts(IProgressMonitor monitor)
{
Artifact[] artifacts = getArtifacts();
int total = artifacts.length;
@@ -417,10 +445,10 @@ public final class BundlePoolAnalyzer
checkCancelation(monitor);
int percent = ++i * 100 / total;
- if (percent != damagedArchivesPercent)
+ if (percent != damagedArtifactsPercent)
{
- damagedArchivesPercent = percent;
- analyzer.listener.bundlePoolChanged(this, false, false);
+ damagedArtifactsPercent = percent;
+ analyzer.handler.bundlePoolChanged(this, false, false);
}
synchronized (artifact)
@@ -441,18 +469,19 @@ public final class BundlePoolAnalyzer
{
synchronized (this)
{
- damagedArchives.add(artifact);
+ damagedArtifacts.add(artifact);
+ damagedArtifactsArray = null;
}
- analyzer.listener.bundlePoolChanged(this, false, false);
+ analyzer.handler.bundlePoolChanged(this, false, false);
artifact.setDamaged();
- analyzer.listener.artifactChanged(artifact);
+ analyzer.handler.artifactChanged(artifact);
}
}
}
- analyzer.listener.bundlePoolChanged(this, false, false);
+ analyzer.handler.bundlePoolChanged(this, false, false);
}
private static boolean isDamaged(File file, String type)
@@ -462,7 +491,7 @@ public final class BundlePoolAnalyzer
return true;
}
- if (Artifact.ARCHIVE.equals(type))
+ if (Artifact.TYPE_PLUGIN.equals(type))
{
ZipInputStream in = null;
ZipFile zip = null;
@@ -534,7 +563,9 @@ public final class BundlePoolAnalyzer
private final Set<Artifact> artifacts = new HashSet<Artifact>();
- private final Set<Artifact> damagedArchives = new HashSet<Artifact>();
+ private final Set<Artifact> damagedArtifacts = new HashSet<Artifact>();
+
+ private Artifact[] damagedArtifactsArray;
public Profile(BundlePool bundlePool, IProfile p2Profile, File installFolder)
{
@@ -609,23 +640,29 @@ public final class BundlePoolAnalyzer
{
synchronized (bundlePool)
{
- return !damagedArchives.isEmpty();
+ return !damagedArtifacts.isEmpty();
}
}
- public int getDamagedArchivesCount()
+ public int getDamagedArtifactsCount()
{
synchronized (bundlePool)
{
- return damagedArchives.size();
+ return damagedArtifacts.size();
}
}
- public Artifact[] getDamagedArchives()
+ public Artifact[] getDamagedArtifacts()
{
synchronized (bundlePool)
{
- return damagedArchives.toArray(new Artifact[damagedArchives.size()]);
+ if (damagedArtifactsArray == null)
+ {
+ damagedArtifactsArray = damagedArtifacts.toArray(new Artifact[damagedArtifacts.size()]);
+ Arrays.sort(damagedArtifactsArray);
+ }
+
+ return damagedArtifactsArray;
}
}
@@ -655,7 +692,7 @@ public final class BundlePoolAnalyzer
artifact.addProfile(this);
}
- bundlePool.analyzer.listener.profileChanged(this);
+ bundlePool.analyzer.handler.profileChanged(this);
}
}
}
@@ -667,19 +704,21 @@ public final class BundlePoolAnalyzer
*/
public static final class Artifact implements Comparable<Artifact>
{
- public static final String FOLDER = "Folder";
+ public static final String REPAIR_TASK_NAME = "Repairing artifacts";
- public static final String ARCHIVE = "Archive";
+ public static final String TYPE_FEATURE = "Feature";
- public static final String FILE = "File";
+ public static final String TYPE_PLUGIN = "Plugin";
+
+ public static final String TYPE_BINARY = "Binary";
private final BundlePool bundlePool;
private final IArtifactKey key;
- private final File file;
+ private final String type;
- private final String relativePath;
+ private final File file;
private final List<Profile> profiles = new ArrayList<Profile>();
@@ -691,8 +730,19 @@ public final class BundlePoolAnalyzer
this.key = key;
this.file = file;
- int start = bundlePool.location.getAbsolutePath().length();
- relativePath = file.getAbsolutePath().substring(start + 1);
+ String classifier = key.getClassifier();
+ if ("org.eclipse.update.feature".equals(classifier))
+ {
+ type = TYPE_FEATURE;
+ }
+ else if ("osgi.bundle".equals(classifier))
+ {
+ type = TYPE_PLUGIN;
+ }
+ else
+ {
+ type = TYPE_BINARY;
+ }
}
public boolean isUnused()
@@ -715,35 +765,24 @@ public final class BundlePoolAnalyzer
return key;
}
- public File getFile()
+ public String getType()
{
- return file;
+ return type;
}
- public boolean isFolder()
+ public String getID()
{
- return file.isDirectory();
+ return key.getId();
}
- public String getType()
+ public String getVersion()
{
- if (isFolder())
- {
- return FOLDER;
- }
-
- String path = file.getPath();
- if (path.endsWith(".jar") || path.endsWith(".zip"))
- {
- return ARCHIVE;
- }
-
- return FILE;
+ return key.getVersion().toString();
}
- public String getRelativePath()
+ public File getFile()
{
- return relativePath;
+ return file;
}
public List<Profile> getProfiles()
@@ -753,7 +792,17 @@ public final class BundlePoolAnalyzer
public int compareTo(Artifact o)
{
- return relativePath.compareTo(o.relativePath);
+ int result = type.compareTo(o.type);
+ if (result == 0)
+ {
+ result = key.getId().compareTo(o.key.getId());
+ if (result == 0)
+ {
+ result = key.getVersion().compareTo(o.key.getVersion());
+ }
+ }
+
+ return result;
}
@Override
@@ -802,7 +851,7 @@ public final class BundlePoolAnalyzer
@Override
public String toString()
{
- return key.toString();
+ return key.getId() + " " + key.getVersion();
}
void addProfile(Profile profile)
@@ -817,55 +866,71 @@ public final class BundlePoolAnalyzer
{
synchronized (bundlePool)
{
- profile.damagedArchives.add(this);
+ profile.damagedArtifacts.add(this);
+ profile.damagedArtifactsArray = null;
}
- bundlePool.analyzer.listener.profileChanged(profile);
+ bundlePool.analyzer.handler.profileChanged(profile);
}
}
public synchronized void delete(IProgressMonitor monitor)
{
- IFileArtifactRepository p2BundlePool = bundlePool.getP2BundlePool(monitor);
- p2BundlePool.removeDescriptor(key, monitor);
-
if (isUnused())
{
- damaged = false;
-
- synchronized (bundlePool)
- {
- bundlePool.unusedArtifacts.remove(this);
- bundlePool.artifacts.remove(key);
- bundlePool.damagedArchives.remove(this);
- }
-
- bundlePool.analyzer.listener.bundlePoolChanged(bundlePool, true, false);
+ deleteUnused(monitor);
}
else
{
+ monitor.subTask("Deleting " + this);
+ IOUtil.delete(file);
damaged = true;
+
synchronized (bundlePool)
{
- bundlePool.damagedArchives.add(this);
+ bundlePool.damagedArtifacts.add(this);
+ bundlePool.damagedArtifactsArray = null;
}
- bundlePool.analyzer.listener.bundlePoolChanged(bundlePool, false, false);
- bundlePool.analyzer.listener.artifactChanged(this);
+ bundlePool.analyzer.handler.bundlePoolChanged(bundlePool, false, false);
+ bundlePool.analyzer.handler.artifactChanged(this);
for (Profile profile : profiles)
{
synchronized (bundlePool)
{
- profile.damagedArchives.add(this);
+ profile.damagedArtifacts.add(this);
+ profile.damagedArtifactsArray = null;
}
- bundlePool.analyzer.listener.profileChanged(profile);
+ bundlePool.analyzer.handler.profileChanged(profile);
}
}
}
- public synchronized boolean repair(IProgressMonitor monitor)
+ private void deleteUnused(IProgressMonitor monitor)
+ {
+ monitor.subTask("Deleting " + this);
+ IFileArtifactRepository p2BundlePool = bundlePool.getP2BundlePool(monitor);
+ p2BundlePool.removeDescriptor(key, monitor);
+ damaged = false;
+
+ synchronized (bundlePool)
+ {
+ bundlePool.artifacts.remove(key);
+ bundlePool.artifactsArray = null;
+
+ bundlePool.unusedArtifacts.remove(this);
+ bundlePool.unusedArtifactsArray = null;
+
+ bundlePool.damagedArtifacts.remove(this);
+ bundlePool.damagedArtifactsArray = null;
+ }
+
+ bundlePool.analyzer.handler.bundlePoolChanged(bundlePool, true, false);
+ }
+
+ public synchronized boolean repair(Set<URI> repositoryURIs, IProgressMonitor monitor)
{
if (!damaged)
{
@@ -874,31 +939,34 @@ public final class BundlePoolAnalyzer
if (isUnused())
{
- delete(monitor);
+ deleteUnused(monitor);
return true;
}
- if (doRepair(monitor))
+ monitor.subTask("Repairing " + this);
+ if (repositoryURIs == null ? doRepair(monitor) : doRepair(repositoryURIs, monitor))
{
damaged = false;
- bundlePool.analyzer.listener.artifactChanged(this);
+ bundlePool.analyzer.handler.artifactChanged(this);
synchronized (bundlePool)
{
- bundlePool.damagedArchives.remove(this);
+ bundlePool.damagedArtifacts.remove(this);
+ bundlePool.damagedArtifactsArray = null;
}
for (Profile profile : profiles)
{
synchronized (bundlePool)
{
- profile.damagedArchives.remove(this);
+ profile.damagedArtifacts.remove(this);
+ profile.damagedArtifactsArray = null;
}
- bundlePool.analyzer.listener.profileChanged(profile);
+ bundlePool.analyzer.handler.profileChanged(profile);
}
- bundlePool.analyzer.listener.bundlePoolChanged(bundlePool, false, false);
+ bundlePool.analyzer.handler.bundlePoolChanged(bundlePool, false, false);
return true;
}
@@ -908,27 +976,53 @@ public final class BundlePoolAnalyzer
private boolean doRepair(IProgressMonitor monitor)
{
Set<URI> repositoryURIs = bundlePool.getRepositoryURIs();
- SubMonitor progress = SubMonitor.convert(monitor, 2 * repositoryURIs.size()).detectCancelation();
- if (doRepair(repositoryURIs, progress))
+ SubMonitor progress = SubMonitor.convert(monitor, repositoryURIs.size()).detectCancelation();
+
+ Set<URI> poolURIs = new HashSet<URI>();
+ for (BundlePool pool : bundlePool.analyzer.getBundlePools().values())
+ {
+ if (pool != bundlePool)
+ {
+ URI uri = pool.getLocation().toURI();
+ poolURIs.add(uri);
+ }
+ }
+
+ if (doRepair(poolURIs, progress))
{
return true;
}
- Set<URI> allURIs = new LinkedHashSet<URI>(bundlePool.analyzer.getRepositoryURIs());
- allURIs.removeAll(repositoryURIs);
- if (doRepair(allURIs, progress))
+ if (doRepair(repositoryURIs, progress))
{
return true;
}
+ // Set<URI> allURIs = new LinkedHashSet<URI>(bundlePool.analyzer.getRepositoryURIs());
+ // allURIs.removeAll(repositoryURIs);
+ // allURIs.removeAll(poolURIs);
+ //
+ // if (!allURIs.isEmpty())
+ // {
+ // allURIs = prompter.getAdditionalURIs(allURIs);
+ // if (!allURIs.isEmpty())
+ // {
+ // if (doRepair(allURIs, progress))
+ // {
+ // return true;
+ // }
+ // }
+ // }
+
return false;
}
- private boolean doRepair(Set<URI> repositoryURIs, SubMonitor progress)
+ private boolean doRepair(Set<URI> repositoryURIs, IProgressMonitor monitor)
{
+ SubMonitor progress = SubMonitor.convert(monitor, repositoryURIs.size()).detectCancelation();
for (URI uri : repositoryURIs)
{
- if (doRepair(uri, progress))
+ if (doRepair(uri, progress.newChild()))
{
return true;
}
@@ -939,48 +1033,63 @@ public final class BundlePoolAnalyzer
private boolean doRepair(URI repositoryURI, SubMonitor progress)
{
+ IFileArtifactRepository p2BundlePool = bundlePool.getP2BundlePool(progress.newChild());
+ IArtifactDescriptor[] oldDescriptors = null;
+
try
{
+ oldDescriptors = p2BundlePool.getArtifactDescriptors(key);
+ p2BundlePool.removeDescriptors(oldDescriptors, progress.newChild());
+
IArtifactRepositoryManager repositoryManager = P2.getArtifactRepositoryManager();
IArtifactRepository repository = repositoryManager.loadRepository(repositoryURI, progress.newChild());
+ progress.setTaskName(REPAIR_TASK_NAME);
for (IArtifactDescriptor descriptor : repository.getArtifactDescriptors(key))
{
- File tmp = new File(file.getAbsolutePath() + ".tmp");
- FileOutputStream destination = null;
+ OutputStream destination = null;
try
{
- destination = new FileOutputStream(tmp);
+ destination = p2BundlePool.getOutputStream(descriptor);
IStatus status = repository.getArtifact(descriptor, destination, progress.newChild());
if (status.getSeverity() == IStatus.OK)
{
- IOUtil.close(destination);
- IOUtil.copyFile(tmp, file);
return true;
}
}
finally
{
IOUtil.close(destination);
- if (!tmp.delete())
- {
- tmp.deleteOnExit();
- }
}
}
}
catch (OperationCanceledException ex)
{
+ restoreDescriptors(p2BundlePool, oldDescriptors);
throw ex;
}
+ catch (Error err)
+ {
+ restoreDescriptors(p2BundlePool, oldDescriptors);
+ throw err;
+ }
catch (Exception ex)
{
+ restoreDescriptors(p2BundlePool, oldDescriptors);
Activator.log(ex);
}
return false;
}
+
+ private void restoreDescriptors(IFileArtifactRepository p2BundlePool, IArtifactDescriptor[] oldDescriptors)
+ {
+ if (oldDescriptors != null && oldDescriptors.length != 0)
+ {
+ p2BundlePool.addDescriptors(oldDescriptors, new NullProgressMonitor());
+ }
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolComposite.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolComposite.java
index 348932d11a..876bb3035e 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolComposite.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolComposite.java
@@ -12,16 +12,18 @@ package org.eclipse.emf.cdo.releng.internal.setup.ui;
import org.eclipse.emf.cdo.releng.internal.setup.ui.BundlePoolAnalyzer.Artifact;
import org.eclipse.emf.cdo.releng.internal.setup.ui.BundlePoolAnalyzer.BundlePool;
-import org.eclipse.emf.cdo.releng.internal.setup.ui.BundlePoolAnalyzer.Listener;
+import org.eclipse.emf.cdo.releng.internal.setup.ui.BundlePoolAnalyzer.Handler;
import org.eclipse.emf.cdo.releng.internal.setup.ui.BundlePoolAnalyzer.Profile;
import org.eclipse.emf.cdo.releng.setup.util.UIUtil;
+import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.om.monitor.SubMonitor;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.ILazyContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@@ -38,6 +40,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyAdapter;
@@ -50,6 +53,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
@@ -58,12 +62,14 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -71,23 +77,25 @@ import java.util.Set;
*/
public class BundlePoolComposite extends Composite
{
- private static final int TABLE_STYLE = SWT.BORDER | SWT.FULL_SELECTION | SWT.NO_SCROLL | SWT.V_SCROLL;
+ private static final int TABLE_STYLE = SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.NO_SCROLL | SWT.V_SCROLL;
private final Set<ISelectionProvider> changingSelection = new HashSet<ISelectionProvider>();
private TableViewer bundlePoolViewer;
+ private BundlePoolContentProvider bundlePoolContentProvider;
+
private TableViewer artifactViewer;
- private TableViewer profileViewer;
+ private ArtifactContentProvider artifactContentProvider;
- private Button selectAllArtifactsButton;
+ private TableViewer profileViewer;
- private Button selectUnusedArtifactsButton;
+ private ProfileContentProvider profileContentProvider;
- private Button selectDamagedArchivesButton;
+ private Button selectAllArtifactsButton;
- private Button repairArchivesButton;
+ private Button repairArtifactsButton;
private Button deleteArtifactsButton;
@@ -113,7 +121,7 @@ public class BundlePoolComposite extends Composite
createArtifactViewer(verticalSashForm);
createProfileViewer(verticalSashForm);
- verticalSashForm.setWeights(new int[] { 2, 1 });
+ verticalSashForm.setWeights(new int[] { 3, 1 });
addDisposeListener(new DisposeListener()
{
@@ -136,22 +144,11 @@ public class BundlePoolComposite extends Composite
public void run()
{
initAgent();
+
shell.setCursor(oldCursor);
setEnabled(true);
- bundlePoolViewer.setInput(analyzer);
-
- getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- Collection<BundlePool> bundlePools = analyzer.getBundlePools().values();
- if (!bundlePools.isEmpty())
- {
- bundlePoolViewer.setSelection(new StructuredSelection(bundlePools.iterator().next()));
- }
- }
- });
+ bundlePoolContentProvider.setInput(bundlePoolViewer, analyzer);
}
});
}
@@ -187,18 +184,19 @@ public class BundlePoolComposite extends Composite
unusedArtifactsColumn.setAlignment(SWT.RIGHT);
unusedArtifactsColumn.setWidth(105);
- TableColumn damagedArchivesColumn = new TableViewerColumn(bundlePoolViewer, SWT.NONE).getColumn();
- damagedArchivesColumn.setText("Damaged Archives");
- damagedArchivesColumn.setAlignment(SWT.RIGHT);
- damagedArchivesColumn.setWidth(118);
+ TableColumn damagedArtifactsColumn = new TableViewerColumn(bundlePoolViewer, SWT.NONE).getColumn();
+ damagedArtifactsColumn.setText("Damaged Artifacts");
+ damagedArtifactsColumn.setAlignment(SWT.RIGHT);
+ damagedArtifactsColumn.setWidth(125);
TableColumn profilesColumn = new TableViewerColumn(bundlePoolViewer, SWT.NONE).getColumn();
profilesColumn.setText("Profiles");
profilesColumn.setAlignment(SWT.RIGHT);
profilesColumn.setWidth(55);
+ bundlePoolContentProvider = new BundlePoolContentProvider();
+ bundlePoolViewer.setContentProvider(bundlePoolContentProvider);
bundlePoolViewer.setLabelProvider(new TableLabelProvider(getDisplay()));
- bundlePoolViewer.setContentProvider(new BundlePoolContentProvider());
bundlePoolViewer.addSelectionChangedListener(new SelectionChangedListener()
{
@Override
@@ -206,11 +204,11 @@ public class BundlePoolComposite extends Composite
{
currentBundlePool = (BundlePool)((IStructuredSelection)event.getSelection()).getFirstElement();
- artifactViewer.setInput(currentBundlePool);
+ artifactContentProvider.setInput(artifactViewer, currentBundlePool);
artifactViewer.setSelection(StructuredSelection.EMPTY);
updateArtifactButtons();
- profileViewer.setInput(currentBundlePool);
+ profileContentProvider.setInput(profileViewer, currentBundlePool);
profileViewer.setSelection(StructuredSelection.EMPTY);
// bundlePoolMoveButton.setEnabled(true);
@@ -270,15 +268,20 @@ public class BundlePoolComposite extends Composite
TableColumn artifactColumn = new TableViewerColumn(artifactViewer, SWT.NONE).getColumn();
artifactColumn.setText("Artifact");
- artifactColumn.setWidth(569);
+ artifactColumn.setWidth(365);
artifactColumn.setResizable(false);
+ TableColumn versionVersion = new TableViewerColumn(artifactViewer, SWT.NONE).getColumn();
+ versionVersion.setText("Version");
+ versionVersion.setWidth(205);
+
TableColumn profilesColumn = new TableViewerColumn(artifactViewer, SWT.NONE).getColumn();
profilesColumn.setText("Profiles");
profilesColumn.setAlignment(SWT.RIGHT);
profilesColumn.setWidth(56);
- artifactViewer.setContentProvider(new ArtifactContentProvider());
+ artifactContentProvider = new ArtifactContentProvider();
+ artifactViewer.setContentProvider(artifactContentProvider);
artifactViewer.setLabelProvider(new TableLabelProvider(getDisplay()));
artifactViewer.addSelectionChangedListener(new SelectionChangedListener()
{
@@ -305,64 +308,66 @@ public class BundlePoolComposite extends Composite
});
Composite artifactButtonBar = new Composite(artifactComposite, SWT.NONE);
- artifactButtonBar.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, false));
+ artifactButtonBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
GridLayout artifactButtonBarLayout = new GridLayout(5, false);
artifactButtonBarLayout.marginWidth = 0;
artifactButtonBarLayout.marginHeight = 0;
artifactButtonBar.setLayout(artifactButtonBarLayout);
- selectAllArtifactsButton = new Button(artifactButtonBar, SWT.NONE);
- selectAllArtifactsButton.setText("Select All");
- selectAllArtifactsButton.setEnabled(false);
- selectAllArtifactsButton.addSelectionListener(new SelectionAdapter()
+ final Combo filterCombo = new Combo(artifactButtonBar, SWT.READ_ONLY);
+ filterCombo.add(ArtifactContentProvider.SHOW_ALL);
+ filterCombo.add(ArtifactContentProvider.SHOW_UNUSED);
+ filterCombo.add(ArtifactContentProvider.SHOW_DAMAGED);
+ filterCombo.select(0);
+ filterCombo.pack();
+ filterCombo.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
- artifactViewer.setSelection(new StructuredSelection(currentBundlePool.getArtifacts()));
+ String selection = filterCombo.getText();
+ artifactContentProvider.setFilter(selection);
+ // artifactViewer.setItemCount(artifactContentProvider.getElements(currentBundlePool).length);
+ // artifactViewer.refresh();
+ updateArtifactButtons();
}
});
- selectUnusedArtifactsButton = new Button(artifactButtonBar, SWT.NONE);
- selectUnusedArtifactsButton.setText("Select Unused");
- selectUnusedArtifactsButton.setEnabled(false);
- selectUnusedArtifactsButton.addSelectionListener(new SelectionAdapter()
+ selectAllArtifactsButton = new Button(artifactButtonBar, SWT.NONE);
+ selectAllArtifactsButton.setText("Select All");
+ selectAllArtifactsButton.setEnabled(false);
+ selectAllArtifactsButton.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
- artifactViewer.setSelection(new StructuredSelection(currentBundlePool.getUnusedArtifacts()));
+ artifactViewer.setSelection(new StructuredSelection(currentBundlePool.getArtifacts()));
}
});
- selectDamagedArchivesButton = new Button(artifactButtonBar, SWT.NONE);
- selectDamagedArchivesButton.setText("Select Damaged");
- selectDamagedArchivesButton.setEnabled(false);
- selectDamagedArchivesButton.addSelectionListener(new SelectionAdapter()
- {
- @Override
- public void widgetSelected(SelectionEvent e)
- {
- artifactViewer.setSelection(new StructuredSelection(currentBundlePool.getDamagedArchives()));
- }
- });
+ new Label(artifactButtonBar, SWT.NONE).setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- repairArchivesButton = new Button(artifactButtonBar, SWT.NONE);
- repairArchivesButton.setText("Repair");
- repairArchivesButton.setEnabled(false);
- repairArchivesButton.addSelectionListener(new SelectionAdapter()
+ repairArtifactsButton = new Button(artifactButtonBar, SWT.NONE);
+ repairArtifactsButton.setText("Repair");
+ repairArtifactsButton.setEnabled(false);
+ repairArtifactsButton.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
Artifact[] artifacts = getSelectedArtifacts();
- repairArchives(artifacts);
+ repairArtifacts(artifacts);
}
});
deleteArtifactsButton = new Button(artifactButtonBar, SWT.NONE);
deleteArtifactsButton.setText("Delete");
deleteArtifactsButton.setEnabled(false);
+ new Label(artifactButtonBar, SWT.NONE);
+ new Label(artifactButtonBar, SWT.NONE);
+ new Label(artifactButtonBar, SWT.NONE);
+ new Label(artifactButtonBar, SWT.NONE);
+ new Label(artifactButtonBar, SWT.NONE);
deleteArtifactsButton.addSelectionListener(new SelectionAdapter()
{
@Override
@@ -400,12 +405,13 @@ public class BundlePoolComposite extends Composite
artifactsColumn.setAlignment(SWT.RIGHT);
artifactsColumn.setWidth(62);
- TableColumn damagedArchivesColumn = new TableViewerColumn(profileViewer, SWT.NONE).getColumn();
- damagedArchivesColumn.setText("Damaged Archives");
- damagedArchivesColumn.setAlignment(SWT.RIGHT);
- damagedArchivesColumn.setWidth(117);
+ TableColumn damagedArtifactsColumn = new TableViewerColumn(profileViewer, SWT.NONE).getColumn();
+ damagedArtifactsColumn.setText("Damaged Artifacts");
+ damagedArtifactsColumn.setAlignment(SWT.RIGHT);
+ damagedArtifactsColumn.setWidth(125);
- profileViewer.setContentProvider(new ProfileContentProvider());
+ profileContentProvider = new ProfileContentProvider();
+ profileViewer.setContentProvider(profileContentProvider);
profileViewer.setLabelProvider(new TableLabelProvider(getDisplay()));
profileViewer.addSelectionChangedListener(new SelectionChangedListener()
{
@@ -461,9 +467,9 @@ public class BundlePoolComposite extends Composite
private void initAgent()
{
- analyzer = new BundlePoolAnalyzer(new Listener()
+ analyzer = new BundlePoolAnalyzer(new Handler()
{
- public void analyzerChanged(BundlePoolAnalyzer analyzer)
+ public void analyzerChanged(final BundlePoolAnalyzer analyzer)
{
if (analyzer == BundlePoolComposite.this.analyzer)
{
@@ -474,6 +480,18 @@ public class BundlePoolComposite extends Composite
bundlePoolViewer.refresh();
artifactViewer.refresh();
profileViewer.refresh();
+
+ getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ Object[] elements = bundlePoolContentProvider.getElements(analyzer);
+ if (elements.length != 0)
+ {
+ bundlePoolViewer.setSelection(new StructuredSelection(elements[0]));
+ }
+ }
+ });
}
});
}
@@ -492,13 +510,14 @@ public class BundlePoolComposite extends Composite
if (artifacts)
{
artifactViewer.refresh();
-
+ artifactViewer.setItemCount(artifactContentProvider.getElements(bundlePool).length);
updateArtifactButtons();
}
if (profiles)
{
profileViewer.refresh();
+ profileViewer.setItemCount(profileContentProvider.getElements(bundlePool).length);
}
}
}
@@ -562,51 +581,47 @@ public class BundlePoolComposite extends Composite
return profiles.toArray(new Profile[profiles.size()]);
}
- private void updateButton(Button button, String text, int count, boolean prompt)
+ private boolean updateButton(Button button, String text, int count, String suffix)
{
+ button.setEnabled(count != 0);
if (count != 0)
{
text += " " + count;
}
- text += " Selected";
- if (prompt)
- {
- text += "...";
- }
+ text += suffix;
if (!button.getText().equals(text))
{
button.setText(text);
- button.getParent().getParent().layout(true);
+ return true;
}
- button.setEnabled(count != 0);
+ return false;
}
private void updateArtifactButtons()
{
+ boolean changed = false;
+
if (currentBundlePool != null)
{
- selectAllArtifactsButton.setEnabled(currentBundlePool.getArtifactCount() != 0);
- selectUnusedArtifactsButton.setEnabled(currentBundlePool.getUnusedArtifactsCount() != 0);
- selectDamagedArchivesButton.setEnabled(currentBundlePool.getDamagedArchivesCount() != 0);
+ Object[] elements = artifactContentProvider.getElements(currentBundlePool);
+ changed |= updateButton(selectAllArtifactsButton, "Select All", elements.length, "");
}
Artifact[] artifacts = getSelectedArtifacts();
int count = artifacts.length;
- updateButton(deleteArtifactsButton, "Delete", count, true);
- for (int i = 0; i < artifacts.length; i++)
+ changed |= updateButton(deleteArtifactsButton, "Delete", count, " Selected");
+ changed |= updateButton(repairArtifactsButton, "Repair", count, " Selected");
+
+ if (changed)
{
- Artifact artifact = artifacts[i];
- if (!artifact.isDamaged())
- {
- --count;
- }
+ Composite parent = repairArtifactsButton.getParent();
+ parent.pack();
+ parent.getParent().layout();
}
-
- updateButton(repairArchivesButton, "Repair", count, true);
}
// private void updateProfileButtons(BundlePool bundlePool)
@@ -643,6 +658,8 @@ public class BundlePoolComposite extends Composite
}
}
});
+
+ artifactViewer.refresh();
}
catch (InvocationTargetException ex)
{
@@ -654,22 +671,33 @@ public class BundlePoolComposite extends Composite
}
}
- private void repairArchives(final Artifact[] artifacts)
+ private void repairArtifacts(final Artifact[] artifacts)
{
try
{
+ final List<Artifact> remaining = new ArrayList<Artifact>();
+
UIUtil.runInProgressDialog(getShell(), new IRunnableWithProgress()
{
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
- SubMonitor progress = SubMonitor.convert(monitor, "Repairing archives", artifacts.length).detectCancelation();
+ SubMonitor progress = SubMonitor.convert(monitor, Artifact.REPAIR_TASK_NAME, artifacts.length)
+ .detectCancelation();
for (Artifact artifact : artifacts)
{
- artifact.repair(progress.newChild());
+ if (!artifact.repair(null, progress.newChild()))
+ {
+ remaining.add(artifact);
+ }
}
}
});
+
+ if (!remaining.isEmpty())
+ {
+ new AdditionalURIPrompterDialog(getShell(), remaining);
+ }
}
catch (InvocationTargetException ex)
{
@@ -748,137 +776,7 @@ public class BundlePoolComposite extends Composite
/**
* @author Eike Stepper
*/
- protected static abstract class ColumnResizer extends ControlAdapter implements IStructuredContentProvider
- {
- private Table table;
-
- private int lastWidth = -1;
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- if (table == null)
- {
- table = ((TableViewer)viewer).getTable();
- table.addControlListener(this);
- }
-
- apply();
- }
-
- @Override
- public void controlResized(ControlEvent e)
- {
- int tableWidth = table.getSize().x;
- if (tableWidth != lastWidth)
- {
- lastWidth = tableWidth;
-
- ScrollBar bar = table.getVerticalBar();
- if (bar != null && bar.isVisible())
- {
- tableWidth -= bar.getSize().x;
- }
-
- final TableColumn[] columns = table.getColumns();
- for (int i = 1; i < columns.length; i++)
- {
- tableWidth -= columns[i].getWidth();
- }
-
- columns[0].setWidth(tableWidth);
- }
- }
-
- public void apply()
- {
- UIUtil.asyncExec(table.getDisplay(), new Runnable()
- {
- public void run()
- {
- controlResized(null);
- }
- });
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class BundlePoolContentProvider extends ColumnResizer
- {
- private BundlePoolAnalyzer agent;
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- super.inputChanged(viewer, oldInput, newInput);
- agent = (BundlePoolAnalyzer)newInput;
- }
-
- public Object[] getElements(Object inputElement)
- {
- List<BundlePool> bundlePools = new ArrayList<BundlePool>(agent.getBundlePools().values());
- Collections.sort(bundlePools);
- return bundlePools.toArray();
- }
-
- public void dispose()
- {
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class ArtifactContentProvider extends ColumnResizer
- {
- private BundlePool bundlePool;
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- super.inputChanged(viewer, oldInput, newInput);
- bundlePool = (BundlePool)newInput;
- }
-
- public Object[] getElements(Object inputElement)
- {
- return bundlePool.getArtifacts();
- }
-
- public void dispose()
- {
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class ProfileContentProvider extends ColumnResizer
- {
- private BundlePool bundlePool;
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- super.inputChanged(viewer, oldInput, newInput);
- bundlePool = (BundlePool)newInput;
- }
-
- public Object[] getElements(Object inputElement)
- {
- return bundlePool.getProfiles();
- }
-
- public void dispose()
- {
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class TableLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider
+ public static final class TableLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider
{
private final Color gray;
@@ -901,8 +799,9 @@ public class BundlePoolComposite extends Composite
case 2:
return Integer.toString(bundlePool.getUnusedArtifactsCount());
case 3:
- int percent = bundlePool.getDamagedArchivesPercent();
- return Integer.toString(bundlePool.getDamagedArchivesCount()) + (percent == 100 ? "" : " (" + percent + "%)");
+ int percent = bundlePool.getDamagedArtifactsPercent();
+ return Integer.toString(bundlePool.getDamagedArtifactsCount())
+ + (percent == 100 ? "" : " (" + percent + "%)");
case 4:
return Integer.toString(bundlePool.getProfilesCount());
}
@@ -913,8 +812,10 @@ public class BundlePoolComposite extends Composite
switch (columnIndex)
{
case 0:
- return artifact.getRelativePath();
+ return artifact.getID();
case 1:
+ return artifact.getVersion();
+ case 2:
return Integer.toString(artifact.getProfiles().size());
}
}
@@ -928,11 +829,11 @@ public class BundlePoolComposite extends Composite
case 1:
return Integer.toString(profile.getArtifacts().size());
case 2:
- return Integer.toString(profile.getDamagedArchivesCount());
+ return Integer.toString(profile.getDamagedArtifactsCount());
}
}
- return element.toString();
+ return String.valueOf(element);
}
public Image getColumnImage(Object element, int columnIndex)
@@ -943,7 +844,7 @@ public class BundlePoolComposite extends Composite
{
BundlePool bundlePool = (BundlePool)element;
String key = "bundlePool";
- if (bundlePool.getDamagedArchivesCount() != 0)
+ if (bundlePool.getDamagedArtifactsCount() != 0)
{
key += "Damaged";
}
@@ -974,6 +875,11 @@ public class BundlePoolComposite extends Composite
return getPluginImage(key);
}
+
+ if (element instanceof URI)
+ {
+ return getPluginImage("repository");
+ }
}
return null;
@@ -1003,4 +909,192 @@ public class BundlePoolComposite extends Composite
return ResourceManager.getPluginImage("org.eclipse.emf.cdo.releng.setup", "icons/obj16/" + key + ".gif");
}
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private static abstract class TableContentProvider extends ControlAdapter implements IStructuredContentProvider,
+ ILazyContentProvider
+ {
+ public static final String SHOW_ALL = "Show All";
+
+ private static final int FIRST_TIME = -1;
+
+ private final ControlListener columnListener = new ControlAdapter()
+ {
+ @Override
+ public void controlResized(ControlEvent e)
+ {
+ resizeColumns(true);
+ }
+ };
+
+ private TableViewer tableViewer;
+
+ private Object input;
+
+ private String filter = SHOW_ALL;
+
+ private int lastWidth = FIRST_TIME;
+
+ public void setInput(TableViewer viewer, Object input)
+ {
+ if (tableViewer == null)
+ {
+ tableViewer = viewer;
+ tableViewer.getTable().addControlListener(this);
+ }
+
+ Object[] elements = getElements(input);
+ tableViewer.setInput(input);
+ tableViewer.setItemCount(elements.length);
+ tableViewer.refresh();
+
+ ScrollBar verticalBar = tableViewer.getTable().getVerticalBar();
+ if (verticalBar != null)
+ {
+ verticalBar.setSelection(verticalBar.getMinimum());
+ }
+
+ resizeColumns();
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ input = newInput;
+ }
+
+ public void dispose()
+ {
+ input = null;
+ tableViewer = null;
+ }
+
+ public void updateElement(int index)
+ {
+ Object[] elements = getElements(input);
+ Object element = index < elements.length ? elements[index] : null;
+ tableViewer.replace(element, index);
+ }
+
+ public boolean isFiltered(String filter)
+ {
+ return ObjectUtil.equals(filter, this.filter);
+ }
+
+ public void setFilter(String filter)
+ {
+ this.filter = filter;
+ UIUtil.asyncExec(tableViewer.getTable().getDisplay(), new Runnable()
+ {
+ public void run()
+ {
+ tableViewer.setSelection(StructuredSelection.EMPTY);
+ tableViewer.setItemCount(getElements(input).length);
+ tableViewer.refresh();
+ }
+ });
+ }
+
+ @Override
+ public void controlResized(ControlEvent e)
+ {
+ resizeColumns(false);
+ }
+
+ public void resizeColumns()
+ {
+ Table table = tableViewer.getTable();
+ if (!table.isDisposed())
+ {
+ UIUtil.asyncExec(table.getDisplay(), new Runnable()
+ {
+ public void run()
+ {
+ resizeColumns(true);
+ }
+ });
+ }
+ }
+
+ private void resizeColumns(boolean force)
+ {
+ Table table = tableViewer.getTable();
+ int tableWidth = table.getSize().x;
+ if (force || tableWidth != lastWidth)
+ {
+ boolean firstTime = lastWidth == FIRST_TIME;
+ lastWidth = tableWidth;
+
+ ScrollBar bar = table.getVerticalBar();
+ if (bar != null && bar.isVisible())
+ {
+ tableWidth -= bar.getSize().x;
+ }
+
+ final TableColumn[] columns = table.getColumns();
+ for (int i = 1; i < columns.length; i++)
+ {
+ TableColumn column = columns[i];
+ tableWidth -= column.getWidth();
+
+ if (firstTime)
+ {
+ column.addControlListener(columnListener);
+ }
+ }
+
+ columns[0].setWidth(tableWidth);
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class BundlePoolContentProvider extends TableContentProvider
+ {
+ public Object[] getElements(Object input)
+ {
+ Map<File, BundlePool> map = ((BundlePoolAnalyzer)input).getBundlePools();
+ BundlePool[] bundlePools = map.values().toArray(new BundlePool[map.size()]);
+ Arrays.sort(bundlePools);
+ return bundlePools;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class ArtifactContentProvider extends TableContentProvider
+ {
+ public static final String SHOW_UNUSED = "Unused";
+
+ public static final String SHOW_DAMAGED = "Damaged";
+
+ public Object[] getElements(Object input)
+ {
+ if (isFiltered(SHOW_UNUSED))
+ {
+ return ((BundlePool)input).getUnusedArtifacts();
+ }
+ else if (isFiltered(SHOW_DAMAGED))
+ {
+ return ((BundlePool)input).getDamagedArtifacts();
+ }
+
+ return ((BundlePool)input).getArtifacts();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class ProfileContentProvider extends TableContentProvider
+ {
+ public Object[] getElements(Object input)
+ {
+ return ((BundlePool)input).getProfiles();
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolDialog.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolDialog.java
index 6ae2eda614..ee50854880 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolDialog.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/BundlePoolDialog.java
@@ -23,7 +23,7 @@ public final class BundlePoolDialog extends AbstractSetupDialog
{
private BundlePoolDialog(Shell parentShell)
{
- super(parentShell, "Bundle Pool Management", 680, 750);
+ super(parentShell, "Bundle Pool Management", 750, 750);
setShellStyle(SWT.TITLE | SWT.MAX | SWT.RESIZE | SWT.BORDER | SWT.APPLICATION_MODAL);
}

Back to the top