---
title: "插件开发——记录"
author: "bachelor007"
date: "2010-03-17T13:26:35Z"
tags: []
categories: ["非技术"]
slug: "untitled"
draft: false
lastmod: "2010-03-25T17:32:11Z"
id: 617963
url: "https://bachelor007.iteye.com/blog/617963"
---

创建dynamic web project的第一个wizard page  
org.eclipse.jst.servlet.ui.project.facet.WebProjectFirstPage  
创建dynamic web project的wizard  
org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard  
指定src webContent的wizard page  
org.eclipse.jst.servlet.ui.project.facet.WebFacetInstallPage  
webContent默认值的设置地方  
org.eclipse.wst.project.facet.ProductManager.WEB\_CONTENT\_FOLDER = "WebContent"

modify方法将调用所有指定的action创建j2ee project  
org.eclipse.wst.common.project.facet.core.internal.FacetedProject.modify(Set actions, IProgressMonitor monitor)  
首先会调用java action生成java project，接着是调用j2ee action 将前面生成java project变成j2ee project，接着是调用用户指定的action为j2ee project添加一些其他的东东  
添加java配置的action  
org.eclipse.jst.common.project.facet.JavaFacetInstallDelegate  
添加j2ee配置的action  
org.eclipse.jst.j2ee.web.project.facet.WebFacetInstallDelegate

要得到插件目录下的文件，不应该通过IPath.toFile()方法，而应该通过先使用FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry(dir)).getFile()得到文件绝对路径，然后使用new File()来得到系统文件

IFile.getFullPath()是得到相对于当前project的相对路径, IFile.getLocation()则是得到绝对路径

 

File转换为IFile：

IPath ipath =  new Path(file.getAbsolutePath());  
  IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(ipath);

 

在Editor中打开工程中的文件：

IWorkbenchPage page = getWorkbenchPage();  
   if (page != null)  
       { IDE.openEditor(page, iFile, true);}

 

 

Editor与Outline相关联，需要提供合适的适配器，获取Outline页面的实例：

editor.getAdapter(IContentOutlinePage.class);

 

获取Property页面的实例：

part.getAdapter(IPropertysheet Page.class);

 

或者：Platform.getAdapterManager().getAdapter(this,adapter)