terrine

          改造easyexplore插件

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

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

          easyexplore的cvs地址是anonymous@easystruts.cvs.sourceforge.net:/cvsroot/easystruts,下載源碼之后發(fā)現(xiàn)easyexplore已經(jīng)悄悄的更新了,多了“執(zhí)行外部命令”等功能,圖標(biāo)也改成xp風(fēng)格,不過多了一層子菜單,感覺不如原來方便,而且我只對(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ù)暮唵危?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中增加一個(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è)自己修改過的jar上來,歡迎大家從這里下載。

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

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

          評(píng)論

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

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

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

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

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

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

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

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

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

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


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


          網(wǎng)站導(dǎo)航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 靖宇县| 兴安盟| 潜山县| 宁强县| 湟源县| 双桥区| 柳河县| 定结县| 诏安县| 恩施市| 上林县| 曲水县| 玉门市| 九龙城区| 通化市| 安乡县| 嘉义县| 库尔勒市| 东明县| 新民市| 玛沁县| 眉山市| 舞阳县| 鄂伦春自治旗| 嘉定区| 武强县| 富顺县| 绥芬河市| 两当县| 西乌珠穆沁旗| 方城县| 观塘区| 抚顺县| 双峰县| 阿瓦提县| 张家港市| 博爱县| 永顺县| 水城县| 建水县| 秦安县|