Friday, May 23, 2008
[tip]convert dos format to unix
set file format=unix
or dos2unix, unix2dos
Thursday, May 22, 2008
[tip]Makefile
GTK_LIB=$(shell pkg-config --libs gtk+-2.0)
GTK_INC=$(shell pkg-config --cflags gtk+-2.0)
gcc -o yourlibrary.so $(GTK_INC) $(GTK_LIB)
Wednesday, April 16, 2008
[OSGi][Equinox]URL Handlers Service
Use a sample to illustrate how to contribute your scheme(protocol):
1. register your URLStreamHandlerService implementation, which must contain a property named "url.handler.protocol". below register my scheme 'smb'
public void start(BundleContext context) throws Exception {
Hashtable properties = new Hashtable();
properties.put( URLConstants.URL_HANDLER_PROTOCOL, new String[] { "smb" } );
context.registerService(URLStreamHandlerService.class.getName(), new SmbURLHandler(), properties );
}
2. your URL Handler extends AbstractURLStreamHandlerService, and implements abstract function 'openConnection(URL)'
public class SmbURLHandler extends AbstractURLStreamHandlerService {
public URLConnection openConnection(URL url) throws IOException {
return new SmbURLConnection(url);
}
}
3. your URL Connection extends java.net.URLConnection
public class SmbURLConnection extends URLConnection {
protected SmbURLConnection(URL url) {
super(url);
}
public void connect() throws IOException {
}
}
Monday, March 31, 2008
[OSGi][Equinox]the Bundle-NativeCode implementation in Equinox
Wednesday, March 19, 2008
[shell]Learning Note - 3/19/08
Tuesday, March 11, 2008
[Eclipse]How to use qualifier string when exporting features and plug-ins
If you want to use the qualifier string, you must define your feature and plug-in version like below:
1.0.0.qualifier, 2.2.2.qaulifier
:)
Tuesday, April 3, 2007
万恶的注册表
最近几天被一个注册表相关的defect搞的焦头烂额。
背景是这样的,产品在安装的时候需要通过修改注册表注册文件关联等信息。在先前安装程序基于InstallShield时工作正确,但在最近安装程序改用MSI后,我们写入注册表的信息没有被写到所期望的位置。
通过各种试验,查找资料,终于搞明白原因。我们修改注册表的进程不是当前用户进程,而是系统进程,因此写入到HKEY_CURRENT_USER下的数据不能被写入到当前登陆用户下。
We should not use "HKEY_CURRENT_USER" to retrival current user's registry key value. Because Windows Services always startup before user login. It may happen some error or loading the wrong setting profile. If you still insist on using the current user registry key setting, please refer "RegOpenCurrentUser".
最后只好将这些数据写到了Local Machine键值下。
Friday, March 9, 2007
[Eclipse]get rid of the menus of eclipse platform
When you develop a rich client application base on eclipse framework, and your application require eclipse platform feature, you would find that your application has some menu items contributed by eclipse platform. Those menu items are defined by several plug-ins' implementation of actionSet extention point. In fact Eclipse provides an activity mechanism to suppress the extension points which you don't want to use. However, you must know the identification name of extension points which you want to suppress. It's a hard work to find out all of them from dozens of plugins. so, I wrote a utility function to list all the extension points of specified name.
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = registry.getExtensionPoint("org.eclipse.ui.actionSets");
IExtension[] extensions = extensionPoint.getExtensions();
for(int i = 0; i < extensions.length; i++){
IConfigurationElement elements[] = extensions[i ].getConfigurationElements();
for(int j = 0; j < elements.length; j++){
String pluginId = elements[j].getNamespaceIdentifier();
if(pluginId.indexOf("org.eclipse") > -1){ //$NON-NLS-1$
IConfigurationElement[] subElements = elements[j].getChildren("action");
for(int m = 0; m < subElements.length; m++){
System.out.println("Plugin: " + pluginId + " Id: " +
subElements[m].getAttribute("id"));
}
}
}
}
and the follow snippet is about the activities of menus of eclipse platform:
<extension point="org.eclipse.ui.activities">
<activity id="activity.platform" name="hidePlatformMenus"/>
<activityPatternBinding activityId="activity.platform" pattern="org\.eclipse\.platform/org\.eclipse\.ui\.cheatsheets\.actions\.CheatSheetHelpMenuAction"/>
<activity id="activity.search" name="hideSearchMenus"/>
<activityPatternBinding activityId="activity.search" pattern="org\.eclipse\.search/org\.eclipse\.search\..*"/>
<activity
id="activity.ide"
name="hideIDEMenus">
</activity>
<activityPatternBinding
activityId="activity.ide"
pattern="org\.eclipse\.ui\.ide/org\.eclipse\.ui\.actions\.showKeyAssistHandler">
</activityPatternBinding>
<activityPatternBinding
activityId="activity.ide"
pattern="org\.eclipse\.ui\.ide/org\.eclipse\.update\.ui\..*">
</activityPatternBinding>
<activity
id="activity.editor"
name="hideEditorMenus">
</activity>
<activityPatternBinding
activityId="activity.editor"
pattern="org\.eclipse\.ui\.editors/org\.eclipse\.ui\.edit\.text\.openExternalFile">
</activityPatternBinding>
<activityPatternBinding
activityId="activity.editor"
pattern="org\.eclipse\.ui\.editors/org\.eclipse\.ui\.edit\.text\.delimiter\..*">
</activityPatternBinding>
<activity
id="activity.externaltool"
name="hideExternaltoolMenus">
</activity>
<activityPatternBinding
activityId="activity.externaltool"
pattern="org\.eclipse\.ui\.externaltools/org\.eclipse\.ui\.externaltools\.ExternalToolMenuDelegateMenu">
</activityPatternBinding>
</extension>
Wednesday, January 24, 2007
加载jar文件里的本地库
java程序开发中经常用到JNI调用本地library, 同时又希望将library同class文件编译成一个jar文件以方便deploy.
但是JDK的classloader不支持从jar文件中加载library, 一个变通的方法就是jar里的library以临时文件的方式写到临时目录或java.library目录.
附上两篇文档链接 :
Load Library inside a jar file
Wednesday, January 17, 2007
[Eclipse]Eclipse update support
Those days my work is focus on eclipse's update. Now I understand the general mechanism and meet some issues when using it in development work.
The update mechanism includes four major types: install, enable, disable and uninstall. And all of those operations can be executed by command line, such as installing a feature can use following line:
-application org.eclipse.update.core.standaloneUpdate -command install -featureId my.feature -version 1.0.0 -from file:/v:/local_updateSite/ -to file:/v:/eclipse/.
The installation process would copy the feature and plugins which are included by the feature to the local site from the update site, then execute the feature's global install handler if it has one.
Some strange issue occurs when I want to disable a feature.Then I try to disable the feature with command,
-command disable -featureId my.feature -version 1.0.0 -to file:/v:/eclipse/
The output of command means that the command is executed successfully.
But I list the status of features with command line "-command listFeatures", the status of my.feature is still enable.
Then I try to uninstall my.feature with command,
-command uninstall -featureId my.feature -version 1.0.0 -to file:/v:/eclipse/
It fails, and the following is the root cause found in log file.
!MESSAGE [Cannot find unconfigured feature my.feature with version 1.0.0]
unconfigured feature means the feature is disabled.
Thursday, October 19, 2006
[Eclipse]The call sequence between partActivated and menu update
I met a defect that dynamically created menu items disappear after creating a new viewPart. It caused me overtime last Friday. Today I find the root cause.
The scenario is:
open first document, the items are shown well
open another document, the items disappear
The requirement is that showing the menu items while current part is document, otherwise hide them.
So our implementation is:
when current document part is deactivated, set menu items invisible
when document part is activated, set menu items visible
After debugging, I found that menu items was updated before the part activated listener was notified. Hence the menu is invisible while the parent menu is updated. The resolved solution is that setting menu items visible while part opened listener is notified.
Wednesday, October 18, 2006
[debug][java]Remote debug in Eclipse
There are two important parameters for jvm. And we must launch remote java app with those two parameters.
-Xdebug //tells jvm starting with debug mode
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044 //transport=dt_socket represents communication with socket, address=1044 represents that the port number is 1044
Then there are 3 steps in local env:
1.import source code into eclipse's project
2.Debug-Remote Java Application, see attachement as a sample
3.insert breakpoint,
update:
a simpler way:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000