Search in sources :

Example 11 with Binding

use of org.eclipse.jface.bindings.Binding in project translationstudio8 by heartsome.

the class ConflictModel2 method init.

public void init(BindingManager manager, BindingModel model) {
    bindingManager = manager;
    bindingModel = model;
    conflictsMap = new HashMap();
    Iterator i = bindingModel.getBindings().iterator();
    while (i.hasNext()) {
        BindingElement be = (BindingElement) i.next();
        if (be.getModelObject() instanceof Binding) {
            updateConflictsFor(be);
        }
    }
    controller.addPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getSource() == ConflictModel2.this && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
                if (event.getNewValue() != null) {
                    updateConflictsFor((BindingElement) event.getOldValue(), (BindingElement) event.getNewValue());
                    setConflicts((Collection) conflictsMap.get(event.getNewValue()));
                } else {
                    setConflicts(null);
                }
            } else if (BindingModel.PROP_BINDING_REMOVE.equals(event.getProperty())) {
                updateConflictsFor((BindingElement) event.getOldValue(), (BindingElement) event.getNewValue(), true);
            }
        }
    });
}
Also used : Binding(org.eclipse.jface.bindings.Binding) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) HashMap(java.util.HashMap) BindingElement(org.eclipse.ui.internal.keys.model.BindingElement) Iterator(java.util.Iterator) Collection(java.util.Collection)

Example 12 with Binding

use of org.eclipse.jface.bindings.Binding in project translationstudio8 by heartsome.

the class KeyController2 method filterDupliteBind.

@SuppressWarnings("restriction")
public void filterDupliteBind() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
    BindingService service = (BindingService) bindingService;
    BindingManager bindingManager = service.getBindingManager();
    //service.getBindingManager().
    Binding[] bindings = bindingManager.getBindings();
    List<Binding> bindTemp = new ArrayList<Binding>();
    List<String> ids = new ArrayList<String>();
    for (Binding bind : bindings) {
        if (null == bind) {
            continue;
        }
        ParameterizedCommand command = bind.getParameterizedCommand();
        if (null == command) {
            continue;
        }
        String id = command.getId();
        if (!ids.contains(id)) {
            ids.add(id);
            bindTemp.add(bind);
        }
    }
    bindingManager.setBindings(bindTemp.toArray(new Binding[ids.size()]));
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) BindingManager(org.eclipse.jface.bindings.BindingManager) KeyBinding(org.eclipse.jface.bindings.keys.KeyBinding) Binding(org.eclipse.jface.bindings.Binding) IBindingService(org.eclipse.ui.keys.IBindingService) BindingService(org.eclipse.ui.internal.keys.BindingService) ArrayList(java.util.ArrayList) IBindingService(org.eclipse.ui.keys.IBindingService) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand)

Example 13 with Binding

use of org.eclipse.jface.bindings.Binding in project translationstudio8 by heartsome.

the class KeyController2 method init.

public void init(IServiceLocator locator, List<String> lstRemove) {
    getEventManager().clear();
    this.serviceLocator = locator;
    //	filterDupliteBind();
    fBindingManager = loadModelBackend(serviceLocator);
    contextModel = new ContextModel(this);
    contextModel.init(serviceLocator);
    fSchemeModel = new SchemeModel(this);
    fSchemeModel.init(fBindingManager);
    bindingModel = new BindingModel2(this);
    bindingModel.init(serviceLocator, fBindingManager, contextModel);
    HashSet<BindingElement> set = bindingModel.getBindings();
    Iterator<BindingElement> iterator = set.iterator();
    while (iterator.hasNext()) {
        BindingElement bindingElement = iterator.next();
        if (lstRemove.contains(bindingElement.getId())) {
            iterator.remove();
        }
    }
    bindingModel.setBindings(set);
    Map<Binding, BindingElement> mapBBe = bindingModel.getBindingToElement();
    Iterator<Entry<Binding, BindingElement>> it = mapBBe.entrySet().iterator();
    while (it.hasNext()) {
        Entry<Binding, BindingElement> entry = (Entry<Binding, BindingElement>) it.next();
        if (lstRemove.contains(entry.getValue().getId())) {
            it.remove();
        }
    }
    bindingModel.setBindingToElement(mapBBe);
    conflictModel = new ConflictModel2(this);
    conflictModel.init(fBindingManager, bindingModel);
    addSetContextListener();
    addSetBindingListener();
    addSetConflictListener();
    addSetKeySequenceListener();
    addSetSchemeListener();
    addSetModelObjectListener();
}
Also used : KeyBinding(org.eclipse.jface.bindings.keys.KeyBinding) Binding(org.eclipse.jface.bindings.Binding) Entry(java.util.Map.Entry) ContextModel(org.eclipse.ui.internal.keys.model.ContextModel) BindingElement(org.eclipse.ui.internal.keys.model.BindingElement) SchemeModel(org.eclipse.ui.internal.keys.model.SchemeModel)

Example 14 with Binding

use of org.eclipse.jface.bindings.Binding in project translationstudio8 by heartsome.

the class KeyAssistHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
    BindingService service = (BindingService) bindingService;
    ArrayList<Binding> lstBinding = new ArrayList<Binding>(Arrays.asList(bindingService.getBindings()));
    List<String> lstRemove = Constants.lstRemove;
    Iterator<Binding> it = lstBinding.iterator();
    while (it.hasNext()) {
        Binding binding = it.next();
        ParameterizedCommand pCommand = binding.getParameterizedCommand();
        if (pCommand == null || lstRemove.contains(pCommand.getCommand().getId())) {
            it.remove();
        }
    }
    service.getKeyboard().openKeyAssistShell(lstBinding);
    return null;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Binding(org.eclipse.jface.bindings.Binding) IBindingService(org.eclipse.ui.keys.IBindingService) BindingService(org.eclipse.ui.internal.keys.BindingService) ArrayList(java.util.ArrayList) IBindingService(org.eclipse.ui.keys.IBindingService) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand)

Aggregations

Binding (org.eclipse.jface.bindings.Binding)14 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)11 KeyBinding (org.eclipse.jface.bindings.keys.KeyBinding)9 BindingElement (org.eclipse.ui.internal.keys.model.BindingElement)9 Collection (java.util.Collection)5 Iterator (java.util.Iterator)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)3 TriggerSequence (org.eclipse.jface.bindings.TriggerSequence)3 IBindingService (org.eclipse.ui.keys.IBindingService)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 Command (org.eclipse.core.commands.Command)2 IWorkbench (org.eclipse.ui.IWorkbench)2 ICommandService (org.eclipse.ui.commands.ICommandService)2 BindingService (org.eclipse.ui.internal.keys.BindingService)2 ModelElement (org.eclipse.ui.internal.keys.model.ModelElement)2