Push-to-Client フィーチャーは、IDE 構成をユーザー間で共有する方法を提供します。 開発者は自身の構成をローカル側でエクスポートできるため、以前の IDE 環境を後で復元することができます。 開発者のチームは、1 つの IDE をセットアップしてから、Push-to-Client によって、その IDE を共通のサーバーで共有できます。 開発者がそのサーバーに接続すると、自身の IDE が自動的に、以前にエクスポートされた構成と同期します。 このようにして、共通の設定をチーム間で共有することができます。
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>
それぞれの拡張機能に class、description、icon、id、および
name が必要です。
このコントリビューションの機能は、クラスに組み込まれています。
クラスは IConfigurationExtension を実装している必要があります。
多くの場合、ConfigurationExtension 実装を拡張することが理想的です。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);
}
この場合、ユーザーは、すべての構成情報を取り出すか、または何も取り出さないかだけを選択できます。@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);
}
Push-to-Client ウィザードによるエクスポートでは、エレメントは次のように表示されます。

拡張機能「Test Extension」のルート・エレメントの名前および説明は拡張ポイントから取られますが、子エレメントは populateExportElements() の実装によって作成されます。
exportToCache() メソッドは、ユーザーがエクスポート・ウィザードを終了したときに呼び出されます。 構成拡張のエレメントが渡され、選択された項目に応じて、対応する構成成果物が、指定された cachedFolder ディレクトリーの下のフォーマットで保存されます。 このフォーマットは、インプリメンターによって決定されます。 この cachedFolder ディレクトリーは、構成拡張ごとに固有のもので、構成 id を名前として使用します。
@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"));
...
}
}
構成がキャッシュ・ディレクトリーにエクスポートされた後、基本 Push-to-Client フレームワークは残りの操作を処理します。 ローカル・ロケーションにエクスポートする場合、キャッシュされた情報はそのロケーションにアーカイブされます。共通サーバーにエクスポートする場合、変更された情報がアーカイブされ、そのサーバーに転送されます。
構成をインポートするとき、Push-to-Client フレームワークは、エクスポートされた構成アーカイブをまず Eclipse ワークスペースにダウンロードしてから、アーカイブの内容を RemoteSystemsTempFiles フォルダーに解凍します。 エクスポートと同様、インポートでも、構成拡張ごとにキャッシュ・フォルダーがあります。これは、エクスポートに使用されるものと同じフォルダーです。 インポート・ウィザードは、インポートするエレメントについてユーザーにプロンプトを出す必要があります。 populateExportElements() と同様に、それぞれの構成拡張は、受信する情報を表す構成エレメントを作成することによって、populateImportElements() を実装しています。 このメソッド用の唯一のパラメーターは、ご使用の構成拡張のキャッシュ・フォルダーを返すエレメントです。
@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
...
インポートへの応答として、次のダイアログが表示されます。 通常、インポートされるものすべてがデフォルトで選択されています。

@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 ...
}
}
}
}
}
}