置顶随笔
摘要: 1.在tabbedProperties(eclipse3.2以上支持)中,如果要建立一个treeview,且想要click任何一列都可以实现celledit,需要在创建treeview的时候加上style: SWT.FULL_SELECTION
2.tabbedProperties中section的大小现在无法做到根据widget的大小自动调整,目前只能用getMinimumHeight()返回一个固定值
阅读全文
2008年12月2日
1.有的时候在project的java build path中定义好了一些jar包依赖,但是project在运行的时候仍然报NoClassDef的错误.这是因为project的MANIFEST.MF文件没有更新.手动在MANIFEST.MF加上那些jar包就可以了.
2.Plugin A 依赖 Plugin B.B也把相应的package export出来了,但是A还是找不到B里面定义的类.修改A的MANIFEST.MF文件,在dependence tab里去掉Plugin B,再添加B.此时发现有5,6个同样的Plugin B出现在选择plugin的list中.cancel 掉该对话框,然后重启eclipse,在A的dependence里面重新加上B,问题解决.
2008年10月14日
由于Eclipse的易扩展性,理论上可以有无数个Action运行在一个RCP 程序中,但是快捷键是有限的,尤其是一些常用的,像Ctrl+C,Ctrl+S之类的普通用户能记得住的就那么几个,万一你自定义的Action的快捷键和Eclipse默认的发生了冲突怎么办?比如Eclipse默认Ctrl+S是Save的快捷键,但是你又自定义了一个SaveAction,希望用户按下Ctrl+S之后执行的是自己的SaveAction的run方法.
一般给Action绑定快捷键的方法是自定义binding和command,然后在action中指定definition id为command的id.如下:
<extension
point="org.eclipse.ui.bindings">
<key
commandId="myplugin.actions.save"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+S">
</key>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="myplugin.actions.save"
name="Save">
</command>
</extension>
这样的方法一般是不会有冲突的,但是像我们上面提到的情况,如果你自定义一个binding,它的key sequence是Ctrl+S,那就会有问题.由于org.eclipse.ui插件已经提供了一个Ctrl+S的快捷键,所以系统中会有两个Ctrl+S,这样Eclipse会在右下角pop up一个assist dialog,让你从两个Action中选择一个,这样可能会造成一些用户使用上的不习惯.
解决办法:
1.直接改快捷键.
这个最简单了,比如把你自己的save定义成Alt+S.但是这个方法也是最不好的方法,因为很多用户并不知道Alt+S在你的程序里面就是save.
2.修改自定义action的definition id
我们刚才说过,action的definition id绑定着一个command,而command又对应着一个binding,Eclipse通过这样的方式实现action和快捷键的绑定.我们再来看看Eclipse定义的command和key binding(摘自org.eclipse.ui的plugin.xml):
<command
name="%command.save.name"
description="%command.save.description"
categoryId="org.eclipse.ui.category.file"
id="org.eclipse.ui.file.save" />
<key
commandId="org.eclipse.ui.file.save"
sequence="M1+S"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
<key
Eclipse的Save Action把definition id指定为org.eclipse.ui.file.save,然后它就和上面的command进行了绑定,而这个command对应的key就是"M1+S"(Ctrl + S),这样就实现了快捷键绑定.如果我们也把自定义的Save Action的definition id指定为org.eclipse.ui.file.save,是不是就可以达到目的呢?答案是肯定的.
Eclipse中的Action存在着一个类似"优先级"的概念(具体实现是通过action handler).越"具体"的action,优先级越高.Eclipse的Save Action明显是一个global的action,(同样的global action还有copy, cut,undo,redo等等).而我们自定义的action一般是实现了IWorkbenchWindowActionDelegate接口的,就是说,它是contribute to workbench window的,它是一个workbench action,它的优先级就高于任何global action.同理,如果你定义一个editor action或者view action,由于它比workbench还"具体"(workbench可以包含多个editor或view,workbench action对这些editor或view都是有效的;而editor action只对某个具体的editor有效),所以editor action的优先级就高于workbench action.这样,如果自定义的action和eclipse缺省的action都绑定到同一个command,那么eclipse runtim最后会选择自定义的action来执行.
3.终极解决大法:自定义schema
Eclipse 有一个default的快捷键schema文件:org.eclipse.ui.defaultAcceleratorConfiguration.它存储着Eclipse所有的快捷键.如果你自定义一个自己的schema文件,并把它设成当前使用的schema文件,那么Eclipse就会调用自定义的schema文件.(新的schema文件可以在org.eclipse.ui.bindings扩展点中定义,请注意,在定义新schema的时候由一个parentID属性,如果你定义了它,新的schema会像类继承一样把parent schema里面的key binding全继承下来.如果不定义,则是一个全新的schema)
假定我们已经有了一个新的schema文件,id是myplugin.schema.然后我们在org.eclipse.ui.bindings下定义一个key:
<key
commandId="myplugin.actions.save"
contextId="org.eclipse.ui.contexts.window"
schemaId="myplugin.schema"
sequence="CTRL+S">
</key>
我们已经把schemaId换成了myplugin.schema,表示我们把CTRL+S加到了myplugin.schema中,然后把新建的schema文件在product配置文件plugin_customization.ini中设置成当前的key schema文件:
org.eclipse.ui/KEY_CONFIGURATION_ID=myplugin.schema
这种方法虽然麻烦了一点,但却可以治标又治本.而且由于可以指定parent schema,我们完全可以把org.eclipse.ui.defaultAcceleratorConfiguration作为parent schema,继承它全部的快捷键配置,只定制几个会产生冲突的快捷键即可
2008年8月12日
gef中经常会有很多连线,这些连线如何和每个node连接,允不允许交叉等等都是用router来控制的.网上有篇文章对这个做了一些介绍:
http://www-128.ibm.com/developerworks/cn/opensource/os-ecl-gef/part2/
我现在做的这个项目需要在两个node之间同时存在多根线,如果不使用router的话就只能看见一根,在diagram的 figure里面set一个FanRouter作为缺省的router就可以解决这个问题.两个node之间如果存在多根连线的话,FanRouter会把它们分布成扇形,每根连线都可以看见.但是FanRouter好像只能在diagram的figure里面设置,如果每根connection你都设置成FanRouter,反而不会启效果,这可能跟它的handlecollision方法的算法有关.
但是设置成FanRouter之后有一个问题:我的项目中还有那种自连接的connection(该connection的source和target是同一个node),原先我是把这种connection的router设置为bendconnectionrouter,但是后来设置了FanRouter之后BendConnectionRouter好像就失效了,不管你的connection上面有多少个bendpoint都看不出来效果.
后来终于找到了让这两张router和平共处的办法,只要加一行:fanRouter.setNextRouter(new BendPointConnectionRouter());setNextRouter这个方法有点怪,按照字面的理解,应该是fanrouter的下一个router,按理说应该是先用fanrouter来layout 连线,然后再使用BendPointConnectionRouter来layout 连线,但是它实际上是先用BendPointConnectionRouter来layout 连线,然后再使用fanRouter.
2008年8月5日
GEF中自带有Directeditrequest,所以实现Directedit还是比较容易的,八进制的gef例子里面就有实现.但我在给directedit加上content assist的时候却发现由一个小bug不太好弄,费了两天才搞定,现在先记下来,以供参考
directedit是通过一个text celleditor来实现编辑功能的,所以可以在directeditmanager类里面的initCellEditor方法里面加上ContentAssistHandler来实现auto complete.但是加上去之后却发现有一个问题:不支持用鼠标来选择proposal.只能用键盘上的上下箭头来选择.虽然也可以用,但是终究不是那么的人性化.
为了修复这个bug,走了不少的弯路,一开始以为是contentassist的问题,因为它是deprecated,所以换了3.3里面的assist api,发现还是不行.后来才知道是因为celleditor有一个focus listener,当用户点击proposals 来选择一行的时候,celleditor的focus就lost了,就会调用focusLost方法,导致directedit编辑失败.所以我重写了celleditor的focusLost方法,把它设成当focus在contentassist的popup dialog就什么都不干,否则调用父类的focusLost方法.理论上是一个好的解决方法,但是contentassist的hasPopupFocus居然一直都返回false,这个方法也失败了.
最后,在bug.eclipse.org上面有人提到GMF里面的TextDirectEditManager是可以做到用鼠标选择proposal的,于是又去看gmf的这个类,它也是继承自DirectEditManager,不过它消除这个bug不是在listener上作文章,而是在commit方法里面,在这个方法里面判断popup dialog是否是active的,如果是的话则给celleditor加上deactive lock,不允许它deactive,这样来实现用鼠标选择proposal.
下面是TextDirectEditManager的方法commit里面的部分代码:
Shell activeShell = Display.getCurrent().getActiveShell();
if (activeShell != null
&& getCellEditor().getControl().getShell().equals(
activeShell.getParent())) {
Control[] children = activeShell.getChildren();
if (children.length == 1 && children[0] instanceof Table) {
/*
* CONTENT ASSIST: focus is lost to the content assist pop up -
* stay in focus
*/
getCellEditor().getControl().setVisible(true);
((MyTextCellEditor) getCellEditor()).setDeactivationLock(true);
return;
}
}
下面是MyTextCellEditor里面对于deactive lock的应用,MyTextCellEditor的deactive之前会判断一下deactive lock是否为true:
public boolean isDeactivationLocked() {
return deactivationLock;
}
public void deactivate() {
if (! isDeactivationLocked())
super.deactivate();
setDeactivationLock(false);
}
public void setDeactivationLock(boolean deactivationLock) {
this.deactivationLock = deactivationLock;
}
2008年5月27日
使用java自带的xml api生成的xml文件,其格式都是没有缩进的,每个element都是顶到最前面,今天终于找到了比较好的处理方法,赶紧记下来.
使用Java标准的JAXP来输出可以使用:
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(new DOMSource(document), new StreamResult(outputFile));
中间的红色代码是用于设置缩进的,比较遗憾的是JAXP只抽象出是否设置缩进(indent: yes|no),但并没有抽象出设置缩进量长度的常量(indent-number),所以默认的缩进量长度为0。如果有下面这样一个xml文档:<root><a><b>c</b></a></root>会被格式化为:
<root>
<a>
<b>c</b>
</a>
</root>
由于JAXP只是一个Java一个处理XML的框架,根据实现的不一样,可以传入实现特定的某个Key来设置缩进量。比如在Java 1.4下面,可以通过下面语句将缩进量设为2:
ransformer.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount", "2");
或
transformer.setOutputProperty(
"{http://xml.apache.org/xalan}indent-amount", "2");
上面两句不同之处仅在于命名空间。
而在Java 1.5下面,情况就有些复杂了。Java 1.5集成了JXAP 1.3(Java 1.4集成的是JXAP 1.1,不同之处参见http://java.sun.com/j2se/1.5.0/docs/guide/xml/jaxp/JAXP-Compatibility_150.html),实现基于Xerces类库。由于内部实现上的Bug,导致了设置缩进的不同:
TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute("indent-number", new Integer(2));
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(new DOMSource(document), new StreamResult(new?BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile)))));
注意红色代码的不同之处。第一句设置TransformerFactory的indent-number属性,在Java 1.4下面运行会抛出异常,因为其不支持该属性,而在Java 1.5中却只能通过该属性来设置缩进。后面标为红色的代码则是由于Sun实现上的Bug,只有通过StreamResult(Writer)构造函数生成才能正确设置缩进(通过OutputStream或者File生成的StreamResult是无法设置缩进的,其实现上会忽略任何非正式的属性,而仅仅采用rt.jar下面com\sun\org\apache\xml\internal\serializer\output_xml.properties中的配置。详细可以在com.sun.org.apache.xml.internal.serializer.ToStream类的setOutputStream方法中加断点进行分析)
?
如果忽略掉可移植性,确认绑定在Sun的JRE实现上面,则可以通过如下代码来更好的实现:
OutputFormat format = new OutputFormat(document);
format.setIndenting(true);
format.setIndent(2);
Writer output = new BufferedWriter( new FileWriter(outputFile) );
XMLSerializer serializer = new XMLSerializer(output, format);
serializer.serialize(document);
但是OutputFormat类和XMLSerializer类都是位于com.sun.org.apache.xml.internal.serialize包下。
如果应用对增加一个300K左右的jar包不敏感的话,我还是强烈推荐用dom4j来处理xml,其API设计的非常易用,写出来的代码比用JXAP写出来的代码漂亮多了,也容易维护,也不会出现上面那种两个Java版本不兼容的问题。
2008年5月6日
Java 对文件进行读写操作的例子很多,让初学者感到十分困惑,我觉得有必要将各种方法进行
一次分析,归类,理清不同方法之间的异同点。
一.在 JDK 1.0 中,通常是用 InputStream & OutputStream 这两个基类来进行读写操作的。
InputStream 中的 FileInputStream 类似一个文件句柄,通过它来对文件进行操作,类似的,在
OutputStream 中我们有 FileOutputStream 这个对象。
用FileInputStream 来读取数据的常用方法是:
FileInputStream fstream = new FileInputStream(args[0]);
DataInputStream in = new DataInputStream(fstream);
用 in.readLine() 来得到数据,然后用 in.close() 关闭输入流。
完整代码见 Example 1。
用FileOutputStream 来写入数据的常用方法是:
FileOutputStream out out = new FileOutputStream("myfile.txt");
PrintStream p = new PrintStream( out );
用 p.println() 来写入数据,然后用 p.close() 关闭输入。
完整代码见 Example 2。
二.在 JDK 1.1中,支持两个新的对象 Reader & Writer, 它们只能用来对文本文件进行操作,而
JDK1.1中的 InputStream & OutputStream 可以对文本文件或二进制文件进行操作。
用FileReader 来读取文件的常用方法是:
FileReader fr = new FileReader("mydata.txt");
BufferedReader br = new BufferedReader(fr);
用 br.readLing() 来读出数据,然后用br.close() 关闭缓存,用fr.close() 关闭文件。
完整代码见 Example 3。
用 FileWriter 来写入文件的常用方法是:
FileWriter fw = new FileWriter("mydata.txt");
PrintWriter out = new PrintWriter(fw);
在用out.print 或 out.println 来往文件中写入数据,out.print 和 out.println的唯一区别是后者写
入数据或会自动开一新行。写完后要记得 用out.close() 关闭输出,用fw.close() 关闭文件。
完整代码见 Example 4。
-------------------------------------------------------------- following is the source code of examples------------------------------------------------------
Example 1:
// FileInputDemo
// Demonstrates FileInputStream and DataInputStream
import java.io.*;
class FileInputDemo {
public static void main(String args[]) {
// args.length is equivalent to argc in C
if (args.length == 1) {
try {
// Open the file that is the first command line parameter
FileInputStream fstream = new FileInputStream(args[0]);
// Convert our input stream to a DataInputStream
DataInputStream in = new DataInputStream(fstream);
// Continue to read lines while there are still some left to read
while (in.available() !=0) {
// Print file line to screen
System.out.println (in.readLine());
}
in.close();
} catch (Exception e) {
System.err.println("File input error");
}
}
else
System.out.println("Invalid parameters");
}
}
Example 2:
// FileOutputDemo
// Demonstration of FileOutputStream and PrintStream classes
import java.io.*;
class FileOutputDemo
{
public static void main(String args[]) {
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
try {
// connected to "myfile.txt"
out = new FileOutputStream("myfile.txt");
// Connect print stream to the output stream
p = new PrintStream( out );
p.println ("This is written to a file");
p.close();
} catch (Exception e) {
System.err.println ("Error writing to file");
}
}
}
Example 3:
// FileReadTest.java
// User FileReader in JDK1.1 to read a file
import java.io.*;
class FileReadTest {
public static void main (String[] args) {
FileReadTest t = new FileReadTest();
t.readMyFile();
}
void readMyFile() {
String record = null;
int recCount = 0;
try {
FileReader fr = new FileReader("mydata.txt");
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null) {
recCount++;
System.out.println(recCount + ": " + record);
}
br.close();
fr.close();
} catch (IOException e) {
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
}
}
}
Example 4:
// FileWriteTest.java
// User FileWriter in JDK1.1 to writer a file
import java.io.*;
class FileWriteTest {
public static void main (String[] args) {
FileWriteTest t = new FileWriteTest();
t.WriteMyFile();
}
void WriteMyFile() {
try {
FileWriter fw = new FileWriter("mydata.txt");
PrintWriter out = new PrintWriter(fw);
out.print(“hi,this will be wirte into the file!”);
out.close();
fw.close();
} catch (IOException e) {
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
}
}
}
2007年7月30日
10)使用ISMP 11.5的project file
ISMP 11.5的project file是uip格式的,IA不能直接打开它。我们可以在ISMP 11.5中导出一种DIM file,然后在
IA的organization-->DIM Reference-->add DIM Reference中使用它。ISMP 11 sp1之前的版本IA不再兼容
11)installer运行时参数
你可以在installer运行的时候添加一些参数,比如
installer.exe -i console //在console模式下运行
//在silent模式下运行,由于silent模式不会有任何界面,所以你可以
//设置一些安装的属性,格式如下:
installer.exe -i silent <propertyname>=<value>
//具体实例:
installer.exe -i silent USER_INSTALL_DIR=C:\Mydirectory
//如果你属性很多,你可以都写在一个文件中,然后引用就可以了
installer.exe -i silent -f <path to the properties file>
12)用代码启动IA的build
稍微复杂一点的java项目在编译打包的时候都少不了要用到ant。如果我们要在ant中启动IA来制作安装程序该怎么做呢
IA的安装目录下有一个build.exe,用它就可以了。
build.exe <path to IA project file>
13)source path
在Edit菜单里面可以设置source path。感觉它跟ISMP的alias是一样的。无非就是让你设置IA_HOME,PROJECT_HOME等等。
和alias不同的是,source path都是global,没有project类型的。source path存放在C:\Documents and Settings\Administrator\InstallAnywhere\80\Enterprise\preferences中
14)merge modules
当我们需要有一个project包含其他project的时候,就要用到merge modules。最典型的例子就是office包含word,powerpoint
,excel等。merge modules最少要有两个project,一个parent project,若干个child project。merge modules主要有以下几种:
i. design time merge module
这种merge module直接把child project拷贝到了parent project中,child project中的panel和action都会在parent project
的安装过程中出现,并且你可以在parent project中修改它们。如果原来的child project做了某些变化,parent project中的child project不会有任何变化。
这种merge module只生成一个uninstaller,它会卸载掉整个软件产品。如果要只卸载child project,好像可以通过把child project
设成feature来实现,但我目前还没有实验过。
ii. dynamic time merge module
这种merge module不拷贝child project到parent project中,它只链接到child project。所以child project的任何变化都会反映到
parent project中。但是你不能在parent project中修改child project的panel和action,因为你只是链接到child project。
这种merge module会生成多个uninstaller,分别用来卸载parent project 和child projects。
iii. build time merge module
和dynamic time merge module类似,不同的是build time merge module不会出现child project的panel。换句话说,child project是以silent模式安装的。
怎么在具体的项目中用merge module呢?首先,你需要把child project build成merge module,会生成一个文件。然后在parent project的
orgnization-->Modules 导入就可以了
15)Custom Code
IA的advanced designer已经可以满足大部分用户的需要了,如果你所要的功能advanced designer还无法实现,你可以自己编写Custom Code来实现。可以说
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的安装目录下有一个javadoc目录,里面有IA提供的api的文档,跟java的api的文档的使用方法是一样的。IA为以上四种Custom Code提供了四个
缺省的类来实现,分别是CustomCodeAction,CustomCodePanel,CustomCodeConsoleAction,CustomCodeRule,你可以去继承它们并添加你需要的
功能。
代码写好了之后不能直接用于IA中,还需要编译,打包。打包有两种方法
一)打包成类的JAR包
先写好代码,然后用javac命令编译(当然你也可以用eclipse,netbean来得到class文件),最后把class file压成jar包。
点击Add Action-->Execute Custom Code,指定你的jar包的位置,如果用到了第三方的jar包,记得把它们添加到“Dependencies”中
ps:点击Add Action,你会看到有四个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,不能通过Add Action添加,你需要点击Add Rule-->evaluate custom code
来执行
二)打包成plugin
先写好代码,然后用javac命令编译(当然你也可以用eclipse,netbean来得到class文件)。
创建一个properties文件,然后把这个properties文件打包成一个jar包。可见与第一种方法的区别就是多了一个属性文件
举一个属性文件的例子:
plguin.name=my custom action
plugin.main.class=MySampleAction
plugin.type=action
//如果你写了preinstall,那在preinstall view中Add Action-->Plugin里面可以看见这个plugin,否则是看不见的。
plugin.available=preinstall,install,postinstall
//property.myproperty=this value
property.database=localhost
打包完成后,把jar包拷贝到IA安装目录下的plugins文件夹,然后重启IA(eclipse的用户肯定很熟悉这个操作吧,呵呵)
然后你就可以在Add Action-->Plug-Ins里面发现你自己写的plugin了。
最后列一下IA提供的api中比较重要的方法(IA提供了一个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可以到
它的网站上查询。
最后,引用training teacher的一句话作为本文的结尾“不管你的产品有多好,用户第一印象是看你的安装程序,如果你的安装程序不够人性化,甚至安装失败了,那用户对它的评价就不会高”
不知道你是否注意过,当你安装java jdk的时候,当你安装微软office的时候,当你装db2的时候,你都会看到一个熟悉的标记---installshield。installshield可以说是当今安装程序解决方案的巨无霸了,功能十分强大,你可以用它制作出你想要的安装程序。但是功能的强大也带来一个坏处,就是要上手非常难。所以公司特意请macrovision(就是制作installshield的公司)的人给我们进行了一个training,感觉收获还是很大的,所以把我认为重要的地方纪录下来,一方面万一自己忘了可以查一查,另一方面说不定对别人也有帮助。
先从版本说起。installshield有专门用于制作java安装程序的产品,由于java是跨平台的语言,所以installshield对应的产品就叫installshield multiple platform,简称ismp。我接触的最早版本是ismp 5.0,后来又出了ismp 11.5,再后来ismp改名字叫Install Anywhere(以下简称IA)。目前我们training用的版本是IA 8.0,相信应该是最新的版本了。IA是共享软件,不注册的话有21天的试用期。
安装程序是一个可定制性非常强的东西,每个软件作者的需求都不一样。有的推崇简单就是美,一般只需要用户选择安装的目录,然后就一路next就装完了;但有的软件非常复杂,比如需要设置参数,需要选择安装哪些部分,甚至需要启动windows的系统服务。这时候就需要比较复杂的配置了。installshield针对两种用户设计了不同的开发环境:一种是common designer,另一种是Advanced Designer。当你第一次打开IA的时候,缺省的是common designer,你只需要做一些简单的配置,比如产品的名称,需要安装的文件,要不要绑定虚拟机等等,然后就可以build出一个安装程序了。Advanced Designer是为高级用户设置的,提供了更多,更丰富的功能,你可以用它来打造你所需要的安装程序。本文主要是针对Advanced Designer进行一些说明。
1)安装模式(install modes)
gui:这是最常用的一种模式,在安装过程中会弹出若干个panel,比如welcome panel,license panel,destination panel等等。
console:用这种模式安装程序时,不会出现panel。它的所有信息都在控制台中出现。说的再通俗一点,就是整个安装过程只有一个dos窗口,这个窗口先会显示一行信息欢迎你安装本软件,然后是让你选择destination,再安装,最后会显示一行安装成功的信息
silent:顾名思义,这种模式在安装的时候不会弹出任何窗口,它会安静地装上软件,所以用户也不能自己设定安装目录,一般都市由安装程序安装到固定的目录上
2)install sets
很多安装程序都有完全安装,最小安装,自定义安装等选项,这一般是用features来实现的。你可以把你的产品分成几个features,然后由用户来选择一部分进行安装。
3)actions
IA中很多操作被称为actions,常见的有copy files,delete files,modifying registry, creating service, modifying configurations files等
4)variable
IA中很重要的一个概念,你可以用variable来存放属性信息,比如安装目录,用户名等等。比如
安装目录可能会在很多地方都用到,如果你安装目录是硬编码的,万一将来要修改就要改
很多地方,容易出错;如果用variable来保存的话,只要修改变量值就可以了。注意一点:variable
的值基本上都是string类型的
5)magic folders
IA里面独有的概念,但感觉没什么新意,就是variables的一种,专门用于定义folder的
variable而已
6)InstallAnywhere registry
不同于windows的registry,这是InstallAnywhere自己的registry。每个用IA制作的安装程序,在安装的过程中
都会把自己注册到这个InstallAnywhere registry(注意:你只能在InstallAnywhere registry找到安装的
component,找不到product)。它的一个典型应用就是当你需要检查这个机器上是否安装过某个软件的时候,就可以
用search这个IA registry。不过如果你是用其他工具制作的安装程序,IA registry就不会有记录了。
7)execute command&execute script
execute command是用来执行command,常用的dos命令(copy,cd等)你都可以写在这里。execute script其实就是
execute command的加强版:如果你有多个命令,不需要建多个execute command,把它们写在execute script就好了
8)计算所需空间
在IA中,默认的空间大小是用byte来计算的,所以如果你的软件比较大的话,那一长串的阿拉伯数字会把用户吓倒的
解决方法是,在pre-install summary panel的配置项中,有一个是Edit Custom Field。在那里新建一个field。Variable
name是显示给用户看的内容,比如你可以写disk space。variable value是你的软件所需的硬盘大小。你可以先算出来
,存在一个变量中,然后让variable value等于这个变量就可以了。
9)results variable
用来存放用户的选择。比如在show message dialog中,有一个results variable是$CHOSEN_DIALOG_BUTTON$
它用来存放用户按的是OK 还是Cancel
2007年6月26日
摘要: How to understand and use Eclipse Production Configuration
...
阅读全文
2007年4月11日
摘要: 1.在tabbedProperties(eclipse3.2以上支持)中,如果要建立一个treeview,且想要click任何一列都可以实现celledit,需要在创建treeview的时候加上style: SWT.FULL_SELECTION
2.tabbedProperties中section的大小现在无法做到根据widget的大小自动调整,目前只能用getMinimumHeight()返回一个固定值
阅读全文