【问题标题】:Eclipse plug-in where to create resources ans dispose themEclipse 插件在哪里创建和释放资源
【发布时间】:2014-08-29 17:49:06
【问题描述】:

开发作为产品和可部署插件 (jar) 导出的 eclipse 插件时的一般问题。 创建资源(颜色等)和处置它们的最佳地点在哪里?在Activator 类的start() 中尝试过。问题是我无法在那里获得Display 对象。

还在ApplicationWorkbenchWindowAdvisor 中尝试过,我可以通过PlatformUI.getWorkbench().getDisplay() 访问显示器。仅当插件作为产品导出时才会调用此类。

【问题讨论】:

    标签: eclipse resources rcp


    【解决方案1】:

    对于颜色和字体,您可以使用“org.eclipse.ui.themes”扩展点。然后 Eclipse 将为您管理这些资源。这还允许用户自定义“首选项 > 常规 > 外观 > 颜色和字体”中的值。

    要获得使用扩展点定义的颜色和字体,请使用:

    ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
    
    Color color = theme.getColorRegistry().get("color id");
    
    Font font = theme.getFontRegistry().get("font id");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多