|
Lines 42-47
Link Here
|
| 42 |
import org.eclipse.jface.bindings.keys.KeyLookupFactory; |
42 |
import org.eclipse.jface.bindings.keys.KeyLookupFactory; |
| 43 |
import org.eclipse.jface.bindings.keys.KeyStroke; |
43 |
import org.eclipse.jface.bindings.keys.KeyStroke; |
| 44 |
import org.eclipse.jface.contexts.IContextIds; |
44 |
import org.eclipse.jface.contexts.IContextIds; |
|
|
45 |
import org.eclipse.jface.internal.InternalPolicy; |
| 45 |
import org.eclipse.jface.util.Policy; |
46 |
import org.eclipse.jface.util.Policy; |
| 46 |
import org.eclipse.jface.util.Util; |
47 |
import org.eclipse.jface.util.Util; |
| 47 |
import org.eclipse.swt.SWT; |
48 |
import org.eclipse.swt.SWT; |
|
Lines 181-186
Link Here
|
| 181 |
* Otherwise, this value may be empty. |
182 |
* Otherwise, this value may be empty. |
| 182 |
*/ |
183 |
*/ |
| 183 |
private Map activeBindingsByParameterizedCommand = null; |
184 |
private Map activeBindingsByParameterizedCommand = null; |
|
|
185 |
|
| 186 |
private Set triggerConflicts = new HashSet(); |
| 184 |
|
187 |
|
| 185 |
/** |
188 |
/** |
| 186 |
* The scheme that is currently active. An active scheme is the one that is |
189 |
* The scheme that is currently active. An active scheme is the one that is |
|
Lines 272-279
Link Here
|
| 272 |
*/ |
275 |
*/ |
| 273 |
private Map prefixTable = null; |
276 |
private Map prefixTable = null; |
| 274 |
|
277 |
|
| 275 |
private Set triggerConflicts = new HashSet(); |
|
|
| 276 |
|
| 277 |
/** |
278 |
/** |
| 278 |
* <p> |
279 |
* <p> |
| 279 |
* Constructs a new instance of <code>BindingManager</code>. |
280 |
* Constructs a new instance of <code>BindingManager</code>. |
|
Lines 438-444
Link Here
|
| 438 |
* This method completes in <code>O(1)</code>. |
439 |
* This method completes in <code>O(1)</code>. |
| 439 |
*/ |
440 |
*/ |
| 440 |
private final void clearSolution() { |
441 |
private final void clearSolution() { |
| 441 |
setActiveBindings(null, null, null); |
442 |
setActiveBindings(null, null, null, null); |
| 442 |
} |
443 |
} |
| 443 |
|
444 |
|
| 444 |
/** |
445 |
/** |
|
Lines 511-517
Link Here
|
| 511 |
* computed). |
512 |
* computed). |
| 512 |
*/ |
513 |
*/ |
| 513 |
private final void computeBindings(final Map activeContextTree, |
514 |
private final void computeBindings(final Map activeContextTree, |
| 514 |
final Map bindingsByTrigger, final Map triggersByCommandId) { |
515 |
final Map bindingsByTrigger, final Map triggersByCommandId, |
|
|
516 |
final Map conflictsByTrigger) { |
| 515 |
/* |
517 |
/* |
| 516 |
* FIRST PASS: Remove all of the bindings that are marking deletions. |
518 |
* FIRST PASS: Remove all of the bindings that are marking deletions. |
| 517 |
*/ |
519 |
*/ |
|
Lines 632-637
Link Here
|
| 632 |
activeContextTree); |
634 |
activeContextTree); |
| 633 |
if (winner == null) { |
635 |
if (winner == null) { |
| 634 |
// warn once ... so as not to flood the logs |
636 |
// warn once ... so as not to flood the logs |
|
|
637 |
conflictsByTrigger.put(trigger, match); |
| 635 |
if (triggerConflicts.add(trigger)) { |
638 |
if (triggerConflicts.add(trigger)) { |
| 636 |
final StringWriter sw = new StringWriter(); |
639 |
final StringWriter sw = new StringWriter(); |
| 637 |
final BufferedWriter buffer = new BufferedWriter(sw); |
640 |
final BufferedWriter buffer = new BufferedWriter(sw); |
|
Lines 997-1006
Link Here
|
| 997 |
// Compute the active bindings. |
1000 |
// Compute the active bindings. |
| 998 |
commandIdsByTrigger = new HashMap(); |
1001 |
commandIdsByTrigger = new HashMap(); |
| 999 |
final Map triggersByParameterizedCommand = new HashMap(); |
1002 |
final Map triggersByParameterizedCommand = new HashMap(); |
|
|
1003 |
final Map conflictsByTrigger = new HashMap(); |
| 1000 |
computeBindings(null, commandIdsByTrigger, |
1004 |
computeBindings(null, commandIdsByTrigger, |
| 1001 |
triggersByParameterizedCommand); |
1005 |
triggersByParameterizedCommand, conflictsByTrigger); |
| 1002 |
existingCache.setBindingsByTrigger(commandIdsByTrigger); |
1006 |
existingCache.setBindingsByTrigger(commandIdsByTrigger); |
| 1003 |
existingCache.setTriggersByCommandId(triggersByParameterizedCommand); |
1007 |
existingCache.setTriggersByCommandId(triggersByParameterizedCommand); |
|
|
1008 |
existingCache.setConflictsByTrigger(conflictsByTrigger); |
| 1004 |
return Collections.unmodifiableMap(commandIdsByTrigger); |
1009 |
return Collections.unmodifiableMap(commandIdsByTrigger); |
| 1005 |
} |
1010 |
} |
| 1006 |
|
1011 |
|
|
Lines 1057-1067
Link Here
|
| 1057 |
|
1062 |
|
| 1058 |
// Compute the active bindings. |
1063 |
// Compute the active bindings. |
| 1059 |
final Map commandIdsByTrigger = new HashMap(); |
1064 |
final Map commandIdsByTrigger = new HashMap(); |
|
|
1065 |
final Map conflictsByTrigger = new HashMap(); |
| 1060 |
triggersByParameterizedCommand = new HashMap(); |
1066 |
triggersByParameterizedCommand = new HashMap(); |
| 1061 |
computeBindings(null, commandIdsByTrigger, |
1067 |
computeBindings(null, commandIdsByTrigger, |
| 1062 |
triggersByParameterizedCommand); |
1068 |
triggersByParameterizedCommand, conflictsByTrigger); |
| 1063 |
existingCache.setBindingsByTrigger(commandIdsByTrigger); |
1069 |
existingCache.setBindingsByTrigger(commandIdsByTrigger); |
| 1064 |
existingCache.setTriggersByCommandId(triggersByParameterizedCommand); |
1070 |
existingCache.setTriggersByCommandId(triggersByParameterizedCommand); |
|
|
1071 |
existingCache.setConflictsByTrigger(conflictsByTrigger); |
| 1065 |
|
1072 |
|
| 1066 |
return Collections.unmodifiableMap(triggersByParameterizedCommand); |
1073 |
return Collections.unmodifiableMap(triggersByParameterizedCommand); |
| 1067 |
} |
1074 |
} |
|
Lines 1703-1709
Link Here
|
| 1703 |
if (bindings == null) { |
1710 |
if (bindings == null) { |
| 1704 |
// Not yet initialized. This is happening too early. Do nothing. |
1711 |
// Not yet initialized. This is happening too early. Do nothing. |
| 1705 |
setActiveBindings(Collections.EMPTY_MAP, Collections.EMPTY_MAP, |
1712 |
setActiveBindings(Collections.EMPTY_MAP, Collections.EMPTY_MAP, |
| 1706 |
Collections.EMPTY_MAP); |
1713 |
Collections.EMPTY_MAP, Collections.EMPTY_MAP); |
| 1707 |
return; |
1714 |
return; |
| 1708 |
} |
1715 |
} |
| 1709 |
|
1716 |
|
|
Lines 1732-1738
Link Here
|
| 1732 |
Tracing.printTrace("BINDINGS", "Cache hit"); //$NON-NLS-1$ //$NON-NLS-2$ |
1739 |
Tracing.printTrace("BINDINGS", "Cache hit"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 1733 |
} |
1740 |
} |
| 1734 |
setActiveBindings(commandIdsByTrigger, existingCache |
1741 |
setActiveBindings(commandIdsByTrigger, existingCache |
| 1735 |
.getTriggersByCommandId(), existingCache.getPrefixTable()); |
1742 |
.getTriggersByCommandId(), existingCache.getPrefixTable(), |
|
|
1743 |
existingCache.getConflictsByTrigger()); |
| 1736 |
return; |
1744 |
return; |
| 1737 |
} |
1745 |
} |
| 1738 |
|
1746 |
|
|
Lines 1744-1755
Link Here
|
| 1744 |
// Compute the active bindings. |
1752 |
// Compute the active bindings. |
| 1745 |
commandIdsByTrigger = new HashMap(); |
1753 |
commandIdsByTrigger = new HashMap(); |
| 1746 |
final Map triggersByParameterizedCommand = new HashMap(); |
1754 |
final Map triggersByParameterizedCommand = new HashMap(); |
|
|
1755 |
final Map conflictsByTrigger = new HashMap(); |
| 1747 |
computeBindings(activeContextTree, commandIdsByTrigger, |
1756 |
computeBindings(activeContextTree, commandIdsByTrigger, |
| 1748 |
triggersByParameterizedCommand); |
1757 |
triggersByParameterizedCommand, conflictsByTrigger); |
| 1749 |
existingCache.setBindingsByTrigger(commandIdsByTrigger); |
1758 |
existingCache.setBindingsByTrigger(commandIdsByTrigger); |
| 1750 |
existingCache.setTriggersByCommandId(triggersByParameterizedCommand); |
1759 |
existingCache.setTriggersByCommandId(triggersByParameterizedCommand); |
|
|
1760 |
existingCache.setConflictsByTrigger(conflictsByTrigger); |
| 1751 |
setActiveBindings(commandIdsByTrigger, triggersByParameterizedCommand, |
1761 |
setActiveBindings(commandIdsByTrigger, triggersByParameterizedCommand, |
| 1752 |
buildPrefixTable(commandIdsByTrigger)); |
1762 |
buildPrefixTable(commandIdsByTrigger), |
|
|
1763 |
conflictsByTrigger); |
| 1753 |
existingCache.setPrefixTable(prefixTable); |
1764 |
existingCache.setPrefixTable(prefixTable); |
| 1754 |
} |
1765 |
} |
| 1755 |
|
1766 |
|
|
Lines 2153-2163
Link Here
|
| 2153 |
* solution. |
2164 |
* solution. |
| 2154 |
*/ |
2165 |
*/ |
| 2155 |
private final void setActiveBindings(final Map activeBindings, |
2166 |
private final void setActiveBindings(final Map activeBindings, |
| 2156 |
final Map activeBindingsByCommandId, final Map prefixTable) { |
2167 |
final Map activeBindingsByCommandId, final Map prefixTable, |
|
|
2168 |
final Map conflicts) { |
| 2157 |
this.activeBindings = activeBindings; |
2169 |
this.activeBindings = activeBindings; |
| 2158 |
final Map previousBindingsByParameterizedCommand = this.activeBindingsByParameterizedCommand; |
2170 |
final Map previousBindingsByParameterizedCommand = this.activeBindingsByParameterizedCommand; |
| 2159 |
this.activeBindingsByParameterizedCommand = activeBindingsByCommandId; |
2171 |
this.activeBindingsByParameterizedCommand = activeBindingsByCommandId; |
| 2160 |
this.prefixTable = prefixTable; |
2172 |
this.prefixTable = prefixTable; |
|
|
2173 |
InternalPolicy.currentConflicts = conflicts; |
| 2161 |
|
2174 |
|
| 2162 |
fireBindingManagerChanged(new BindingManagerEvent(this, true, |
2175 |
fireBindingManagerChanged(new BindingManagerEvent(this, true, |
| 2163 |
previousBindingsByParameterizedCommand, false, null, false, |
2176 |
previousBindingsByParameterizedCommand, false, null, false, |