@Override public TriggerSequence getTriggerSequence() { return getKeySequence(); } }
private static void getBindingForPlatform(KeySequence keySequence, String platform, ParameterizedCommand parameterizedCommand, String schemeId, String contextId, String locale, List bindings, String modifiedSequence, String[] platforms) throws ParseException { int j = 0; for (; j < platforms.length; j++) { if(platforms[j].equals(SWT.getPlatform())) { KeyBinding newBinding = new KeyBinding(KeySequence .getInstance(modifiedSequence), parameterizedCommand, schemeId, contextId, locale, platforms[j], null, Binding.SYSTEM); bindings.add(newBinding); break; } } if(j == platforms.length) { // platform doesn't match. use the unmodified sequence KeyBinding newBinding = new KeyBinding(keySequence, parameterizedCommand, schemeId, contextId, locale, null, null, Binding.SYSTEM); bindings.add(newBinding); } }
/** * @param binding * @param contextModel */ public void fill(KeyBinding binding, ContextModel contextModel) { setCommandInfo(binding.getParameterizedCommand()); setTrigger(binding.getTriggerSequence()); setContext((ContextElement) contextModel.getContextIdToElement().get( binding.getContextId())); setUserDelta(Integer.valueOf(binding.getType())); setModelObject(binding); }
if (obj instanceof KeyBinding) { KeyBinding keyBinding = (KeyBinding) obj; if (!keyBinding.getContextId().equals(context.getId())) { final KeyBinding binding = new KeyBinding(keyBinding .getKeySequence(), keyBinding.getParameterizedCommand(), activeSchemeId, context.getId(), null, null, null, Binding.USER); if (keyBinding.getType() == Binding.USER) { fBindingManager.removeBinding(keyBinding); } else { fBindingManager.addBinding(new KeyBinding(keyBinding .getKeySequence(), null, keyBinding.getSchemeId(), keyBinding.getContextId(), null, null, null, Binding.USER));
/** * Handles the selection event on the table containing the bindings for a * particular command. This updates the context and trigger sequence based * on the selected binding. */ private void selectedTableBindingsForCommand() { final int selection = tableBindingsForCommand.getSelectionIndex(); if ((selection >= 0) && (selection < tableBindingsForCommand.getItemCount())) { final TableItem item = tableBindingsForCommand.getItem(selection); final KeyBinding binding = (KeyBinding) item.getData(ITEM_DATA_KEY); setContextId(binding.getContextId()); setKeySequence(binding.getKeySequence()); } update(); }
cmd = (ParameterizedCommand) obj; } else if (obj instanceof KeyBinding) { cmd = ((KeyBinding) obj).getParameterizedCommand(); pcmd = (ParameterizedCommand) obj; } else if (obj instanceof KeyBinding) { pcmd = ((KeyBinding) obj).getParameterizedCommand();
if (obj instanceof KeyBinding) { KeyBinding keyBinding = (KeyBinding) obj; if (!keyBinding.getKeySequence().equals(keySequence)) { if (keySequence != null && !keySequence.isEmpty()) { String activeSchemeId = fSchemeModel.getSelectedElement() String activeContextId = selectedElement == null ? IContextService.CONTEXT_ID_WINDOW : selectedElement.getId(); final KeyBinding binding = new KeyBinding(keySequence, keyBinding.getParameterizedCommand(), activeSchemeId, activeContextId, null, null, null, Binding.USER); Map bindingToElement = bindingModel.getBindingToElement(); bindingToElement.remove(keyBinding); if (keyBinding.getType() == Binding.USER) { fBindingManager.removeBinding(keyBinding); } else { fBindingManager.addBinding(new KeyBinding(keyBinding .getKeySequence(), null, keyBinding .getSchemeId(), keyBinding.getContextId(), null, null, null, Binding.USER)); } else { bindingModel.getBindingToElement().remove(keyBinding); if (keyBinding.getType() == Binding.USER) { fBindingManager.removeBinding(keyBinding); } else { fBindingManager.addBinding(new KeyBinding(keyBinding .getKeySequence(), null, keyBinding
KeyBinding b = (KeyBinding) i.next(); ParameterizedCommand parameterizedCommand = b .getParameterizedCommand(); cmdsForBindings.add(parameterizedCommand); if (!bindingToElement.containsKey(b)) {
if (keyBinding.getType() == Binding.USER) { bindingManager.removeBinding(keyBinding); } else { KeySequence keySequence = keyBinding.getKeySequence(); bindingManager.addBinding(new KeyBinding(keySequence, null, keyBinding.getSchemeId(), keyBinding.getContextId(), null, null, null, Binding.USER)); .getParameterizedCommand(); bindingElement.fill(parameterizedCommand); commandToElement.put(parameterizedCommand, bindingElement);
public Binding createBinding(TriggerSequence sequence, ParameterizedCommand command, String contextId, Map<String, String> attributes) { String schemeId = DEFAULT_SCHEME_ID; String locale = null; String platform = null; int bindingType = Binding.SYSTEM; if (sequence != null && !sequence.isEmpty() && contextId != null) { if (attributes != null) { String tmp = attributes.get(SCHEME_ID_ATTR_TAG); if (tmp != null && tmp.length() > 0) { schemeId = tmp; } locale = attributes.get(LOCALE_ATTR_TAG); platform = attributes.get(PLATFORM_ATTR_TAG); if (USER_TYPE.equals(attributes.get(TYPE_ATTR_TAG))) { bindingType = Binding.USER; } } return new KeyBinding((KeySequence) sequence, command, schemeId, contextId, locale, platform, null, bindingType); } return null; }
@Override public TriggerSequence getTriggerSequence() { return getKeySequence(); } }
cmd = ((KeyBinding) modelObject).getParameterizedCommand();
@Override public Binding createBinding(TriggerSequence sequence, ParameterizedCommand command, String contextId, Map<String, String> attributes) { String schemeId = DEFAULT_SCHEME_ID; String locale = null; String platform = null; int bindingType = Binding.SYSTEM; if (sequence != null && !sequence.isEmpty() && contextId != null) { if (attributes != null) { String tmp = attributes.get(SCHEME_ID_ATTR_TAG); if (tmp != null && tmp.length() > 0) { schemeId = tmp; } locale = attributes.get(LOCALE_ATTR_TAG); platform = attributes.get(PLATFORM_ATTR_TAG); if (USER_TYPE.equals(attributes.get(TYPE_ATTR_TAG))) { bindingType = Binding.USER; } } return new KeyBinding((KeySequence) sequence, command, schemeId, contextId, locale, platform, null, bindingType); } return null; }
public TriggerSequence getTriggerSequence() { return getKeySequence(); } }
private static void addGenericBindings(KeySequence keySequence, ParameterizedCommand parameterizedCommand, String schemeId, String contextId, String locale, List bindings, String modifiedSequence, String[] platforms) throws ParseException { KeyBinding originalBinding = new KeyBinding(keySequence, parameterizedCommand, schemeId, contextId, locale, null, null, Binding.SYSTEM); bindings.add(originalBinding); String platform = SWT.getPlatform(); boolean modifierExists = false; for (String currentPlatform : platforms) { if(currentPlatform.equals(platform)) { modifierExists = true; break; } } if(modifierExists) { KeyBinding newBinding = new KeyBinding(KeySequence.getInstance(modifiedSequence), parameterizedCommand, schemeId, contextId, locale, SWT.getPlatform(), null, Binding.SYSTEM); KeyBinding deleteBinding = new KeyBinding(keySequence, null, schemeId, contextId, locale, SWT.getPlatform(), null, Binding.SYSTEM); bindings.add(newBinding); bindings.add(deleteBinding); } }
private void updateKeyBindingList() { if( activeBindings != null ) { List keyBindingList = new ArrayList(); final Iterator bindingItr = activeBindings.entrySet().iterator(); while( bindingItr.hasNext() ) { final Map.Entry entry = ( Map.Entry )bindingItr.next(); Binding binding = ( Binding )entry.getValue(); if( binding instanceof KeyBinding ) { KeyBinding keyBinding = ( KeyBinding )binding; KeySequence keySequence = keyBinding.getKeySequence(); KeyStroke[] keyStroke = keySequence.getKeyStrokes(); if( keyStroke.length > 0 ) { keyBindingList.add( keyStroke[ 0 ].toString() ); } } } String[] array = new String[ keyBindingList.size() ]; keyBindingList.toArray( array ); Display display = Display.getCurrent(); if( display == null ) { throw new IllegalStateException(); } display.setData( RWT.ACTIVE_KEYS, array ); display.setData( RWT.CANCEL_KEYS, array ); } } // ENDRAP [if]
KeyBinding binding = new KeyBinding(keySequence, parameterizedCommand, schemeId, contextId, locale, platform, null, Binding.SYSTEM);
/** * Handles the selection event on the remove button. This removes all * user-defined bindings matching the given key sequence, scheme and * context. It then adds a new deletion binding for the selected trigger * sequence. */ private void selectedButtonRemove() { final String contextId = getContextId(); final String schemeId = getSchemeId(); final KeySequence keySequence = getKeySequence(); localChangeManager.removeBindings(keySequence, schemeId, contextId, null, null, null, Binding.USER); localChangeManager.addBinding(new KeyBinding(keySequence, null, schemeId, contextId, null, null, null, Binding.USER)); update(true); }
cocoaTempList.add(new KeyBinding(keySequence, parameterizedCommand, schemeId, contextId, locale, Util.WS_COCOA, null, Binding.SYSTEM));
/** * Handles the selection event on the add button. This removes all * user-defined bindings matching the given key sequence, scheme and * context. It then adds a new binding with the current selections. */ private void selectedButtonAdd() { final ParameterizedCommand command = getParameterizedCommand(); final String contextId = getContextId(); final String schemeId = getSchemeId(); final KeySequence keySequence = getKeySequence(); localChangeManager.removeBindings(keySequence, schemeId, contextId, null, null, null, Binding.USER); localChangeManager.addBinding(new KeyBinding(keySequence, command, schemeId, contextId, null, null, null, Binding.USER)); update(true); }