子非魚

          BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
            21 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks

          2011年9月15日 #


          eclipse瘦身后發(fā)現(xiàn)jboss server view找不到

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

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

          該doc插件包在瘦身時被干掉了,導(dǎo)致jbossideplugin未正常加載,恢復(fù)該包即可
          posted @ 2011-09-15 18:40 子非魚 閱讀(287) | 評論 (0)編輯 收藏

          2009年3月29日 #

               摘要:   閱讀全文
          posted @ 2009-03-29 13:27 子非魚| 編輯 收藏

          2009年3月28日 #

               摘要:   閱讀全文
          posted @ 2009-03-28 11:54 子非魚 閱讀(908) | 評論 (1)編輯 收藏

               摘要: 內(nèi)存溢出與JVM參數(shù)設(shè)置  閱讀全文
          posted @ 2009-03-28 10:09 子非魚| 編輯 收藏

               摘要: 轉(zhuǎn)自 http://topic.csdn.net/u/20080929/02/4e0ef626-98ee-4d6d-96ed-fe40afe8290b.html  閱讀全文
          posted @ 2009-03-28 09:18 子非魚| 編輯 收藏

          2008年10月6日 #

          轉(zhuǎn)自:http://lemon.javaeye.com/blog/51480
                  http://www.aygfsteel.com/fhawk/archive/2007/01/16/28993.html
          利用IKeyBindingService接口為Action綁定快捷鍵:

          1、
          設(shè)置commands extension

             <extension
                     
          point = "org.eclipse.ui.commands">
                     
          <!-- activeKeyConfiguration項用來說明所綁定快捷鍵的初始設(shè)置 -->
                     
          <activeKeyConfiguration value="org.eclipse.ui.defaultAcceleratorConfiguration"/>
                     
          <!-- 如果快捷鍵設(shè)置有多套,可以添加多個類別 -->
                     
          <category
                         
          name="intelliPlatform.Category1"
                         description
          ="Test description"
                         id
          ="intelliPlatform.Category1"/>
                     
          <!-- 其中id為這個command的ID,相關(guān)的action通過這個ID標(biāo)志找到這個command -->
                     
          <command
                       
          name="intelliPlatform.command.DataSource"
                       category
          ="intelliPlatform.Category1"
                       description
          ="數(shù)據(jù)源配置"
                       id
          ="com.longtop.intelliplatform.ide.project.commands.DataSource"/>
                  
          <!-- 具體的快捷鍵設(shè)置,其中command指定實際的coomand的ID -->
                  
          <keyBinding
                       
          command="com.longtop.intelliplatform.ide.project.commands.DataSource"
                       configuration
          ="org.eclipse.ui.defaultAcceleratorConfiguration"
                       keySequence
          ="Ctrl+Shift+D"/>
             
          </extension>
           以上是設(shè)置了plugin.xml中command extension,并指定了keybinding,在keybinding中
           的keysequence中的字符串是設(shè)置的快捷鍵。 

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

          在具體的Action配置中,只要在其屬性definitionId設(shè)置成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>

          注意:當(dāng)給相關(guān)的action設(shè)置完definitionID后,必須保證其中設(shè)置的command是有的,而且是正確的,否則有可能導(dǎo)致該action顯示不出來。
          更具體的信息請參考eclipse開發(fā)參考中關(guān)于擴(kuò)展點(diǎn)org.eclipse.ui.commands的詳細(xì)描述。

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

          2、
           建立Acion,在此建立的action可以是實現(xiàn)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、
          在創(chuàng)建CopyAction的instance之后,將copyActionInstance用IKeyBindingService綁定到
          指定的command。
          獲得IKeyBinddingservice的一種簡單方式為:
          IKeyBindingService keyBindingService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getKeyBindingService();
          keyBindingService.registerAction(copyActionInstance);


          注意:
          1、action的definitionid和command定義的id必須一致。
          2、當(dāng)指定的keySequence與系統(tǒng)默認(rèn)的沖突時,如:在窗體的菜單欄中
          指定了Edit->Copy(默認(rèn)的快捷鍵為Ctrl+C),若將上面的keySequence改為
          M1+C(Ctrl+C)則系統(tǒng)默認(rèn)的快捷鍵(Ctrl+C)將更改為Ctrl+Insert。即RCP默認(rèn)
          的為用戶指定的優(yōu)先,系統(tǒng)動態(tài)更新。
          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包名規(guī)范
          //弱驗證(只要能被java支持的名稱,如中文名稱)
          IStatus val = JavaConventions.validatePackageName(folder);                 
          if (val.getSeverity() == IStatus.ERROR) {
               
          return false;
          }
           
          /**
               * 強(qiáng)驗證:是否是嚴(yán)格符合命名規(guī)范的包名,標(biāo)識:以字母開頭,字母與數(shù)字的組合,字母必須都是小寫。
               * 
          @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 參數(shù)亂碼問題
          Hql中有中文參數(shù)(如from test as c where c.name='張三')的話被翻譯成sql的時候會出現(xiàn)亂碼,解決方法:
          在Spring的配制文件applicationContext.xml文件中添加以下代碼:
              <property name="hibernateProperties">
                  
          <props>
                           
                      
          <prop key="hibernate.query.factory_class">
                          org.hibernate.hql.classic.ClassicQueryTranslatorFactory
                      
          </prop>
                  
          </props>
              
          </property>

          list轉(zhuǎn)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,應(yīng)該填寫 bin.excludes = **/.copyarea.db )



          構(gòu)建時過濾文件

           

          Properties -> Java Compiler -> Building

          勾選Enable project specific settings, 在Output folder欄的Filtered Resources中填寫你要過濾的文件   (例如:過濾bin目錄中所有文件夾下的CC配置文件.copyarea.db,應(yīng)該填寫 *.copyarea.db)


          posted @ 2008-02-20 10:10 子非魚| 編輯 收藏

          2008年1月24日 #

          內(nèi)部類調(diào)用外部類對象(轉(zhuǎn))
          內(nèi)部類可以使用外部類名.this引用外部類的當(dāng)前對象,然后就可以使用外部類的任何屬性和方法了   
            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中增加下面的內(nèi)容:
            <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類是許多開源框架中頻繁使用的兩個工具,它們都能實現(xiàn)將一個類中的屬性拷貝到另一個類中,這個功能甚至是spring實現(xiàn)依賴注入的基礎(chǔ)。研究一下apache的comon包中如何實現(xiàn)這個兩個工具,可以發(fā)現(xiàn)它們都是使用java.lang.reflect和java.beans這兩個包下的幾個類來實現(xiàn)的。

              這里我們通過編寫一個將一個類的所有屬性拷貝到另一個類的相應(yīng)屬性的方法來分析是如何實現(xiàn)拷貝功能的.先把方法放上來:

          /** 實現(xiàn)將源類屬性拷貝到目標(biāo)類中
             * 
          @param source 
             * 
          @param target
             
          */

          public static void copyProperties(Object source, Object target) {
             
          try {
                  
          //獲取目標(biāo)類的屬性信息
                  BeanInfo targetbean = Introspector.getBeanInfo(target.getClass());
                  PropertyDescriptor[] propertyDescriptors 
          = targetbean.getPropertyDescriptors();
                  
          //對每個目標(biāo)類的屬性查找set方法,并進(jìn)行處理
                  for (int i = 0; i < propertyDescriptors.length; i++{
                       PropertyDescriptor pro 
          = propertyDescriptors[i];
                       Method wm 
          = pro.getWriteMethod();
                       
          if (wm != null{//當(dāng)目標(biāo)類的屬性具有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方法是私有的或不可達(dá)),則拋出SecurityException
                                     if (!Modifier.isPublic(rm.getDeclaringClass().getModifiers())) {
                                          rm.setAccessible(
          true);
                                     }

                                    
          //獲取對應(yīng)屬性get所得到的值
                                    Object value = rm.invoke(source,new Object[0]);
                                    
          if (!Modifier.isPublic(wm.getDeclaringClass().getModifiers())) {
                                         wm.setAccessible(
          true);
                                    }

                                    
          //調(diào)用目標(biāo)類對應(yīng)屬性的set方法對該屬性進(jìn)行填充
                                    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();
            }

          }

          兩個工具的其他方法實現(xiàn)雖然有點(diǎn)差別,但原理都跟上面的例子差不多,有興趣的話可以寫個測試類試試是否可以使用.

          轉(zhuǎn)自: http://lemonfamily.blogdriver.com/lemonfamily/1240784.html

          posted @ 2007-10-25 10:16 子非魚| 編輯 收藏

          僅列出標(biāo)題  下一頁
          主站蜘蛛池模板: 同心县| 陇南市| 高碑店市| 大田县| 长乐市| 巴林右旗| 五峰| 泰顺县| 平乐县| 独山县| 通道| 台中市| 佳木斯市| 开远市| 丹凤县| 沙雅县| 山东| 轮台县| 长阳| 资兴市| 全南县| 潮安县| 中西区| 甘洛县| 且末县| 嘉黎县| 弥渡县| 栾川县| 齐齐哈尔市| 于田县| 柳州市| 保山市| 玉龙| 黄浦区| 石林| 莱芜市| 东丰县| 民丰县| 抚州市| 汝州市| 铜梁县|