GWT with Gears
自分の中で密かに盛り上がっていたgwt-google-apisの
gwt-gears-1.1.0だったのですが
先日、MASHUP AWARDでついにgoogleさんの対象APIとして発表されました。
[新API紹介]Google の審査対象 API を発表!
——————–
GWT with Gears
Gearsのインストール/未インストールにより表示するメッセージを変えてみる。
0.プロジェクトを作成し、GWTモジュールを作成します。
モジュール名は、com.gethapp.sample.gwg.App
としています。
1.上に書いているgwt-gears-1.1.0.zipをダウンロードし、
プロジェクトにgwt-gears.jarを追加します。
2.モジュール.gwt.xmlファイルへgears-apiを使います宣言を追加
<inherits name='com.google.gwt.gears.Gears'/>
3.モジュール.gwt.xmlファイルにgearsのinstall判定を行います。
gearsインストールされている場合は、App、
未インストールの場合はAppNoGearsが起動します。
<replace-with class="com.gethapp.sample.gwg.client.AppNoGears">
<when-type-is class="com.gethapp.sample.gwg.client.App"/>
<when-property-is name="gears.installed" value="false"/>
</replace-with>
App.gwt.xml
<module>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.gears.Gears'/>
<entry-point class='com.gethapp.sample.gwg.client.App'/>
<inherits name="com.google.gwt.user.theme.standard.Standard"/>
<replace-with class="com.gethapp.sample.gwg.client.AppNoGears">
<when-type-is class="com.gethapp.sample.gwg.client.App"/>
<when-property-is name="gears.installed" value="false"/>
</replace-with>
</module>
4.App.javaと同じフォルダーに
新規クラスとしてAppNoGears.javaを作成し、
それぞれの以下の通り修正します。
App.java#onModuleLoad
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
rootPanel.add(new HTML("Gears installed."));
}
AppNoGears.java#onModuleLoad
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
rootPanel.add(new HTML("Gears not installed."));
}
あとは、Installing/Uninstalling Gearsに従って
Gearsでインストールや、Firefoxの場合、プラグインを無効にしたりして
Appを起動して動作確認してください。
#ちなみにマックの場合はhostedモードでは判定できませんでしたが、
#wwwモードでやれば、Firefoxで確認できました。
Leave a Reply