1 19 20 package org.netbeans.modules.java.project; 21 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.ActionListener ; 24 import javax.swing.AbstractAction ; 25 import javax.swing.JMenu ; 26 import javax.swing.JMenuItem ; 27 import javax.swing.JRadioButtonMenuItem ; 28 import org.openide.awt.Mnemonics; 29 import org.openide.util.NbBundle; 30 import org.openide.util.actions.Presenter; 31 32 36 public final class ChangePackageViewTypeAction extends AbstractAction implements Presenter.Popup { 37 38 public ChangePackageViewTypeAction() {} 39 40 public void actionPerformed(ActionEvent e) { 41 assert false : e; 42 } 43 44 public JMenuItem getPopupPresenter() { 45 JMenu menu = new JMenu (); 46 Mnemonics.setLocalizedText(menu, NbBundle.getMessage(ChangePackageViewTypeAction.class, "LBL_change_package_type")); 47 menu.add(createChoice(JavaProjectSettings.TYPE_PACKAGE_VIEW, NbBundle.getMessage(ChangePackageViewTypeAction.class, "ChangePackageViewTypeAction_list"))); 48 menu.add(createChoice(JavaProjectSettings.TYPE_TREE, NbBundle.getMessage(ChangePackageViewTypeAction.class, "ChangePackageViewTypeAction_tree"))); 49 return menu; 50 } 51 52 private JMenuItem createChoice(final int type, String label) { 53 JRadioButtonMenuItem item = new JRadioButtonMenuItem (); 54 Mnemonics.setLocalizedText(item, label); 55 item.setSelected(JavaProjectSettings.getPackageViewType() == type); 56 item.addActionListener(new ActionListener () { 57 public void actionPerformed(ActionEvent e) { 58 JavaProjectSettings.setPackageViewType(type); 59 } 60 }); 61 return item; 62 } 63 64 } 65 | Popular Tags |