
Java
Stroot_Zhang
这个作者很懒,什么都没留下…
展开
-
RCP 自定义启动界面
自定义界面的过程实际上就是实现一个自定义扩展类(继承自AbstractSplashHandler)的过程。主要步骤;1、为RCP工程增加org.eclipse.core.runtime.products扩展点,并设定ID属性,此ID即为RCP程序的ProductID。2、在org.eclipse.core.runtime.products扩展点中增加product扩展项原创 2013-09-28 11:42:49 · 3907 阅读 · 0 评论 -
动态生成command
目的:在程序运行时动态生成各菜单子项。实现思路:通过menuContribution的class属性类实现。步骤:1、在org.eclipse.ui.menus中定义一个menuContribution项,同时通过locationURI设置此menuContribution的依附对象。2、实现menuContribution项的class类。注意此类必须继承自E原创 2013-09-13 15:41:00 · 1334 阅读 · 0 评论 -
RCP 通过代码调用Commands
代码示例:// From a view you get the site which allow to get the serviceIHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);try { handlerService.executeCo原创 2013-09-13 14:09:15 · 1497 阅读 · 0 评论 -
RCP 右键菜单片段
public void createContexMenu(Composite parent) { testAction = new Action("a") { @Override public void run() { System.out.println("Context menu clicked!"); } }; // 创建菜单管理工具类。 Men原创 2013-09-11 21:09:57 · 1284 阅读 · 0 评论 -
RCP右键菜单添加
RCP右键菜单添加步骤:1、菜单项生成。菜单项的生成可以通过plugin.XML编辑器添加,或者通过手动编码实现。plugin.XML编辑器添加:在org.eclipse.ui.menus扩展点添加一个menuContribution,并通过locationURI为其指定好依附对象,然后为其添加菜单项。手动编码实现忽略。2、使用菜单项。光有菜单项还不行,原创 2013-09-13 10:39:01 · 2894 阅读 · 0 评论 -
RCP动态菜单添加
目标效果:对于一个List VIew,仅当其中至少有一元素被选中时,右键菜单中才显示菜单项。实现思路:使用visible when表达式。具体步骤:1、在menuContribute中添加Command项。2、为Command项添加所有必要关联,如:CommandID。3、为此Command添加visibleWhen元素,checkEnabled属性设置为fal原创 2013-09-13 11:38:58 · 2377 阅读 · 0 评论 -
RCP获取插件目录中图像文件
代码示例: // 获取类所在插件。 Bundle bundle = FrameworkUtil.getBundle(View.class); // 获取相对与插件的位置。 URL url = FileLocator.find(bundle, new Path("icons/" + file), null); // 获取图像描述符。 ImageDescripto原创 2013-08-03 16:46:09 · 944 阅读 · 0 评论 -
Eclipse 常用快捷键
快速定位:Ctrl+Shift+R 查找资源文件Ctrl + Shift + O 引入及管理imports语句Ctrl + Shift + T 打开Open Type 查找类文件编辑:Ctrl+D 删除当前行Ctrl + E 打开编辑器(切换窗口)重构:Alt + Shift + R 重构Alt + Shift + L 抽取本地变量Alt +原创 2013-07-27 16:17:10 · 471 阅读 · 0 评论 -
Velocity Reference Notation "$!" Meaning.
$! means Quiet Reference Notation When Velocity encounters an undefined reference, its normal behavior is to output the image of the reference. For example, suppose the following reference appea原创 2013-08-01 15:01:56 · 1017 阅读 · 0 评论 -
Top 10 mistakes in Eclipse Plug-in Development
原文地址:http://www.eclipse-tips.com/tips/3-top-10-mistakes-in-eclipse-plug-in-developmentHaving trained a lot of new comers to the Eclipse plug-in development, I've seen certain common mistakes转载 2013-07-24 12:57:32 · 727 阅读 · 0 评论 -
Eclipse RCP 中Site与各组件之间的关系
Site为各组件提供了一个接口,供其访问workbench的各种资源。各Site与各组件之间的关系如下:参考资料:1、Eclipse RCP 中 Part 和 Site、菜单和工具栏2、Eclipse RCP 中组件解析原创 2013-09-13 21:57:19 · 1139 阅读 · 0 评论 -
Eclipse RCP 中组件解析
Eclipse 平台核心的组件包括如下5类:WorkbenchWorkbenchWindowWorkbenchPageWorkbenchPartViewPart 和 EditorPart各组件意义:1、WorkbenchWorkbench 代表 Eclipse 工作台,是 Eclipse 平台 GUI 总控制器,其作用类似于SWT的Display类。Workbe原创 2013-09-13 21:49:49 · 1785 阅读 · 0 评论 -
[Editing]Get current active view reference instance
.Example code:PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()1Reference:1. http://stackoverflow.com/questions/3201248/how-can原创 2013-09-13 20:13:09 · 1204 阅读 · 0 评论 -
RCP TableViewer获取CheckBox 状态
代码示例:viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.CHECK);// 设置表格显示方式。table = viewer.getTable();table.setHeaderVisible(true);table.se原创 2013-09-26 14:37:54 · 1860 阅读 · 1 评论 -
[Editing]动态显示、隐藏RCP工具栏
参考资料:1、How to hide RCP toolbar using custom perspective2、Hiding menu and tool bars in Eclipse RCP Application原创 2013-09-21 22:30:21 · 2098 阅读 · 0 评论 -
获取当前RCP应用路径数据存储路径
代码: final IPreferenceStore store = TourbookPlugin.getDefault() .getPreferenceStore(); // 电塔图标注册。 store.setDefault("TowerImageFilePath", (Platform.getInstanceLocation() .getURL().getP原创 2013-09-17 21:22:41 · 1062 阅读 · 0 评论 -
RCP 扩展点扩展属性类获取代码示例
代码示例: public static void registerOverlays(final Map map) { final IExtensionRegistry registry = RegistryFactory.getRegistry(); final IExtensionPoint point = registry .getExtensionPoint("net原创 2013-09-17 22:03:23 · 1055 阅读 · 0 评论 -
RCP 已发布程序Debug信息获取
目的:获取已发布的RCP程序抛出的异常。解决方法:使用Command方式启动,同时附加启动参数 -debuglog。实例:RCP.exe -debuglog参考资料:1、Eclipse 4 RCP - Tutorial原创 2013-09-17 19:24:24 · 957 阅读 · 0 评论 -
RCP 自定义用于visible/enable when表达式的变量
目的:定义类似于selection的变量,用于visible when表达式的判定。实现思路:使用source provider来实现。具体步骤:1、定义source provider:添加org.eclipse.ui.services扩展项sourceProvider,实现其provider属性类,此类为本文的重点所在,其功能为对外提供变量值,同时通过priority原创 2013-09-13 15:23:51 · 1760 阅读 · 0 评论 -
SWT 自定义鼠标图像。
目的:使用指定图像作为鼠标的显示样式。参考代码:import org.eclipse.swt.graphics.Cursor;import org.eclipse.swt.graphics.Image;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Shell;public c原创 2013-09-15 11:28:44 · 927 阅读 · 0 评论 -
RCP handler处理函数中获取当前选择项。
目的:在command的处理函数中获取触发当前command时被选中的条目。方法:使用HandlerUtil工具类获取。代码示例: public Object execute(ExecutionEvent event) throws ExecutionException { // 获取需要导出的线路。 ISelection selection = Handl原创 2013-09-14 20:50:00 · 2133 阅读 · 0 评论 -
运行中获取当前执行位置所在类、所在函数等信息
目的:为方便Debug,需要在运行时确定当前执行位置的上下文信息,如确定当前执行代码所在类、所在文件,所在函数、所在行等。思路:1、使用Java的栈跟踪API。2、使用反射机制?具体实现:思路1:代码示例:/* Utility class: Getting the name of the current executing method * ht原创 2013-09-14 10:53:32 · 1049 阅读 · 0 评论 -
Common Eclipse PDE plug-in icons legend
原文地址:http://devblog.virtage.com/2013/02/common-eclipse-pde-plug-in-icons-legend/Newcomers to OSGi bundles/Eclipse plug-ins development with Eclipse PDE IDE may be scared with many small ic转载 2013-07-24 11:35:43 · 782 阅读 · 0 评论 -
Java基本功——Reference
原文地址:http://dreamhead.blogbus.com/logs/2005/05/1189478.html这是一篇一年多之前便已写就的文章,那时,因为很多Java程序员只求追随新生的事物,却连基本的概念都没有,很多讨论中,很明显是基本功不过硬,于是萌生写一个系列文章,讨论Java的基本功,下面便是在这个想法下催生出的第一篇文章。可事实上,真正完成的也只有这一篇。因为转载 2013-07-23 20:36:37 · 649 阅读 · 0 评论 -
RCP设置Plugin.properties
Localization in RCP plugins is usually done by including translations in a property file and using their id in plugin.xml.I spend some time lately trying to understand why some translations were n转载 2013-07-18 11:12:05 · 1041 阅读 · 0 评论 -
java.util.logging.Logger 使用例程
import java.io.IOException;import java.util.logging.FileHandler;import java.util.logging.Logger;public class Log { public static void main(String[] args) { Logger logger = Logger.getLogger("han原创 2013-07-02 15:28:57 · 942 阅读 · 0 评论 -
Java 巨量文件遍历
Java在遍历目录下文件时,采用的策略是一次性提取所有的条目,此种方式才处理巨量文件时容易出现内存不足的异常。为避免此种情况发生,可采用调用系统API或命令的方式先生成文件列表,如:system("dir /a-d /b d:\\mydir\\*.* >d:\\allfiles.txt");原创 2013-07-01 17:50:58 · 1110 阅读 · 0 评论 -
What is a plug-in fragment?
Sometimes it is useful to make part of a plug-in optional, allowing it to be installed, uninstalled, or updated independently from the rest of the plug-in. For example, a plug-in may have a library th翻译 2013-07-12 16:16:00 · 831 阅读 · 0 评论 -
National Language Support
National Language Support (NLS) is a set of features that enable a software product to function properly in every global market for which the product is targeted.原创 2013-07-12 16:55:16 · 1138 阅读 · 0 评论 -
错误解决:The type [X] is not accessible due to restriction on required library [Y].
Error Info: The type [X] is not accessible due to restriction on required library [Y]. It was actually a wrong Eclipse configuration of the Java compiler. What has to be done is to set the "Forbid翻译 2013-07-10 20:17:30 · 969 阅读 · 0 评论 -
Hibernate sessionFactory相关xml设置
thread打开自动线程管理。What does sessionFactory.getCurrentSession() do? First, you can call it as many times and anywhere you like once you get hold of your org.hibernate.SessionFactory. The getCurren翻译 2013-06-19 20:08:21 · 749 阅读 · 0 评论 -
Hibernate Java Application
First of all, you need to tell Hibernate some information regarding the database system you intend to use, such as host name, port number, JDBC driver class name, database connection URL… via some kin转载 2013-06-19 17:02:17 · 881 阅读 · 0 评论 -
SWT/JFace开发需要多少包
必须:org.eclipse.core.runtime_*.jar org.eclipse.swt.win32.win32.x86_*.jarorg.eclipse.jface_*.jar(如果用到了JFace就要这个)org.eclipse.equinox.common_*.jar(其中包含了部分core.runtime下的类,如果没加进来会报如下错误:NoClass原创 2013-06-09 16:41:33 · 799 阅读 · 0 评论 -
JFace TableViewer Note
1. JFace Table Viewer1.1. TableViewerYou can use the TableViewer class to create tables using the JFace framework. The SWT Table widget is wrapped into the TableViewer and can still be翻译 2013-07-20 11:18:30 · 2143 阅读 · 0 评论 -
SWT - table layout - Resize the column of a table to fill all the available space
示例代码: Composite container = new Composite(parent, SWT.NONE); TableColumnLayout tableLayout = new TableColumnLayout(); container.setLayout(tableLayout); tableViewer = new TableViewer(containe转载 2013-07-20 14:53:00 · 2297 阅读 · 0 评论 -
enum singleton
原文:http://en.wikipedia.org/wiki/Singleton_pattern#The_Enum-wayIn the second edition of his book Effective Java, Joshua Bloch claims that "a single-element enum type is the best way to implem转载 2013-07-20 13:21:03 · 920 阅读 · 0 评论 -
How To Read XML File In Java – (SAX Parser)
原文地址:http://www.mkyong.com/java/how-to-read-xml-file-in-java-sax-parser/SAX parser is work differently with DOM parser, it either load any XML document into memory nor create any object representa转载 2013-07-23 19:33:25 · 889 阅读 · 0 评论 -
全球化 Eclipse RCP 应用程序
原文地址:http://www.ibm.com/developerworks/cn/opensource/os-eclipse-globalrcp/index.html?ca=dat-cn-0727简介Eclipse Rich Client Platform(RCP)有着许多优势,如开发迅速、自然的感观、可扩展性和多平台支持。许多公司都采用 RCP 来开发他们的软件。对于跨转载 2013-07-29 17:40:28 · 1218 阅读 · 0 评论 -
RCP 国际化
原文地址:http://jjxliu306.iteye.com/blog/1882002Eclipse体系已对国际化功能封装的很不错了,因此在RCP中处理国际化很方便,下面借用jjxliu306的一个例子来展示如何在RCP中使用国际化。 1. 首先创建一个RCP应用工程。注意将工程设置为RCP工程。 为方便测试,选择He转载 2013-07-29 17:27:22 · 1922 阅读 · 0 评论 -
关于Preference的一点理解
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://allenyoung.blogbus.com/logs/1694872.html稍微正规一点儿的plug-in都会有Preference page,在那里我们可以设置一个plug-in的profile,来个性化plug-in的显示及运行效果。Eclipse把Preference作为一个ex转载 2013-07-21 20:53:48 · 1246 阅读 · 0 评论