Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 759|回复: 0

解决Eclipse Problems视图丢失图标问题

[复制链接]
  • TA的每日心情
    奋斗
    2024-11-24 15:47
  • 签到天数: 804 天

    [LV.10]以坛为家III

    2053

    主题

    2111

    帖子

    72万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    726782
    发表于 2021-9-4 14:12:57 | 显示全部楼层 |阅读模式

    在基于Eclipse 3.7平台构建的项目中,发现Problems视图图标显示异常:

     

     

    解决方法:

      首先在WorkbenchWindowAdvisor实现类中的preWindowOpen方法中调用:

    IDE.registerAdapters();

     这样就注册了各种适配器类,然后在WorkbenchAdvisor的实现类的initialize方法中初始化图片注册表,可以参考IDEWorkbenchAdvisor类中的initialize方法,

      1 /**
      2      * Declares all IDE-specific workbench images. This includes both "shared"
      3      * images (named in {@link IDE.SharedImages}) and internal images (named in
      4      * {@link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}).
      5      * 
      6      * @see IWorkbenchConfigurer#declareImage
      7      */
      8     private void declareWorkbenchImages() {
      9 
     10         final String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
     11         final String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; // Enabled //$NON-NLS-1$
     12 
     13         // toolbar
     14         // icons.
     15         final String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; // Disabled //$NON-NLS-1$
     16         // //$NON-NLS-1$
     17         // toolbar
     18         // icons.
     19         final String PATH_ETOOL = ICONS_PATH + "etool16/"; // Enabled toolbar //$NON-NLS-1$
     20         // //$NON-NLS-1$
     21         // icons.
     22         final String PATH_DTOOL = ICONS_PATH + "dtool16/"; // Disabled toolbar //$NON-NLS-1$
     23         // //$NON-NLS-1$
     24         // icons.
     25         final String PATH_OBJECT = ICONS_PATH + "obj16/"; // Model object //$NON-NLS-1$
     26         // //$NON-NLS-1$
     27         // icons
     28         final String PATH_WIZBAN = ICONS_PATH + "wizban/"; // Wizard //$NON-NLS-1$
     29         // //$NON-NLS-1$
     30         // icons
     31 
     32         // View icons
     33         final String PATH_EVIEW= ICONS_PATH + "eview16/"; //$NON-NLS-1$
     34 
     35 
     36         Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
     37 
     38         declareWorkbenchImage(ideBundle,
     39                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, PATH_ETOOL
     40                         + "build_exec.gif", false); //$NON-NLS-1$
     41         declareWorkbenchImage(ideBundle,
     42                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER,
     43                 PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
     44         declareWorkbenchImage(ideBundle,
     45                 IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED,
     46                 PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
     47 
     48         declareWorkbenchImage(ideBundle,
     49                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, PATH_ETOOL
     50                         + "search_src.gif", false); //$NON-NLS-1$
     51         declareWorkbenchImage(ideBundle,
     52                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER,
     53                 PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
     54         declareWorkbenchImage(ideBundle,
     55                 IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED,
     56                 PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
     57 
     58         declareWorkbenchImage(ideBundle,
     59                 IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL
     60                         + "next_nav.gif", false); //$NON-NLS-1$
     61 
     62         declareWorkbenchImage(ideBundle,
     63                 IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, PATH_ETOOL
     64                         + "prev_nav.gif", false); //$NON-NLS-1$
     65 
     66         declareWorkbenchImage(ideBundle,
     67                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, PATH_WIZBAN
     68                         + "newprj_wiz.png", false); //$NON-NLS-1$
     69         declareWorkbenchImage(ideBundle,
     70                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ,
     71                 PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
     72         declareWorkbenchImage(ideBundle,
     73                 IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, PATH_WIZBAN
     74                         + "newfile_wiz.png", false); //$NON-NLS-1$
     75 
     76         declareWorkbenchImage(ideBundle,
     77                 IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ,
     78                 PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
     79         declareWorkbenchImage(ideBundle,
     80                 IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ,
     81                 PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
     82 
     83         declareWorkbenchImage(ideBundle,
     84                 IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ,
     85                 PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
     86         declareWorkbenchImage(ideBundle,
     87                 IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ,
     88                 PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
     89 
     90         declareWorkbenchImage(ideBundle,
     91                 IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ,
     92                 PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
     93 
     94         declareWorkbenchImage(ideBundle,
     95                 IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, PATH_WIZBAN
     96                         + "saveas_wiz.png", false); //$NON-NLS-1$
     97 
     98         declareWorkbenchImage(ideBundle,
     99                 IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, PATH_WIZBAN
    100                         + "quick_fix.png", false); //$NON-NLS-1$
    101 
    102         declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT,
    103                 PATH_OBJECT + "prj_obj.gif", true); //$NON-NLS-1$
    104         declareWorkbenchImage(ideBundle,
    105                 IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
    106                         + "cprj_obj.gif", true); //$NON-NLS-1$
    107         declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER,
    108                 PATH_ELOCALTOOL + "gotoobj_tsk.gif", true); //$NON-NLS-1$
    109 
    110 
    111         // Quick fix icons
    112         declareWorkbenchImage(ideBundle,
    113                 IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED,
    114                 PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
    115 
    116         declareWorkbenchImage(ideBundle,
    117                 IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED,
    118                 PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
    119 
    120         declareWorkbenchImage(ideBundle,
    121                 IDEInternalWorkbenchImages.IMG_OBJS_FIXABLE_WARNING,
    122                 PATH_OBJECT + "quickfix_warning_obj.gif", true); //$NON-NLS-1$
    123         declareWorkbenchImage(ideBundle,
    124                 IDEInternalWorkbenchImages.IMG_OBJS_FIXABLE_ERROR,
    125                 PATH_OBJECT + "quickfix_error_obj.gif", true); //$NON-NLS-1$
    126 
    127 
    128         // task objects
    129         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_HPRIO_TSK,
    130         // PATH_OBJECT+"hprio_tsk.gif");
    131         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_MPRIO_TSK,
    132         // PATH_OBJECT+"mprio_tsk.gif");
    133         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
    134         // PATH_OBJECT+"lprio_tsk.gif");
    135 
    136         declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK,
    137                 PATH_OBJECT + "taskmrk_tsk.gif", true); //$NON-NLS-1$
    138         declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK,
    139                 PATH_OBJECT + "bkmrk_tsk.gif", true); //$NON-NLS-1$
    140 
    141         declareWorkbenchImage(ideBundle,
    142                 IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, PATH_OBJECT
    143                         + "complete_tsk.gif", true); //$NON-NLS-1$
    144         declareWorkbenchImage(ideBundle,
    145                 IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, PATH_OBJECT
    146                         + "incomplete_tsk.gif", true); //$NON-NLS-1$
    147         declareWorkbenchImage(ideBundle,
    148                 IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, PATH_OBJECT
    149                         + "welcome_item.gif", true); //$NON-NLS-1$
    150         declareWorkbenchImage(ideBundle,
    151                 IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, PATH_OBJECT
    152                         + "welcome_banner.gif", true); //$NON-NLS-1$
    153         declareWorkbenchImage(ideBundle,
    154                 IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, PATH_OBJECT
    155                         + "error_tsk.gif", true); //$NON-NLS-1$
    156         declareWorkbenchImage(ideBundle,
    157                 IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, PATH_OBJECT
    158                         + "warn_tsk.gif", true); //$NON-NLS-1$
    159         declareWorkbenchImage(ideBundle,
    160                 IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT
    161                         + "info_tsk.gif", true); //$NON-NLS-1$
    162 
    163         declareWorkbenchImage(ideBundle,
    164                 IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, PATH_ELOCALTOOL
    165                         + "flatLayout.gif", true); //$NON-NLS-1$
    166         declareWorkbenchImage(ideBundle,
    167                 IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT,
    168                 PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
    169         declareWorkbenchImage(ideBundle,
    170                 IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY,
    171                 PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
    172 
    173         declareWorkbenchImage(ideBundle,
    174                 IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW,
    175                 PATH_EVIEW + "problems_view.gif", true); //$NON-NLS-1$
    176         declareWorkbenchImage(ideBundle,
    177                 IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW_ERROR,
    178                 PATH_EVIEW + "problems_view_error.gif", true); //$NON-NLS-1$
    179         declareWorkbenchImage(ideBundle,
    180                 IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW_WARNING,
    181                 PATH_EVIEW + "problems_view_warning.gif", true); //$NON-NLS-1$
    182 
    183         // synchronization indicator objects
    184         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_WBET_STAT,
    185         // PATH_OVERLAY+"wbet_stat.gif");
    186         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_SBET_STAT,
    187         // PATH_OVERLAY+"sbet_stat.gif");
    188         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_CONFLICT_STAT,
    189         // PATH_OVERLAY+"conflict_stat.gif");
    190 
    191         // content locality indicator objects
    192         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_NOTLOCAL_STAT,
    193         // PATH_STAT+"notlocal_stat.gif");
    194         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LOCAL_STAT,
    195         // PATH_STAT+"local_stat.gif");
    196         // declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_FILLLOCAL_STAT,
    197         // PATH_STAT+"filllocal_stat.gif");
    198     }
    199 
    200     /**
    201      * Declares an IDE-specific workbench image.
    202      * 
    203      * @param symbolicName
    204      *            the symbolic name of the image
    205      * @param path
    206      *            the path of the image file; this path is relative to the base
    207      *            of the IDE plug-in
    208      * @param shared
    209      *            <code>true</code> if this is a shared image, and
    210      *            <code>false</code> if this is not a shared image
    211      * @see IWorkbenchConfigurer#declareImage
    212      */
    213     private void declareWorkbenchImage(Bundle ideBundle, String symbolicName,
    214             String path, boolean shared) {
    215         URL url = FileLocator.find(ideBundle, new Path(path), null);
    216         ImageDescriptor desc = ImageDescriptor.createFromURL(url);
    217         getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
    218     }

    将上述代码复制到WorkbenchAdvisor实现类中,然后在initialize方法中调用declareWorkbenchImages方法就行了

    @Override
        public void initialize(IWorkbenchConfigurer configurer) {
            super.initialize(configurer);
            
            declareWorkbenchImages();
        }

     

     

     

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-12-22 13:55 , Processed in 0.068980 second(s), 28 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表