2012-06-01 2 views
6

이클립스 용 Google Closure Compiler 플러그인을 만들고 싶습니다. JavaScript 파일을 축소 버전으로 컴파일하기위한 팝업 메뉴 항목이 이미 있습니다. 그러나 *.js을 저장할 때마다 자동으로 축소 된 버전이 자동으로 생성되는 것이 도움이 될 것입니다. 나는 본성과 건축 자, 연장 점 및 IResourceChangeListener에 관해 읽거나 들었습니다. 그러나 나는 내가 무엇을 사용해야하는지, 특히 그것이 작동하도록하는 방법을 알아낼 수 없었다.이클립스 플러그인에서 액션 저장하기

"같은 종류의 일"을 수행하는 플러그인의 실제 예가 있습니까? 그렇기 때문에이 글이나 튜토리얼에서 그런 글을 쓸 수 있습니까? 나는 아래의 대답

IResourceChangeListener 사용하는 프로젝트를 검색하고이 코드를 내놓았다 :

매니페스트 : http://codepaste.net/3yahwe

plugin.xml : http://codepaste.net/qek3rw

활성제 : http://codepaste.net/s7xowm

DummyStartup : http://codepaste.net/rkub82

MinifiedJavascriptUpdater 다음 IResourceChangeListenerresourceChanged() 기능에 대한 코드를 보유하고있는 MinifiedJavascriptUpdater.java에서이 http://codepaste.net/koweuh

에 도달되지 않습니다.

답변

5

대답은 여기에서 http://www.eclipse.org/forums/index.php/t/362425/

솔루션은 활성에 코드를 얻을 수 및 제거되는 MinifiedJavascriptUpdater : 이미 그 기사를 읽고이 있지만 거기에 예 "이것을 시도"

package closure_compiler_save; 

import org.eclipse.ui.plugin.AbstractUIPlugin; 
import org.osgi.framework.BundleContext; 

/** 
* The activator class controls the plug-in life cycle 
*/ 
public class Activator extends AbstractUIPlugin { 

    // The plug-in ID 
    public static final String PLUGIN_ID = "closure-compiler-save"; //$NON-NLS-1$ 

    // The shared instance 
    private static Activator plugin; 

    /** 
    * The constructor 
    */ 
    public Activator() { 
    } //gets here 

    @Override 
    public void start(BundleContext context) throws Exception { 
     super.start(context); 
     Activator.plugin = this; 

     ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() { 
      public void resourceChanged(IResourceChangeEvent event) { 
       System.out.println("Something changed!"); 
      } 
     }); 
    } 

    @Override 
    public void stop(BundleContext context) throws Exception { 
     Activator.plugin = null; 
     super.stop(context); 
    } 

    /** 
    * Returns the shared instance 
    * 
    * @return the shared instance 
    */ 
    public static Activator getDefault() { 
     return plugin; 
    } 
} 
1

이 경우 빌더가 필요합니다. 이클립스는 여러분이하고 싶은 것, 즉 상황이 바뀌어도 유지되어야하는 생성 된 아티팩트에 대한 개념을 광범위하게 지원합니다. This Paper은 매우 오래되었지만 완전히 정확합니다.

코드를 컴파일 할 때 모든 언어 플러그인 (JDT, CDT 등)이 이러한 일을합니다.

+0

. 나는 그 경험의 단계에서 일하도록하지 못했습니다. 불행히도 완전히 작동하는 예제가 없습니다. – DarsVaeda

+0

당신은 그것을 사용하는 플러그인을 보여줄'IResourceChangeListener'에 대해 구글을 원할 것입니다. RCP 응용 프로그램에서 작동하도록 만들었으므로 오픈 소스 세계에서 비슷한 것을 찾을 수있을 것입니다. –

+0

Google에서 어디에서 찾을 수 있습니까? 나는하지 않는다. – DarsVaeda

관련 문제