use of javax.swing.KeyStroke in project adempiere by adempiere.
the class AMenu method createMenu.
// getPreferredSize
/**
* Create Menu
*/
private void createMenu() {
// File
JMenu mFile = AEnv.getMenu("File");
menuBar.add(mFile);
AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this);
AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, KeyEvent.SHIFT_MASK), mFile, this);
mFile.addSeparator();
AEnv.addMenuItem("Logout", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.SHIFT_MASK + Event.ALT_MASK), mFile, this);
AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.SHIFT_MASK + Event.ALT_MASK), mFile, this);
// View
JMenu mView = AEnv.getMenu("View");
menuBar.add(mView);
if (MRole.getDefault().isAllow_Info_Product()) {
AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK), mView, this);
}
if (MRole.getDefault().isAllow_Info_BPartner()) {
AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK + Event.CTRL_MASK), mView, this);
}
if (MRole.getDefault().isShowAcct() && MRole.getDefault().isAllow_Info_Account()) {
AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK + Event.CTRL_MASK), mView, this);
}
if (MRole.getDefault().isAllow_Info_Schedule()) {
AEnv.addMenuItem("InfoSchedule", null, null, mView, this);
}
//FR [ 1966328 ]
if (MRole.getDefault().isAllow_Info_MRP()) {
AEnv.addMenuItem("InfoMRP", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_CRP()) {
AEnv.addMenuItem("InfoCRP", "Info", null, mView, this);
}
mView.addSeparator();
if (MRole.getDefault().isAllow_Info_Order()) {
AEnv.addMenuItem("InfoOrder", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_Invoice()) {
AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_InOut()) {
AEnv.addMenuItem("InfoInOut", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_Payment()) {
AEnv.addMenuItem("InfoPayment", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_CashJournal()) {
AEnv.addMenuItem("InfoCashLine", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_Resource()) {
AEnv.addMenuItem("InfoAssignment", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_Asset()) {
AEnv.addMenuItem("InfoAsset", "Info", null, mView, this);
}
// Tools
JMenu mTools = AEnv.getMenu("Tools");
menuBar.add(mTools);
AEnv.addMenuItem("Calculator", null, null, mTools, this);
AEnv.addMenuItem("Calendar", null, null, mTools, this);
AEnv.addMenuItem("Editor", null, null, mTools, this);
MUser user = MUser.get(Env.getCtx());
if (user.isAdministrator())
AEnv.addMenuItem("Script", null, null, mTools, this);
if (AEnv.isWorkflowProcess())
AEnv.addMenuItem("WorkFlow", null, null, mTools, this);
if (MRole.getDefault().isShowPreference()) {
mTools.addSeparator();
AEnv.addMenuItem("Preference", null, null, mTools, this);
}
//Window Menu
m_WindowMenu = new WindowMenu(windowManager, this);
menuBar.add(m_WindowMenu);
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.CTRL_MASK);
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ks, "ShowAllWindow");
AppsAction action = new AppsAction("ShowAllWindow", ks, false);
this.getRootPane().getActionMap().put("ShowAllWindow", action);
action.setDelegate(this);
// Help
JMenu mHelp = AEnv.getMenu("Help");
menuBar.add(mHelp);
AEnv.addMenuItem("Online", null, null, mHelp, this);
AEnv.addMenuItem("EMailSupport", null, null, mHelp, this);
AEnv.addMenuItem("About", null, null, mHelp, this);
}
use of javax.swing.KeyStroke in project adempiere by adempiere.
the class CompiereToolTipUI method getAcceleratorString.
/**
* Get Accelerator String
* @return string
*/
public String getAcceleratorString() {
String str = super.getAcceleratorString();
if (tip == null || isAcceleratorHidden())
return str;
JComponent comp = tip.getComponent();
if (comp == null || comp instanceof JTabbedPane || comp instanceof JMenuItem)
return str;
KeyStroke[] keys = comp.getRegisteredKeyStrokes();
StringBuffer controlKeyStr = new StringBuffer();
for (int i = 0; i < keys.length; i++) {
int mod = keys[i].getModifiers();
int condition = comp.getConditionForKeyStroke(keys[i]);
if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
String prefix = KeyEvent.getKeyModifiersText(mod);
if (prefix.length() > 1) {
if (controlKeyStr.length() > 0)
controlKeyStr.append(" ");
controlKeyStr.append(prefix).append("-").append(KeyEvent.getKeyText(keys[i].getKeyCode()));
// just first
break;
}
}
}
return controlKeyStr.toString();
}
use of javax.swing.KeyStroke in project adempiere by adempiere.
the class SwingTool method getKeyStrokeFor.
public static KeyStroke getKeyStrokeFor(char c, List usedStrokes) {
int m = Event.CTRL_MASK;
KeyStroke o = null;
for (Iterator i = usedStrokes.iterator(); i.hasNext(); ) {
o = (KeyStroke) i.next();
if (c == o.getKeyChar()) {
if (c == o.getKeyChar()) {
if (o.getModifiers() != Event.SHIFT_MASK + Event.CTRL_MASK) {
m = Event.SHIFT_MASK + Event.CTRL_MASK;
} else if (o.getModifiers() != Event.SHIFT_MASK + Event.ALT_MASK) {
m = Event.SHIFT_MASK + Event.ALT_MASK;
} else {
m = -1;
}
}
}
}
KeyStroke s = null;
if (m != -1) {
s = KeyStroke.getKeyStroke(c, m);
usedStrokes.add(s);
}
return s;
}
use of javax.swing.KeyStroke in project jmeter by apache.
the class MainFrame method addQuickComponentHotkeys.
private void addQuickComponentHotkeys(JTree treevar) {
Action quickComponent = new AbstractAction("Quick Component") {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
String propname = "gui.quick_" + actionEvent.getActionCommand();
String comp = JMeterUtils.getProperty(propname);
log.debug("Event {}: {}", propname, comp);
if (comp == null) {
log.warn("No component set through property: {}", propname);
return;
}
GuiPackage guiPackage = GuiPackage.getInstance();
try {
guiPackage.updateCurrentNode();
TestElement testElement = guiPackage.createTestElement(SaveService.aliasToClass(comp));
JMeterTreeNode parentNode = guiPackage.getCurrentNode();
while (!MenuFactory.canAddTo(parentNode, testElement)) {
parentNode = (JMeterTreeNode) parentNode.getParent();
}
if (parentNode.getParent() == null) {
log.debug("Cannot add element on very top level");
} else {
JMeterTreeNode node = guiPackage.getTreeModel().addComponent(testElement, parentNode);
guiPackage.getMainFrame().getTree().setSelectionPath(new TreePath(node.getPath()));
}
} catch (Exception err) {
// $NON-NLS-1$
log.warn("Failed to perform quick component add: {}", comp, err);
}
}
};
InputMap inputMap = treevar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
KeyStroke[] keyStrokes = new KeyStroke[] { KeyStrokes.CTRL_0, KeyStrokes.CTRL_1, KeyStrokes.CTRL_2, KeyStrokes.CTRL_3, KeyStrokes.CTRL_4, KeyStrokes.CTRL_5, KeyStrokes.CTRL_6, KeyStrokes.CTRL_7, KeyStrokes.CTRL_8, KeyStrokes.CTRL_9 };
for (int n = 0; n < keyStrokes.length; n++) {
treevar.getActionMap().put(ActionNames.QUICK_COMPONENT + String.valueOf(n), quickComponent);
inputMap.put(keyStrokes[n], ActionNames.QUICK_COMPONENT + String.valueOf(n));
}
}
use of javax.swing.KeyStroke in project jadx by skylot.
the class CommonSearchDialog method initCommon.
protected void initCommon() {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
getRootPane().registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
}
Aggregations