2010-02-17 128 views
1

我正在使用動態MenuContribution,並得到警告說我的兩個引用標識符「無法找到」。即使貢獻有效。這些警告讓我煩惱。動態MenuContribution - 獲取警告

我在我的一個插件中定義了一個​​實現。基本上,它看起來是這樣的:

public class ViewerHistoryMenuItems extends CompoundContributionItem 
    implements IExecutableExtension { 

    private static final String PARAM_TYPE = "type"; 
    private static final String PARAM_COMMAND = "command"; 

    // some fields 

    public void setInitializationData(final IConfigurationElement config, 
      final String propertyName, final Object data) { 
     /* set fields */ 
    } 

    protected final IContributionItem[] getContributionItems() { 
     /* create Items */ 
    } 
} 

在其他插件我用這個ContributionItem實現通過聲明如下:在問題 - 視圖

<menuContribution locationURI="menu:mylocationUri"> 
    <dynamic id="myId"> 
     <class class="ViewerHistoryMenuItems"> 
      <parameter 
        name="type" 
        value="someValue"> 
      </parameter> 
      <parameter 
        name="command" 
        value="someCommandId"> 
      </parameter> 
     </class> 
    </dynamic> 
    <command 
     commandId="someCommandId" 
     icon="anIcon.png"> 
    </command> 
</menuContribution> 

當尋找我得到兩個條目有(每個插件in,which use this contribution):

**Referenced identifier 'type' in attribute 'name' cannot be found** 

**Referenced identifier 'command' in attribute 'name' cannot be found** 

我在這裏錯過了什麼?任何想法,爲什麼我得到這個警告?

PS:這沒有幫助,使這兩個領域PARAM_TYPE & PARAM_COMMAND公衆

回答

2

我不認爲這是關係到內部字段的類中的存在。

如果你看一個類似的錯誤(不一樣的,因爲它包括annotationType),修正涉及的定義說引用標識符:

Referenced identifier 'com.atlassian.connector.eclipse.cruicible.ui.comment.annotation' 
in attribute 'annotationType' cannot be found 

修正了:

+ <extension 
+   point="org.eclipse.ui.editors.annotationTypes"> 
+  <type 
+   markerType="com.atlassian.connector.eclipse.crucible.ui.com.atlassian.connector.eclipse.cruicible.ui.comment.marker" 
+   name="com.atlassian.connector.eclipse.cruicible.ui.comment.annotation"> 
+  </type> 
+ </extension> 
+ <extension 
+   id="com.atlassian.connector.eclipse.cruicible.ui.comment.marker" 
+   point="org.eclipse.core.resources.markers"> 
+ </extension> 

考慮到extension point org.eclipse.ui.menus help page

<!ELEMENT parameter EMPTY> 
<!ATTLIST parameter 
    name IDREF #REQUIRED 
    value CDATA #REQUIRED 
> 

可執行擴展或命令的參數 - 取決於它在擴展中的顯示位置。

  • 名稱 - 名稱是任一參數的名稱來傳遞到可執行擴展名,或該命令的參數的標識符。
  • value - 此參數傳遞的值。

您需要在名稱引用屬性,在plugin.xml目前其他地方的ID。

+0

它說「名稱是參數的名稱......」所以我想我使用了它,並且調用了一個參數「type」和另一個「command」。但我想,我必須更多地考慮你的深刻答案,VonC。 – pimpf0r 2010-02-17 12:17:52

+0

@ pimpf0r:就是這樣:我不確定「參數的名稱」可以引用任何* internal *字段類。在聲明模式下,比如'plugin.xml',我希望參數在所述'plugin.xml'的其他地方定義好。 – VonC 2010-02-17 12:50:53

+0

好吧,我想我找到了「別處」。在這種情況下的其他地方意味着:定義/聲明參考命令的位置。我在我的動態聲明中提到同一個plugin.xml中的一個命令。但是添加的參數沒有在那裏聲明。 感謝您的幫助,VonC。 * high5 * – pimpf0r 2010-02-17 13:41:46

0

當然,VonC。在這裏,我們去:

在動態聲明(見上文)有兩個參數引用

<parameter 
    name="type" 
    value="someValue"> 
</parameter> 
<parameter 
    name="command" 
    value="someCommandId"> 
</parameter> 

這兩個參數是爲了傳遞給命令本身。命令聲明在同一個plugin.xml內,但不是聲明瞭這兩個commandParameters。

我所做的是添加這些缺少的commandParameters,解決了缺少的引用,這是警告中明確指出的。

<command 
    categoryId="aCategory" 
       id="someCommandId" 
       name="%theName"> 
    <commandParameter 
    id="type" 
    name="type"/> 
    <commandParameter 
    id="command" 
    name="command"> 
    </commandParameter> 
</command> 

所以,你是絕對正確的說「修正涉及的定義所述參考標識符」。問題只是其中什麼我不得不定義。 我想,在這種情況下,我並沒有考慮最明顯的問題。