ECLIPSE PLUG-IN RCP
此部分有的是自己的开发中的经验,有的是在论坛中看到别人的经验。我在这里把部分觉得好的部分收集,整理。希望对大家有帮助。
1:登陆对话框
public Object run(Object args) throws Exception {
Display display = PlatformUI.createDisplay();
try {
Platform.endSplash();
/**
* 登录
*/
if (!login())
return IPlatformRunnable.EXIT_OK;
logger.info("正在初始化客户端......");
//
InitUIProgress.addInfor("初始化主界面...");
int returnCode = PlatformUI.createAndRunWorkbench(display,
new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IPlatformRunnable.EXIT_RESTART;
}
return IPlatformRunnable.EXIT_OK;
} finally {
display.dispose();
}
}
2:该写actionBar 的 ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window)
IActionBarConfigurer configurer = getActionBarConfigurer();
final IWorkbenchWindow window = configurer.getWindowConfigurer().getWindow();
MenuManager perspectiveMenu = new MenuManager("Open Perspective");
IContributionItem perspectiveList = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window);
perspectiveMenu.add(perspectiveList);
windowMenu.add(perspectiveMenu);
3:让其viewpart显示流线型
在 WorkbenchWindowAdvisor 中的preWindowOpen()中设置
//显示特效
PlatformUI.getPreferenceStore().setDefault(
IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, true);
//不显示传统的窗口
PlatformUI.getPreferenceStore().setDefault(
IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
false);
4:可以使用action来做, 调用下面的方法:
IWorkbench.showPerspective(String perspectiveId, IWorkbenchWindow window)
or
IWorkbench.showPerspective(String perspectiveId, IWorkbenchWindow window, IAdaptable input)
IWorkbench和IWorkbenchWindow对象都可以在ViewPart中找到.
5:定义热键
getShell().getDisplay().addFilter(SWT.KeyDown, globEvent);
将plugin.xml里面hotkey
<extension
point="org.eclipse.ui.bindings">
<!--key
commandId="org.eclipse.ui.file.exit"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+X">
</key -->
</extension>
6.如何或得RCP中的一些路径问题
从插件中获得绝对路径:
AaaaPlugin.getDefault().getStateLocation().makeAbsolute().toFile().getAbsolutePath());
通过文件得到Project:
IProject project = ((IFile)o).getProject();
通过文件得到全路径:
String path = ((IFile)o).getLocation().makeAbsolute().toFile().getAbsolutePath();
得到整个Workspace的根:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
从根来查找资源:
IResource resource = root.findMember(new Path(containerName));
从Bundle来查找资源:
Bundle bundle = Platform.getBundle(pluginId);
URL fullPathString = BundleUtility.find(bundle, filePath);
得到Appliaction workspace:
Platform.asLocalURL(PRODUCT_BUNDLE.getEntry("")).getPath()).getAbsolutePath();
得到runtimeworkspace:
Platform.getInstanceLocation().getURL().getPath();
从编辑器来获得编辑文件:
IEditorPart editor = ((DefaultEditDomain)(parent.getViewer().getEditDomain())).getEditorPart();
IEditorInput input = editor.getEditorInput();
if(input instanceof IFileEditorInput){
IFile file = ((IFileEditorInput)input).getFile();
}
得到plugin.xml中的所以ACTION
IContributionItem[] items = getViewSite().getActionBars().getMenuManager().getItems();
for (int i = 0; i < items.length; i++) {
manager.add(items[i]);
}
分享到:
相关推荐
eclilpse rcp的一些资源.rareclilpse rcp的一些资源.rareclilpse rcp的一些资源.rareclilpse rcp的一些资源.rareclilpse rcp的一些资源.rareclilpse rcp的一些资源.rar
RCP&OSGI;
RCP在线升级RCP在线升级RCP在线升级RCP在线升级RCP在线升级
RCP与GEF的课件,简单的介绍了RCP和GEF中的各组件的功能,已经工作流程
RCP 常见的扩展点指南 RCP最精华的部分之一,详细分析了RCP如何建立扩展点的。
想学习RCP的看一下啊 这是一个可以能直接用的工程。不过需要导入到您的工程中
RCP导出EXE 老大难问题。 RCp 程序导出步骤,保证能够导出~
Eclipse RCP允许开发者使用eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP入手可能会比较困难、费时。接下来我们将主要讲述如何让RCP工作. ...
clipse RCP允许开发者使用eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP入手可能会比较困难、费时。接下来我们将主要讲述如何让RCP工作 ...
有关rcp的内容 是rcp入门的好帮手,rcp自学的好帮手
Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT
Eclipse RCP富客户端平台,基于Eclipse开发的。
RCP项目的登录窗体RCP项目的登录窗体RCP项目的登录窗体RCP项目的登录窗体
RCP系统使用的弹出式日期控件,可切换上月下月,前一年后一年,可选择年、月
RCP源码例子 RCP源码例子 RCP源码例子
RCP中文入门教程,RCP中文入门教程,RCP中文入门教程,RCP中文入门教程
EclipseRcp 例子程序
rcp for java one
eclipse rcp check table
eclipse rcp 例子 源码