子非鱼

BlogJava 首页 新随笔 联系 聚合 管理
  21 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks

2011年9月15日 #


eclipse瘦身后发现jboss server view找不到

原因: org.jboss.ide.eclipse.as.feature中定义:

 <requires>
          ...
          <import plugin="org.eclipse.wst.server.ui.doc.user"/>
          ...
</requires>

该doc插件包在瘦身时被干掉了,导致jbossideplugin未正常加载,恢复该包即可
posted @ 2011-09-15 18:40 子非鱼 阅读(249) | 评论 (0)编辑 收藏

2009年3月29日 #

     摘要:   阅读全文
posted @ 2009-03-29 13:27 子非鱼| 编辑 收藏

2009年3月28日 #

     摘要:   阅读全文
posted @ 2009-03-28 11:54 子非鱼 阅读(867) | 评论 (1)编辑 收藏

     摘要: 内存溢出与JVM参数设置  阅读全文
posted @ 2009-03-28 10:09 子非鱼| 编辑 收藏

     摘要: 转自 http://topic.csdn.net/u/20080929/02/4e0ef626-98ee-4d6d-96ed-fe40afe8290b.html  阅读全文
posted @ 2009-03-28 09:18 子非鱼| 编辑 收藏

2008年10月6日 #

转自:http://lemon.javaeye.com/blog/51480
        http://www.blogjava.net/fhawk/archive/2007/01/16/28993.html
利用IKeyBindingService接口为Action绑定快捷键:

1、
设置commands extension

   <extension
           
point = "org.eclipse.ui.commands">
           
<!-- activeKeyConfiguration项用来说明所绑定快捷键的初始设置 -->
           
<activeKeyConfiguration value="org.eclipse.ui.defaultAcceleratorConfiguration"/>
           
<!-- 如果快捷键设置有多套,可以添加多个类别 -->
           
<category
               
name="intelliPlatform.Category1"
               description
="Test description"
               id
="intelliPlatform.Category1"/>
           
<!-- 其中id为这个command的ID,相关的action通过这个ID标志找到这个command -->
           
<command
             
name="intelliPlatform.command.DataSource"
             category
="intelliPlatform.Category1"
             description
="数据源配置"
             id
="com.longtop.intelliplatform.ide.project.commands.DataSource"/>
        
<!-- 具体的快捷键设置,其中command指定实际的coomand的ID -->
        
<keyBinding
             
command="com.longtop.intelliplatform.ide.project.commands.DataSource"
             configuration
="org.eclipse.ui.defaultAcceleratorConfiguration"
             keySequence
="Ctrl+Shift+D"/>
   
</extension>
 以上是设置了plugin.xml中command extension,并指定了keybinding,在keybinding中
 的keysequence中的字符串是设置的快捷键。 

------------

在具体的Action配置中,只要在其属性definitionId设置成command的ID即可,示例如下:
<action
 
label="Sample Action"
 icon
="icons/sample.gif"
 class
="cli.bacchus.portal.ui.actions.BacchusAction"
 tooltip
="Hello, Eclipse world"
 menubarPath
="sampleMenu/sampleGroup"
 toolbarPath
="sampleGroup"
 id
="bacchus.portal.ui.actions.BacchusAction"
 definitionId
="com.longtop.intelliplatform.ide.project.commands.datesource">
</action>

注意:当给相关的action设置完definitionID后,必须保证其中设置的command是有的,而且是正确的,否则有可能导致该action显示不出来。
更具体的信息请参考eclipse开发参考中关于扩展点org.eclipse.ui.commands的详细描述。

------------

2、
 建立Acion,在此建立的action可以是实现IAction接口的任何类。比较方便的是继承
 org.eclipse.jface.Action,然后在新类中覆盖父类的run() 方法.

 public class CopyAction extends Action{
   
public CopyAction(){
    setId(
"org.example.copyaction");
    setActionDefinitionId(
"com.longtop.intelliplatform.ide.project.commands.DataSource");
   }

 }

3、
在创建CopyAction的instance之后,将copyActionInstance用IKeyBindingService绑定到
指定的command。
获得IKeyBinddingservice的一种简单方式为:
IKeyBindingService keyBindingService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getKeyBindingService();
keyBindingService.registerAction(copyActionInstance);


