eclipse 知識匯總

來源:互聯網
上載者:User

標籤:io   ar   os   sp   for   檔案   on   art   cti   

得到某PLUGIN的路徑:  
  Platform.getBundle("mypluginid").getLocation().
  eclipse採用osgi後好像還可以:
  Activator.getDefault().getBundle().getLocation().(前提是這個外掛程式有Activator這個類.這個類繼承了ECLIPSE的Plugin類)
  eclipse採用osgi前好像好像是:
  MyPlugin.getDefault().getBundle().getLocation().(前提是這個外掛程式有MyPlugin這個類.這個類繼承了ECLIPSE的Plugin類)   
  2. 得到工作區路徑: Platform.getlocation();或
  ResourcesPlugin.getWorkspace();好像
  Platform.getInstanceLocation()也可行
  3. 得到ECLIPSE安裝路徑
  Platform.getInstallLocation();
  4. 從外掛程式中獲得絕對路徑:   
  AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath()
  通過檔案得到Project:
  IProject project = ((IFile)o).getProject();

  通過檔案得到全路徑:
  String path = ((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath();

  得到整個Workspace的根:
  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

  從根來尋找資源:
  IResource resource = root.findMember(new Path(containerName));

  從Bundle來尋找資源:
  Bundle bundle = Platform.getBundle(pluginId);
  URL fullPathString = BundleUtility.find(bundle, filePath);

  得到Appliaction workspace:
  Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath();

  得到runtimeworkspace:
  Platform.getInstanceLocation().getURL().getPath();

  從編輯器來獲得編輯檔案
  IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();
  IEditorInput input = editor.getEditorInput();
  if(input instanceof IFileEditorInput){
  IFile file = ((IFileEditorInput)input).getFile();
  }

  擷取外掛程式的絕對路徑:
  FileLocator.resolve(BuildUIPlugin.getDefault().getBundle().getEntry("/")).getFile();  

eclipse 知識匯總

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.