terrine

          改造easyexplore插件

          easyexplore是一個(gè)eclipse的小插件,它能直接打開(kāi)選中文件所在的目錄,雖然只有幾K的體積,卻給我們帶來(lái)了很大的方便。不過(guò)為了追求更高的易用性,我在dev2dev的一篇文章的基礎(chǔ)上(這篇文章似乎漏掉了一些改動(dòng),而且易用性還是不夠高:),對(duì)它進(jìn)行了一點(diǎn)小小的改進(jìn),改進(jìn)后的功能(僅適用于windows)是:

          1.如果選中的是目錄,則在資源管理器中打開(kāi)這個(gè)目錄(而不是在它的上級(jí)選中該目錄);2.如果選中的是文件,則資源管理器中打開(kāi)所在的文件夾并選中這個(gè)文件;另外,順便把新的xp風(fēng)格圖標(biāo)給拿了過(guò)來(lái)。

          easyexplore的cvs地址是anonymous@easystruts.cvs.sourceforge.net:/cvsroot/easystruts,下載源碼之后發(fā)現(xiàn)easyexplore已經(jīng)悄悄的更新了,多了“執(zhí)行外部命令”等功能,圖標(biāo)也改成xp風(fēng)格,不過(guò)多了一層子菜單,感覺(jué)不如原來(lái)方便,而且我只對(duì)explore這個(gè)功能感興趣,所以只取回org/sf/easyexplore/EasyExplorePlugin.java,org/sf/easyexplore/actions/EasyExploreAction.java和org/sf/easyexplore/preferences/EasyExplorePreferencePage.java三個(gè)文件的1.1版本進(jìn)行修改。代碼是相當(dāng)?shù)暮?jiǎn)單:

          在EasyExplorePlugin.java中改變defaultTagert的值:
          protected void initializeDefaultPreferences(IPreferenceStore store) {
                  String defaultTarget 
          = "shell_open_command {0}";
                  String osName 
          = System.getProperty("os.name");
                  
          if ( osName.indexOf("Windows"!= -1 ) {
                      defaultTarget 
          = "explorer.exe /e,";
                  }
                  
          else if ( osName.indexOf("Mac"!= -1 ) {
                      defaultTarget 
          = "open";            
                  }
                  
                  store.setDefault(EasyExplorePreferencePage.P_TARGET, defaultTarget);
              }
          在EasyExploreAction.java中增加一個(gè)判斷條件,如果選中的文件那么在資源管理器中也選中之:
          public void run(IAction action) {
                  
          try {
                      
          if ( "unknown".equals(selected) ) {
                          MessageDialog.openInformation(
          new Shell(),"Easy Explore","Unable to explore " + selectedClass.getName());
                          EasyExplorePlugin.log(
          "Unable to explore " + selectedClass);
                          
          return;
                      }
                      File directory 
          = null;
                      
          if ( selected instanceof IResource ) {
                          directory
          = new File(((IResource)selected).getLocation().toOSString());
                      } 
          else if ( selected instanceof File ) {
                          directory
          = (File) selected;
                      } 

                      String target 
          = EasyExplorePlugin.getDefault().getTarget();
                      
                      
          if (!EasyExplorePlugin.getDefault().isSupported()) {
                          MessageDialog.openInformation(
          new Shell(),"Easy Explore",
                              
          "This platform (" + 
                              System.getProperty(
          "os.name"+ 
                              
          ") is currently unsupported.\n" + 
                              
          "You can try to provide the correct command to execute in the Preference dialog.\n" +
                              
          "If you succeed, please be kind to post your discovery on EasyExplore website http://sourceforge.net/projects/easystruts,\n" +
                              
          "or by email farialima@users.sourceforge.net. Thanks !");
                          
          return;
                      }

                      
          if(directory.isFile() 
                          
          && System.getProperty("os.name").indexOf("Windows"!= -1 ) {
                          target 
          = target.trim() + "/select,";
                      }
                      
          if ( target.indexOf("{0}"== -1 ) {
                          target 
          = target.trim() + " {0}";
                      }    
                      
                      target 
          = MessageFormat.format(target, new String[]{directory.toString()});
                      
                      
          try { 
                          EasyExplorePlugin.log(
          "running: "+target);
                          Runtime.getRuntime().exec(target);
                      } 
          catch ( Throwable t ) {
                          MessageDialog.openInformation(
          new Shell(),"Easy Explore","Unable to execute " +target);
                          EasyExplorePlugin.log(t);
                      }
                  } 
          catch (Throwable e) {
                      EasyExplorePlugin.log(e);
                  }
              }
          重新編譯打包之后,替換掉org.sf.easyexplore_1.0.4.jar中的easyexplore.jar和圖標(biāo),搞定收工。
          放了一個(gè)自己修改過(guò)的jar上來(lái),歡迎大家從這里下載。

          另外推薦一個(gè)好用的bookmark插件quickmarks,可以通過(guò)Ctrl,Alt和數(shù)字鍵非常快捷的創(chuàng)建和跳回書(shū)簽,類似于JBuilder和IDEA的功能,比eclipse自帶的bookmark強(qiáng)太多了。項(xiàng)目地址是http://eclipse-tools.sourceforge.net/quickmarks

          posted on 2007-06-02 22:54 Jay 閱讀(3211) 評(píng)論(5)  編輯  收藏

          評(píng)論

          # re: 改造easyexplore插件 2007-06-03 09:58 CowNew開(kāi)源團(tuán)隊(duì)

          把這個(gè)修改提交給他們呀,這樣所有的人都能使用這個(gè)增強(qiáng)的功能了。:)。  回復(fù)  更多評(píng)論   

          # re: 改造easyexplore插件 2007-06-04 09:29 Welkin Hu

          我用的是從sf下載的jar包。是只有一個(gè)Easy Explorer菜單的版本。樓主所說(shuō)的增強(qiáng)特性,在這個(gè)版本中已經(jīng)是這樣了。  回復(fù)  更多評(píng)論   

          # re: 改造easyexplore插件 2007-06-04 16:20 hcqenjoy

          Welkin Hu 我下載的怎么不是你說(shuō)的版本?? 能提供下你的版本嗎  回復(fù)  更多評(píng)論   

          # re: 改造easyexplore插件 2007-06-04 21:07 Jay

          @Welkin Hu
          可以提供一個(gè)下載的鏈接嗎,我下載的是1.0.4版本的 都沒(méi)有這個(gè)功能  回復(fù)  更多評(píng)論   

          # re: 改造easyexplore插件[未登錄](méi) 2008-12-29 11:43 Dennis

          不錯(cuò)的enhancement,本來(lái)我也想改,給你搶先了,hoho  回復(fù)  更多評(píng)論   


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 深水埗区| 盖州市| 芦溪县| 江川县| 绥宁县| 普格县| 闻喜县| 孝昌县| 望都县| 中方县| 易门县| 南陵县| 中牟县| 宾川县| 沿河| 千阳县| 板桥市| 丹棱县| 萨嘎县| 岗巴县| 冷水江市| 万源市| 胶州市| 巴里| 二连浩特市| 清丰县| 威远县| 黄梅县| 台山市| 哈巴河县| 遂宁市| 阜城县| 涪陵区| 清流县| 高阳县| 邹城市| 田阳县| 大港区| 泉州市| 蒙阴县| 新龙县|