cownew开源-eclipse插件开发学习知识点笔记
2006-07-21 00:33
579 查看
1、从TextEditor继承,调用setSourceViewerConfiguration,并传进去一个从SourceViewerConfiguration 继承的配置类,就可以实现各种代码editor。
2、swt尽量使用GridLayout布局(不是java.awt中的GridLayout,而是swt中的)和GridData域。文章:http://coolbear.yculblog.com/post.89429.html
3、得到文件的编辑器的方法:
public static IEditorPart findEditor(IFile file){
IEditorReference[] editors = getActivePage().getEditorReferences();;
for (int i = 0; i < editors.length; i++) {
IEditorPart part = (IEditorPart)editors[i].getPart(false);
if (part != null ){
IEditorInput input = part.getEditorInput();
if(input instanceof FileEditorInput && ((FileEditorInput)input).getFile().equals(file))
return part;
}
}
return null;
}
4、得到工作区中所有工程的方法:
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
.getProjects();
这在开发自己的工程向导的时候很有用处。
5、工程特有文件判断方法
project.getFile("cownew.prj").exists();
project.getDescription().hasNature();
给工程增加Nature的方法:
IProjectDescription desc = project.getDescription();
String[] oldNatureIds = desc.getNatureIds();
String[] newNatureIds = new String[oldNatureIds.length +1];
System.arraycopy(oldNatureIds, 0, newNatureIds, 0, oldNatureIds.length);
newNatureIds[oldNatureIds.length] = "CowNewNature";
desc.setNatureIds(newNatureIds);
project.setDescription(desc, monitor);
6、创建文件夹的方法:
IFolder folder = project.getFolder("myfold");
if (folder!=null && !folder.exists())
folder.create(false, true, null);
7、弹出包选择对话框的方法:
ElementListSelectionDialog dialog = new ElementListSelectionDialog(
getShell(), new LabelProvider());
dialog.setIgnoreCase(false);
dialog.setElements(getAllPackages().toArray());
String path = currentPackage();
dialog.setInitialSelections(new Object[] { path });
dialog.open();
fPKName.setText((String) dialog.getFirstResult());
public List getAllPackages() {
List list = new ArrayList();
IResource res = getFirstSelection();
IProject project = res.getProject();
File file = project.getFolder("src").getLocation().toFile();
File[] fs = file.listFiles();
for (int i = 0; i < fs.length; i++) {
if (fs[i].isDirectory())
iterator("", fs[i], list);
}
Collections.sort(list);
return list;
}
8 objectClass="org.eclipse.core.resources.IFile"代表菜单应用到文件
9 透视图的的实现很简单,就是在构造函数里边打开一些视图,使一些action(这样菜单和按钮也就都可用)可以用,比如:
String editorArea = layout.getEditorArea();
IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
0.30f, editorArea);
left.addView(PACKAGE_VIEW_ID);
layout.setEditorAreaVisible(true);
layout.addShowViewShortcut(IDESystem.BUSINESSVIEW_ID);
本文出自 “CowNew开源团队” 博客,转载请与作者联系!
2、swt尽量使用GridLayout布局(不是java.awt中的GridLayout,而是swt中的)和GridData域。文章:http://coolbear.yculblog.com/post.89429.html
3、得到文件的编辑器的方法:
public static IEditorPart findEditor(IFile file){
IEditorReference[] editors = getActivePage().getEditorReferences();;
for (int i = 0; i < editors.length; i++) {
IEditorPart part = (IEditorPart)editors[i].getPart(false);
if (part != null ){
IEditorInput input = part.getEditorInput();
if(input instanceof FileEditorInput && ((FileEditorInput)input).getFile().equals(file))
return part;
}
}
return null;
}
4、得到工作区中所有工程的方法:
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
.getProjects();
这在开发自己的工程向导的时候很有用处。
5、工程特有文件判断方法
project.getFile("cownew.prj").exists();
project.getDescription().hasNature();
给工程增加Nature的方法:
IProjectDescription desc = project.getDescription();
String[] oldNatureIds = desc.getNatureIds();
String[] newNatureIds = new String[oldNatureIds.length +1];
System.arraycopy(oldNatureIds, 0, newNatureIds, 0, oldNatureIds.length);
newNatureIds[oldNatureIds.length] = "CowNewNature";
desc.setNatureIds(newNatureIds);
project.setDescription(desc, monitor);
6、创建文件夹的方法:
IFolder folder = project.getFolder("myfold");
if (folder!=null && !folder.exists())
folder.create(false, true, null);
7、弹出包选择对话框的方法:
ElementListSelectionDialog dialog = new ElementListSelectionDialog(
getShell(), new LabelProvider());
dialog.setIgnoreCase(false);
dialog.setElements(getAllPackages().toArray());
String path = currentPackage();
dialog.setInitialSelections(new Object[] { path });
dialog.open();
fPKName.setText((String) dialog.getFirstResult());
public List getAllPackages() {
List list = new ArrayList();
IResource res = getFirstSelection();
IProject project = res.getProject();
File file = project.getFolder("src").getLocation().toFile();
File[] fs = file.listFiles();
for (int i = 0; i < fs.length; i++) {
if (fs[i].isDirectory())
iterator("", fs[i], list);
}
Collections.sort(list);
return list;
}
8 objectClass="org.eclipse.core.resources.IFile"代表菜单应用到文件
9 透视图的的实现很简单,就是在构造函数里边打开一些视图,使一些action(这样菜单和按钮也就都可用)可以用,比如:
String editorArea = layout.getEditorArea();
IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
0.30f, editorArea);
left.addView(PACKAGE_VIEW_ID);
layout.setEditorAreaVisible(true);
layout.addShowViewShortcut(IDESystem.BUSINESSVIEW_ID);
本文出自 “CowNew开源团队” 博客,转载请与作者联系!
相关文章推荐
- Eclipse插件开发 学习笔记 PDF 第一篇到第四篇 免分下载 开发基础 核心技术 高级进阶 综合实例
- Eclipse插件开发学习笔记【1】---Eclipse环境搭建
- Java-Eclipse插件开发学习笔记
- Eclipse插件开发 学习笔记 PDF 第一篇到第四篇 免分下载 开发基础 核心技术 高级进阶 综合实例
- Eclipse插件开发学习笔记 (一)
- Eclipse plugins 插件开发学习 - 扩展点介绍
- C++ 学习笔记之一:开发环境搭建(Eclipse+minGW)
- Hadoop学习笔记之五:使用Eclipse插件
- Hadoop 学习笔记七 任务远程提交--Eclipse插件
- Java学习笔记之Eclipse plugin插件安装
- 不错的maven学习笔记,收藏——Maven学习 (二) Eclipse 上安装 Maven3插件
- 学习eclipse插件开发资源全收集(plugin)
- Eclipse插件开发学习
- [知了堂学习笔记]_eclipse引入svn插件,并将项目同步到svn
- Soot 学习笔记 2:使用 Eclipse 插件
- jquery插件开发学习笔记(二)
- hadoop学习笔记(3)-eclipse下搭建hadoop开发环境各种问题的解决
- hadoop学习笔记--4.Ubuntu下Eclipse+hadoop开发配置
- Eclipse插件开发之Preference扩展点的学习
- 学习eclipse插件开发资源全收集(plugin)