Eclipse/プラグイン開発のTIPS集/org.eclipse.ui.menusにvisibleWhenで条件指定する
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
#contents
Eclipseのメニューバーやポップアップメニューは org.eclipse...
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.ui.po...
<menu id="nu.mine.kino.plugin.newaction.menus.sample...
label="トップのメニュー">
<command commandId="nu.mine.kino.plugin.samples.rc...
style="push">
</command>
<command
commandId="nu.mine.kino.plugin.newaction.command...
style="push">
</command>
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false"> <-ifEmptyは、Selecti...
<adapt type="org.eclipse.jdt.core.IJavaEleme...
</adapt>
</iterate>
</with>
</visibleWhen>
</menu>
</menuContribution>
</extension>
このようにmenuやcommandに対して
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false">
<adapt type="org.eclipse.jdt.core.IJavaElement">
</adapt>
</iterate>
</with>
</visibleWhen>
という条件を設定できるって事ですね。
-[[メニューバーを構築する(Eclipse3.3版)>Eclipse/プラグイ...
-[[ポップアップメニューの機能を追加する(Eclipse3.3版)>Ecl...
**色々な条件指定 [#x349af6f]
***選択しているオブジェクトの種類で制御 [#tf397535]
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false"> <-ifEmptyは、Selectionがな...
<adapt type="org.eclipse.jdt.core.IJavaElement">
</adapt>
</iterate>
</with>
</visibleWhen>
***複雑な条件。 [#lab7ada4]
#ref(capture01.png)
<visibleWhen checkEnabled="false">
<with variable="activeMenuSelection"> <!-- 選択したオ...
<!-- (1),(2),(3)どれかを満たせばOK -->
<or>
<iterate ifEmpty="false" >
<adapt type="org.eclipse.jface.text.ITextSelection...
</iterate> //エディタなどで、テキストを選んだら
<and>
<count value="1" /> 選択したオブジェクトが一つ且つ、
<iterate ifEmpty="false" >
<adapt type="org.eclipse.jdt.core.ICompilationUn...
</iterate> 選択されたモノの、Collection の中身がI...
</and>
<and>
<count value="1" /> 選択したオブジェクトが一つ且つ、
<iterate ifEmpty="false" >
<adapt type="org.eclipse.core.resources.IResourc...
</iterate> 選択されたモノの、Collection の中身が...
</and>
</or>
</with>
</visibleWhen>
***あるビューがアクティブになった場合に表示 [#q6276135]
<extension point="org.eclipse.core.expressions.definitio...
<definition id="nu.mine.kino.plugin.samples.rcp.view3....
<with variable="activePartId">
<equals value="nu.mine.kino.plugin.samples.rcp.vie...
</with>
</definition>
</extension>
<visibleWhen>
<reference
definitionId="nu.mine.kino.plugin.samples.rcp.view3...
</reference>
</visibleWhen>
**variableで指定できるパラメタ [#tc4f1bbf]
<with variable="activeMenuSelection">
この変数に設定できる項目は org.eclipse.ui.ISources に定義...
package org.eclipse.ui;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.ui.part.IShowInSource;
public interface ISources {
public static final String ACTIVE_CONTEXT_NAME = "acti...
public static final String ACTIVE_ACTION_SETS_NAME = "...
public static final String ACTIVE_SHELL_NAME = "active...
public static final String ACTIVE_WORKBENCH_WINDOW_SHE...
public static final String ACTIVE_WORKBENCH_WINDOW_NAM...
public static final String ACTIVE_WORKBENCH_WINDOW_IS_...
+ ".isCoolbarVisible";
public static final String ACTIVE_WORKBENCH_WINDOW_IS_...
+ ".isPerspectiveBarVisible";
public static final String ACTIVE_WORKBENCH_WINDOW_ACT...
+ ".activePerspective";
public static final String ACTIVE_EDITOR_NAME = "activ...
public static final String ACTIVE_EDITOR_ID_NAME = "ac...
public static final String ACTIVE_MENU_EDITOR_INPUT_NA...
public static final String ACTIVE_FOCUS_CONTROL_NAME =...
public static final String ACTIVE_FOCUS_CONTROL_ID_NAM...
}
ちなみに全体はこんな感じ。関係ないところは省いてます。
package org.eclipse.ui;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.ui.part.IShowInSource;
public interface ISources {
/**
* The variable name for the active contexts. This is ...
* <code>ISourceProvider</code> and <code>IEvaluationC...
* @since 3.2
*/
public static final String ACTIVE_CONTEXT_NAME = "acti...
/**
* The variable name for the active action sets. This ...
* {@link ISourceProvider} and {@link IEvaluationConte...
* @since 3.2
*/
public static final String ACTIVE_ACTION_SETS_NAME = "...
/**
* The variable name for the active shell. This is for...
* <code>ISourceProvider</code> and <code>IEvaluationC...
*/
public static final String ACTIVE_SHELL_NAME = "active...
/**
* The variable name for the active workbench window s...
* with the <code>ISourceProvider</code> and
* <code>IEvaluationContext</code>.
* @since 3.2
*/
public static final String ACTIVE_WORKBENCH_WINDOW_SHE...
/**
* The variable name for the active workbench window. ...
* the <code>ISourceProvider</code> and <code>IEvaluat...
*/
public static final String ACTIVE_WORKBENCH_WINDOW_NAM...
/**
* The variable name for the coolbar visibility state ...
* workbench window. This is for use with the <code>IS...
* and <code>IEvaluationContext</code>.
*
* @since 3.3
*/
public static final String ACTIVE_WORKBENCH_WINDOW_IS_...
+ ".isCoolbarVisible"; //$NON-NLS-1$
/**
* The variable name for the perspective bar visibilit...
* workbench window. This is for use with the <code>IS...
* and <code>IEvaluationContext</code>.
*
* @since 3.3
*/
public static final String ACTIVE_WORKBENCH_WINDOW_IS_...
+ ".isPerspectiveBarVisible"; //$NON-NLS-1$
/**
* The variable name for the current perspective of th...
* window. This is for use with the <code>ISourceProvi...
* <code>IEvaluationContext</code>.
*
* @since 3.4
*/
public static final String ACTIVE_WORKBENCH_WINDOW_ACT...
+ ".activePerspective"; //$NON-NLS-1$
/**
* The variable name for the active editor part. This ...
* <code>ISourceProvider</code> and <code>IEvaluationC...
* @since 3.2
*/
public static final String ACTIVE_EDITOR_NAME = "activ...
/**
* The variable name for the active editor identifier....
* the <code>ISourceProvider</code> and <code>IEvaluat...
*
* @since 3.2
*/
public static final String ACTIVE_EDITOR_ID_NAME = "ac...
/**
* The variable name for the <b>local</b> editor input...
* available while a context menu is visible.
*
* @since 3.3
*/
public static final String ACTIVE_MENU_EDITOR_INPUT_NA...
/**
* The variable name for the active focus Control, whe...
* IFocusService.
*
* @since 3.3
*/
public static final String ACTIVE_FOCUS_CONTROL_NAME =...
/**
* The variable name for the active focus Control id, ...
* IFocusService.
*
* @since 3.3
*/
public static final String ACTIVE_FOCUS_CONTROL_ID_NAM...
}
これらが全て、この箇所の変数として有効なのかはまだよく分...
----
この記事は
#vote(おもしろかった[10],そうでもない[0])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
終了行:
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
#contents
Eclipseのメニューバーやポップアップメニューは org.eclipse...
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.ui.po...
<menu id="nu.mine.kino.plugin.newaction.menus.sample...
label="トップのメニュー">
<command commandId="nu.mine.kino.plugin.samples.rc...
style="push">
</command>
<command
commandId="nu.mine.kino.plugin.newaction.command...
style="push">
</command>
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false"> <-ifEmptyは、Selecti...
<adapt type="org.eclipse.jdt.core.IJavaEleme...
</adapt>
</iterate>
</with>
</visibleWhen>
</menu>
</menuContribution>
</extension>
このようにmenuやcommandに対して
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false">
<adapt type="org.eclipse.jdt.core.IJavaElement">
</adapt>
</iterate>
</with>
</visibleWhen>
という条件を設定できるって事ですね。
-[[メニューバーを構築する(Eclipse3.3版)>Eclipse/プラグイ...
-[[ポップアップメニューの機能を追加する(Eclipse3.3版)>Ecl...
**色々な条件指定 [#x349af6f]
***選択しているオブジェクトの種類で制御 [#tf397535]
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false"> <-ifEmptyは、Selectionがな...
<adapt type="org.eclipse.jdt.core.IJavaElement">
</adapt>
</iterate>
</with>
</visibleWhen>
***複雑な条件。 [#lab7ada4]
#ref(capture01.png)
<visibleWhen checkEnabled="false">
<with variable="activeMenuSelection"> <!-- 選択したオ...
<!-- (1),(2),(3)どれかを満たせばOK -->
<or>
<iterate ifEmpty="false" >
<adapt type="org.eclipse.jface.text.ITextSelection...
</iterate> //エディタなどで、テキストを選んだら
<and>
<count value="1" /> 選択したオブジェクトが一つ且つ、
<iterate ifEmpty="false" >
<adapt type="org.eclipse.jdt.core.ICompilationUn...
</iterate> 選択されたモノの、Collection の中身がI...
</and>
<and>
<count value="1" /> 選択したオブジェクトが一つ且つ、
<iterate ifEmpty="false" >
<adapt type="org.eclipse.core.resources.IResourc...
</iterate> 選択されたモノの、Collection の中身が...
</and>
</or>
</with>
</visibleWhen>
***あるビューがアクティブになった場合に表示 [#q6276135]
<extension point="org.eclipse.core.expressions.definitio...
<definition id="nu.mine.kino.plugin.samples.rcp.view3....
<with variable="activePartId">
<equals value="nu.mine.kino.plugin.samples.rcp.vie...
</with>
</definition>
</extension>
<visibleWhen>
<reference
definitionId="nu.mine.kino.plugin.samples.rcp.view3...
</reference>
</visibleWhen>
**variableで指定できるパラメタ [#tc4f1bbf]
<with variable="activeMenuSelection">
この変数に設定できる項目は org.eclipse.ui.ISources に定義...
package org.eclipse.ui;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.ui.part.IShowInSource;
public interface ISources {
public static final String ACTIVE_CONTEXT_NAME = "acti...
public static final String ACTIVE_ACTION_SETS_NAME = "...
public static final String ACTIVE_SHELL_NAME = "active...
public static final String ACTIVE_WORKBENCH_WINDOW_SHE...
public static final String ACTIVE_WORKBENCH_WINDOW_NAM...
public static final String ACTIVE_WORKBENCH_WINDOW_IS_...
+ ".isCoolbarVisible";
public static final String ACTIVE_WORKBENCH_WINDOW_IS_...
+ ".isPerspectiveBarVisible";
public static final String ACTIVE_WORKBENCH_WINDOW_ACT...
+ ".activePerspective";
public static final String ACTIVE_EDITOR_NAME = "activ...
public static final String ACTIVE_EDITOR_ID_NAME = "ac...
public static final String ACTIVE_MENU_EDITOR_INPUT_NA...
public static final String ACTIVE_FOCUS_CONTROL_NAME =...
public static final String ACTIVE_FOCUS_CONTROL_ID_NAM...
}
ちなみに全体はこんな感じ。関係ないところは省いてます。
package org.eclipse.ui;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.ui.part.IShowInSource;
public interface ISources {
/**
* The variable name for the active contexts. This is ...
* <code>ISourceProvider</code> and <code>IEvaluationC...
* @since 3.2
*/
public static final String ACTIVE_CONTEXT_NAME = "acti...
/**
* The variable name for the active action sets. This ...
* {@link ISourceProvider} and {@link IEvaluationConte...
* @since 3.2
*/
public static final String ACTIVE_ACTION_SETS_NAME = "...
/**
* The variable name for the active shell. This is for...
* <code>ISourceProvider</code> and <code>IEvaluationC...
*/
public static final String ACTIVE_SHELL_NAME = "active...
/**
* The variable name for the active workbench window s...
* with the <code>ISourceProvider</code> and
* <code>IEvaluationContext</code>.
* @since 3.2
*/
public static final String ACTIVE_WORKBENCH_WINDOW_SHE...
/**
* The variable name for the active workbench window. ...
* the <code>ISourceProvider</code> and <code>IEvaluat...
*/
public static final String ACTIVE_WORKBENCH_WINDOW_NAM...
/**
* The variable name for the coolbar visibility state ...
* workbench window. This is for use with the <code>IS...
* and <code>IEvaluationContext</code>.
*
* @since 3.3
*/
public static final String ACTIVE_WORKBENCH_WINDOW_IS_...
+ ".isCoolbarVisible"; //$NON-NLS-1$
/**
* The variable name for the perspective bar visibilit...
* workbench window. This is for use with the <code>IS...
* and <code>IEvaluationContext</code>.
*
* @since 3.3
*/
public static final String ACTIVE_WORKBENCH_WINDOW_IS_...
+ ".isPerspectiveBarVisible"; //$NON-NLS-1$
/**
* The variable name for the current perspective of th...
* window. This is for use with the <code>ISourceProvi...
* <code>IEvaluationContext</code>.
*
* @since 3.4
*/
public static final String ACTIVE_WORKBENCH_WINDOW_ACT...
+ ".activePerspective"; //$NON-NLS-1$
/**
* The variable name for the active editor part. This ...
* <code>ISourceProvider</code> and <code>IEvaluationC...
* @since 3.2
*/
public static final String ACTIVE_EDITOR_NAME = "activ...
/**
* The variable name for the active editor identifier....
* the <code>ISourceProvider</code> and <code>IEvaluat...
*
* @since 3.2
*/
public static final String ACTIVE_EDITOR_ID_NAME = "ac...
/**
* The variable name for the <b>local</b> editor input...
* available while a context menu is visible.
*
* @since 3.3
*/
public static final String ACTIVE_MENU_EDITOR_INPUT_NA...
/**
* The variable name for the active focus Control, whe...
* IFocusService.
*
* @since 3.3
*/
public static final String ACTIVE_FOCUS_CONTROL_NAME =...
/**
* The variable name for the active focus Control id, ...
* IFocusService.
*
* @since 3.3
*/
public static final String ACTIVE_FOCUS_CONTROL_ID_NAM...
}
これらが全て、この箇所の変数として有効なのかはまだよく分...
----
この記事は
#vote(おもしろかった[10],そうでもない[0])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
ページ名: