2011-11-16 10 views
2

RCP 응용 프로그램에 문제가 있습니다. 마지막으로, 내 CommandState 클래스RCP 응용 프로그램 활동

<extension 
    point="org.eclipse.ui.services"> 
    <sourceProvider 
     provider="myproject.util.CommandState"> 
    <variable 
      name="myproject.view.input.active" 
      priorityLevel="workbench"> 
    </variable> 

그리고 :

public class CommandState extends AbstractSourceProvider { 

    public final static String OUTPUT_VIEW = "myproject.view.input.active"; 
    // then goes some others variables, i just skip them 
    // .... 

    public final static String [] ACTIONS = {OUTPUT_VIEW /*and all others variables*/}; 

    public final static String ENABLED = "ENABLED"; 
    public final static String DISENABLED = "DISENABLED"; 

    private final Map <String, String> currentState = new HashMap <String, String>(); 

    @Override 
    public void dispose() { 
    } 

    @Override 
    public String[] getProvidedSourceNames() { 
     return ACTIONS; 
    } 

    @Override 
    public Map <String, String> getCurrentState() { 
     return currentState; 
    } 

    public void setEnabled(boolean enabled, String [] commands) { 
     String value = enabled ? ENABLED : DISENABLED; 
     for (String command : commands) { 
      currentState.put(command, value); 
      fireSourceChanged(ISources.WORKBENCH, command, value); 
     } 
    } 
} 

<extension 
    point="org.eclipse.ui.activities"> 
    <activity 
     id="myproject.view.input.activity" 
     name="myproject.view.input.activity"> 
    <enabledWhen> 
     <with 
       variable="myproject.view.input.active"> 
      <equals 
       value="ENABLED"> 
      </equals> 
     </with> 
    </enabledWhen> 
    </activity> 
    <activityPatternBinding 
     activityId="myproject.view.input.activity" 
     pattern="myproject.gui/myproject.view.input"> 
    </activityPatternBinding> 

그럼 난 내 SourceProvider 정의 :

첫째, 내 plugin.xml에에 활동을 정의

내 로그인 창에서 응용 프로그램이 사용자 권한을 확인하고보기, 명령 등을 활성화 또는 비활성화합니다. CommandState의 tEnabled 메소드. 명령을 잘 작동, 그들은 활성화 또는 비활성화 올바르게 (나는 다른 방법으로 그들을 비활성화,하지만 내가 비록 내가 설명 된 것과 같은 방식으로 활동을 통해 그들을 해제해도 작동합니다). 나는 내 응용 프로그램과 내가 전에를 디버깅하려고

!ENTRY org.eclipse.ui 4 4 2011-11-16 15:54:43.284 
!MESSAGE Exception in org.eclipse.ui.internal.PageLayout.addView: org.eclipse.ui.PartInitException: Could not create view: myproject.view.input 

