java

位置:IT落伍者 >> java >> 浏览文章

基于Eclipse的工具开发: 设定构建路径实战[2]


发布日期:2018年05月13日
 
基于Eclipse的工具开发: 设定构建路径实战[2]
——此文章摘自《自己动手写开发工具基于Eclipse的工具开发》定价特价 详细>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave>

public class ActionAddLucene implements IObjectActionDelegate

{

private static final String FILESEPARATOR =

SystemgetProperty(fileseparator/);

private static final String LUCENESRCJAR = lucenesrcjar;

private static final String LUCENEJAR = lucenejar;

private static final String LIB = lib;

private static final String RESOUCELIB = resoucelib;

private IStructuredSelection structSelection;

public ActionAddLucene()

{

super();

}

public void setActivePart(IAction action IWorkbenchPart targetPart)

{

}

public void run(IAction action)

{

Object selectObj = structSelectiongetFirstElement();

if (selectObj instanceof IProject)

{

IProject project = (IProject) selectObj;

IJavaProject javaProject = JavaCorecreate(project);

IClasspathEntry[] oldPaths = javaProjectreadRawClasspath();

IClasspathEntry luceneLibEntry =

JavaCorenewLibraryEntry(project

getFile(LIB + FILESEPARATOR + LUCENEJAR)

getFullPath() project

getFile(LIB + FILESEPARATOR +

LUCENESRCJAR)getFullPath() null

false);

if(classPathExists(oldPathsluceneLibEntry))

{

return;

}

URL luceneLib = ActivatorgetDefault()getBundle()getEntry(

RESOUCELIB + FILESEPARATOR + LUCENEJAR);

URL luceneSrc = ActivatorgetDefault()getBundle()getEntry(

RESOUCELIB + FILESEPARATOR + LUCENESRCJAR);

IClasspathEntry[] newPaths =

new IClasspathEntry[oldPathslength + ];

Systemarraycopy(oldPaths newPaths oldPathslength);

IFolder libFolder = projectgetFolder(LIB);

if (!libFolderexists())

{

try

{

libFoldercreate(true true null);

} catch (CoreException e)

{

handleException(e);

}

}

copyURLToFile(luceneLib project

LIB + FILESEPARATOR + LUCENEJAR);

copyURLToFile(luceneSrc project

LIB + FILESEPARATOR + LUCENESRCJAR);

right>[http://developcsaicn/Java_Eclipse/htm>] [] [http://developcsaicn/Java_Eclipse/htm>] [http://developcsaicn/Java_Eclipse/htm>]

               

上一篇:基于Eclipse的工具开发: 设定构建路径实战[3]

下一篇:Spring总结实例之消息与事件