Skip to content

Commit

Permalink
Refresh the bundle model after building the automatic manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed May 7, 2024
1 parent 8046286 commit 7e279bc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1261,4 +1261,15 @@ public void addExtensionDeltaListener(IExtensionDeltaListener listener) {
public void removeExtensionDeltaListener(IExtensionDeltaListener listener) {
fWorkspaceManager.removeExtensionDeltaListener(listener);
}

public void update(IProject project) {
synchronized (fEntriesSynchronizer) {
IPluginModelBase model = fWorkspaceManager.getModel(project);
if (model == null) {
fWorkspaceManager.createModel(project, true);
} else {
fWorkspaceManager.updateModel(project, model);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -332,29 +332,33 @@ private void handleBundleManifestDelta(IFile file, IResourceDelta delta) {
} else if (kind == IResourceDelta.ADDED || model == null) {
createModel(project, true);
} else if (kind == IResourceDelta.CHANGED && (IResourceDelta.CONTENT & delta.getFlags()) != 0) {
if (model instanceof IBundlePluginModelBase) {
// check to see if localization changed (bug 146912)
String oldLocalization = ((IBundlePluginModelBase) model).getBundleLocalization();
IBundleModel bmodel = ((IBundlePluginModelBase) model).getBundleModel();
boolean wasFragment = bmodel.isFragmentModel();
Map<String, IManifestHeader> oldHeaders = bmodel.getBundle().getManifestHeaders();

loadModel(bmodel, true);
String newLocalization = ((IBundlePluginModelBase) model).getBundleLocalization();

// Fragment-Host header was added or removed
if (wasFragment != bmodel.isFragmentModel()) {
removeModel(project);
createModel(project, true);
} else {
if (model instanceof AbstractNLModel && (oldLocalization != null && (newLocalization == null || !oldLocalization.equals(newLocalization))) || (newLocalization != null && (oldLocalization == null || !newLocalization.equals(oldLocalization)))) {
((AbstractNLModel) model).resetNLResourceHelper();
}
updateModel(project, model);
}
}

Map<String, IManifestHeader> newHeaders = bmodel.getBundle().getManifestHeaders();
if (hasModelChanged(oldHeaders, newHeaders)) {
addChange(model, IModelProviderEvent.MODELS_CHANGED);
}
protected void updateModel(IProject project, IPluginModelBase model) {
if (model instanceof IBundlePluginModelBase) {
// check to see if localization changed (bug 146912)
String oldLocalization = ((IBundlePluginModelBase) model).getBundleLocalization();
IBundleModel bmodel = ((IBundlePluginModelBase) model).getBundleModel();
boolean wasFragment = bmodel.isFragmentModel();
Map<String, IManifestHeader> oldHeaders = bmodel.getBundle().getManifestHeaders();

loadModel(bmodel, true);
String newLocalization = ((IBundlePluginModelBase) model).getBundleLocalization();

// Fragment-Host header was added or removed
if (wasFragment != bmodel.isFragmentModel()) {
removeModel(project);
createModel(project, true);
} else {
if (model instanceof AbstractNLModel && (oldLocalization != null && (newLocalization == null || !oldLocalization.equals(newLocalization))) || (newLocalization != null && (oldLocalization == null || !newLocalization.equals(oldLocalization)))) {
((AbstractNLModel) model).resetNLResourceHelper();
}

Map<String, IManifestHeader> newHeaders = bmodel.getBundle().getManifestHeaders();
if (hasModelChanged(oldHeaders, newHeaders)) {
addChange(model, IModelProviderEvent.MODELS_CHANGED);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.pde.internal.core.ICoreConstants;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDECoreMessages;
import org.eclipse.pde.internal.core.PluginModelManager;
import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
import org.eclipse.pde.internal.core.natures.BndProject;
import org.eclipse.pde.internal.core.project.PDEProject;
Expand Down Expand Up @@ -188,6 +189,8 @@ public void addClasspath(aQute.bnd.osgi.Jar jar) {
}
}
}
PluginModelManager modelManager = PDECore.getDefault().getModelManager();
modelManager.update(project);
}
if (monitor.isCanceled()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,8 @@ private void cleanup() {
}
}

public IFile getManifestFile() {
return manifestFile;
}

}

0 comments on commit 7e279bc

Please sign in to comment.