注意:
1、action的definitionid和command定义的id必须一致。
2、当指定的keySequence与系统默认的冲突时,如:在窗体的菜单栏中
指定了Edit->Copy(默认的快捷键为Ctrl+C),若将上面的keySequence改为
M1+C(Ctrl+C)则系统默认的快捷键(Ctrl+C)将更改为Ctrl+Insert。即RCP默认
的为用户指定的优先,系统动态更新。
3、IKeyBindingService指定的快捷键是有作用范围的。




为主菜单绑定快捷键

主菜单的快捷键即为 Alt + 菜单名称中带下划线的字母
定义主菜单快捷键只要在主菜单lable中确定的字母前面加上&字符即可
如:
plugin.properties  menulabel = &Intelliplatform
plugin_zh.properties menulabel = 平台(&I)
(注意:在该label引用的properties国际化文件中加,直接在plugin.xml中加好像无效,此处存疑)
posted @ 2008-10-06 15:18 子非鱼| 编辑 收藏

2008年4月12日 #

JAVA中HashMap的成员遍历  
方法一:  
        Set   entries;  
        entries=map.keySet(); 
        Iterator   iter=entries.iterator();  
        while(iter.hasNext()){  
              Object   obj=iter.next();  
              System.out.println(obj+":"+map.get(obj));      
        }            

   
    方法二:      
        Set   entries;  
        entries=map.entrySet();
        Iterator   iter=entries.iterator();  
        while(iter.hasNext())  
        {  
              System.out.println(iter.next()+"   ");      
        }  

另外,JAVA中 interface和class都可以作为对变量的声明。


    public static void copyDirtoDest(String srcDir, String toDir) {
        Copy copyDir 
= new Copy();
        copyDir.setOverwrite(
true);
        copyDir.setProject(
new Project());
        FileSet fileSet 
= new FileSet();
        fileSet.setDir(
new File(srcDir));
        copyDir.addFileset(fileSet);
        File dest 
= new File(toDir);

        copyDir.setTodir(dest);
        copyDir.execute();
    }


    
public static void copyFiletoDestDir(String srcFile, String destDir) {
        Copy copy 
= new Copy();
        copy.setProject(
new Project());
        copy.setFile(
new File(srcFile));
        copy.setTodir(
new File(destDir));
        copy.execute();
    }


    
public static void makeDir(String dir) {
        Mkdir mkdir 
= new Mkdir();
        mkdir.setProject(
new Project());
        mkdir.setDir(
new File(dir));
        mkdir.execute();
    }


    
public static void copyFiletoDestandRename(String srcFile, String destFile) {
        Copy copyTask 
= new Copy();
        copyTask.setProject(
new Project());
        copyTask.setFile(
new File(srcFile));
        copyTask.setTofile(
new File(destFile));
        copyTask.execute();
    }


    
public static void moveFiletoDest(String srcFile, String destDir) {
        Move move 
= new Move();
        move.setProject(
new Project());
        move.setFile(
new File(srcFile));
        move.setTodir(
new File(destDir));
        move.execute();
    }


验证文件夹名称是否符合java包名规范
//弱验证(只要能被java支持的名称,如中文名称)
IStatus val = JavaConventions.validatePackageName(folder);                 
if (val.getSeverity() == IStatus.ERROR) {
     
return false;
}
 
/**
     * 强验证:是否是严格符合命名规范的包名,标识:以字母开头,字母与数字的组合,字母必须都是小写。
     * 
@param str1
     * 
@return
     
*/

    
public static boolean isPackageName(String str1){
        String regex 
= "^[a-z][a-z[\\d]]*";  
        Pattern p 
= Pattern.compile(regex);
        Matcher m 
= p.matcher(str1);        
        
return  m.matches();
    }


hibernate3 hql 参数乱码问题
Hql中有中文参数(如from test as c where c.name='张三')的话被翻译成sql的时候会出现乱码,解决方法:
在Spring的配制文件applicationContext.xml文件中添加以下代码:
    <property name="hibernateProperties">
        
<props>
                 
            
<prop key="hibernate.query.factory_class">
                org.hibernate.hql.classic.ClassicQueryTranslatorFactory
            
</prop>
        
</props>
    
</property>

list转Array
(IAction[]) list.toArray(new IAction[0]);
(IAction[]) list.toArray(new IAction[list.size()]);
posted @ 2008-04-12 23:07 子非鱼| 编辑 收藏

2008年2月20日 #


打包时过滤文件

在build.properties中的bin.excludes加入要过滤的文件
(例如:过滤jar包中所有文件夹下的CC配置文件.copyarea.db,应该填写 bin.excludes = **/.copyarea.db )



构建时过滤文件

 

Properties -> Java Compiler -> Building

