`
- 浏览:
34305 次
-
1、选择java类的Dialog的使用
java 代码
- final IJavaSearchScope searchScope = SearchEngine
- .createWorkspaceScope();
- addButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- TypeSelectionDialog2 dialog = new TypeSelectionDialog2(
- getShell(), false,
- new ProgressMonitorDialog(getShell()), searchScope,
- IJavaSearchConstants.TYPE);
- dialog.setMessage("Select an Entity bean");
- dialog.setBlockOnOpen(true);
- dialog.setTitle("Type Selection");
- if (Dialog.OK == dialog.open()) {
- IType obj = (IType) dialog.getFirstResult();
- String className = obj.getResource().getName();
- String packageName = obj.getPackageFragment()
- .getElementName();
- list.add(packageName + "."+ className);
- }
- }
- });
2、包选择的Dialog的使用
java 代码
- browseButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- IJavaProject javaProject = JavaCore.create(getProject(obj));
- SelectionDialog dialog = null;
- try {
- dialog = JavaUI
- .createPackageDialog(
- getShell(),
- javaProject,
- IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS);
- dialog.setTitle("Package Selection");
- dialog.setMessage("Choose a folder");
- } catch (JavaModelException e1) {
-
- }
- if (dialog.open() != Window.OK) {
- return;
- }
- IPackageFragment pck = (IPackageFragment) dialog.getResult()[0];
- if (pck != null) {
- packageTxt.setText(pck.getElementName());
- }
- }
- });
3、自定义带有多选框的Dialog的创建及其使用
创建:
java 代码
- public class CheckboxSelectionDialog extends Dialog {
-
- class ContentProvider implements IStructuredContentProvider {
- public Object[] getElements(Object inputElement) {
- return new Object[] {};
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- private Table table;
-
- private CheckboxTableViewer ctv;
-
- private TableViewer tv;
-
- private java.util.List initialSelections;
-
- private String[] result;
-
- private String title;
-
- private String label;
-
-
-
-
-
-
- public CheckboxSelectionDialog (Shell parentShell,
- java.util.List initialSelections, String title, String label) {
- super(parentShell);
- this.initialSelections = initialSelections;
- this.title = title;
- this.label = label;
- }
-
-
-
-
-
-
- protected Control createDialogArea(Composite parent) {
- Composite container = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout();
- container.setLayout(gridLayout);
-
- final Label selectLabel = new Label(container, SWT.NONE);
- selectLabel.setLayoutData(new GridData());
-
- selectLabel.setText(label);
-
- tv = new TableViewer(container, SWT.CHECK | SWT.MULTI | SWT.BORDER
- | SWT.FULL_SELECTION);
-
- tv.setContentProvider(new ContentProvider());
- tv.setInput(new Object());
- table = tv.getTable();
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- tv.add(initialSelections.toArray());
-
- return container;
- }
-
-
-
-
-
-
- protected void createButtonsForButtonBar(Composite parent) {
- final Button button = createButton(parent, IDialogConstants.OK_ID,
- IDialogConstants.OK_LABEL, true);
- if (initialSelections.size() <= 0)
- button.setEnabled(false);
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
- }
-
-
-
-
- protected Point getInitialSize() {
- return new Point(300, 375);
- }
-
- public String[] getResult() {
- return this.result;
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
-
- newShell.setText(title);
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- TableItem[] children = table.getItems();
- ArrayList v = new ArrayList(children.length);
- for (int i = 0; i < children.length; i++) {
- TableItem item = children[i];
- if (item.getChecked()) {
- v.add(item.getData());
- }
- }
- int size = v.size();
- result = new String[size];
- for (int i = 0; i < v.size(); i++)
- result[i] = v.get(i).toString();
- }
- super.buttonPressed(buttonId);
- }
-
- }
使用:
java 代码
- List list = new ArrayList();
- for (int i = 0; i < file.length; i++) {
- list.add(i);
- }
-
- CheckModuleSelectionDialog dialog = new CheckModuleSelectionDialog(
- ProjectUtil.getShell(), list, "Select a Project",
- "Select the Project container.");
- if (dialog.open() == ContainerSelectionDialog.OK) {
- String[] result = dialog.getResult();
- }
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
### Eclipse插件开发指南 #### 一、Eclipse概述 **1.1 Eclipse简介** Eclipse是一个开源的、可扩展的集成开发环境(IDE),主要应用于Java开发,但通过插件支持,它也广泛用于C/C++、PHP、Python、Ruby等其他语言...
### Eclipse插件开发知识点概述 #### 一、Eclipse插件开发简介 Eclipse插件开发是指在Eclipse平台上创建自定义插件的过程。Eclipse作为一个开源的集成开发环境(IDE),支持通过添加插件来扩展其功能。《Eclipse...
本章中,我们介绍了Eclipse插件开发中两个重要的扩展点:透视图(Perspectives)和视图(Views)。通过学习这些扩展点,开发者可以轻松地构建定制化的开发环境,满足不同项目的需求。在实际开发中,还有许多其他扩展...
由于其高度可扩展性,用户可以通过安装各种插件来增强Eclipse的功能,满足特定的需求。本文主要介绍一种常用的插件安装方法——通过外部目录安装插件。 #### 二、准备工作 在详细介绍安装方法之前,首先需要做一些...
- **广泛的插件支持**:用户可以根据需求安装各种插件来扩展Eclipse的功能。 - **良好的社区支持**:拥有活跃的用户社区和丰富的文档资源。 #### 下载Eclipse的准备工作 在下载Eclipse之前,需要确保已经安装了Java...
安装过程中,Eclipse可能会提示你安装额外的依赖项,如SVN连接器,确保都勾选上并继续安装。 安装完毕后,需要重启Eclipse以使新安装的插件生效。重启后,你可以在Eclipse的“资源”(Resources)视图或“项目”...
常用的Eclipse Git插件包括EGit等。安装EGit后,用户可以直接在Eclipse中进行版本控制操作,如克隆仓库、提交更改、拉取更新等。 #### 二、使用Eclipse进行Git代码管理的步骤 ##### 1. 安装EGit插件 在Eclipse中...
在开发过程中,代码编辑器的智能辅助功能极大提升了编码效率,其中,自动补齐(代码提示)是最为常用的功能之一。Eclipse作为一款强大的开源集成开发环境(IDE),提供了丰富的功能来支持Java、Android等项目的开发...
Eclipse 是 Java 开发中最流行的集成开发环境(IDE),它提供了强大的功能和插件来提高开发效率。本篇博文旨在为刚刚入门 Java 的新手提供一个快速掌握 Eclipse 使用的指南。 1. 常用快捷键 熟练使用快捷键对于...
2. **插件开发**:学习如何开发自定义插件,扩展 Eclipse 的功能。 3. **性能优化**:合理配置内存分配、减少不必要的插件加载等措施,提高 Eclipse 的运行速度。 #### 六、社区资源 - **官方文档**:访问 Eclipse ...
4. **安装插件**:如果需要使用特定的功能,可以通过Eclipse内置的市场来搜索并安装插件。例如,安装Git插件可以通过“Help”菜单下的“Marketplace”选项进行搜索安装。 #### 四、常用操作简介 - **创建新项目**...
Eclipse SVN插件可以集成SVN版本控制功能到Eclipse开发环境中,让开发者可以直接在Eclipse中进行版本控制的操作。然而,在实际使用Eclipse SVN插件时,用户可能会遇到各种各样的报错信息,这些报错信息可能会阻碍...
#### 四、Eclipse常用快捷键及技巧 Eclipse提供了许多快捷键,能够极大地提高开发效率。 1. **加注释**:`Ctrl+/`。 2. **查看变量定义或方法源代码**:`Ctrl+左键`。 3. **引出Source**:`Alt+Shift+S`。 4. **...
它包含了Eclipse Classic的基本功能,同时还加入了支持Java EE标准的各种工具和插件。 - **Luna SR1a**: “Luna”是Eclipse的一个版本代号,而“SR1a”则代表Service Release 1a,即Luna版本的一个维护更新版本。...
这一特性使得 Eclipse 能够迅速聚集开发者社区的支持,并不断吸引新的贡献者加入到项目的开发中来。 **1.3 Eclipse 版本介绍** Eclipse 有不同的版本,包括但不限于: - **Eclipse Classic**:这是最经典的 ...
- 插件系统:用户可以通过安装插件扩展Eclipse的功能。 - 集成的开发工具:包括项目管理、版本控制、调试工具等。 - **使用场景**:Eclipse IDE适用于各种规模的Java项目开发,包括桌面应用、Web应用以及企业级...
标签中的“eclipse插件”表明jdeclipse是为Eclipse IDE设计的,Eclipse作为开源且高度可扩展的开发平台,拥有丰富的插件生态系统。jdeclipse插件的加入使得Eclipse不仅能够处理Java开发的常规任务,还能方便地处理反...
在Eclipse插件开发中,通常会为插件创建一个专用的透视图(Perspective)。首先,我们需要准备一些资源文件,例如图标等。例如,将包含图标的`icons`目录复制到当前插件项目中,如`myplugin2`项目,复制后的路径应...