10)使用ISMP 11.5的project file
ISMP 11.5的project file是uip格式的,IA不能直接打開(kāi)它。我們可以在ISMP 11.5中導(dǎo)出一種DIM file,然后在
IA的organization-->DIM Reference-->add DIM Reference中使用它。ISMP 11 sp1之前的版本IA不再兼容
11)installer運(yùn)行時(shí)參數(shù)
你可以在installer運(yùn)行的時(shí)候添加一些參數(shù),比如
installer.exe -i console //在console模式下運(yùn)行
//在silent模式下運(yùn)行,由于silent模式不會(huì)有任何界面,所以你可以
//設(shè)置一些安裝的屬性,格式如下:
installer.exe -i silent <propertyname>=<value>
//具體實(shí)例:
installer.exe -i silent USER_INSTALL_DIR=C:\Mydirectory
//如果你屬性很多,你可以都寫(xiě)在一個(gè)文件中,然后引用就可以了
installer.exe -i silent -f <path to the properties file>
12)用代碼啟動(dòng)IA的build
稍微復(fù)雜一點(diǎn)的java項(xiàng)目在編譯打包的時(shí)候都少不了要用到ant。如果我們要在ant中啟動(dòng)IA來(lái)制作安裝程序該怎么做呢
IA的安裝目錄下有一個(gè)build.exe,用它就可以了。
build.exe <path to IA project file>
13)source path
在Edit菜單里面可以設(shè)置source path。感覺(jué)它跟ISMP的alias是一樣的。無(wú)非就是讓你設(shè)置IA_HOME,PROJECT_HOME等等。
和alias不同的是,source path都是global,沒(méi)有project類(lèi)型的。source path存放在C:\Documents and Settings\Administrator\InstallAnywhere\80\Enterprise\preferences中
14)merge modules
當(dāng)我們需要有一個(gè)project包含其他project的時(shí)候,就要用到merge modules。最典型的例子就是office包含word,powerpoint
,excel等。merge modules最少要有兩個(gè)project,一個(gè)parent project,若干個(gè)child project。merge modules主要有以下幾種:
i. design time merge module
這種merge module直接把child project拷貝到了parent project中,child project中的panel和action都會(huì)在parent project
的安裝過(guò)程中出現(xiàn),并且你可以在parent project中修改它們。如果原來(lái)的child project做了某些變化,parent project中的child project不會(huì)有任何變化。
這種merge module只生成一個(gè)uninstaller,它會(huì)卸載掉整個(gè)軟件產(chǎn)品。如果要只卸載child project,好像可以通過(guò)把child project
設(shè)成feature來(lái)實(shí)現(xiàn),但我目前還沒(méi)有實(shí)驗(yàn)過(guò)。
ii. dynamic time merge module
這種merge module不拷貝child project到parent project中,它只鏈接到child project。所以child project的任何變化都會(huì)反映到
parent project中。但是你不能在parent project中修改child project的panel和action,因?yàn)槟阒皇擎溄拥絚hild project。
這種merge module會(huì)生成多個(gè)uninstaller,分別用來(lái)卸載parent project 和child projects。
iii. build time merge module
和dynamic time merge module類(lèi)似,不同的是build time merge module不會(huì)出現(xiàn)child project的panel。換句話(huà)說(shuō),child project是以silent模式安裝的。
怎么在具體的項(xiàng)目中用merge module呢?首先,你需要把child project build成merge module,會(huì)生成一個(gè)文件。然后在parent project的
orgnization-->Modules 導(dǎo)入就可以了
15)Custom Code
IA的advanced designer已經(jīng)可以滿(mǎn)足大部分用戶(hù)的需要了,如果你所要的功能advanced designer還無(wú)法實(shí)現(xiàn),你可以自己編寫(xiě)Custom Code來(lái)實(shí)現(xiàn)。可以說(shuō)
Custom Code是IA的more advanced designer。
Custom Code分成以下幾種:
i.custom code actions
ii.custom code panels
iii.custom code consoles
iv.custom code rules
在IA的安裝目錄下有一個(gè)javadoc目錄,里面有IA提供的api的文檔,跟java的api的文檔的使用方法是一樣的。IA為以上四種Custom Code提供了四個(gè)
缺省的類(lèi)來(lái)實(shí)現(xiàn),分別是CustomCodeAction,CustomCodePanel,CustomCodeConsoleAction,CustomCodeRule,你可以去繼承它們并添加你需要的
功能。
代碼寫(xiě)好了之后不能直接用于IA中,還需要編譯,打包。打包有兩種方法
一)打包成類(lèi)的JAR包
先寫(xiě)好代碼,然后用javac命令編譯(當(dāng)然你也可以用eclipse,netbean來(lái)得到class文件),最后把class file壓成jar包。
點(diǎn)擊Add Action-->Execute Custom Code,指定你的jar包的位置,如果用到了第三方的jar包,記得把它們添加到“Dependencies”中
ps:點(diǎn)擊Add Action,你會(huì)看到有四個(gè)tab:General,Panels,Consoles,Plug-ins。如果你是Custom Code Action,要選擇General里面的
Execute Custom Code,如果你是custom code panels,你要選擇Panels里面的Execute Custom Code,如果是custom code consoles,
要選擇Consoles里面的Execute Custom Code,如果是custom code rules,不能通過(guò)Add Action添加,你需要點(diǎn)擊Add Rule-->evaluate custom code
來(lái)執(zhí)行
二)打包成plugin
先寫(xiě)好代碼,然后用javac命令編譯(當(dāng)然你也可以用eclipse,netbean來(lái)得到class文件)。
創(chuàng)建一個(gè)properties文件,然后把這個(gè)properties文件打包成一個(gè)jar包。可見(jiàn)與第一種方法的區(qū)別就是多了一個(gè)屬性文件
舉一個(gè)屬性文件的例子:
plguin.name=my custom action
plugin.main.class=MySampleAction
plugin.type=action
//如果你寫(xiě)了preinstall,那在preinstall view中Add Action-->Plugin里面可以看見(jiàn)這個(gè)plugin,否則是看不見(jiàn)的。
plugin.available=preinstall,install,postinstall
//property.myproperty=this value
property.database=localhost
打包完成后,把jar包拷貝到IA安裝目錄下的plugins文件夾,然后重啟IA(eclipse的用戶(hù)肯定很熟悉這個(gè)操作吧,呵呵)
然后你就可以在A(yíng)dd Action-->Plug-Ins里面發(fā)現(xiàn)你自己寫(xiě)的plugin了。
最后列一下IA提供的api中比較重要的方法(IA提供了一個(gè)zip包IAClasses.zip在IA安裝目錄下)
public class MySampleAction extends CustomCodeAction
{
public void install(InstallerProxy ip)
{
}
}
subsititue(String var)-recursively gets the variable value
getVariable(String var)- jaut gets the variable value
for example:
database_name=$user_install_dir$/mydir
subsititue(String var) C:\pf\macrovision\mydir
getVariable(String var)
$user_install_dir$/mydir
public class MyCustom Panel extend CustomCodePanel{
public boolean setupUI(CustomCodePanelProxy ccpp){
//execute some condition or logic
return true or false;//if true ,display,or don't display
public voidpanelIsDisplayed()
{//you will put controls and logic for displaying the panel
//this is where you will use java's swing classes to display controls on your dialogs
//just for text area,if you wanna add a button to the bottom,then you need
//to create a new dialog by swing ,
}
public boolean okToContinue()
{
}
}
}
public class MyCustomConsole extend CustomCodeConsoleAction{
public boolean setup(CustomCodePanelProxy ccpp){
//any validation you want to execute before displaying this console panel
you will put here
}
}
}
public class MyCustomRule extends CustomCodeRule{
public void evaluateRule()
{
//in this method,you can put the logic to evaulate this custom rule
//return true or false
}
}
}
在IA安裝目錄下的Custom Code文件夾,你可以找到一些sample code,更多的sample code可以到
它的網(wǎng)站上查詢(xún)。
最后,引用training teacher的一句話(huà)作為本文的結(jié)尾“不管你的產(chǎn)品有多好,用戶(hù)第一印象是看你的安裝程序,如果你的安裝程序不夠人性化,甚至安裝失敗了,那用戶(hù)對(duì)它的評(píng)價(jià)就不會(huì)高”