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);
}
}
});
}
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()]));
}
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();
}
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;
}
Aggregations