Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corporation and others.
* Copyright (c) 2000, 2021, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -312,13 +312,18 @@ public interface ICoreConstants {
String OSGI_INF_FOLDER_NAME = "OSGI-INF/"; //$NON-NLS-1$
String FEATURE_FOLDER_NAME = "features"; //$NON-NLS-1$

String P2_INF_FILENAME = "p2.inf"; //$NON-NLS-1$
String P2_INF_BUNDLE_DESCRIPTOR = "META-INF/p2.inf"; //$NON-NLS-1$

// Common paths
IPath MANIFEST_PATH = IPath.fromOSString(BUNDLE_FILENAME_DESCRIPTOR);
IPath PLUGIN_PATH = IPath.fromOSString(PLUGIN_FILENAME_DESCRIPTOR);
IPath FRAGMENT_PATH = IPath.fromOSString(FRAGMENT_FILENAME_DESCRIPTOR);
IPath FEATURE_PATH = IPath.fromOSString(FEATURE_FILENAME_DESCRIPTOR);
IPath BUILD_PROPERTIES_PATH = IPath.fromOSString(BUILD_FILENAME_DESCRIPTOR);
IPath OSGI_INF_PATH = IPath.fromOSString(OSGI_INF_FOLDER_NAME);
IPath P2_INF_BUNDLE_PATH = IPath.fromOSString(P2_INF_BUNDLE_DESCRIPTOR);
IPath P2_INF_FEATURE_PATH = IPath.fromOSString(P2_INF_FILENAME);

// Extension point identifiers
String EXTENSION_POINT_SOURCE = PDECore.PLUGIN_ID + ".source"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2024 IBM Corporation and others.
* Copyright (c) 2010, 2024, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -260,6 +260,30 @@ public static IFolder getMetaInf(IProject project) {
return getBundleRelativeFolder(project, IPath.fromOSString(ICoreConstants.MANIFEST_FOLDER_NAME));
}

/**
* Returns the resource in the specified project corresponding to its
* <code>META-INF/p2.inf</code> file (for bundle/plugin projects).
*
* @param project project
* @return <code>META-INF/p2.inf</code> file that may or may not exist
*/
public static IFile getBundleP2Inf(IProject project) {
return getBundleRelativeFile(project, ICoreConstants.P2_INF_BUNDLE_PATH);
}

/**
* Returns the resource in the specified project corresponding to its
* <code>p2.inf</code> file (for feature projects). Feature projects have
* the p2.inf file in the project root, not in META-INF.
*
* @param project
* project
* @return <code>p2.inf</code> file that may or may not exist
*/
public static IFile getFeatureP2Inf(IProject project) {
return getBundleRelativeFile(project, ICoreConstants.P2_INF_FEATURE_PATH);
}

/**
* Returns a file relative to the bundle root of the specified project.
*
Expand Down
14 changes: 14 additions & 0 deletions ui/org.eclipse.pde.ui/.settings/.api_filters
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/pde/internal/ui/editor/p2inf/P2InfModel.java" type="org.eclipse.pde.internal.ui.editor.p2inf.P2InfModel">
<filter comment="fil" id="574619656">
<message_arguments>
<message_argument value="IBaseModel"/>
<message_argument value="P2InfModel"/>
</message_arguments>
</filter>
<filter comment="filter" id="574619656">
<message_arguments>
<message_argument value="IModelChangeProvider"/>
<message_argument value="P2InfModel"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/pde/internal/ui/editor/plugin/JavaAttributeWizardPage.java" type="org.eclipse.pde.internal.ui.editor.plugin.JavaAttributeWizardPage">
<filter id="571473929">
<message_arguments>
Expand Down
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %name
Bundle-SymbolicName: org.eclipse.pde.ui; singleton:=true
Bundle-Version: 3.16.400.qualifier
Bundle-Version: 3.16.500.qualifier
Bundle-Activator: org.eclipse.pde.internal.ui.PDEPlugin
Bundle-Vendor: %provider-name
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corporation and others.
* Copyright (c) 2000, 2021, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -52,6 +52,8 @@
import org.eclipse.pde.internal.ui.editor.build.BuildSourcePage;
import org.eclipse.pde.internal.ui.editor.context.InputContext;
import org.eclipse.pde.internal.ui.editor.context.InputContextManager;
import org.eclipse.pde.internal.ui.editor.p2inf.P2InfInputContext;
import org.eclipse.pde.internal.ui.editor.p2inf.P2InfSourcePage;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.dnd.RTFTransfer;
import org.eclipse.swt.dnd.TextTransfer;
Expand Down Expand Up @@ -172,8 +174,14 @@ protected void createResourceContexts(InputContextManager manager, IFileEditorIn
FileEditorInput in = new FileEditorInput(buildFile);
manager.putContext(in, new BuildInputContext(this, in, file == buildFile));
}
IFile p2InfFile = PDEProject.getFeatureP2Inf(project);
if (p2InfFile != null && p2InfFile.exists()) {
FileEditorInput in = new FileEditorInput(p2InfFile);
manager.putContext(in, new P2InfInputContext(this, in, false));
}
manager.monitorFile(featureFile);
manager.monitorFile(buildFile);
manager.monitorFile(p2InfFile);
}

@Override
Expand All @@ -200,6 +208,11 @@ public void monitoredFileAdded(IFile file) {
IEditorInput in = new FileEditorInput(file);
fInputContextManager.putContext(in, new BuildInputContext(this, in, false));
}
} else if (name.equalsIgnoreCase(ICoreConstants.P2_INF_FILENAME)) {
if (!fInputContextManager.hasContext(P2InfInputContext.CONTEXT_ID)) {
IEditorInput in = new FileEditorInput(file);
fInputContextManager.putContext(in, new P2InfInputContext(this, in, false));
}
}
}

Expand Down Expand Up @@ -254,6 +267,12 @@ protected void createSystemFileContexts(InputContextManager manager, FileStoreEd
IEditorInput in = new FileStoreEditorInput(store);
manager.putContext(in, new BuildInputContext(this, in, file == buildFile));
}
File p2InfFile = new File(file.getParentFile(), ICoreConstants.P2_INF_FILENAME);
if (p2InfFile.exists()) {
IFileStore store = EFS.getStore(p2InfFile.toURI());
IEditorInput in = new FileStoreEditorInput(store);
manager.putContext(in, new P2InfInputContext(this, in, false));
}
} catch (CoreException e) {
PDEPlugin.logException(e);
}
Expand Down Expand Up @@ -298,6 +317,7 @@ protected void addEditorPages() {
}
addSourcePage(FeatureInputContext.CONTEXT_ID);
addSourcePage(BuildInputContext.CONTEXT_ID);
addSourcePage(P2InfInputContext.CONTEXT_ID);
}

@Override
Expand All @@ -323,6 +343,9 @@ protected IEditorPart createSourcePage(PDEFormEditor editor, String title, Strin
if (contextId.equals(BuildInputContext.CONTEXT_ID)) {
return new BuildSourcePage(editor, title, name);
}
if (contextId.equals(P2InfInputContext.CONTEXT_ID)) {
return new P2InfSourcePage(editor, contextId, title);
}
return super.createSourcePage(editor, title, name, contextId);
}

Expand Down Expand Up @@ -426,9 +449,18 @@ protected boolean isPatchEditor() {
public void showEditorInput(IEditorInput editorInput) {
String name = editorInput.getName();
if (name.equals(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR)) {
setActivePage(0);
} else {
setActivePage(getPageCount() - 3);
setActivePage(FeatureFormPage.PAGE_ID);
} else if (name.equalsIgnoreCase(ICoreConstants.BUILD_FILENAME_DESCRIPTOR)) {
IFormPage uiPage = findPage(BuildPage.PAGE_ID);
if (uiPage != null) {
setActivePage(uiPage.getId());
}

} else if (name.equalsIgnoreCase(ICoreConstants.P2_INF_FILENAME)) {
IFormPage page = findPage(P2InfInputContext.CONTEXT_ID);
if (page != null) {
setActivePage(page.getId());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2015 IBM Corporation and others.
* Copyright (c) 2005, 2015, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -45,11 +45,18 @@ public boolean matches(IEditorReference editorRef, IEditorInput input) {
// build.properties matches with editors that have a feature.xml file
// as their input and that feature.xml is at the root
if (inputFile.getName().equals(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR)) {
if (currInputFile.getName().equals(ICoreConstants.BUILD_FILENAME_DESCRIPTOR)) {
if (currInputFile.getName().equals(ICoreConstants.BUILD_FILENAME_DESCRIPTOR)
|| currInputFile.getName().equals(ICoreConstants.P2_INF_FILENAME)) {
return inputFile.getProjectRelativePath().toString().equals(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR);
}
return inputFile.equals(currInputFile);
} else if (inputFile.getName().equals(ICoreConstants.BUILD_FILENAME_DESCRIPTOR)) {
if (currInputFile.getName().equals(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR))
return currInputFile.getProjectRelativePath().toString().equals(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR);
return inputFile.equals(currInputFile);
} else if (inputFile.getName().equals(ICoreConstants.P2_INF_FILENAME)) {
// p2.inf should match the feature editor when the current editor
// input is the feature.xml at the project root
if (currInputFile.getName().equals(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR)) {
return currInputFile.getProjectRelativePath().toString().equals(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR);
}
Expand All @@ -60,5 +67,4 @@ public boolean matches(IEditorReference editorRef, IEditorInput input) {
return false;
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.pde.internal.ui.editor.p2inf;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.pde.core.IBaseModel;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
import org.eclipse.pde.internal.ui.editor.context.InputContext;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.ui.IEditorInput;

public class P2InfInputContext extends InputContext {
public static final String P2_INF_PARTITION = "___p2_inf_partition"; //$NON-NLS-1$

public static final String CONTEXT_ID = "p2inf-context"; //$NON-NLS-1$

public P2InfInputContext(PDEFormEditor editor, IEditorInput input, boolean primary) {
super(editor, input, primary);
create();
}

@Override
protected Charset getDefaultCharset() {
return StandardCharsets.UTF_8;
}

@Override
protected IBaseModel createModel(IEditorInput input) throws CoreException {
IDocument document = getDocumentProvider().getDocument(input);
P2InfModel model = new P2InfModel(document);
model.load();
return model;
}

@Override
public P2InfModel getModel() {
return (P2InfModel) super.getModel();
}

@Override
public String getId() {
return CONTEXT_ID;
}

@Override
protected void addTextEditOperation(ArrayList<TextEdit> ops, IModelChangedEvent event) {

}

@Override
public void doRevert() {
// Revert to the saved version by reloading the model from the document
P2InfModel model = getModel();
if (model != null) {
model.load();
}
}

@Override
protected String getPartitionName() {
return P2_INF_PARTITION;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright (c) 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.pde.internal.ui.editor.p2inf;

import org.eclipse.jface.text.IDocument;
import org.eclipse.pde.core.IBaseModel;
import org.eclipse.pde.core.IModelChangeProvider;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.core.IModelChangedListener;

public class P2InfModel implements IBaseModel, IModelChangeProvider {

private final IDocument document;
private volatile boolean valid;
private volatile boolean disposed;

public P2InfModel(IDocument document) {
this.document = document;
}

public void load() {
valid = document != null;
}

public IDocument getDocument() {
return document;
}

@Override
public boolean isEditable() {
return true;
}

@Override
public boolean isValid() {
return valid;
}

@Override
public boolean isDisposed() {
return disposed;
}

@Override
public void dispose() {
disposed = true;
}

@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IDocument.class) {
return adapter.cast(document);
}
return null;
}

@Override
public void addModelChangedListener(IModelChangedListener listener) {
}

@Override
public void fireModelChanged(IModelChangedEvent event) {
}

@Override
public void fireModelObjectChanged(Object object, String property, Object oldValue, Object newValue) {
}

@Override
public void removeModelChangedListener(IModelChangedListener listener) {
}
}
Loading
Loading