terrine

          改造easyexplore插件

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

          1.如果選中的是目錄,則在資源管理器中打開這個目錄(而不是在它的上級選中該目錄);2.如果選中的是文件,則資源管理器中打開所在的文件夾并選中這個文件;另外,順便把新的xp風格圖標給拿了過來。

          easyexplore的cvs地址是anonymous@easystruts.cvs.sourceforge.net:/cvsroot/easystruts,下載源碼之后發(fā)現(xiàn)easyexplore已經(jīng)悄悄的更新了,多了“執(zhí)行外部命令”等功能,圖標也改成xp風格,不過多了一層子菜單,感覺不如原來方便,而且我只對explore這個功能感興趣,所以只取回org/sf/easyexplore/EasyExplorePlugin.java,org/sf/easyexplore/actions/EasyExploreAction.java和org/sf/easyexplore/preferences/EasyExplorePreferencePage.java三個文件的1.1版本進行修改。代碼是相當?shù)暮唵危?br>
          在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中增加一個判斷條件,如果選中的文件那么在資源管理器中也選中之:
          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和圖標,搞定收工。
          放了一個自己修改過的jar上來,歡迎大家從這里下載。

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

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

          評論

          # re: 改造easyexplore插件 2007-06-03 09:58 CowNew開源團隊

          把這個修改提交給他們呀,這樣所有的人都能使用這個增強的功能了。:)。  回復  更多評論   

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

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

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

          Welkin Hu 我下載的怎么不是你說的版本?? 能提供下你的版本嗎  回復  更多評論   

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

          @Welkin Hu
          可以提供一個下載的鏈接嗎,我下載的是1.0.4版本的 都沒有這個功能  回復  更多評論   

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

          不錯的enhancement,本來我也想改,給你搶先了,hoho  回復  更多評論   


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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 长沙市| 德阳市| 浦县| 阜康市| 华亭县| 威信县| 革吉县| 项城市| 吴旗县| 平塘县| 乐都县| 兴宁市| 江川县| 格尔木市| 宁国市| 长沙市| 鄄城县| 且末县| 玛纳斯县| 吉水县| 红安县| 通化县| 清丰县| 建昌县| 新竹县| 汕头市| 东阳市| 乌海市| 井研县| 含山县| 清流县| 六枝特区| 邹平县| 桓仁| 海盐县| 安宁市| 怀安县| 庆元县| 大英县| 南岸区| 泾川县|