1 11 package org.eclipse.ui.internal.keys; 12 13 import org.eclipse.jface.bindings.BindingManager; 14 import org.eclipse.jface.bindings.Scheme; 15 import org.eclipse.ui.commands.IKeyConfiguration; 16 import org.eclipse.ui.commands.IKeyConfigurationListener; 17 import org.eclipse.ui.commands.NotDefinedException; 18 19 25 public final class SchemeLegacyWrapper implements IKeyConfiguration { 26 27 31 private final BindingManager bindingManager; 32 33 36 private final Scheme scheme; 37 38 47 public SchemeLegacyWrapper(final Scheme scheme, 48 final BindingManager bindingManager) { 49 if (scheme == null) { 50 throw new NullPointerException ("Cannot wrap a null scheme"); } 52 53 if (bindingManager == null) { 54 throw new NullPointerException ( 55 "Cannot wrap a scheme without a binding manager"); } 57 58 this.scheme = scheme; 59 this.bindingManager = bindingManager; 60 } 61 62 67 public void addKeyConfigurationListener( 68 IKeyConfigurationListener keyConfigurationListener) { 69 scheme.addSchemeListener(new LegacySchemeListenerWrapper( 70 keyConfigurationListener, bindingManager)); 71 } 72 73 78 public int compareTo(Object o) { 79 return scheme.compareTo(o); 80 } 81 82 87 public String getDescription() throws NotDefinedException { 88 try { 89 return scheme.getDescription(); 90 } catch (final org.eclipse.core.commands.common.NotDefinedException e) { 91 throw new NotDefinedException(e); 92 } 93 } 94 95 100 public String getId() { 101 return scheme.getId(); 102 } 103 104 109 public String getName() throws NotDefinedException { 110 try { 111 return scheme.getName(); 112 } catch (final org.eclipse.core.commands.common.NotDefinedException e) { 113 throw new NotDefinedException(e); 114 } 115 } 116 117 122 public String getParentId() throws NotDefinedException { 123 try { 124 return scheme.getParentId(); 125 } catch (final org.eclipse.core.commands.common.NotDefinedException e) { 126 throw new NotDefinedException(e); 127 } 128 } 129 130 135 public boolean isActive() { 136 return scheme.getId().equals(bindingManager.getActiveScheme().getId()); 137 } 138 139 144 public boolean isDefined() { 145 return scheme.isDefined(); 146 } 147 148 153 public void removeKeyConfigurationListener( 154 IKeyConfigurationListener keyConfigurationListener) { 155 scheme.removeSchemeListener(new LegacySchemeListenerWrapper( 156 keyConfigurationListener, bindingManager)); 157 158 } 159 160 } 161 | Popular Tags |