——此文章摘自《自己动手写开发工具
基于Eclipse的工具开发》定价
¥
特价
¥
详细>>http://track
linktech
cn/?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>]