use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class ApplicationWorkbenchAdvisor method declareWorkbenchImage.
/**
* Declares an IDE-specific workbench image.
* @param symbolicName
* the symbolic name of the image
* @param path
* the path of the image file; this path is relative to the base of the IDE plug-in
* @param shared
* <code>true</code> if this is a shared image, and <code>false</code> if this is not a shared image
* @see IWorkbenchConfigurer#declareImage
*/
private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String path, boolean shared) {
URL url = FileLocator.find(ideBundle, new Path(path), null);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
}
use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class ImageCellRender method createPrintRenderer.
public ICellRenderer createPrintRenderer(Printer printer) {
ObjectImageRenderer renderer = new ObjectImageRenderer(printer);
for (Object o : keyMap.keySet()) {
String key = keyMap.get(o);
ImageDescriptor imageDesc = getImageRegistry().getDescriptor(key);
renderer.addObjectImageDescriptorMapping(o, key, imageDesc);
}
return renderer;
}
use of org.eclipse.jface.resource.ImageDescriptor in project translationstudio8 by heartsome.
the class BrowserViewPart method getTitleImage.
public Image getTitleImage(String iamgeUrl) {
Image cacheImage = titleIamgeCache.get(iamgeUrl);
if (null != cacheImage) {
return cacheImage;
}
URL url = null;
try {
url = new URL(iamgeUrl);
} catch (MalformedURLException e) {
e.printStackTrace();
}
if (null == url) {
return null;
}
Image image = null;
try {
ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url);
ImageData imageData = imageDescriptor.getImageData();
ImageData scaledTo = imageData.scaledTo(16, 16);
image = ImageDescriptor.createFromImageData(scaledTo).createImage();
} catch (Exception e) {
// no need handle
return null;
}
if (null != image) {
titleIamgeCache.put(iamgeUrl, image);
}
return image;
}
use of org.eclipse.jface.resource.ImageDescriptor in project jop by jop-devel.
the class JOPUIImages method declareRegistryImage.
/**
* Declare an Image in the registry table.
* @param key The key to use when registering the image
* @param path The path where the image can be found. This path is relative to where
* this plugin class is found (i.e. typically the packages directory)
*/
private static final void declareRegistryImage(String key, String path) {
ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
Bundle bundle = Platform.getBundle(JOPUIPlugin.PLUGIN_ID);
URL url = null;
if (bundle != null) {
url = FileLocator.find(bundle, new Path(path), null);
desc = ImageDescriptor.createFromURL(url);
}
JOPUIPlugin.getDefault().getImageRegistry().put(key, desc);
}
use of org.eclipse.jface.resource.ImageDescriptor in project GT by Tencent.
the class DevicesView method makeActions.
/**
* 初始化action
*/
private void makeActions() {
/**
* 测试按钮
*/
testAction = new StartTestAction();
testAction.setText("Start");
testAction.setToolTipText("开始检测");
testAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/start.png"));
/**
* 刷新按钮
*/
refreshAction = new Action() {
public void run() {
refreshGetPkgInfo();
}
};
refreshAction.setText("获取手机上的进程列表");
refreshAction.setToolTipText("获取手机上的进程列表");
refreshAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/refresh.png"));
/**
* 打开log目录
*/
openResultDirAction = new Action() {
public void run() {
try {
if (PCInfo.OSName.toLowerCase().indexOf("window") != -1) {
Runtime.getRuntime().exec("explorer.exe " + Constant.LOG_FOLDER_ON_PC + File.separator + TestSence.getInstance().curDir);
} else {
Runtime.getRuntime().exec("open " + Constant.LOG_FOLDER_ON_PC + File.separator + TestSence.getInstance().curDir);
}
} catch (IOException e) {
e.printStackTrace();
APTConsoleFactory.getInstance().APTPrint("打开测试结果文件夹失败");
}
}
};
openResultDirAction.setText("打开测试结果保存目录");
openResultDirAction.setToolTipText("打开测试结果保存目录");
openResultDirAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));
/**
* 打开log
*/
openLogWithChartAction = new Action() {
public void run() {
FileDialog dialog = new FileDialog(sourcePkgTableViewer.getControl().getShell(), SWT.OPEN);
//设置初始路径
dialog.setFilterPath(Constant.LOG_FOLDER_ON_PC);
//返回的全路径(路径+文件名)
final String fileName = dialog.open();
if (fileName == null) {
return;
}
final APTLogFileHeader afh = APTLogFileParse.pareseAPTLogFileHeader(fileName);
if (afh == null) {
APTConsoleFactory.getInstance().APTPrint("文件头格式不兼容");
return;
}
//在数据量比较大时,解析会比较大
APTState.getInstance().DealWithEventBefore(APTEventEnum.OPENLOG_OPER);
APTConsoleFactory.getInstance().APTPrint("正解析log数据,请稍候......");
final CPUView cpuViewPart = (CPUView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CPUView.ID);
final MemoryView memViewPart = (MemoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MemoryView.ID);
cpuViewPart.setCpuTableViewerFilter(null);
cpuViewPart.setJiffiesTableViewerFilter(null);
memViewPart.setTableViewerFilter(null);
Thread parseLogThread = new Thread(new Runnable() {
@Override
public void run() {
final JfreeChartDatas datas = APTLogFileParse.getData(fileName, afh);
if (datas == null) {
APTConsoleFactory.getInstance().APTPrint("文件格式不兼容");
return;
}
if (datas.monitorItem.equals(Constant.TEXT_ITEM_TITLES[Constant.CPU_INDEX])) {
cpuViewPart.cpuRealTimeChart.fillData(datas);
} else {
memViewPart.memRealTimeChart.fillData(datas);
}
}
});
parseLogThread.start();
try {
//TODO 这里使用会不会存在很卡的情况,打开比较大的文件的时候
parseLogThread.join();
for (int i = 0; i < afh.pkgNames.length; i++) {
PkgInfo item = new PkgInfo();
item.contents[PkgInfo.NAME_INDEX] = afh.pkgNames[i];
item.contents[PkgInfo.PID_INDEX] = "-1";
addDataItem(targetPkgTableViewer, item);
}
APTState.getInstance().DealWithEventAfter(APTEventEnum.OPENLOG_OPER);
//APTConsoleFactory.getInstance().APTPrint("打开log更新");
GetCurCheckedStateUtil.update();
APTConsoleFactory.getInstance().APTPrint("log打开完毕");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
openLogWithChartAction.setText("用JFreechart打开log");
openLogWithChartAction.setToolTipText("用JFreechart打开log");
openLogWithChartAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/generate_chart.png"));
/**
* 复制数据
*/
copyAction = new CopyAllFromTableViewAction(sourcePkgTableViewer);
copyAction.setText("复制");
copyAction.setToolTipText("复制当前显示的表格数据到剪切板");
ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/save.png");
copyAction.setImageDescriptor(descriptor);
/**
* 添加菜单
*/
addPkgAction = new Action() {
@Override
public void run() {
if (isSupportAddOrDeleteOper) {
super.run();
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
IStructuredSelection iss = (IStructuredSelection) sourcePkgTableViewer.getSelection();
if (iss == null) {
return;
}
PkgInfo itemData = (PkgInfo) iss.getFirstElement();
addDataItem(targetPkgTableViewer, itemData);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
};
addPkgAction.setText("添加");
addPkgAction.setToolTipText("添加该进程到被测进程列表");
addPkgAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/add.png"));
/**
* 删除菜单
*/
removePkgAction = new Action() {
@Override
public void run() {
if (isSupportAddOrDeleteOper) {
super.run();
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
TableItem[] selectData = targetPkgTableViewer.getTable().getSelection();
if (selectData == null || selectData.length == 0) {
return;
}
PkgInfo itemData = (PkgInfo) selectData[0].getData();
targetPkgTableViewer.remove(itemData);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
};
removePkgAction.setText("删除");
removePkgAction.setToolTipText("从被测进程列表中删除该进程");
removePkgAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/remove.png"));
pmapAction = new GetPMAPInfoAction(sourcePkgTableViewer);
pmapAction.setText("PMAP");
pmapAction.setToolTipText("PMAP");
pmapAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/pmap.png"));
smapAction = new GetSMAPInfoAction(sourcePkgTableViewer);
smapAction.setText("SMAP");
smapAction.setToolTipText("SMAP");
smapAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/pmap.png"));
dumpHprofAction = new DumpHprofAction();
dumpHprofAction.setText("DumpHprof");
dumpHprofAction.setToolTipText("DumpHprof");
dumpHprofAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/dump.png"));
gcAction = new GCAction();
gcAction.setText("GC");
gcAction.setToolTipText("GC");
gcAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/gc.png"));
}
Aggregations