??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
Q?/SPAN>1Q创建工E?/SPAN>
l ?/SPAN>Eclipse中创建如下图的简单工E?/SPAN>
Q?/SPAN>2Q指?/SPAN>Repository位置
l Windows -> Open Perspective -> Other
l 选择CVS Repository Exploring,打开CVS Repository Exploring
l ?/SPAN>CVS Repositories视图中右击,选择New -> Repository Location
l 指定CVSL名和Repository路径Q带/?/SPAN>Repository名)
l 指定用户名和密码
l 指定通信协议Q通常使用pserver
l 点击Finish创徏Repository位置信息
Q?/SPAN>3Q共享工E?/SPAN>
l ?/SPAN>Navigator视图中右dE名Q选择Team -> Share Project
l 选择已创建的Repository位置Q也可以在此处新建)
l ~省使用工程名作为模块名
l 向导的最后一|C工E中要被提交和q加的文?BR>
l
l ׃n后的工程如下图所C?BR>
Q?/SPAN>1Q简q?/SPAN>
l CVS Q?/SPAN>Concurrent Versions SystemQ系l在团队开发项目时q行版本控制Q采用的?/SPAN>C/S架构
l Eclipse内徏?/SPAN>CVS客户端,方便团队CVS控制
l 目前Unixq_都带CVS服务器,Windowsq_比较行的是CVSNTQ?/SPAN>http://www.cvsnt.com/cvspro/Q?/SPAN>
l 先要安装CVSNTQ我的是?/SPAN>Windows 2003 Server上)
l 安装完后启动CVSNT Control PanelQ可以在Service Status中看到q行中的服务
Q?/SPAN>2Q创?/SPAN>CVS Repository
l 选择Repositories,点击Add按钮创徏新的CVS Repository
l Location部分指定保存Repository的目录(可以新徏Q?/SPAN>
l Name部分指定Repository名(?/SPAN>/开始)
l 保Publish Repository选中
l 在确认初始化Repository创建好?/SPAN>Repository
Q?/SPAN>3Q配|选项
l Z?/SPAN>Eclipse能够正常?/SPAN>CVSNT通信Q还要将Compatibility中?/SPAN>Respond as cvs 1.11.2 to version requestw中
Q?/SPAN>4Q用L(fng)?/SPAN>
l CVSNT最单的用户理方式是?/SPAN>NT验证l合Q这P创徏一?/SPAN>NT用户也就创徏了一?/SPAN>CVS用户
l 通过pȝ理员设|用L(fng)讉K权限来控制用户对CVS的访问,例如Qؓ(f)了用户能够?/SPAN>CVS提交更新的文Ӟ必ȝ该用户变更的权限
Q?Q?/FONT> ExpandableComposite
l Web面中一个通用的主题是h收羃一部分面内容的能?
l Eclipse Form也提供了q样一个控Ӟ(x)ExpandableComposite
l 下面的代码片断是使用ExpandableComposite的一个例子:(x)
ExpandableComposite ec = toolkit.createExpandableComposite(body,
ExpandableComposite.TREE_NODE
| ExpandableComposite.CLIENT_INDENT);
ec.setText("Expandable Composite title");
String ctext = "We will now create a somewhat long text so that "
+ "we can use it as content for the expandable composite. "
+ "Expandable composite is used to hide or show the text using the "
+ "toggle control";
Label client = toolkit.createLabel(ec, ctext, SWT.WRAP);
ec.setClient(client);
td = new TableWrapData();
td.colspan = 2;
ec.setLayoutData(td);
ec.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
l q个控g有很多风|TREE_NODE使得该控件具有树(wi)型节点的展开、收~功能;?/SPAN>TWISTIE使得控gh三角头风格
l EXPANDED使得初始展开昄
l CLIENT_INDENT使得Client内容~进寚w
l ExpandableComposite呈现为激zL件和标题Q而可以展开、收~的内容UCؓ(f)Client
l Client必须是可展开?/SPAN>compositeQ上例是Label控gQ?/SPAN>
l 最后需要添?SPAN lang=EN-US>Expansion监听器在状态变化时Qreflow FormQ即Ҏ(gu)控g的新的大重新定位和更新滚动条)
l 下面是上例的q行l果Q?BR>
Q?SPAN lang=EN-US>2QSection
l Eclipse Form中最常用的定制控件就?/SPAN>SectionQ在PDE中到处可见)
l Section扩展ExpandableCompositeQ但h下面的新Ҏ(gu):(x)
n 在标题下面有一个分隔控?SPAN lang=EN-US>
n 在分隔控件下面可以有一个描q文?SPAN lang=EN-US>
l 下面的代码片断是使用Section的一个例子,代码?/SPAN>ExpandableComposite没有太大差别Q这里是用了TWISTIE风格Q?/SPAN>
Section section = toolkit.createSection(body, Section.DESCRIPTION
| Section.TWISTIE | Section.EXPANDED);
td = new TableWrapData(TableWrapData.FILL);
td.colspan = 2;
section.setLayoutData(td);
section.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
section.setText("Section title");
toolkit.createCompositeSeparator(section);
section
.setDescription("This is the description that goes below the title");
Composite sectionClient = toolkit.createComposite(section);
sectionClient.setLayout(new GridLayout());
button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO);
button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO);
section.setClient(sectionClient);
l 下面是上例的q行l果Q?/FONT>
Eclipse Form提供?/SPAN>2个新的布局
Q?/SPAN>1Q?/SPAN>TableWrapLayout
l 问题Q如果将上例中超链接的文本设|的_?/SPAN>
link.setText("This is an example of a form that is much longer and will need to wrap.");
即讄?/SPAN>SWT.WRAPQ文本内容不?x)自?/SPAN>WRAPQ这是因Z内容的布局?/SPAN>GridLayout
l Eclipse Form提供替代的布局TableWrapLayoutQ类gGridLayoutQ但是具有象HTML表格一栯?/SPAN>WRAP功能
l 下面是解册链接文本自动WRAP的例子:(x)
public void createPartControl(Composite parent) {
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);
form.setText("Hello, Eclipse Forms");
Composite body = form.getBody();
TableWrapLayout layout = new TableWrapLayout();
body.setLayout(layout);
Hyperlink link = toolkit.createHyperlink(body, "Click here.", SWT.WRAP);
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
System.out.println("Link activated!");
}
});
layout.numColumns = 2;
link.setText("This is an example of a form that is much longer and will need to wrap.");
TableWrapData td = new TableWrapData();
td.colspan = 2;
link.setLayoutData(td);
Label label = toolkit.createLabel(body, "Text field label:");
Text text = toolkit.createText(body, "");
td = new TableWrapData(TableWrapData.FILL_GRAB);
text.setLayoutData(td);
text.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
Button button = toolkit.createButton(body,
"An example of a checkbox in a form", SWT.CHECK);
td = new TableWrapData();
td.colspan = 2;
button.setLayoutData(td);
toolkit.paintBordersFor(body);
}
l 下面是程序变化的地方Q?/SPAN>
n TableWrapLayout替代GridLayout
n 使用TableWrapData来提供布局数据信息
n 讄的属性?/SPAN>colspan?/SPAN>rowspan{来源于HTML表格单元的属?/SPAN>
l 要注意的是:(x)需要自?SPAN lang=EN-US style="COLOR: black">WRAP的控Ӟ需要设|成SWT.WRAP风格
Q?SPAN lang=EN-US>2Q?/SPAN>ColumnLayout
l ColumnLayout?/SPAN>Eclipse Form提供的另一个定制布局
l ColumnLayout的布局方式是从上到下,从左到右
l 在变?/SPAN>Form的宽度时Q会(x)自动调整控g列数以适应Form的宽?/SPAN>
l ColumnLayout的设|很单,通常只要讄列数的范_(d)~省?/SPAN>1-3Q?/SPAN>
l 在后面的相关部分?x)给Z用的例子
l 既强大又单,有助于更Ҏ(gu)的集?/SPAN>AOP到新的或已存在的目?/SPAN>
l AspectWerkz 主要Ҏ(gu):(x)
Ø q行时和加蝲时字节码修正Q你可以在运行时或编译时L的改造Q何(旧)应用E序或除?/SPAN>rt.jar以外的外部类?/SPAN>
Ø 支持join point模型
Ø 支持AnnotationQ匹?/SPAN>JavaDoc?/SPAN>JSR-175Q支持用戯定义Annotation
Ø 支持部v多个Aspect定义文g到部|的应用E序Q?SPAN lang=EN-US>WEB-INF/aop.xml、META-INF/aop.xmlQ?o:p>
Ø Introduction/内类型声明(也称MixinQ,也就是具有添加接口和实现到已存在的类中的能力
Ø Annotation定义Q定?/SPAN>Aspect使用的运行时AnnotationQؓ(f)JSR-175准备Q?/SPAN>
Ø XML定义Q定?/SPAN>Aspect使用?/SPAN>XMLQ?/SPAN>XML可以用来_、改写和解析Annotation定义
Ø 插g?/SPAN>Aspect理器能够和IoC框架Q如Spring?/SPAN>PicoContainerQ一起工?/SPAN>
Ø 四种不同?SPAN lang=EN-US>Advice和Introduction部v模型Q范_(d)Q?/SPAN>perJVMQ单模式Q?/SPAN> perClass?/SPAN>perInstance ?/SPAN>perThread
Ø Advice和Introduction能够动态部|Ӏ反部v或重新部|?/SPAN>
Ø 高性能Q?SPAN lang=EN-US>JIT~译
Ø 使用Fine-grained模式语言选择join point
Ø 所?SPAN lang=EN-US>Advice能够和所有的join point和各U合类型的pointcut
Ø 脱机变换Q可以用作后处理器)
Ø Aspect?/SPAN>Advice和Introduction使用POJO~码
Ø 目标cd以是正规?SPAN lang=EN-US>POJOQ也是不需要接?o:p>
Ø 支持通过定义传递参数给Advice和定义可重用的Advice堆栈
Ø 元数据被加到cM
Ø 单的用法和配|?SPAN lang=EN-US>
讉Kq_专有信息q不是一件容易的事。虽然可以?/SPAN> Runtime.exec() 创徏q程Q但׃q_之间的差异,构造参数集常常令h头痛不已?/SPAN>Tiger提供了新?/SPAN>ProcessBuilderc,使得讉Kq_专有信息更加Ҏ(gu)?/SPAN>
1?/SPAN>讉K环境变量
System.getenv()有两U方法:(x)
Q?/SPAN>1Q指定环境变量名来获得环境变量|如下面的例子Q?/SPAN>
public class EnvTest {
public static void main(String[] args) {
System.out.println(System.getenv("JAVA_HOME"));
}
}
输出的结果可能是Q?/SPAN>
E:\develop\j2sdk1.4.2_05
Q?/SPAN>2Q?/SPAN>q回所有环境变量的Map对象Q下面的例子输出所有环境变量名和|(x)
public class EnvDump {
public static void main(String[] args) {
for (Entry entry : System.getenv().entrySet()) {
System.out.println(entry.getKey() + "=" + entry.getValue());
}
}
}
2?/SPAN>ProcessBuilder
l 早期Java版本允许使用 Runtime
.exec()
Ҏ(gu)创徏本机q程Q该Ҏ(gu)仍然有效Q但是因Z?/SPAN>String
数组作ؓ(f)参数、以 File
参数作ؓ(f)工作目录Q所以定制子q程比较困难
l 使用新的ProcessBuilder
c?/SPAN>可以化这个过E?/SPAN>
l 下面是一个启?/SPAN>EditPlus的简单的例子Q?/SPAN>
public class ProcessTest {
public static void main(String[] args) throws IOException {
Process p = new ProcessBuilder(“C:\\Program Files\\EditPlus 2\\editplus.exe?.start();
}
}
l 下面是在执行命o(h)时指定参数的例子Q?/SPAN>
public class ProcessTest {
public static void main(String[] args) throws IOException {
Process p = new ProcessBuilder("ping", "sina.com.cn").start();
InputStream is = p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
}
l ProcessBuilder
提供?directory()
Ҏ(gu)改变q程的工作目录,使用 environment()
Ҏ(gu)在进E空间中d和删除环境变?/SPAN>Q下面是来自JDK5的例子:(x)
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
Map<String, String> env = pb.environment();
env.put("VAR1", "myValue");
env.remove("OTHERVAR");
env.put("VAR2", env.get("VAR1") + "suffix");
pb.directory("myDir");
Process p = pb.start();