我想改變圖像視圖內的圖像。日食偵察圖像變化
我知道getTestImageField().setImageId(Icons.Logo);
不起作用,因爲它不會刷新渲染器。
因爲我需要使用setImage()
,所以我需要一種方法從Icons
類中獲取圖像。
帕特里克建議我嘗試
final IconProviderService provider = SERVICES.getService(IconProviderService.class);
final IconSpec ic = provider.getIconSpec(AbstractIcons.StatusError);
final byte[] content = ic.getContent();
但我的問題是,ic
總是null
。
雖然我調試這個我注意到,裏面IconProviderService.class
在第57行:
@Override
protected URL findResource(String fullPath) {
URL[] entries = FileLocator.findEntries(m_hostBundle, new Path(fullPath));
if (entries != null && entries.length > 0) {
URL url = entries[entries.length - 1];
if (LOG.isDebugEnabled()) {
LOG.debug("find image " + fullPath + " in bundle " + m_hostBundle.getSymbolicName() + "->" + url);
}
return url;
}
return null;
}
URL[]
條目總是空不管巫婆圖標我努力表現。
經過進一步調試後,我發現FileLocator
試圖從bundle中查找片段,然後在這些片段中查找路徑。 (line 242
)
Bundle[] fragments = activator.getFragments(b);
但Bundle[] fragments
總是空。
通常我的包b
是(Bundle) EquinoxBundle : org.eclipse.scout.rt.ui.rap.mobile_4.0.100.20140829-1424
。
我想嘗試用不同的包,所以我做的:
final BundleContext context = Activator.getDefault().getBundle().getBundleContext();
for (final Bundle b : context.getBundles()) {
final IconProviderService provider = SERVICES.getService(IconProviderService.class);
provider.setHostBundle(b);
final IconSpec ic = provider.getIconSpec(AbstractIcons.StatusError);
if (ic != null) {
final byte[] content = ic.getContent();
imageField().setImage(content);
}
}
但fragments
(從上面的代碼)始終爲空。
這聽起來像是一件難事。您能否請添加以下信息: 圖標是否適合您? (例如,在表格列上的getConfiguredIconId) 您想要顯示的圖標文件(png)在哪裏? 位於相應的圖標類(java文件)在哪裏? 你在哪個包中檢索圖標? 在調用檢索IconSpec期間,AbstractIconProviderService中的m_hostBundle的值是什麼? – Patrick
是設置圖標正在工作。如果我設置了getConfiguredIconId,它可以工作,如果在代碼集setIconId和更新頁面中,它也可以。圖標是Scout內部的默認圖標,或我添加的圖標(客戶端/資源/圖標/ ...)。 Icons.class位於共享文件夾(根目錄)中。我發佈的包是:org.eclipse.scout.rt.ui.rap.mobile。 –
我嘗試設置不同的包provider.setHostBundle(Activator.getDefault()。getBundle());但它也沒有工作。 –