package sunline.ide2.transaction.utils;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertySheet;
import sunline.ide2.transaction.gef.uis.editor.TransViewEditor;
/**
* 对界面操作的常用方法
* @author Administrator
*
*/
public class UIUtil {
public static void closeEditor(String id)
{
//System.out.println("closeing... :"+id);
IEditorReference[] editorRefs=getActivePage().getEditorReferences();
for(IEditorReference editorRef:editorRefs)
{
//System.out.println(editorRef.getId());
if(id.equals(editorRef.getId()))
{
//System.out.println("close :"+id);
getActivePage().closeEditor(editorRef.getEditor(true), true);
break;
}
}
}
public static IWorkbenchPage getActivePage()
{
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
return page;
}
public static PropertySheet getPropertySheet()
{
IWorkbenchPage page = getActivePage();
IViewPart ivp = page.findView("org.eclipse.ui.views.PropertySheet");
if (ivp == null) {
try {
ivp = page.showView("org.eclipse.ui.views.PropertySheet");
} catch (PartInitException e1) {
e1.printStackTrace();
}
}
PropertySheet property = (PropertySheet) ivp;
return property;
}
public static IEditorPart getActiveEditor()
{
IWorkbenchPage page = getActivePage();
return page.getActiveEditor();
}
public static IEditorPart getEditor(String id)
{
IWorkbenchPage page = getActivePage();
IEditorReference[] editorRefs=getActivePage().getEditorReferences();
for(IEditorReference editorRef:editorRefs)
{
//System.out.println(editorRef.getId());
if(id.equals(editorRef.getId()))
{
return editorRef.getEditor(true);
}
}
return null;
}
public static IWorkbenchPart getActivePart()
{
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
return page.getActivePart();
}
//现实一般模型的属性
public static void showPropertyInPropertySheet(IAdaptable model)
{
PropertySheet property = getPropertySheet();
IPropertySource source= (IPropertySource) model.getAdapter(IPropertySource.class);
// IPropertySourceProvider sourceProvider= (IPropertySource) model.getAdapter(IPropertySourceProvider.class);
if(source!=null)
{
//将选择的对象 加载到 属性面板中,有属性源 动态的创建具体的属性内容
StructuredSelection sel=new StructuredSelection(model);
property.selectionChanged(getActivePart(), sel);
}
else
{
LogUtil.log("error:showPropertyInPropertySheet model 格式不正确。");
}
}
}
分享到:
相关推荐
Display的主要任务是事件处理,它负责从操作系统的事件队列中读取事件,传递给RCP的事件监听器以便完成具体的任务。需要注意的是,Display对象不代表应用程序窗口的任何可视控件,在应用程序主窗口打开之前,Display...
其中,向视图中添加控件的操作,我们即可以手工编写,也可以使用Designer插件,我这里推荐大家使用Designer插件,该插件对RCP提供功能非常强大的支持,如果使用Designer插件开发视图,则plugin.xml文
(例如,向导筛选器创建器)msgs上的标签可用于控制每个单独字段(主题,发件人等)的字体/颜色,以及在应用或删除标签时执行操作。 (以这种方式处理垃圾邮件/ Fishy邮件。)可以随时重命名或移动文件夹,而不会...
对于UI/UX设计,有界面设计工具,如Sketch、Adobe XD,可以帮助设计师快速构建应用程序界面模型,并生成规范的设计稿供开发人员参考实现。 跨平台支持: 跨平台开发工具如Xamarin、React Native和Flutter,让...
Katalon Studio 是一个 2015 年才推出的自动化测试框架,基于 Eclipise RCP 技术开发,使用 Selenium 和 Appium 作为底层框架,在 UI 层能全面支持 Web 和 Android、iOS 移动应用的自动化,在 API 接口自动化测试...
1.4.2 SWT所支持的操作系统 6 1.5 Sun AWT/Swing与Eclipse SWT 7 1.5.1 Swing与SWT的比较 7 1.5.2 SWT的优势和不足 8 1.6 SWT与JFace、Eclipse 9 1.6.1 JFace是SWT的扩展 9 1.6.2 Eclipse的UI界面基于...
10.1 在RCP上构建应用程序的 理由...... 235 10.1.1 给企业带来的好处..... 235 10.1.2 给软件开发者带来的 好处..... 236 10.1.3 给用户带来的好处..... 236 10.2 复习Eclipse体系结构...... 237 10.2.1 Eclipse...
这个新的小部件允许在Java SWT或Eclipse RCP应用程序中开发现代的Web UI。 使用与其他SWT浏览器相同的API,可以轻松地将其嵌入Eclipse视图中。 不再为每个平台定制代码,不再为Linux安装特定的库,在Windows中使用...
10.1 在RCP上构建应用程序的 理由...... 235 10.1.1 给企业带来的好处..... 235 10.1.2 给软件开发者带来的 好处..... 236 10.1.3 给用户带来的好处..... 236 10.2 复习Eclipse体系结构...... 237 ...
10.1 在RCP上构建应用程序的 理由...... 235 10.1.1 给企业带来的好处..... 235 10.1.2 给软件开发者带来的 好处..... 236 10.1.3 给用户带来的好处..... 236 10.2 复习Eclipse体系结构...... 237 ...
├── zheng-ui -- 前台thymeleaf模板[端口:1000] ├── zheng-config -- 配置中心[端口:1001] ├── zheng-upms -- 用户权限管理系统 | ├── zheng-upms-common -- upms系统公共模块 | ├── zheng-upms-dao ...