Skip to content

Commit

Permalink
Show only single editor when open plain BND files
Browse files Browse the repository at this point in the history
Currently the manifest editor shows an error when one opens a plain bnd
file. This is because no "manifest first" parts are found and the bnd
form page is only added for pde.bnd files.

This now fixes the issue by making manifest-first files completely
optional and show a plain bnd editor instead in case of only a bnd file.
  • Loading branch information
laeubi committed Oct 25, 2023
1 parent b62ea08 commit 078112b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ public boolean isDirty() {
}

public void monitorFile(IFile file) {
if (file == null) {
return;
}
monitoredFiles.add(file);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.IBaseModel;
import org.eclipse.pde.core.IIdentifiable;
import org.eclipse.pde.core.build.IBuild;
Expand Down Expand Up @@ -239,33 +237,28 @@ protected void createResourceContexts(InputContextManager manager, IFileEditorIn
manifestFile = container.getFile(ICoreConstants.MANIFEST_PATH);
} else if (name.endsWith(BndProject.INSTRUCTIONS_FILE_EXTENSION)) {
IProject project = file.getProject();
manifestFile = PDEProject.getManifest(project);
buildFile = PDEProject.getBuildProperties(project);
pluginFile = PDEProject.getPluginXml(project);
if (name.equalsIgnoreCase(BndProject.INSTRUCTIONS_FILE)) {
IEditorInput in = new FileEditorInput(file);
BndInputContext bndInputContext = new BndInputContext(this, in, true);
manager.putContext(in, bndInputContext);
manager.monitorFile(file);
manager.addInputContextListener(bndInputContext);
manifestFile = PDEProject.getManifest(project);
buildFile = PDEProject.getBuildProperties(project);
pluginFile = PDEProject.getPluginXml(project);
}
IEditorInput in = new FileEditorInput(file);
BndInputContext bndInputContext = new BndInputContext(this, in, true);
manager.putContext(in, bndInputContext);
manager.monitorFile(file);
manager.addInputContextListener(bndInputContext);
}
if (manifestFile == null) {
MessageDialog.openError(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OpenPluginManifestsAction_title,
NLS.bind(PDEUIMessages.OpenManifestsAction_cannotOpenThisFile, name));
return;
}
if (manifestFile.exists()) {
if (manifestFile != null && manifestFile.exists()) {
IEditorInput in = new FileEditorInput(manifestFile);
manager.putContext(in, new BundleInputContext(this, in, file == manifestFile));
}
manager.monitorFile(manifestFile);
if (pluginFile.exists()) {
if (pluginFile != null && pluginFile.exists()) {
FileEditorInput in = new FileEditorInput(pluginFile);
manager.putContext(in, new PluginInputContext(this, in, file == pluginFile, fragment));
}
manager.monitorFile(pluginFile);
if (buildFile.exists()) {
if (buildFile != null && buildFile.exists()) {
FileEditorInput in = new FileEditorInput(buildFile);
manager.putContext(in, new BuildInputContext(this, in, false));
}
Expand Down Expand Up @@ -401,12 +394,14 @@ public void contextRemoved(InputContext context) {
private void updateFirstThreePages() {
try {
int index = getActivePage();
removePage(0);
removePage(0);
removePage(0);
addPage(0, new RuntimePage(this));
addPage(0, new DependenciesPage(this));
addPage(0, new OverviewPage(this));
removePage(RuntimePage.PAGE_ID);
removePage(DependenciesPage.PAGE_ID);
removePage(OverviewPage.PAGE_ID);
if (fInputContextManager.hasContext(BundleInputContext.CONTEXT_ID)) {
addPage(0, new RuntimePage(this));
addPage(0, new DependenciesPage(this));
addPage(0, new OverviewPage(this));
}
setActivePage(index);
} catch (PartInitException e) {
PDEPlugin.logException(e);
Expand Down Expand Up @@ -527,9 +522,11 @@ protected void createJarEntryContexts(InputContextManager manager, JarEntryEdito
@Override
protected void addEditorPages() {
try {
addPage(new OverviewPage(this));
addPage(new DependenciesPage(this));
addPage(new RuntimePage(this));
if (fInputContextManager.hasContext(BundleInputContext.CONTEXT_ID)) {
addPage(new OverviewPage(this));
addPage(new DependenciesPage(this));
addPage(new RuntimePage(this));
}
if (showExtensionTabs()) {
addExtensionTabs();
}
Expand Down

0 comments on commit 078112b

Please sign in to comment.