List of usage examples for org.eclipse.jface.action LegacyActionTools findKeyCode
public static int findKeyCode(String token)
From source file:org.pentaho.ui.xul.jface.tags.JfaceMenuitem.java
License:Open Source License
public void setAccesskey(String accessKey) { if (contributionItem != null) { int mask = 0; if (accessKey.indexOf("ctrl") > -1) { //$NON-NLS-1$ boolean isMac = System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0; mask += isMac ? SWT.COMMAND : SWT.CTRL; }/*w w w.ja v a 2 s.co m*/ if (accessKey.indexOf("shift") > -1) { //$NON-NLS-1$ mask += SWT.SHIFT; } if (accessKey.indexOf("alt") > -1) { //$NON-NLS-1$ mask += SWT.ALT; } if (accessKey.indexOf("pageup") > -1) { //$NON-NLS-1$ mask += SWT.PAGE_UP; } if (accessKey.indexOf("pagedown") > -1) { //$NON-NLS-1$ mask += SWT.PAGE_DOWN; } if (accessKey.indexOf("home") > -1) { //$NON-NLS-1$ mask += SWT.HOME; } if (accessKey.indexOf("esc") > -1) { //$NON-NLS-1$ mask += SWT.ESC; } remainder = accessKey.replaceAll("ctrl", "").replaceAll("shift", "").replaceAll("alt", "") .replaceAll("-", "").trim(); if (remainder.length() == 1) { mask += remainder.toUpperCase().charAt(0); } else if (remainder.length() > 1 && remainder.startsWith("f")) { //$NON-NLS-1$ // function key mask += LegacyActionTools.findKeyCode(remainder); } contributionItem.getAction().setAccelerator(mask); contributionItem.update(IAction.TEXT); } }
From source file:org.pentaho.ui.xul.swt.tags.SwtMenuitem.java
License:Open Source License
public void setAccesskey(String accessKey) { if (item != null && item.isDisposed() == false) { int mask = 0; if (accessKey.indexOf("ctrl") > -1) { //$NON-NLS-1$ mask |= SWT.MOD1;//from w w w . j a va 2s . c o m } if (accessKey.indexOf("shift") > -1) { //$NON-NLS-1$ mask |= SWT.SHIFT; } if (accessKey.indexOf("alt") > -1) { //$NON-NLS-1$ mask |= SWT.ALT; } if (accessKey.indexOf("pageup") > -1) { //$NON-NLS-1$ mask |= SWT.PAGE_UP; } if (accessKey.indexOf("pagedown") > -1) { //$NON-NLS-1$ mask |= SWT.PAGE_DOWN; } if (accessKey.indexOf("home") > -1) { //$NON-NLS-1$ mask |= SWT.HOME; } if (accessKey.indexOf("esc") > -1) { //$NON-NLS-1$ mask |= SWT.ESC; } if (accessKey.indexOf("up") > -1 && accessKey.indexOf("pageup") == -1) { //$NON-NLS-1$ mask |= SWT.ARROW_UP; } if (accessKey.indexOf("down") > -1 && accessKey.indexOf("pagedown") == -1) { //$NON-NLS-1$ mask |= SWT.ARROW_DOWN; } if (accessKey.indexOf("left") > -1) { //$NON-NLS-1$ mask |= SWT.ARROW_LEFT; } if (accessKey.indexOf("right") > -1) { //$NON-NLS-1$ mask |= SWT.ARROW_RIGHT; } String remainder = accessKey.replaceAll("ctrl", "").replaceAll("shift", "").replaceAll("alt", "") .replaceAll("-", "").trim(); if (remainder.length() == 1) { mask += remainder.toUpperCase().charAt(0); } else if (remainder.length() > 1 && remainder.startsWith("f")) { //$NON-NLS-1$ // function key mask += LegacyActionTools.findKeyCode(remainder); } item.setAccelerator(mask); } }