1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

call update method on owner for missing extensions

This commit is contained in:
David Inglis 2002-09-09 15:40:20 +00:00
parent 5c8cdfbd11
commit 95f5a88e72
6 changed files with 40 additions and 12 deletions

View file

@ -11,6 +11,7 @@ public interface ICDescriptor {
public String getPlatform();
public IProject getProject();
public ICExtensionReference[] get(String name);
public ICExtensionReference[] get(String name, boolean update);
public ICExtensionReference create(String name, String id);
public void remove(ICExtensionReference extension);
}

View file

@ -6,5 +6,5 @@ package org.eclipse.cdt.core;
public interface ICOwner {
public void configure(ICDescriptor cproject);
public void update(ICDescriptor cproject);
public void update(ICDescriptor cproject, String extensionID);
}

View file

@ -45,7 +45,7 @@ import org.xml.sax.SAXException;
public class CDescriptor implements ICDescriptor {
/* constants */
private static final String[] EMPTY_STRING_ARRAY = new String[0];
private ICOwnerInfo fOwner;
private COwner fOwner;
private IProject fProject;
private String fPlatform = "*";
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_ATTRIBUTE = "attribute";
private boolean fDirty;
protected void readCDTProject(IPath projectLocation) {
FileInputStream file = null;
try {
@ -141,10 +143,24 @@ public class CDescriptor implements ICDescriptor {
return fProject;
}
public ICExtensionReference[] get(String name) {
return (CExtensionReference[]) extMap.get(name);
public ICExtensionReference[] get(String extensionID) {
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) {
CExtensionReference extensions[] = (CExtensionReference[]) extMap.get(name);
if ( extensions == null ) {
@ -156,6 +172,7 @@ public class CDescriptor implements ICDescriptor {
extensions = newExtensions;
extMap.put(name, extensions);
}
setDirty();
extensions[extensions.length-1] = new CExtensionReference(this, name, id);
return extensions[extensions.length-1];
}
@ -173,6 +190,7 @@ public class CDescriptor implements ICDescriptor {
} else {
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;
}
private ICOwnerInfo readProjectDescription(Node node) {
ICOwnerInfo owner = null;
private COwner readProjectDescription(Node node) {
COwner owner = null;
NamedNodeMap attrib = node.getAttributes();
try {
owner = new COwner(attrib.getNamedItem("id").getNodeValue());
@ -254,10 +272,15 @@ public class CDescriptor implements ICDescriptor {
} else {
rscFile.create(inputStream, IResource.FORCE, null);
}
fDirty = false;
}
private boolean isDirty() {
return true;
protected void setDirty() {
fDirty = true;
}
protected boolean isDirty() {
return fDirty;
}
protected String serializeDocument(Document doc) throws IOException {

View file

@ -107,7 +107,7 @@ public class CDescriptorManager implements IResourceChangeListener {
public ICExtension[] createExtensions(String extensionID, IProject project) throws CoreException {
ArrayList extensionList = new ArrayList(1);
ICDescriptor cDescriptor = getDescriptor(project);
ICExtensionReference ext[] = cDescriptor.get(extensionID);
ICExtensionReference ext[] = cDescriptor.get(extensionID, true);
IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
for( int i = 0; i < ext.length; i++ ) {
IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint(ext[i].getExtension());

View file

@ -89,12 +89,12 @@ public class COwner implements ICOwnerInfo {
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();
for( int i = 0; i < element.length; i++ ) {
if ( element[i].getName().equalsIgnoreCase("run") ) {
ICOwner owner = (ICOwner) element[i].createExecutableExtension("class");
owner.update(cproject);
owner.update(cproject, extensionID);
return;
}
}

View file

@ -16,6 +16,10 @@ public class MakeProject implements ICOwner {
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");
}
}
}