tidy up/refactor in prep for FELIX-2500
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@983558 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
index f0ef761..075151b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
@@ -74,7 +74,7 @@
{
if (oldExport != null)
{
- sigil.getBundle().getBundleInfo().removeChild(oldExport);
+ sigil.getBundle().getBundleInfo().removeExport(oldExport);
}
if (newExport != null)
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
index 7cfb4f7..b0addef 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
@@ -25,7 +25,6 @@
import org.apache.felix.sigil.common.model.ModelElementFactory;
import org.apache.felix.sigil.common.model.osgi.IPackageExport;
-import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.model.util.JavaHelper;
@@ -89,7 +88,9 @@
else
{
SubMonitor sub = SubMonitor.convert(monitor);
-
+
+ sub.beginTask("Resolving package users", 200);
+
Set<String> users = JavaHelper.findLocalPackageUsers(
sourceProject, packageName, sub.newChild(100));
Set<String> dependencies = JavaHelper.findLocalPackageDependencies(
@@ -104,18 +105,18 @@
if (users.size() > 0)
{ // attempt to move an API package
- IPackageExport newExport = createNewExport(status,
+ IPackageExport newExport = RefactorUtil.createNewExport(status, changes,
destProject, packageName);
- createNewImport(status, sourceProject, newExport);
+ RefactorUtil.createNewImport(status, changes, sourceProject, newExport);
}
if (dependencies.size() > 0)
{ // moved an impl package
for (String dep : dependencies)
{
- IPackageExport newExport = createNewExport(status,
+ IPackageExport newExport = RefactorUtil.createNewExport(status, changes,
sourceProject, dep);
- createNewImport(status, destProject, newExport);
+ RefactorUtil.createNewImport(status, changes, destProject, newExport);
}
}
}
@@ -134,33 +135,6 @@
}
}
- private void createNewImport(RefactoringStatus status, ISigilProjectModel project,
- IPackageExport export)
- {
- IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(
- IPackageImport.class);
- newImport.setPackageName(export.getPackageName());
- newImport.setVersions(ModelHelper.getDefaultRange(export.getVersion()));
-
- status.addInfo("Creating new import in " + project.getSymbolicName());
- changes.add(new ImportPackageChange(project, null, newImport));
- }
-
- private IPackageExport createNewExport(RefactoringStatus status,
- ISigilProjectModel project, String packageName)
- {
- IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
- IPackageExport.class);
- newExport.setPackageName(packageName);
- // new export inherits project version by default
- newExport.setVersion(project.getVersion());
-
- status.addInfo("Creating new export " + packageName + " in "
- + project.getSymbolicName());
- changes.add(new ExportPackageChange(project, null, newExport));
- return newExport;
- }
-
@Override
public Change createChange(IProgressMonitor monitor) throws CoreException,
OperationCanceledException
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
index 017bc15..1fa8d50 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
@@ -19,10 +19,18 @@
package org.apache.felix.sigil.eclipse.ui.internal.refactor;
+import java.util.List;
+
+import org.apache.felix.sigil.common.model.ModelElementFactory;
+import org.apache.felix.sigil.common.model.osgi.IPackageExport;
+import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
+import org.apache.felix.sigil.eclipse.model.util.ModelHelper;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker;
@@ -38,5 +46,32 @@
IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
IFile file = sigil.getProject().getFile(SigilCore.SIGIL_PROJECT_FILE);
deltaFactory.change(file);
+ }
+
+ static void createNewImport(RefactoringStatus status, List<Change> changes, ISigilProjectModel project,
+ IPackageExport export)
+ {
+ IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ newImport.setPackageName(export.getPackageName());
+ newImport.setVersions(ModelHelper.getDefaultRange(export.getVersion()));
+
+ status.addInfo("Creating new import in " + project.getSymbolicName());
+ changes.add(new ImportPackageChange(project, null, newImport));
}
+
+ static IPackageExport createNewExport(RefactoringStatus status,
+ List<Change> changes, ISigilProjectModel project, String packageName)
+ {
+ IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+ newExport.setPackageName(packageName);
+ // new export inherits project version by default
+ newExport.setVersion(project.getVersion());
+
+ status.addInfo("Creating new export " + packageName + " in "
+ + project.getSymbolicName());
+ changes.add(new ExportPackageChange(project, null, newExport));
+ return newExport;
+ }
}