本文整理汇总了Java中org.openide.awt.DynamicMenuContent类的典型用法代码示例。如果您正苦于以下问题:Java DynamicMenuContent类的具体用法?Java DynamicMenuContent怎么用?Java DynamicMenuContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DynamicMenuContent类属于org.openide.awt包,在下文中一共展示了DynamicMenuContent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getMenuPresenter
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public @Override JMenuItem getMenuPresenter() {
class SpecialMenuItem extends JMenuItem implements DynamicMenuContent {
public SpecialMenuItem() {
super(RunLastBuildAction.this);
}
public @Override JComponent[] getMenuPresenters() {
String label;
BuildExecutionSupport.Item item = BuildExecutionSupportImpl.getInstance().getLastItem();
if (item != null) {
String display = item.getDisplayName();
label = NbBundle.getMessage(RunLastBuildAction.class, "LBL_RunLastBuildAction_specific", display);
} else {
label = (String) getValue(Action.NAME);
}
Mnemonics.setLocalizedText(this, label);
return new JComponent[] {this};
}
public @Override JComponent[] synchMenuPresenters(JComponent[] items) {
return getMenuPresenters();
}
}
return new SpecialMenuItem();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:RunLastBuildAction.java
示例2: ContextAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public ContextAction(Lookup context) {
super(OpenProjectFolderAction_LBL_action());
this.context = context;
boolean foundProject = false;
for (DataFolder d : context.lookupAll(DataFolder.class)) {
if (ProjectManager.getDefault().isProject(d.getPrimaryFile())) {
foundProject = true;
break;
}
}
if (!foundProject) {
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
setEnabled(false);
}
// #199137: do not try to adjust label, etc. according to actual projects
// 1. such computation cannot be done in EQ without sometimes blocking
// 2. even if done asynch, looks bad to update label after popup is posted
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:OpenProjectFolderAction.java
示例3: testManualRefreshPreference
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public void testManualRefreshPreference() throws IOException {
Preferences pref = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction");
assertFalse("Not set", pref.getBoolean("manual", false));
FileObject fo = FileUtil.toFileObject(getWorkDir());
Lookup lkp = Lookups.singleton(DataFolder.findFolder(fo).getNodeDelegate());
FileSystemAction fsa = FileSystemAction.get(FileSystemAction.class);
Action a = fsa.createContextAwareInstance(lkp);
assertEquals("Menu presenter ", true, a instanceof Presenter.Menu);
Presenter.Menu pm = (Presenter.Menu)a;
DynamicMenuContent submenu = (DynamicMenuContent)pm.getMenuPresenter();
assertEquals("No submenu", 0, submenu.getMenuPresenters().length);
pref.putBoolean("manual", true);
DynamicMenuContent submenu2 = (DynamicMenuContent)pm.getMenuPresenter();
assertEquals("One action", 1, submenu2.getMenuPresenters().length);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FileSystemActionTest.java
示例4: actionsToItems
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
private static List<JComponent> actionsToItems(Action[] actions) {
List<JComponent> items = new ArrayList<JComponent>(actions.length);
for (Action action : actions) {
if (action == null) {
items.add(Utils.createJSeparator());
} else {
if (action instanceof DynamicMenuContent) {
DynamicMenuContent dmc = (DynamicMenuContent) action;
JComponent [] components = dmc.getMenuPresenters();
items.addAll(Arrays.asList(components));
} else {
JMenuItem item = Utils.toMenuItem(action);
items.add(item);
}
}
}
return items;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:VersioningMainMenu.java
示例5: ContextBuildInstaller
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public ContextBuildInstaller(Lookup actionContext) {
this.actionContext = actionContext;
putValue(NAME, NbBundle.getMessage(BuildInstallersAction.class, "CTL_BuildInstallers"));
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
Project project = actionContext.lookup(Project.class);
if (project == null) {
setEnabled(false); //#224115
} else {
NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class);
if (watcher == null
|| !NbMavenProject.TYPE_NBM_APPLICATION.equalsIgnoreCase(watcher.getPackagingType())) {
setEnabled(false);
} else {
String version = PluginPropertyUtils.getPluginVersion(watcher.getMavenProject(), "org.codehaus.mojo", "nbm-maven-plugin");
if (version == null || new ComparableVersion(version).compareTo(new ComparableVersion("3.7-SNAPSHOT")) >= 0) {
setEnabled(false); // now handled by maven.apisupport
}
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:BuildInstallersAction.java
示例6: testHideWhenDisabled
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public void testHideWhenDisabled() throws Exception {
class NoOpAction extends AbstractAction {
NoOpAction(String n) {
super(n);
}
public @Override void actionPerformed(ActionEvent e) {}
}
Action a = new NoOpAction("a1");
assertEquals(Collections.singletonList("a1"), popupMenu(a));
a = new NoOpAction("a2");
a.setEnabled(false);
assertEquals(Collections.singletonList("a2[disabled]"), popupMenu(a));
a = new NoOpAction("a3");
a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
assertEquals(Collections.singletonList("a3"), popupMenu(a));
a = new NoOpAction("a4");
a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
a.setEnabled(false);
assertEquals(Collections.emptyList(), popupMenu(a));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:DefaultAWTBridgeTest.java
示例7: testIsPopupVisible
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public void testIsPopupVisible() throws Exception {
ToolsAction ta = ToolsAction.get(ToolsAction.class);
Lookup lkp = Lookups.singleton(this);
FileObject fo = FileUtil.createFolder(FileUtil.getConfigRoot(), "UI/ToolActions");
assertNotNull("ToolActions folder found", fo);
fo.createFolder("Cat1").createData("org-openide-actions-SaveAction.instance").setAttribute("position", 100);
Action a = ta.createContextAwareInstance(lkp);
assertTrue("It is menu presenter", a instanceof Presenter.Popup);
Presenter.Popup pp = (Presenter.Popup)a;
JMenuItem item = pp.getPopupPresenter();
assertTrue("Item is enabled", item.isEnabled());
DynamicMenuContent dmc = (DynamicMenuContent)item;
assertEquals("One presenter to delegte to", 1, dmc.getMenuPresenters().length);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ToolsActionTest.java
示例8: testInlineIsNotBlocked
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public void testInlineIsNotBlocked() throws Exception {
ToolsAction ta = ToolsAction.get(ToolsAction.class);
Lookup lkp = Lookups.singleton(this);
FileObject fo = FileUtil.createFolder(FileUtil.getConfigRoot(), "UI/ToolActions");
assertNotNull("ToolActions folder found", fo);
fo.createFolder("Cat3").createData(BlockingAction.class.getName().replace('.', '-') + ".instance").setAttribute("position", 100);
Action a = ta.createContextAwareInstance(lkp);
assertTrue("It is menu presenter", a instanceof Presenter.Menu);
Presenter.Menu mp = (Presenter.Menu)a;
JMenuItem item = mp.getMenuPresenter();
assertTrue("Item is enabled", item.isEnabled());
DynamicMenuContent dmc = (DynamicMenuContent)item;
final JComponent[] arr = dmc.getMenuPresenters();
assertEquals("One presenter to delegte to", 1, arr.length);
assertFalse("Disabled", arr[0].isEnabled());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ToolsActionSlowTest.java
示例9: SynchronizeAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
@Messages("LBL_SynchronizeAction_disconnected=Connect")
private SynchronizeAction(Collection<? extends HudsonInstance> instances) {
this.instances = instances;
boolean allForbidden = true;
boolean allDisconnected = true;
for (HudsonInstance instance : instances) {
if (!instance.isForbidden()) {
allForbidden = false;
}
if (instance.isConnected()) {
allDisconnected = false;
}
}
if (allForbidden) {
// LogInAction would do the same thing, so confusing to show this as well.
setEnabled(false);
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
} else if (allDisconnected) {
putValue(NAME, LBL_SynchronizeAction_disconnected());
} else {
putValue(NAME, LBL_SynchronizeAction());
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SynchronizeAction.java
示例10: CustomRefactoringAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public CustomRefactoringAction( Lookup lookup ) {
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
Collection<? extends Node> nodes = lookup.lookupAll(Node.class);
setEnabled(false);
if (nodes.size() == 1) {
Node node = nodes.iterator().next();
FileObject fileObject = node.getLookup().lookup(FileObject.class);
if (fileObject != null
&& fileObject.getNameExt().endsWith(XmlUtils.GWT_XML))
{
Project project = FileOwnerQuery.getOwner(fileObject);
if (project != null) {
VaadinSupport support = project.getLookup().lookup(
VaadinSupport.class);
if (support != null && support.isEnabled()) {
setEnabled(true);
}
}
}
}
}
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:24,代码来源:CustomRefactoringAction.java
示例11: getMenuPresenter
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public JMenuItem getMenuPresenter () {
class AntMenuItem extends JMenuItem implements DynamicMenuContent {
public AntMenuItem() {
super(AntActionInstance.this);
}
public JComponent[] getMenuPresenters() {
return isEnabled() ? new JComponent[] {this} : new JComponent[0];
}
public JComponent[] synchMenuPresenters(JComponent[] items) {
return getMenuPresenters();
}
}
return new AntMenuItem();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:AntActionInstance.java
示例12: createReloadAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
@ActionID(id = "org.netbeans.modules.maven.apisupport.NBMReload", category = "Project")
@ActionRegistration(displayName = "#ACT_NBM_Reload", lazy=false)
@ActionReference(position = 1250, path = "Projects/org-netbeans-modules-maven/Actions")
@Messages("ACT_NBM_Reload=Install/Reload in Development IDE")
public static Action createReloadAction() {
Action a = ProjectSensitiveActions.projectCommandAction(NBMRELOAD, ACT_NBM_Reload(), null);
a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
return a;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:NbmActionGoalProvider.java
示例13: createReloadTargetAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
@ActionID(id = "org.netbeans.modules.maven.apisupport.NBMReloadTarget", category = "Project")
@ActionRegistration(displayName = "#ACT_NBM_Reload_Target", lazy=false)
@ActionReference(position = 1225, path = "Projects/org-netbeans-modules-maven/Actions")
@Messages("ACT_NBM_Reload_Target=Reload in Target Platform")
public static Action createReloadTargetAction() {
Action a = ProjectSensitiveActions.projectCommandAction(RELOAD_TARGET, ACT_NBM_Reload_Target(), null);
a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
return a;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:NbmActionGoalProvider.java
示例14: SetMainProject
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
@SuppressWarnings("LeakingThisInConstructor")
public SetMainProject( Lookup context ) {
super( SetMainProject.class.getName() /*this is a fake command to make ActionUtils.SHORTCUTS_MANAGER work*/, LBL_SetAsMainProjectAction_Name(), null, context );
// wpcl = WeakListeners.propertyChange( this, OpenProjectList.getDefault() );
// OpenProjectList.getDefault().addPropertyChangeListener( wpcl );
if ( context == null ) {
OpenProjectList.getDefault().addPropertyChangeListener( WeakListeners.propertyChange( this, OpenProjectList.getDefault() ) );
}
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
refresh(getLookup(), true);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SetMainProject.java
示例15: FXMLOpenAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public FXMLOpenAction(Lookup context) {
this.context = context;
putValue(AbstractAction.NAME, Bundle.CTL_OpenAction());
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
setupOpener();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:FXMLOpenAction.java
示例16: PinTabAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public PinTabAction(Terminal context) {
super(context);
final Terminal terminal = getTerminal();
putValue(NAME, getMessage(terminal.isPinned()));
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:PinTabAction.java
示例17: ContextAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public ContextAction(Lookup context) {
super(NbBundle.getMessage(SystemOpenAction.class, "CTL_SystemOpenAction"));
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
files = new HashSet<File>();
for (DataObject d : context.lookupAll(DataObject.class)) {
File f = FileUtil.toFile(d.getPrimaryFile());
if (f == null || /* #144575 */Utilities.isWindows() && f.isFile() && !f.getName().contains(".")) {
files.clear();
break;
}
files.add(f);
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:SystemOpenAction.java
示例18: convertComponents
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public @Override Component[] convertComponents(Component comp) {
if (comp instanceof JMenuItem) {
JMenuItem item = (JMenuItem) comp;
if (Boolean.TRUE.equals(item.getClientProperty(DynamicMenuContent.HIDE_WHEN_DISABLED)) && !item.isEnabled()) {
return new Component[0];
}
}
if (comp instanceof DynamicMenuContent) {
Component[] toRet = ((DynamicMenuContent)comp).getMenuPresenters();
boolean atLeastOne = false;
Collection<Component> col = new ArrayList<Component>();
for (int i = 0; i < toRet.length; i++) {
if (toRet[i] instanceof DynamicMenuContent && toRet[i] != comp) {
col.addAll(Arrays.asList(convertComponents(toRet[i])));
atLeastOne = true;
} else {
if (toRet[i] == null) {
toRet[i] = new JSeparator();
}
col.add(toRet[i]);
}
}
if (atLeastOne) {
return col.toArray(new Component[col.size()]);
} else {
return toRet;
}
}
return new Component[] {comp};
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:DefaultAWTBridge.java
示例19: testDisableIsOk
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public void testDisableIsOk() throws Exception {
PasteAction p = PasteAction.get(PasteAction.class);
class A extends AbstractAction {
public void actionPerformed(ActionEvent e) {
}
}
A a = new A();
a.setEnabled(false);
// action.putValue("delegates", new A[0]);
TopComponent td = new TopComponent();
td.getActionMap().put(javax.swing.text.DefaultEditorKit.pasteAction, a);
td.requestActive();
assertFalse("Disabled", p.isEnabled());
JMenuItem item = p.getMenuPresenter();
assertTrue("Dynamic one: " + item, item instanceof DynamicMenuContent);
DynamicMenuContent d = (DynamicMenuContent)item;
JComponent[] items = d.getMenuPresenters();
items = d.synchMenuPresenters(items);
assertEquals("One item", 1, items.length);
assertTrue("One jmenu item", items[0] instanceof JMenuItem);
JMenuItem one = (JMenuItem)items[0];
assertFalse("And is disabled", one.getModel().isEnabled());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:PasteActionTest.java
示例20: ContextAction
import org.openide.awt.DynamicMenuContent; //导入依赖的package包/类
public ContextAction(Lookup context) {
putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
putValue(NAME, NbBundle.getMessage(RebuildCoreLibraryAction.class, "CTL_RebuildCoreLibraryAction"));
project = context.lookup(MakeProject.class);
if ( project != null ) {
FileObject chipkitDir = project.getProjectDirectory().getFileObject( CORE_DIRECTORY_NAME );
setEnabled( chipkitDir != null );
} else {
setEnabled( false );
}
}
开发者ID:chipKIT32,项目名称:chipKIT-importer,代码行数:12,代码来源:RebuildCoreLibraryAction.java
注:本文中的org.openide.awt.DynamicMenuContent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论