!ENTRY org.eclipse.ui 4 4 2011-11-16 15:54:43.321 
!MESSAGE Exception in org.eclipse.ui.internal.PageLayout.addView: org.eclipse.ui.PartInitException: Could not create view: myproject.view.input 
!STACK 1 
org.eclipse.ui.PartInitException: Could not create view: myproject.view.input 
    at org.eclipse.ui.internal.ViewFactory.createView(ViewFactory.java:158) 
    at org.eclipse.ui.internal.LayoutHelper.createView(LayoutHelper.java:162) 
    at org.eclipse.ui.internal.PageLayout.createView(PageLayout.java:543) 
    at org.eclipse.ui.internal.PageLayout.addView(PageLayout.java:416) 
    at org.eclipse.ui.internal.PageLayout.addStandaloneView(PageLayout.java:894) 
    at org.eclipse.ui.internal.registry.PerspectiveExtensionReader.processView(PerspectiveExtensionReader.java:295) 
    at org.eclipse.ui.internal.registry.PerspectiveExtensionReader.processExtension(PerspectiveExtensionReader.java:118) 
    at org.eclipse.ui.internal.registry.PerspectiveExtensionReader.readElement(PerspectiveExtensionReader.java:355) 
    at org.eclipse.ui.internal.registry.RegistryReader.readElements(RegistryReader.java:144) 
    at org.eclipse.ui.internal.registry.RegistryReader.readExtension(RegistryReader.java:155) 
    at org.eclipse.ui.internal.registry.RegistryReader.readRegistry(RegistryReader.java:176) 
    at org.eclipse.ui.internal.registry.PerspectiveExtensionReader.extendLayout(PerspectiveExtensionReader.java:82) 
    at org.eclipse.ui.internal.Perspective.loadPredefinedPersp(Perspective.java:818) 
    at org.eclipse.ui.internal.Perspective.createPresentation(Perspective.java:270) 
    at org.eclipse.ui.internal.Perspective.<init>(Perspective.java:156) 
    at org.eclipse.ui.internal.tweaklets.Workbench3xImplementation.createPerspective(Workbench3xImplementation.java:55) 
    at org.eclipse.ui.internal.WorkbenchPage.createPerspective(WorkbenchPage.java:1672) 
    at org.eclipse.ui.internal.WorkbenchPage.busySetPerspective(WorkbenchPage.java:1034) 
    at org.eclipse.ui.internal.WorkbenchPage.access$16(WorkbenchPage.java:1025) 
    at org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.java:3715) 
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) 
    at org.eclipse.ui.internal.WorkbenchPage.setPerspective(WorkbenchPage.java:3713) 
    at org.eclipse.ui.handlers.ShowPerspectiveHandler.openPerspective(ShowPerspectiveHandler.java:146) 
    at org.eclipse.ui.handlers.ShowPerspectiveHandler.openOther(ShowPerspectiveHandler.java:118) 
    at org.eclipse.ui.handlers.ShowPerspectiveHandler.execute(ShowPerspectiveHandler.java:57) 
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293) 
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476) 
    at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:178) 
    at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247) 
    at org.eclipse.ui.actions.PerspectiveMenu.runOther(PerspectiveMenu.java:376) 
    at org.eclipse.ui.actions.PerspectiveMenu$3.runWithEvent(PerspectiveMenu.java:130) 
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) 
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) 
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) 
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258) 
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3540) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3161) 
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640) 
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604) 
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438) 
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
    at myproject.arm.demo.Application.start(Application.java:28) 
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:616) 
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1408) 
    at org.eclipse.equinox.launcher.Main.main(Main.java:1384) 
!SUBENTRY 1 org.eclipse.ui 4 0 2011-11-16 15:54:43.322 
!MESSAGE Could not create view: myproject.view.input 

: 내가보기 오픈 관점을 해제하려고 할 때, 그 뷰 (myproject.view.input이)가 그보기없이 열리지 만도 예외가 발생 것을 포함 내 견해를 열어, 내 CommandState 소스 공급자의 currentState를 확인했다. 모든 변수 값이 정확하고 myproject.view.input.active = DISABLED

예외가 발생하는 이유는 누구나 말할 수있다. ? 어떤 도움이나 아이디어를 주셔서 감사합니다. 큰 포스트 나쁜 언어에 대해 죄송

* 편집 : 시스템이 작동

+0

활동 정의와 관련이없는 것 같지 않습니다. 우리는 더 많은 도움을 위해 stacktrace가 필요합니다 ... –

답변

3

추가 전체 스택 트레이스. 활동은보기 또는 마법사를 사용자가 볼 수 없게 만들지 만 고의적으로 표시 할 수있는 옵션을 제공합니다.

이 활성화 된 활동 인 경우 요소는보기 레지스트리에서보기를 제거하기 때문에 원하는 경우에도 사용자가 의도적으로 표시 할 수 없습니다. 이는 사용자가 RCP 앱에서 관리자보기를 열지 못하도록하기위한 것입니다.

보기를 원근감에 추가했으며 활동이 비활성화 된 경우 해당보기 정의가없는 것처럼 보입니다.

보기를보기 위치 지정자 또는 관리보기로 추가해야합니다. 사용자가 관리 역할로 로그인하면보기를 표시하거나 관리자 관점을 선택할 수 있습니다.

+0

감사합니다! 나는 아직도 아래에 게시 한 것보다 몇 가지 질문이 있습니다. – Peter

+0

다시 한번 감사드립니다. 나는 다른 방식으로 나의 문제를 해결했다. 내 "관리"관점의 관점 공장에서이보기가 존재하는지 여부를 확인하고 존재하는 경우에만 추가합니다. 내가 불필요한 일을 한 것처럼 보이지만 예외없이 잘 작동합니다! – Peter

+0

+100 enabledWhen 요소가있는 활동은보기 레지스트리에서보기를 제거하기 때문에 사용자는 의도 한 경우에도 의도적으로 표시 할 수 없습니다. '. 이것은 내 견해를 영구히 숨기기 위해 필요한 정확한 해결책이었습니다. 이것은 매우 under-documented 인 것처럼 보인다! – SpellingD

관련 문제