本文整理汇总了Java中org.openide.awt.DynamicMenuContent类的典型用法代码示例。如果您正苦于以下问题:Java DynamicMenuContent类的具体用法?Java DynamicMenuContent怎么用?Java DynamicMenuContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DynamicMenuContent类属于org.openide.awt包,在下文中一共展示了DynamicMenuContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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
}
示例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);
}
示例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;
}
示例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
}
}
}
}
示例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));
}
示例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);
}
示例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());
}
示例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());
}
}
示例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);
}
}
}
}
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}