勾选Enable project specific settings, 在Output folder栏的Filtered Resources中填写你要过滤的文件   (例如:过滤bin目录中所有文件夹下的CC配置文件.copyarea.db,应该填写 *.copyarea.db)


posted @ 2008-02-20 10:10 子非鱼| 编辑 收藏

2008年1月24日 #

内部类调用外部类对象(转)
内部类可以使用外部类名.this引用外部类的当前对象,然后就可以使用外部类的任何属性和方法了   
  class   OuterClass{     
  
public   void   show()   {   
        System.out.println(
"method   of  out   class");   
  }
   
  
class   InnerClass{   
  
public   void   showStr(){   
  OuterClass.
this.show()   
  }
   
  }
  


String[] strs = str.split(",");


web.xml中配置tag-lib间接引用

<%@ taglib uri="http://www.ccb.cn/xmdc" prefix="xmdc"%>

        在web.xml中增加下面的内容:
  <taglib>
    
<taglib-uri>http://www.ccb.cn/xmdc</taglib-uri>
    
<taglib-location>/WEB-INF/xmdc.tld</taglib-location>
  
</taglib>

小颖反编译工具无法反编译jdk1.5以上的class的解决办法

下载可以反编译1.5以上的jdk编译的class的新版本jad.exe,替换掉在window路径下的小颖用的老版本的 jad.exe ,小颖就好用了。

其实小颖也就是jad.exe的一个shell,替换了就好了。

jad的下载地址:http://www.kpdus.com/jad.html#download

posted @ 2008-01-24 11:30 子非鱼| 编辑 收藏

2007年10月25日 #

BeanUtils和PropertyUtils类是许多开源框架中频繁使用的两个工具,它们都能实现将一个类中的属性拷贝到另一个类中,这个功能甚至是spring实现依赖注入的基础。研究一下apache的comon包中如何实现这个两个工具,可以发现它们都是使用java.lang.reflect和java.beans这两个包下的几个类来实现的。

    这里我们通过编写一个将一个类的所有属性拷贝到另一个类的相应属性的方法来分析是如何实现拷贝功能的.先把方法放上来:

/** 实现将源类属性拷贝到目标类中
   * 
@param source 
   * 
@param target
   
*/

public static void copyProperties(Object source, Object target) {
   
try {
        
//获取目标类的属性信息
        BeanInfo targetbean = Introspector.getBeanInfo(target.getClass());
        PropertyDescriptor[] propertyDescriptors 
= targetbean.getPropertyDescriptors();
        
//对每个目标类的属性查找set方法,并进行处理
        for (int i = 0; i < propertyDescriptors.length; i++{
             PropertyDescriptor pro 
= propertyDescriptors[i];
             Method wm 
= pro.getWriteMethod();
             
if (wm != null{//当目标类的属性具有set方法时,查找源类中是否有相同属性的get方法
                 BeanInfo sourceBean = Introspector.getBeanInfo(source.getClass());
                 PropertyDescriptor[] sourcepds 
= sourceBean.getPropertyDescriptors();
                 
for (int j = 0; j < sourcepds.length; j++{
                      
if (sourcepds[j].getName().equals(pro.getName())) //匹配
                           Method rm = sourcepds[j].getReadMethod();
                           
//如果方法不可访问(get方法是私有的或不可达),则抛出SecurityException
                           if (!Modifier.isPublic(rm.getDeclaringClass().getModifiers())) {
                                rm.setAccessible(
true);
                           }

                          
//获取对应属性get所得到的值
                          Object value = rm.invoke(source,new Object[0]);
                          
if (!Modifier.isPublic(wm.getDeclaringClass().getModifiers())) {
                               wm.setAccessible(
true);
                          }

                          
//调用目标类对应属性的set方法对该属性进行填充
                          wm.invoke((Object) target, new Object[] { value });
                          
break;
                      }

                 }

              }

          }

   }
 catch (IntrospectionException e) {
       e.printStackTrace();
   }
 catch (IllegalArgumentException e) {
       e.printStackTrace();
   }
 catch (IllegalAccessException e) {
       e.printStackTrace();
  }
 catch (InvocationTargetException e) {
      e.printStackTrace();
  }

}

两个工具的其他方法实现虽然有点差别,但原理都跟上面的例子差不多,有兴趣的话可以写个测试类试试是否可以使用.

转自: http://lemonfamily.blogdriver.com/lemonfamily/1240784.html

posted @ 2007-10-25 10:16 子非鱼| 编辑 收藏

仅列出标题  下一页