|
Lines 19-25
Link Here
|
| 19 |
import java.util.Iterator; |
19 |
import java.util.Iterator; |
| 20 |
import java.util.LinkedList; |
20 |
import java.util.LinkedList; |
| 21 |
import java.util.Map; |
21 |
import java.util.Map; |
| 22 |
|
|
|
| 23 |
import org.eclipse.core.commands.Category; |
22 |
import org.eclipse.core.commands.Category; |
| 24 |
import org.eclipse.core.commands.ParameterizedCommand; |
23 |
import org.eclipse.core.commands.ParameterizedCommand; |
| 25 |
import org.eclipse.core.commands.util.Tracing; |
24 |
import org.eclipse.core.commands.util.Tracing; |
|
Lines 186-191
Link Here
|
| 186 |
|
185 |
|
| 187 |
private TableViewer conflictViewer; |
186 |
private TableViewer conflictViewer; |
| 188 |
|
187 |
|
|
|
188 |
private boolean hasNameConflicts; |
| 189 |
|
| 189 |
private ICommandImageService commandImageService; |
190 |
private ICommandImageService commandImageService; |
| 190 |
|
191 |
|
| 191 |
private ICommandService commandService; |
192 |
private ICommandService commandService; |
|
Lines 828-849
Link Here
|
| 828 |
table.setHeaderVisible(true); |
829 |
table.setHeaderVisible(true); |
| 829 |
TableColumn bindingNameColumn = new TableColumn(table, SWT.LEAD); |
830 |
TableColumn bindingNameColumn = new TableColumn(table, SWT.LEAD); |
| 830 |
bindingNameColumn.setText(NewKeysPreferenceMessages.CommandNameColumn_Text); |
831 |
bindingNameColumn.setText(NewKeysPreferenceMessages.CommandNameColumn_Text); |
| 831 |
bindingNameColumn.setWidth(150); |
832 |
bindingNameColumn.setWidth(100); |
| 832 |
TableColumn bindingContextNameColumn = new TableColumn(table, SWT.LEAD); |
833 |
TableColumn bindingContextNameColumn = new TableColumn(table, SWT.LEAD); |
| 833 |
bindingContextNameColumn.setText(NewKeysPreferenceMessages.WhenColumn_Text); |
834 |
bindingContextNameColumn.setText(NewKeysPreferenceMessages.WhenColumn_Text); |
| 834 |
bindingContextNameColumn.setWidth(150); |
835 |
bindingContextNameColumn.setWidth(100); |
|
|
836 |
TableColumn bindingCategoryNameColumn = new TableColumn(table, SWT.LEAD); |
| 837 |
bindingCategoryNameColumn.setText(NewKeysPreferenceMessages.CategoryColumn_Text); |
| 838 |
bindingCategoryNameColumn.setWidth(100); |
| 835 |
gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
839 |
gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
| 836 |
//gridData.horizontalIndent = 10; |
840 |
//gridData.horizontalIndent = 10; |
| 837 |
table.setLayoutData(gridData); |
841 |
table.setLayoutData(gridData); |
| 838 |
TableLayout tableLayout = new TableLayout(); |
842 |
TableLayout tableLayout = new TableLayout(); |
| 839 |
tableLayout.addColumnData(new ColumnWeightData(60)); |
843 |
tableLayout.addColumnData(new ColumnWeightData(50)); |
| 840 |
tableLayout.addColumnData(new ColumnWeightData(40)); |
844 |
tableLayout.addColumnData(new ColumnWeightData(25)); |
|
|
845 |
tableLayout.addColumnData(new ColumnWeightData(25)); |
| 841 |
table.setLayout(tableLayout); |
846 |
table.setLayout(tableLayout); |
| 842 |
conflictViewer.setContentProvider(new IStructuredContentProvider() { |
847 |
conflictViewer.setContentProvider(new IStructuredContentProvider() { |
| 843 |
|
848 |
|
| 844 |
public Object[] getElements(Object inputElement) { |
849 |
public Object[] getElements(Object inputElement) { |
| 845 |
if (inputElement instanceof Collection) { |
850 |
if (inputElement instanceof Collection) { |
| 846 |
return ((Collection) inputElement).toArray(); |
851 |
Object[] bindings = ((Collection) inputElement).toArray(); |
|
|
852 |
calculateConflicts(bindings); |
| 853 |
return bindings; |
| 847 |
} |
854 |
} |
| 848 |
return new Object[0]; |
855 |
return new Object[0]; |
| 849 |
} |
856 |
} |
|
Lines 859-867
Link Here
|
| 859 |
public String getColumnText(Object o, int index) { |
866 |
public String getColumnText(Object o, int index) { |
| 860 |
BindingElement element = (BindingElement) o; |
867 |
BindingElement element = (BindingElement) o; |
| 861 |
if (index == 0) { |
868 |
if (index == 0) { |
|
|
869 |
if (hasNameConflicts) { |
| 870 |
String desc = element.getDescription(); |
| 871 |
if (desc != null) |
| 872 |
return element.getName() + " (" + desc + ")"; //$NON-NLS-1$ //$NON-NLS-2$ |
| 873 |
return element.getName(); |
| 874 |
} |
| 862 |
return element.getName(); |
875 |
return element.getName(); |
|
|
876 |
} else if (index == 1) { |
| 877 |
return element.getContext().getName(); |
| 878 |
} else { |
| 879 |
return element.getCategory(); |
| 863 |
} |
880 |
} |
| 864 |
return element.getContext().getName(); |
|
|
| 865 |
} |
881 |
} |
| 866 |
}); |
882 |
}); |
| 867 |
conflictViewer |
883 |
conflictViewer |
|
Lines 962-967
Link Here
|
| 962 |
|
978 |
|
| 963 |
} |
979 |
} |
| 964 |
|
980 |
|
|
|
981 |
protected void calculateConflicts(Object[] bindings) { |
| 982 |
hasNameConflicts = false; |
| 983 |
outer: |
| 984 |
for (int i = 0; i < bindings.length; i++) { |
| 985 |
BindingElement binding1 = (BindingElement) bindings[i]; |
| 986 |
for (int j = i + 1; j < bindings.length; j++) { |
| 987 |
BindingElement binding2 = (BindingElement) bindings[j]; |
| 988 |
if (binding1.getName().equals(binding2.getName()) |
| 989 |
&& binding1.getCategory().equals(binding2.getCategory())) { |
| 990 |
hasNameConflicts = true; |
| 991 |
break outer; |
| 992 |
} |
| 993 |
} |
| 994 |
} |
| 995 |
} |
| 996 |
|
| 965 |
private void createTree(Composite parent) { |
997 |
private void createTree(Composite parent) { |
| 966 |
fPatternFilter = new CategoryPatternFilter(true, fDefaultCategory); |
998 |
fPatternFilter = new CategoryPatternFilter(true, fDefaultCategory); |
| 967 |
fPatternFilter.filterCategories(true); |
999 |
fPatternFilter.filterCategories(true); |