The push-to-client feature provides a means of sharing IDE configurations between users. Developers can export their own configurations locally so that at a later time they are able to restore a previous IDE environment. For a team of developers, a single IDE can be set up and then, by way of push-to-client, shared on a common server. When developers connect to that server, they automatically have their IDE synchronized with the previously exported configuration. In this way, common settings can be shared across teams.
com.ibm.etools.systems.pushtoclient.core
org.eclipse.core.resources
org.eclipse.core.runtime
org.eclipse.ui
<extension
point="com.ibm.etools.systems.pushtoclient.core.configurationExtensions">
<configurationExtension
class="p2c.test.ConfigurationExtension1"
description="Custom Elements"
icon="icons/obj.gif"
id="p2c.test.configurationExtension1"
name="Test Extension">
</configurationExtension>
</extension>
Each extension needs to have a class, description, icon, id,
and name. The functionality of the contribution
is embedded in the class. The class needs to implement IConfigurationExtension.
In most cases it is preferable to extend the ConfigurationExtension
implementation.package p2c.test;
import com.ibm.etools.systems.pushtoclient.core.extensions.IConfigurationElement;
import com.ibm.etools.systems.pushtoclient.core.extensions.ConfigurationElement;
import com.ibm.etools.systems.pushtoclient.core.extensions.ConfigurationExtension;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IProgressMonitor;
public class ConfigurationExtension1 extends ConfigurationExtension {
public ConfigurationExtension1(String id, String name, String description){
super(id, name, description);
}
public void populateExportElements(IConfigurationElement parent){
parent.setToExport(true);
}
In this case, users will only have the choice of taking
all the configuration information or none.@Override
public void populateExportElements(
IConfigurationElement parent) {
// folder representing one category of items
ConfigurationElement folderElement = new ConfigurationElement("Element X", "Custom properties X");
parent.add(folderElement);
// contents of first category
ConfigurationElement stuff = new ConfigurationElement("X child element", "");
stuff.setToExport(true);
folderElement.add(stuff);
folderElement.setToExport(true);
// folder representing another category of items
ConfigurationElement folderElement2 = new ConfigurationElement("Element Y", "Custom properties Y");
parent.add(folderElement2);
// contents of the second category
ConfigurationElement thing1 = new ConfigurationElement("Y child element 1", "");
folderElement2.add(thing1);
thing1.setToExport(true);
ConfigurationElement thing2 = new ConfigurationElement("Y child element 2", "");
folderElement2.add(thing2);
folderElement2.setToExport(true);
parent.setToExport(true);
}
When exporting via a push-to-client wizard, the elements will appear like this:

The name and description of the root element for this extension, Test Extension, comes from the extension point, whereas the child elements are produced via the implementation of populateExportElements().
The exportToCache() method is called when a user finishes the export wizard. The elements of the configuration extension are passed in and, depending on the items that were selected, the corresponding configuration artifacts are saved in a format under the supplied cachedFolder directory. The format is determined by the implementer. This cachedFolder directory is unique for each configuration extension and uses the configuration id as the name.
@Override
public void exportToCache(IConfigurationElement element,
IFolder cacheFolder, IProgressMonitor monitor) {
// find all the elements that are "set to export" and
// then save to the cache folder
if (element.hasChildren()){
IConfigurationElement[] folders = element.getChildren();
for (IConfigurationElement folder: folders){
if (folder.isSetToExport()){
IConfigurationElement[] children = folder.getChildren();
for (IConfigurationElement child: children){
if (child.isSetToExport()){
// store in model for export
...
}
}
}
}
// create file to store exported information
IFile file = cacheFolder.getFile(new Path("test.properties"));
...
}
}
After a configuration has been exported to the cache directory, the base push-to-client framework takes care of the rest of the operation. If you are exporting to a local location, the cached information will be archived in that location If you are exporting to a common server, the changed information will be archived and transferred to that server.
When importing configurations, the push-to-client framework first downloads the exported configuration archive to the Eclipse workspace and then extracts the archive contents under the RemoteSystemsTempFiles folder. As with export, with import there is a cached folder for each configuration extension; this is the same folder that is used for export. The import wizard needs to prompt the user for elements to import. As with populateExportElements(), each configuration extension implements populateImportElements() by creating configuration elements to represent the incoming information. The sole parameter for this method is an element which will return the cached folder for your configuration extension.
@Override
public void populateImportElements(
IConfigurationElement parent) {
// parent file is the cached folder for this configuration
File parentFile = parent.getFile();
// test.properties is contained in the parent folder
File testFile = new File(parentFile, "test.properties");
// read and parse the file and populate import elements based on contents of testFile
...
The following dialog will show up in response to the import. Typically everything being imported is selected by default.

@Override
public void importToWorkspace(IConfigurationElement element,
IProgressMonitor monitor) {
// find all the elements that are "set to export" (same as "set to import")
if (element.hasChildren()){
IConfigurationElement[] folders = element.getChildren();
for (IConfigurationElement folder: folders){
if (folder.isSetToExport()){
IConfigurationElement[] children = folder.getChildren();
for (IConfigurationElement child: children){
if (child.isSetToExport()){
// transfer the corresponding information to the workspace ...
}
}
}
}
}
}