快速业务通道

创建自己的Eclipse插件模板-通过定制现有的模板满足特定需求 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-14
s();   //monitor finish action in this wizard   monitor.beginTask("perform finish", sections.length);   ...   //get sections   for (int i = 0; i <sections.length; i++) {     if (sections[i].getClass().equals(PerspectiveSection.class)) {       perspectiveSection = (PerspectiveSection) sections[i];     } else if (sections[i].getClass().equals(ViewSection.class)) {       viewSection = (ViewSection) sections[i];     }   }   ...   //set variables to sections and manage sections   ...   viewSection.setViewClassName(values[j]);   viewSection.setSourcePath(sourceFolderName);   viewSection.execute(project, model, new SubProgressMonitor(monitor, 1));      perspectiveSection.setSourcePath(sourceFolderName);   perspectiveSection.setViewNames(viewNames);   perspectiveSection.execute(project, model, new SubProgressMonitor(monitor, 1)); }

创建自己的Eclipse插件模板-通过定制现有的模板满足特定需求(5)

时间:2011-11-02 IBM Jie Tang

新特性 B:UI 组件定制

正如前面提到的,透视图可以包含用户所需的任意数量的视图,用户可以设置每个视图的名称。为了 收集一个透视图中的所有视图,我们设计了下面的输入面板。它有一个 View Class Name 框和一个 View List 框。用户可以输入视图类名,然后通过单击 Add 把它添加到视图列表中。用户还可以使?? Remove 按钮删除视图。

图 4. 定制的模板选项

创建自己的Eclipse插件模板-通过定制现有的模板满足特定需求 - 编程入门网

为了创建这个面板,在模板项目中添加 ViewOption,它扩展 TemplateOption(见图 3)。我们使用 它设置 UI 组件并存储用户的输入。清单 2 演示如何用一个视图列表和两个按钮定制 UI 组件。

清单 2. ViewOption.java

        //add UI components in this panel
public void createControl(Composite parent, int span) {
  ...
  //create View List
  listLabel = new Label(parent, SWT.LEFT);
  listLabel.setText("View List:");
  listViewerField = new ListViewer(parent);
  listField = (List) listViewerField.getControl();
  GridData listGridData = new GridData(GridData.FILL_HORIZONTAL);
  listGridData.heightHint = 100;
  listField.setLayoutData(listGridData);
...
  //create add button
  addButton = new Button(parent, SWT.PUSH);
  addButton.setText("Add");
  ...
  addButton.setLayoutData(addBtnData);
  addButton.addSelectionListener(...);
  //create remove button
  removeButton = new Button(parent, SWT.PUSH);
  ...
  removeButton.addSelectionListener(...);
}

创建自己的Eclipse插件模板-通过定制现有的模板满足特定需求(6)

时间:2011-11-02 IBM Jie Tang

新特性 C:输入检验功能

输入检验功能是指在使用所有用户输入之前对它们进行检验的过程。输入检验功能对于应用程序的安 全性是极其重要的。在我们的示例中,定义一条检验规则:对于一个透视图中的所有视图,视图类名必须 是惟一的。如果违反此规则,就会在面板顶部显示一条错误消息。

图 5. 定制检验的模板选项

创建自己的Eclipse插件模板-通过定制现有的模板满足特定需求 - 编程入门网

可以通过调用相应区段类中的 validateOptions 方法实现输入检验功能。这个方法是从超类继承的, 可以通过覆盖它实现自己的检验功能。清单 3 给出此示例中的 validateOptions 方法。

清单 3. ViewSection.java 中的 validateOptions 方法

public void validateOptions(TemplateO

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号