mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
[189274] provide import and export operations for profiles
https://bugs.eclipse.org/bugs/show_bug.cgi?id=189274
This commit is contained in:
parent
f47e91b3af
commit
4114889197
1 changed files with 77 additions and 85 deletions
|
@ -138,18 +138,66 @@ public class RSEEnvelope {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return a file handle to a temporary directory
|
||||
* Adds a host to the envelope.
|
||||
* If a host of the same name is already present in the envelope the new host will
|
||||
* be renamed prior to adding it.
|
||||
* @param host the host to be added to the envelope
|
||||
*/
|
||||
private File getTemporaryFolder() {
|
||||
IPath stateLocation = RSECorePlugin.getDefault().getStateLocation();
|
||||
File stateFolder = new File(stateLocation.toOSString());
|
||||
File envelopesFolder = new File(stateFolder, "envelopes"); //$NON-NLS-1$
|
||||
envelopesFolder.mkdir();
|
||||
List envelopeNames = Arrays.asList(envelopesFolder.list());
|
||||
String envelopeName = generateName(envelopeNames);
|
||||
File envelopeFolder = new File(envelopesFolder, envelopeName);
|
||||
envelopeFolder.mkdir();
|
||||
return envelopeFolder;
|
||||
public void add(final IHost host) {
|
||||
// find and add the host-unique filter pools
|
||||
ISubSystem[] subsystems = host.getSubSystems();
|
||||
for (int i = 0; i < subsystems.length; i++) {
|
||||
ISubSystem subsystem = subsystems[i];
|
||||
ISystemFilterPool pool = subsystem.getUniqueOwningSystemFilterPool(false);
|
||||
if (pool != null) {
|
||||
add(pool);
|
||||
}
|
||||
}
|
||||
// add the host
|
||||
String type = IRSEDOMConstants.TYPE_HOST;
|
||||
String name = host.getName();
|
||||
Runnable action = new Runnable() {
|
||||
public void run() {
|
||||
RSEDOMExporter.getInstance().createNode(dom, host, true);
|
||||
}
|
||||
};
|
||||
addNode(type, name, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a filter pool to the envelope.
|
||||
* If a filter pool of the same name is already present in the envelope the new filter pool will
|
||||
* be renamed prior to adding it.
|
||||
* @param pool the filter pool to be added to the envelope
|
||||
*/
|
||||
public void add(final ISystemFilterPool pool) {
|
||||
// add the pool
|
||||
String type = IRSEDOMConstants.TYPE_FILTER_POOL;
|
||||
String name = pool.getName();
|
||||
Runnable action = new Runnable() {
|
||||
public void run() {
|
||||
RSEDOMExporter.getInstance().createNode(dom, pool, true);
|
||||
}
|
||||
};
|
||||
addNode(type, name, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a property set to the envelope.
|
||||
* If a property set of the same name is already present in the envelope the new property set will
|
||||
* be renamed prior to adding it.
|
||||
* @param propertySet the property set to be added to the envelope
|
||||
*/
|
||||
public void add(final IPropertySet propertySet) {
|
||||
// add the property set
|
||||
String type = IRSEDOMConstants.TYPE_FILTER_POOL;
|
||||
String name = propertySet.getName();
|
||||
Runnable action = new Runnable() {
|
||||
public void run() {
|
||||
RSEDOMExporter.getInstance().createNode(dom, propertySet, true);
|
||||
}
|
||||
};
|
||||
addNode(type, name, action);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,73 +302,6 @@ public class RSEEnvelope {
|
|||
return filterPool;
|
||||
}
|
||||
|
||||
private interface NodeAction {
|
||||
abstract void run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a host to the envelope.
|
||||
* If a host of the same name is already present in the envelope the new host will
|
||||
* be renamed prior to adding it.
|
||||
* @param host the host to be added to the envelope
|
||||
*/
|
||||
public void add(final IHost host) {
|
||||
// find and add the host-unique filter pools
|
||||
ISubSystem[] subsystems = host.getSubSystems();
|
||||
for (int i = 0; i < subsystems.length; i++) {
|
||||
ISubSystem subsystem = subsystems[i];
|
||||
ISystemFilterPool pool = subsystem.getUniqueOwningSystemFilterPool(false);
|
||||
if (pool != null) {
|
||||
add(pool);
|
||||
}
|
||||
}
|
||||
// add the host
|
||||
String type = IRSEDOMConstants.TYPE_HOST;
|
||||
String name = host.getName();
|
||||
NodeAction action = new NodeAction() {
|
||||
public void run() {
|
||||
RSEDOMExporter.getInstance().createNode(dom, host, true);
|
||||
}
|
||||
};
|
||||
addNode(type, name, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a filter pool to the envelope.
|
||||
* If a filter pool of the same name is already present in the envelope the new filter pool will
|
||||
* be renamed prior to adding it.
|
||||
* @param pool the filter pool to be added to the envelope
|
||||
*/
|
||||
public void add(final ISystemFilterPool pool) {
|
||||
// add the pool
|
||||
String type = IRSEDOMConstants.TYPE_FILTER_POOL;
|
||||
String name = pool.getName();
|
||||
NodeAction action = new NodeAction() {
|
||||
public void run() {
|
||||
RSEDOMExporter.getInstance().createNode(dom, pool, true);
|
||||
}
|
||||
};
|
||||
addNode(type, name, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a property set to the envelope.
|
||||
* If a property set of the same name is already present in the envelope the new property set will
|
||||
* be renamed prior to adding it.
|
||||
* @param propertySet the property set to be added to the envelope
|
||||
*/
|
||||
public void add(final IPropertySet propertySet) {
|
||||
// add the property set
|
||||
String type = IRSEDOMConstants.TYPE_FILTER_POOL;
|
||||
String name = propertySet.getName();
|
||||
NodeAction action = new NodeAction() {
|
||||
public void run() {
|
||||
RSEDOMExporter.getInstance().createNode(dom, propertySet, true);
|
||||
}
|
||||
};
|
||||
addNode(type, name, action);
|
||||
}
|
||||
|
||||
private IStatus saveProviderId(File parent, IRSEImportExportProvider provider) {
|
||||
IStatus status = Status.OK_STATUS;
|
||||
String providerId = provider.getId();
|
||||
|
@ -347,7 +328,7 @@ public class RSEEnvelope {
|
|||
return providerId;
|
||||
}
|
||||
|
||||
private void addNode(String type, String name, NodeAction action) {
|
||||
private void addNode(String type, String name, Runnable action) {
|
||||
ensureDOM();
|
||||
RSEDOMNode existingNode = dom.getChild(type, name);
|
||||
if (existingNode != null) {
|
||||
|
@ -358,14 +339,10 @@ public class RSEEnvelope {
|
|||
|
||||
private void ensureDOM() {
|
||||
if (dom == null) {
|
||||
initialize();
|
||||
dom = new RSEDOM("dom"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
dom = new RSEDOM("dom"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private String generateName(List usedNames) {
|
||||
String prefix = "env_"; //$NON-NLS-1$
|
||||
int n = 0;
|
||||
|
@ -487,4 +464,19 @@ public class RSEEnvelope {
|
|||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a file handle to a temporary directory
|
||||
*/
|
||||
private File getTemporaryFolder() {
|
||||
IPath stateLocation = RSECorePlugin.getDefault().getStateLocation();
|
||||
File stateFolder = new File(stateLocation.toOSString());
|
||||
File envelopesFolder = new File(stateFolder, "envelopes"); //$NON-NLS-1$
|
||||
envelopesFolder.mkdir();
|
||||
List envelopeNames = Arrays.asList(envelopesFolder.list());
|
||||
String envelopeName = generateName(envelopeNames);
|
||||
File envelopeFolder = new File(envelopesFolder, envelopeName);
|
||||
envelopeFolder.mkdir();
|
||||
return envelopeFolder;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue