mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
call update method on owner for missing extensions
This commit is contained in:
parent
5c8cdfbd11
commit
95f5a88e72
6 changed files with 40 additions and 12 deletions
|
@ -11,6 +11,7 @@ public interface ICDescriptor {
|
||||||
public String getPlatform();
|
public String getPlatform();
|
||||||
public IProject getProject();
|
public IProject getProject();
|
||||||
public ICExtensionReference[] get(String name);
|
public ICExtensionReference[] get(String name);
|
||||||
|
public ICExtensionReference[] get(String name, boolean update);
|
||||||
public ICExtensionReference create(String name, String id);
|
public ICExtensionReference create(String name, String id);
|
||||||
public void remove(ICExtensionReference extension);
|
public void remove(ICExtensionReference extension);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,5 @@ package org.eclipse.cdt.core;
|
||||||
|
|
||||||
public interface ICOwner {
|
public interface ICOwner {
|
||||||
public void configure(ICDescriptor cproject);
|
public void configure(ICDescriptor cproject);
|
||||||
public void update(ICDescriptor cproject);
|
public void update(ICDescriptor cproject, String extensionID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.xml.sax.SAXException;
|
||||||
public class CDescriptor implements ICDescriptor {
|
public class CDescriptor implements ICDescriptor {
|
||||||
/* constants */
|
/* constants */
|
||||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||||
private ICOwnerInfo fOwner;
|
private COwner fOwner;
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
private String fPlatform = "*";
|
private String fPlatform = "*";
|
||||||
private HashMap extMap = new HashMap(4);
|
private HashMap extMap = new HashMap(4);
|
||||||
|
@ -57,6 +57,8 @@ public class CDescriptor implements ICDescriptor {
|
||||||
private final String PROJECT_EXTENSION = "extension";
|
private final String PROJECT_EXTENSION = "extension";
|
||||||
private final String PROJECT_EXTENSION_ATTRIBUTE = "attribute";
|
private final String PROJECT_EXTENSION_ATTRIBUTE = "attribute";
|
||||||
|
|
||||||
|
private boolean fDirty;
|
||||||
|
|
||||||
protected void readCDTProject(IPath projectLocation) {
|
protected void readCDTProject(IPath projectLocation) {
|
||||||
FileInputStream file = null;
|
FileInputStream file = null;
|
||||||
try {
|
try {
|
||||||
|
@ -141,8 +143,22 @@ public class CDescriptor implements ICDescriptor {
|
||||||
return fProject;
|
return fProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICExtensionReference[] get(String name) {
|
public ICExtensionReference[] get(String extensionID) {
|
||||||
return (CExtensionReference[]) extMap.get(name);
|
return (CExtensionReference[]) extMap.get(extensionID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICExtensionReference[] get(String extensionID, boolean update) {
|
||||||
|
ICExtensionReference[] ext = get(extensionID);
|
||||||
|
if ( (ext == null || ext.length == 0) && update) {
|
||||||
|
try {
|
||||||
|
fOwner.update(fProject, this, extensionID);
|
||||||
|
saveInfo();
|
||||||
|
ext = get(extensionID);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICExtensionReference create(String name, String id) {
|
public ICExtensionReference create(String name, String id) {
|
||||||
|
@ -156,6 +172,7 @@ public class CDescriptor implements ICDescriptor {
|
||||||
extensions = newExtensions;
|
extensions = newExtensions;
|
||||||
extMap.put(name, extensions);
|
extMap.put(name, extensions);
|
||||||
}
|
}
|
||||||
|
setDirty();
|
||||||
extensions[extensions.length-1] = new CExtensionReference(this, name, id);
|
extensions[extensions.length-1] = new CExtensionReference(this, name, id);
|
||||||
return extensions[extensions.length-1];
|
return extensions[extensions.length-1];
|
||||||
}
|
}
|
||||||
|
@ -173,6 +190,7 @@ public class CDescriptor implements ICDescriptor {
|
||||||
} else {
|
} else {
|
||||||
extMap.put(ext.getExtension(), extensions);
|
extMap.put(ext.getExtension(), extensions);
|
||||||
}
|
}
|
||||||
|
setDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,8 +218,8 @@ public class CDescriptor implements ICDescriptor {
|
||||||
return node != null ? (node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue()) : null;
|
return node != null ? (node.getFirstChild() == null ? null : node.getFirstChild().getNodeValue()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICOwnerInfo readProjectDescription(Node node) {
|
private COwner readProjectDescription(Node node) {
|
||||||
ICOwnerInfo owner = null;
|
COwner owner = null;
|
||||||
NamedNodeMap attrib = node.getAttributes();
|
NamedNodeMap attrib = node.getAttributes();
|
||||||
try {
|
try {
|
||||||
owner = new COwner(attrib.getNamedItem("id").getNodeValue());
|
owner = new COwner(attrib.getNamedItem("id").getNodeValue());
|
||||||
|
@ -254,10 +272,15 @@ public class CDescriptor implements ICDescriptor {
|
||||||
} else {
|
} else {
|
||||||
rscFile.create(inputStream, IResource.FORCE, null);
|
rscFile.create(inputStream, IResource.FORCE, null);
|
||||||
}
|
}
|
||||||
|
fDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDirty() {
|
protected void setDirty() {
|
||||||
return true;
|
fDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isDirty() {
|
||||||
|
return fDirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String serializeDocument(Document doc) throws IOException {
|
protected String serializeDocument(Document doc) throws IOException {
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class CDescriptorManager implements IResourceChangeListener {
|
||||||
public ICExtension[] createExtensions(String extensionID, IProject project) throws CoreException {
|
public ICExtension[] createExtensions(String extensionID, IProject project) throws CoreException {
|
||||||
ArrayList extensionList = new ArrayList(1);
|
ArrayList extensionList = new ArrayList(1);
|
||||||
ICDescriptor cDescriptor = getDescriptor(project);
|
ICDescriptor cDescriptor = getDescriptor(project);
|
||||||
ICExtensionReference ext[] = cDescriptor.get(extensionID);
|
ICExtensionReference ext[] = cDescriptor.get(extensionID, true);
|
||||||
IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
|
IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
|
||||||
for( int i = 0; i < ext.length; i++ ) {
|
for( int i = 0; i < ext.length; i++ ) {
|
||||||
IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint(ext[i].getExtension());
|
IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint(ext[i].getExtension());
|
||||||
|
|
|
@ -89,12 +89,12 @@ public class COwner implements ICOwnerInfo {
|
||||||
throw new CoreException(status);
|
throw new CoreException(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(IProject project, ICDescriptor cproject) throws CoreException {
|
void update(IProject project, ICDescriptor cproject, String extensionID) throws CoreException {
|
||||||
IConfigurationElement element[] = extension.getConfigurationElements();
|
IConfigurationElement element[] = extension.getConfigurationElements();
|
||||||
for( int i = 0; i < element.length; i++ ) {
|
for( int i = 0; i < element.length; i++ ) {
|
||||||
if ( element[i].getName().equalsIgnoreCase("run") ) {
|
if ( element[i].getName().equalsIgnoreCase("run") ) {
|
||||||
ICOwner owner = (ICOwner) element[i].createExecutableExtension("class");
|
ICOwner owner = (ICOwner) element[i].createExecutableExtension("class");
|
||||||
owner.update(cproject);
|
owner.update(cproject, extensionID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,10 @@ public class MakeProject implements ICOwner {
|
||||||
ext.setExtensionData("command", "make");
|
ext.setExtensionData("command", "make");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(ICDescriptor cproject) {
|
public void update(ICDescriptor cproject, String extensionID) {
|
||||||
|
if ( extensionID.equals(CCorePlugin.BUILDER_MODEL_ID ) ) {
|
||||||
|
ICExtensionReference ext = cproject.create(CCorePlugin.BUILDER_MODEL_ID, CCorePlugin.getDefault().PLUGIN_ID + ".makeBuilder");
|
||||||
|
ext.setExtensionData("command", "make");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue