<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    hengheng123456789

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      297 Posts :: 68 Stories :: 144 Comments :: 0 Trackbacks

    今天在開發(fā)Eclipse插件時(shí)用到了Eclipse 文件資源,不知道在調(diào)試插件過程中如何調(diào)用自定義的圖片,于是在網(wǎng)上查了許久,有如下說明:

    對路徑的測試代碼:
    ????System.out.println(?Thread.currentThread().getContextClassLoader().getResource(""));
    ????System.out.println(PathTest.
    class.getClassLoader().getResource(""));
    ????System.out.println(ClassLoader.getSystemResource(
    ""));
    ????System.out.println(PathTest.
    class.getResource(""));
    ????System.out.println(PathTest.
    class.getResource("/"));
    ????System.out.println(
    new?File("").getAbsolutePath());
    ????System.out.println(System.getProperty(
    "user.dir"));
    結(jié)果如下:
    ???file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/
    ???file:
    /E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/
    ???file:
    /E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/
    ???file:
    /E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/com/wxxr/boss/config/
    ???file:
    /E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/
    ???E:\wxxr_projects2\wxxr
    -applications\wxxr-boss-connector
    ???E:\wxxr_projects2\wxxr
    -applications\wxxr-boss-connector


    一般情況是使用ClassLoader.getSystemResource("");
    但是在調(diào)試插件時(shí)其返回結(jié)果為NULL,郁悶不已,于是又看到如下文章:

    從插件中獲得絕對路徑:
    ???????

    AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath());

    通過文件得到Project:

    IProject?project? = ?((IFile)o).getProject();

    通過文件得到全路徑:

    String?path? = ?((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath();

    得到整個(gè)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();
    }

    最后暫時(shí)使用如下方法獲得成功:
    URL url = Thread.currentThread().getContextClassLoader().getResource(path + name);
    ImageIcon icon = new ImageIcon( url );
    OK暫時(shí)解決,但發(fā)布后不知如何實(shí)現(xiàn),再研究吧:)
    posted on 2006-09-28 15:55 哼哼 閱讀(586) 評論(0)  編輯  收藏 所屬分類: Eclipse

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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 无忧传媒视频免费观看入口| 在线观看免费中文视频| 亚洲AV无码日韩AV无码导航 | 最近的2019免费中文字幕| 久久亚洲日韩精品一区二区三区| 国内精品免费视频自在线| 在线观看免费黄色网址| 色婷五月综激情亚洲综合| 亚洲综合区小说区激情区| 无人在线直播免费观看| 精品一区二区三区免费观看| 亚洲伊人久久精品| 337p日本欧洲亚洲大胆裸体艺术| 成人免费午夜视频| 日本黄色动图免费在线观看| 亚洲AV无码XXX麻豆艾秋| 久久久久亚洲AV片无码下载蜜桃| 亚洲AV蜜桃永久无码精品| 成人免费AA片在线观看| 拍拍拍无挡免费视频网站| 亚洲国产精品精华液| 亚洲熟妇av一区二区三区下载| 亚洲高清成人一区二区三区| 黄页网站在线观看免费高清| 18禁在线无遮挡免费观看网站| 亚洲AV无码专区在线厂| 亚洲另类春色校园小说| 亚洲精品美女久久久久99| 免费人成在线观看网站视频| 在线观看免费人成视频色| 四虎影视在线影院在线观看免费视频 | 日韩精品成人无码专区免费| 一级毛片免费观看不卡的| 一级毛片免费在线播放| 亚洲精品国产suv一区88| 中文字幕亚洲色图| 亚洲精品亚洲人成在线观看| 亚洲国产一区视频| 波多野结衣中文一区二区免费| 无码视频免费一区二三区| 免费成人福利视频|