熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

基於Eclipse的工具開發: 設定構建路徑實戰[2]

2013-11-23 20:44:04  來源: Java開源技術 
    ——此文章摘自《自己動手寫開發工具基於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>]  


From:http://tw.wingwit.com/Article/program/Java/ky/201311/28988.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.