- 浏览: 498354 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
devon.k:
推荐的一种解决方案:https://developer.jbo ...
JBoss应用遇到问题记录 -
liuzl121:
楼主你好,我遇到了你说的第一个问题,能不能详细一些?
JBoss应用遇到问题记录 -
showzh:
...
MySQL5.1列类型 -
zijie110:
...
使用SpringSide的PropertyFilter无法实现 where 属性名1 like '%值1%' or 属性名1 like '%值2%' 的效果 -
JAVA-JVM:
您好,我看了您的一篇文章“用Maven构建Flex4项目实践记 ...
用Maven构建Flex4项目实践记录
------------------------------------------------------------------------------------------------
学习: http://www.blogjava.net/youxia/archive/2006/11/24/83377.html
------------------------------------------------------------------------------------------------
1. 编写 FirstView 类:
package hellorcp.view; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.part.ViewPart; public class FirstView extends ViewPart { private Table table; private Text text_1; private Text text; public static final String ID = "hellorcp.views.FirstView"; //$NON-NLS-1$ /** * Create contents of the view part * * @param parent */ @Override public void createPartControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); final Label label = new Label(container, SWT.NONE); label.setText("姓名:"); label.setBounds(56, 41, 36, 12); text = new Text(container, SWT.BORDER); text.setBounds(98, 38, 80, 15); final Label label_1 = new Label(container, SWT.NONE); label_1.setText("性别:"); label_1.setBounds(212, 41, 30, 12); text_1 = new Text(container, SWT.BORDER); text_1.setBounds(252, 38, 80, 15); final TableViewer tableViewer = new TableViewer(container, SWT.BORDER); // tableViewer.setInput(new Object()); table = tableViewer.getTable(); table.setBounds(56, 75, 374, 143); table.setItemCount(10); table.setLinesVisible(true); // createActions(); initializeToolBar(); initializeMenu(); } /** * Create the actions */ private void createActions() { // Create the actions } /** * Initialize the toolbar */ private void initializeToolBar() { IToolBarManager toolbarManager = getViewSite().getActionBars() .getToolBarManager(); } /** * Initialize the menu */ private void initializeMenu() { IMenuManager menuManager = getViewSite().getActionBars() .getMenuManager(); } @Override public void setFocus() { // Set the focus } }
2. 修改 Perspective.java:
package hellorcp; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; public class Perspective implements IPerspectiveFactory { public void createInitialLayout(IPageLayout layout) { String editorArea = layout.getEditorArea(); layout.addView("hellorcp.view.FirstView", IPageLayout.RIGHT, 0.2f, editorArea); } }
3. 编辑plugin.xml,增加如下代码片段:
<extension point="org.eclipse.ui.views"> <view class="hellorcp.view.FirstView" id="hellorcp.view.FirstView" name="第一个view" /> </extension>
4. 运行程序,效果如下:
5. 自定义视图标签样式:
1) 新增文件 plugin_customization.ini ,内容如下:
org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight
2) 修改 plugin.xml: 找到如下片段:
<extension id="product" point="org.eclipse.core.runtime.products"> <product application="HelloRCP.application" name="RCP Application">
加入以下片段:
<property name="preferenceCustomization" value="plugin_customization.ini"> </property>
3) 保存,运行,效果无变化(plugin_customization.ini放在项目根目录下,应放在哪里?);
6. 构建1个ListView:
1) 新建Person Bean类:
package hellorcp.view; public class Person { private String name; private String sex; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } }
2) 新建 PersonModel 类:
package hellorcp.view; import java.util.ArrayList; public class PersonModel { private ArrayList<Person> list = new ArrayList<Person>(); public interface Listener { public void add(Person p); public void remove(Person p); } private Listener listener; public PersonModel() { // 向list里面填入几个初始化数据 Person p1 = new Person(); p1.setName("病人1"); p1.setSex("男"); list.add(p1); Person p2 = new Person(); p2.setName("病人2"); p2.setSex("女"); list.add(p2); } public void setListener(Listener listener) { this.listener = listener; } public void add(Person p) { list.add(p); if (listener != null) { listener.add(p); } } public void remove(Person p) { list.remove(p); if (listener != null) { listener.remove(p); } } public ArrayList elements() { return list; } }
3) 实现内容提供器(实现了PersonModel中定义的Listener接口):
package hellorcp.view; import hellorcp.view.PersonModel.Listener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; public class PersonContentProvider implements IStructuredContentProvider, Listener { PersonModel input; ListViewer viewer; public Object[] getElements(Object inputElement) { // TODO 自动生成方法存根 return input.elements().toArray(); } public void dispose() { // TODO 自动生成方法存根 if (input != null) { input.setListener(null); } input = null; } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO 自动生成方法存根 viewer = (ListViewer) viewer; input = (PersonModel) newInput; input.setListener(this); } public void add(Person p) { // TODO 自动生成方法存根 viewer.add(p); } public void remove(Person p) { // TODO 自动生成方法存根 viewer.remove(p); } }
4) 实现标签提供器(用于显示列表元素——Person类的对象):
package hellorcp.view; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.swt.graphics.Image; public class PersonLabelProvider implements ILabelProvider { public Image getImage(Object element) { return null; } public String getText(Object element) { // TODO 自动生成方法存根 return ((Person) element).getName(); } public void addListener(ILabelProviderListener listener) { // TODO 自动生成方法存根 } public void dispose() { // TODO 自动生成方法存根 } public boolean isLabelProperty(Object element, String property) { // TODO 自动生成方法存根 return false; } public void removeListener(ILabelProviderListener listener) { // TODO 自动生成方法存根 } }
5) 新建SecondView:
package hellorcp.view; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.part.ViewPart; public class SecondView extends ViewPart { public void createPartControl(Composite parent) { ListViewer viewer = new ListViewer(parent, SWT.BORDER); viewer.setContentProvider(new PersonContentProvider()); viewer.setLabelProvider(new PersonLabelProvider()); viewer.setInput(new PersonModel()); createActions(); initializeToolBar(); initializeMenu(); } private void createActions() { // Create the actions } private void initializeToolBar() { IToolBarManager toolbarManager = getViewSite().getActionBars() .getToolBarManager(); } private void initializeMenu() { IMenuManager menuManager = getViewSite().getActionBars() .getMenuManager(); } public void setFocus() { // Set the focus } }
6) 修改 Perspective.java, 修改后的 Perspective.java:
package hellorcp; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; public class Perspective implements IPerspectiveFactory { public void createInitialLayout(IPageLayout layout) { // FirstView String editorArea = layout.getEditorArea(); layout.addView("hellorcp.view.FirstView", IPageLayout.RIGHT, 0.2f, editorArea); // SecondView layout.setEditorAreaVisible(false); layout.addView("hellorcp.view.SecondView", IPageLayout.RIGHT, 0.5f, editorArea); } }
7) plugin.xml 中增加 SecondView 配置,增加后的片段为:
<extension point="org.eclipse.ui.views"> <view class="hellorcp.view.FirstView" id="hellorcp.view.FirstView" name="第一个view" /> <view class="hellorcp.view.SecondView" id="hellorcp.view.SecondView" name="第二个view" /> </extension>
8) 保存,运行,效果如下:
发表评论
-
Eclipse RCP开发记要
2012-07-05 20:21 1329Eclipse RCP开发学习——一些基础概念 Ec ... -
《Eclipse插件开发学习笔记》要点摘记
2010-08-28 18:40 1214一、Chapter 3. SWT编程基础 1. 开发多 ... -
实用的SWT代码片段收集记录
2010-07-01 18:54 12191. 窗体相对屏幕居中 shell.setLocation( ... -
SWT开发入门学习笔记——01.Hello SWT
2010-06-19 23:36 1650创建一个典型的 SWT 应 ... -
Eclipse RCP开发学习——学习资源收集
2010-03-12 11:15 1474某位达人的学习整理,很好: 简单RCP框架源码分析 R ... -
GUI开发之AWT、Swing、SWT和JFace的比较
2010-03-12 10:46 1454------------------------------- ... -
Eclipse RCP开发学习——一些基础概念
2010-03-12 10:07 1438------------------------------- ... -
Eclipse RCP开发插件—— Visual Editor安装
2010-03-10 11:15 6640------------------------------- ... -
Eclipse RCP插件使用记录索引
2010-03-10 11:03 1526------------------------------- ... -
Eclipse RCP开发入门学习笔记——07.小结
2010-03-02 13:52 1478跟着“海边沫沫”的系列文章进行了入门学习,对RCP的开发有了个 ... -
Eclipse RCP开发入门学习笔记——06.OpenGL
2010-03-02 13:18 2154------------------------------- ... -
Eclipse RCP开发入门学习笔记——05.2D绘图
2010-03-02 11:08 3623------------------------------- ... -
Eclipse RCP开发入门学习笔记——04.在Windows中使用Active X控件
2010-03-02 09:47 1682------------------------------- ... -
Eclipse RCP开发入门学习笔记——02.菜单和对话框
2010-03-01 14:58 2743------------------------------- ... -
Eclipse RCP开发入门学习笔记——01.Hello RCP
2010-02-26 15:00 4323最近急于想要了解桌面客户端开发的方方面面,除了在刚踏入工作岗位 ...
相关推荐
Eclipse插件开发 学习笔记 第一篇 开发基础(01-05).rar Eclipse插件开发 学习笔记 第一篇 开发基础(06-10).rar Eclipse插件开发 学习笔记 第二篇 核心技术(11-16).rar Eclipse插件开发 学习笔记 第二篇 核心技术(17-...
Eclipse插件开发 学习笔记 第一篇 开发基础(01-05).rar Eclipse插件开发 学习笔记 第一篇 开发基础(06-10).rar Eclipse插件开发 学习笔记 第二篇 核心技术(11-16).rar Eclipse插件开发 学习笔记 第二篇 核心技术(17-...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
Eclipse插件开发 学习笔记 第一篇 开发基础(01-05).rar Eclipse插件开发 学习笔记 第一篇 开发基础(06-10).rar Eclipse插件开发 学习笔记 第二篇 核心技术(11-16).rar Eclipse插件开发 学习笔记 第二篇 核心技术(17-...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
第一篇介绍Eclipse平台界面开发的基础知识,包括SWT控件的使用、界面布局、事件处理等内容;第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、...
Eclipse插件开发 学习笔记 第一篇 开发基础(01-05).rar Eclipse插件开发 学习笔记 第一篇 开发基础(06-10).rar Eclipse插件开发 学习笔记 第二篇 核心技术(11-16).rar Eclipse插件开发 学习笔记 第二篇 核心技术(17-...
《Eclipse插件开发》由浅入深、有重点、有针对性地介绍了Eclipse插件开发技术,全书分为4篇共24章。第一篇介绍Eclipse平台界面开发的基础知识,包括SWT控件的使用、界面布局、事件处理等内容;第二篇是插件开发核心...
Eclipse插件开发 学习笔记 第一篇 开发基础(01-05).rar Eclipse插件开发 学习笔记 第一篇 开发基础(06-10).rar Eclipse插件开发 学习笔记 第二篇 核心技术(11-16).rar Eclipse插件开发 学习笔记 第二篇 核心技术(17-...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
Eclipse插件开发 学习笔记 第一篇 开发基础(01-05).rar Eclipse插件开发 学习笔记 第一篇 开发基础(06-10).rar Eclipse插件开发 学习笔记 第二篇 核心技术(11-16).rar Eclipse插件开发 学习笔记 第二篇 核心技术(17-...
第一篇介绍Eclipse平台界面开发的基础知识,包括SWT控件的使用、界面布局、事件处理等内容;第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...
第二篇是插件开发核心技术,主要介绍插件开发的核心知识要点,包括行为(Action)、视图(ViewPart)、编辑器(Editor)、透视图(Perspective)等10章的内容;第三篇主要讲述插件开发的高级内容,包括开发高级内容...