View | Details | Raw Unified | Return to bug 176235 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java (-47 / +169 lines)
Lines 42-47 Link Here
42
import org.eclipse.jface.bindings.keys.KeyStroke;
42
import org.eclipse.jface.bindings.keys.KeyStroke;
43
import org.eclipse.jface.contexts.IContextIds;
43
import org.eclipse.jface.contexts.IContextIds;
44
import org.eclipse.jface.dialogs.IDialogConstants;
44
import org.eclipse.jface.dialogs.IDialogConstants;
45
import org.eclipse.jface.dialogs.IDialogSettings;
45
import org.eclipse.jface.dialogs.MessageDialog;
46
import org.eclipse.jface.dialogs.MessageDialog;
46
import org.eclipse.jface.preference.PreferencePage;
47
import org.eclipse.jface.preference.PreferencePage;
47
import org.eclipse.jface.resource.DeviceResourceException;
48
import org.eclipse.jface.resource.DeviceResourceException;
Lines 52-57 Link Here
52
import org.eclipse.jface.util.PropertyChangeEvent;
53
import org.eclipse.jface.util.PropertyChangeEvent;
53
import org.eclipse.jface.viewers.ArrayContentProvider;
54
import org.eclipse.jface.viewers.ArrayContentProvider;
54
import org.eclipse.jface.viewers.ComboViewer;
55
import org.eclipse.jface.viewers.ComboViewer;
56
import org.eclipse.jface.viewers.IBaseLabelProvider;
55
import org.eclipse.jface.viewers.ISelection;
57
import org.eclipse.jface.viewers.ISelection;
56
import org.eclipse.jface.viewers.ISelectionChangedListener;
58
import org.eclipse.jface.viewers.ISelectionChangedListener;
57
import org.eclipse.jface.viewers.IStructuredSelection;
59
import org.eclipse.jface.viewers.IStructuredSelection;
Lines 253-259 Link Here
253
		/**
255
		/**
254
		 * The index of the column with the button for adding an item.
256
		 * The index of the column with the button for adding an item.
255
		 */
257
		 */
256
		private static final int COLUMN_ADD = 2;
258
		private static final int COLUMN_ADD = 3;
257
259
258
		/**
260
		/**
259
		 * The index of the column containing the command name.
261
		 * The index of the column containing the command name.
Lines 263-270 Link Here
263
		/**
265
		/**
264
		 * The index of the column with the button for removing an item.
266
		 * The index of the column with the button for removing an item.
265
		 */
267
		 */
266
		private static final int COLUMN_REMOVE = 3;
268
		private static final int COLUMN_REMOVE = 4;
267
269
270
271
		/**
272
		 * The index of the column containing the Category.
273
		 */
274
		private static final int COLUMN_CATEGORY = 2;
275
		
268
		/**
276
		/**
269
		 * The index of the column containing the trigger sequence.
277
		 * The index of the column containing the trigger sequence.
270
		 */
278
		 */
Lines 273-279 Link Here
273
		/**
281
		/**
274
		 * The number of columns being displayed.
282
		 * The number of columns being displayed.
275
		 */
283
		 */
276
		private static final int NUMBER_OF_COLUMNS = 4;
284
		private static final int NUMBER_OF_COLUMNS = 5;
277
285
278
		/**
286
		/**
279
		 * A resource manager for this preference page.
287
		 * A resource manager for this preference page.
Lines 377-387 Link Here
377
				case COLUMN_COMMAND:
385
				case COLUMN_COMMAND:
378
					try {
386
					try {
379
						return binding.getParameterizedCommand().getName();
387
						return binding.getParameterizedCommand().getName();
388
						
380
					} catch (final NotDefinedException e) {
389
					} catch (final NotDefinedException e) {
381
						return null;
390
						return null;
382
					}
391
					}
383
				case COLUMN_TRIGGER_SEQUENCE:
392
				case COLUMN_TRIGGER_SEQUENCE:
384
					return binding.getTriggerSequence().format();
393
					return binding.getTriggerSequence().format();
394
					
395
				case COLUMN_CATEGORY:
396
					try {
397
							return binding.getParameterizedCommand().getCommand().getCategory().getName();
398
						} catch (NotDefinedException e) {
399
							// TODO Auto-generated catch block
400
							return null;
401
						}
385
				default:
402
				default:
386
					return null;
403
					return null;
387
				}
404
				}
Lines 416-422 Link Here
416
						return null;
433
						return null;
417
					}
434
					}
418
				}
435
				}
419
436
				if (columnIndex== COLUMN_TRIGGER_SEQUENCE)
437
					return ""; //$NON-NLS-1$
438
				if (columnIndex==COLUMN_CATEGORY){
439
					try {
440
						return ((ParameterizedCommand) value).getCommand().getCategory().getName();
441
					} catch (NotDefinedException e) {
442
						// TODO Auto-generated catch block
443
						return null;
444
					}
445
				}
420
				return null;
446
				return null;
421
			}
447
			}
422
448
Lines 429-434 Link Here
429
	 */
455
	 */
430
	private final class BindingComparator extends ViewerComparator {
456
	private final class BindingComparator extends ViewerComparator {
431
457
458
		private int sortColumn = 0;
459
		private boolean ascending = true;
460
		
432
		public final int category(final Object element) {
461
		public final int category(final Object element) {
433
			switch (grouping) {
462
			switch (grouping) {
434
			case GROUPING_CATEGORY:
463
			case GROUPING_CATEGORY:
Lines 573-592 Link Here
573
					}
602
					}
574
603
575
				} else { // (GROUPING_NONE_NAME.equals(selectedText))
604
				} else { // (GROUPING_NONE_NAME.equals(selectedText))
576
					/*
605
					IBaseLabelProvider baseLabel = filteredTree.getViewer().getLabelProvider();
577
					 * The tree node values will be Binding or
606
					if (baseLabel instanceof ITableLabelProvider) {
578
					 * ParameterizedCommand instances.
607
						ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel;
579
					 */
608
						String e1p = tableProvider.getColumnText(a, sortColumn);
580
					final Object x = ((TreeNode) a).getValue();
609
						String e2p = tableProvider.getColumnText(b, sortColumn);
581
					final Object y = ((TreeNode) b).getValue();
610
						int result = getComparator().compare(e1p, e2p);
582
					final ParameterizedCommand commandX = (x instanceof Binding) ? ((Binding) x)
611
						return ascending ?  result : (-1) * result;
583
							.getParameterizedCommand()
612
					}
584
							: (ParameterizedCommand) x;
613
					return super.compare(viewer, a, b);
585
					final ParameterizedCommand commandY = (y instanceof Binding) ? ((Binding) y)
614
					
586
							.getParameterizedCommand()
587
							: (ParameterizedCommand) y;
588
615
589
					return Util.compare(commandX, commandY);
590
				}
616
				}
591
			} catch (final NotDefinedException e) {
617
			} catch (final NotDefinedException e) {
592
				// This could be made a lot more fine-grained.
618
				// This could be made a lot more fine-grained.
Lines 594-599 Link Here
594
620
595
			return 0;
621
			return 0;
596
		}
622
		}
623
	
624
		/**
625
		 * @return Returns the sortColumn.
626
		 */
627
		public int getSortColumn() {
628
			return sortColumn;
629
		}
630
631
		/**
632
		 * @param sortColumn The sortColumn to set.
633
		 */
634
		public void setSortColumn(int sortColumn) {
635
			this.sortColumn = sortColumn;
636
		}
637
638
		/**
639
		 * @return Returns the ascending.
640
		 */
641
		public boolean isAscending() {
642
			return ascending;
643
		}
644
645
		/**
646
		 * @param ascending The ascending to set.
647
		 */
648
		public void setAscending(boolean ascending) {
649
			this.ascending = ascending;
650
		}
597
	}
651
	}
598
652
599
	/**
653
	/**
Lines 659-664 Link Here
659
	 * <code>NamedHandleObject</code> instances to the end user.
713
	 * <code>NamedHandleObject</code> instances to the end user.
660
	 */
714
	 */
661
	private static final NamedHandleObjectComparator NAMED_HANDLE_OBJECT_COMPARATOR = new NamedHandleObjectComparator();
715
	private static final NamedHandleObjectComparator NAMED_HANDLE_OBJECT_COMPARATOR = new NamedHandleObjectComparator();
716
	
717
	private final static String TAG_DIALOG_SECTION = "org.eclipse.ui.preferences.keysPreferencePage"; //$NON-NLS-1$
718
	
719
	private final String TAG_FIELD = "showAllField"; //$NON-NLS-1$
662
720
663
	/**
721
	/**
664
	 * Sorts the given array of <code>NamedHandleObject</code> instances based
722
	 * Sorts the given array of <code>NamedHandleObject</code> instances based
Lines 717-723 Link Here
717
	 * command. This value is <code>null</code> until the controls are
775
	 * command. This value is <code>null</code> until the controls are
718
	 * created.
776
	 * created.
719
	 */
777
	 */
720
	private Label descriptionValueLabel;
778
	private Text descriptionValueText;
721
779
722
	/**
780
	/**
723
	 * The filtered tree containing the list of commands and bindings to edit.
781
	 * The filtered tree containing the list of commands and bindings to edit.
Lines 1019-1026 Link Here
1019
		final Composite rightDataArea = new Composite(dataArea, SWT.NONE);
1077
		final Composite rightDataArea = new Composite(dataArea, SWT.NONE);
1020
		layout = new GridLayout(1, false);
1078
		layout = new GridLayout(1, false);
1021
		rightDataArea.setLayout(layout);
1079
		rightDataArea.setLayout(layout);
1022
		gridData = new GridData();
1080
		gridData = new GridData(GridData.FILL_BOTH);
1023
		gridData.grabExcessHorizontalSpace = true;
1024
		gridData.verticalAlignment = SWT.TOP;
1081
		gridData.verticalAlignment = SWT.TOP;
1025
		gridData.horizontalAlignment = SWT.FILL;
1082
		gridData.horizontalAlignment = SWT.FILL;
1026
		rightDataArea.setLayoutData(gridData);
1083
		rightDataArea.setLayoutData(gridData);
Lines 1031-1050 Link Here
1031
		gridData = new GridData();
1088
		gridData = new GridData();
1032
		gridData.grabExcessHorizontalSpace = true;
1089
		gridData.grabExcessHorizontalSpace = true;
1033
		gridData.horizontalAlignment = SWT.FILL;
1090
		gridData.horizontalAlignment = SWT.FILL;
1034
		descriptionLabel.setLayoutData(gridData);
1091
		descriptionLabel.setLayoutData(gridData);		
1035
1092
		
1036
		// The description value.
1093
		// The description value.
1037
		descriptionValueLabel = new Label(rightDataArea, SWT.WRAP);
1094
		descriptionValueText = new Text(rightDataArea,SWT.BORDER|SWT.MULTI|SWT.H_SCROLL);
1038
		gridData = new GridData();
1095
		gridData = new GridData(GridData.FILL_BOTH);
1039
		gridData.horizontalAlignment = SWT.FILL;
1096
		gridData.horizontalIndent = 20;
1040
		gridData.verticalAlignment = SWT.FILL;
1097
		descriptionValueText.setLayoutData(gridData);
1041
		gridData.grabExcessHorizontalSpace = true;
1098
		descriptionValueText.setEditable(false);
1042
		gridData.grabExcessVerticalSpace = true;
1043
		gridData.horizontalIndent = 30;
1044
		gridData.verticalIndent = 5;
1045
		gridData.widthHint = 200;
1046
		descriptionValueLabel.setLayoutData(gridData);
1047
1048
		return dataArea;
1099
		return dataArea;
1049
	}
1100
	}
1050
1101
Lines 1122-1143 Link Here
1122
			}
1173
			}
1123
		}
1174
		}
1124
1175
1176
        final BindingComparator comparator = new BindingComparator();
1177
        comparator.setSortColumn(0);
1178
		
1125
		// Create the columns for the tree.
1179
		// Create the columns for the tree.
1180
		
1126
		final TreeColumn commandNameColumn = new TreeColumn(tree, SWT.LEFT,
1181
		final TreeColumn commandNameColumn = new TreeColumn(tree, SWT.LEFT,
1127
				BindingLabelProvider.COLUMN_COMMAND);
1182
				BindingLabelProvider.COLUMN_COMMAND);
1128
		commandNameColumn.setText(NewKeysPreferenceMessages.CommandNameColumn_Text); 
1183
		commandNameColumn.setText(NewKeysPreferenceMessages.CommandNameColumn_Text);
1184
		commandNameColumn.addSelectionListener(new SelectionAdapter(){
1185
			public void widgetSelected(SelectionEvent e) {
1186
            	if (comparator.getSortColumn()==0) {
1187
            		comparator.setAscending(!comparator.isAscending());
1188
            	}
1189
                comparator.setSortColumn(0);
1190
                filteredTree.getViewer().refresh();
1191
				
1192
			}
1193
			
1194
		});
1129
		final TreeColumn triggerSequenceColumn = new TreeColumn(tree, SWT.LEFT,
1195
		final TreeColumn triggerSequenceColumn = new TreeColumn(tree, SWT.LEFT,
1130
				BindingLabelProvider.COLUMN_TRIGGER_SEQUENCE);
1196
				BindingLabelProvider.COLUMN_TRIGGER_SEQUENCE);
1131
		triggerSequenceColumn.setText(NewKeysPreferenceMessages.TriggerSequenceColumn_Text); 
1197
		triggerSequenceColumn.setText(NewKeysPreferenceMessages.TriggerSequenceColumn_Text);
1198
		triggerSequenceColumn.addSelectionListener(new SelectionAdapter(){
1199
			public void widgetSelected(SelectionEvent e) {
1200
            	if (comparator.getSortColumn()==1) {
1201
            		comparator.setAscending(!comparator.isAscending());
1202
            	}
1203
                comparator.setSortColumn(1);
1204
                filteredTree.getViewer().refresh();
1205
				
1206
			}
1207
			
1208
		});
1209
		
1210
1211
		final TreeColumn categoryColumn = new TreeColumn(tree, SWT.LEFT,
1212
				BindingLabelProvider.COLUMN_CATEGORY);
1213
		categoryColumn.setText(NewKeysPreferenceMessages.CategoryColumn_Text);
1214
		categoryColumn.addSelectionListener(new SelectionAdapter(){
1215
			public void widgetSelected(SelectionEvent e) {
1216
            	if (comparator.getSortColumn()==2) {
1217
            		comparator.setAscending(!comparator.isAscending());
1218
            	}
1219
                comparator.setSortColumn(2);
1220
                filteredTree.getViewer().refresh();
1221
				
1222
			}
1223
			
1224
		});
1225
				
1132
		new TreeColumn(tree, SWT.LEFT, BindingLabelProvider.COLUMN_ADD);
1226
		new TreeColumn(tree, SWT.LEFT, BindingLabelProvider.COLUMN_ADD);
1133
		new TreeColumn(tree, SWT.LEFT, BindingLabelProvider.COLUMN_REMOVE);
1227
		new TreeColumn(tree, SWT.LEFT, BindingLabelProvider.COLUMN_REMOVE);
1134
1228
		
1135
		// Set up the providers for the viewer.
1229
		// Set up the providers for the viewer.
1136
		final TreeViewer viewer = filteredTree.getViewer();
1230
		final TreeViewer viewer = filteredTree.getViewer();
1137
		viewer.setLabelProvider(new BindingLabelProvider());
1231
		viewer.setLabelProvider(new BindingLabelProvider());
1138
		viewer.setContentProvider(new TreeNodeContentProvider());
1232
		viewer.setContentProvider(new TreeNodeContentProvider());
1139
		viewer.setComparator(new BindingComparator());
1233
		    
1140
1234
		viewer.setComparator(comparator);
1235
				
1141
		/*
1236
		/*
1142
		 * Listen for selection changes so that the data controls can be
1237
		 * Listen for selection changes so that the data controls can be
1143
		 * updated.
1238
		 * updated.
Lines 1174-1180 Link Here
1174
1269
1175
		return filteredTree;
1270
		return filteredTree;
1176
	}
1271
	}
1177
1272
	
1178
	private final Control createTreeControls(final Composite parent) {
1273
	private final Control createTreeControls(final Composite parent) {
1179
		GridLayout layout;
1274
		GridLayout layout;
1180
		GridData gridData;
1275
		GridData gridData;
Lines 1197-1203 Link Here
1197
		gridData.horizontalAlignment = SWT.FILL;
1292
		gridData.horizontalAlignment = SWT.FILL;
1198
		gridData.verticalAlignment = SWT.TOP;
1293
		gridData.verticalAlignment = SWT.TOP;
1199
		showAllCheckBox.setLayoutData(gridData);
1294
		showAllCheckBox.setLayoutData(gridData);
1200
		showAllCheckBox.setText(NewKeysPreferenceMessages.ShowAllCheckBox_Text); 
1295
		showAllCheckBox.setText(NewKeysPreferenceMessages.ShowAllCheckBox_Text);
1296
		IDialogSettings settings=getDialogSettings();
1297
		showAllCheckBox.setSelection(settings.getBoolean(TAG_FIELD));
1201
		showAllCheckBox.addSelectionListener(new SelectionAdapter() {
1298
		showAllCheckBox.addSelectionListener(new SelectionAdapter() {
1202
			public void widgetSelected(SelectionEvent e) {
1299
			public void widgetSelected(SelectionEvent e) {
1203
				updateTree();
1300
				updateTree();
Lines 1405-1410 Link Here
1405
		}
1502
		}
1406
1503
1407
		setScheme(localChangeManager.getActiveScheme());
1504
		setScheme(localChangeManager.getActiveScheme());
1505
		showAllCheckBox.setSelection(false);
1408
		super.performDefaults();
1506
		super.performDefaults();
1409
	}
1507
	}
1410
1508
Lines 1417-1423 Link Here
1417
		} catch (final IOException e) {
1515
		} catch (final IOException e) {
1418
			logPreferenceStoreException(e);
1516
			logPreferenceStoreException(e);
1419
		}
1517
		}
1420
1518
		saveState(getDialogSettings());
1421
		return super.performOk();
1519
		return super.performOk();
1422
	}
1520
	}
1423
1521
Lines 1601-1608 Link Here
1601
						if (description == null) {
1699
						if (description == null) {
1602
							description = Util.ZERO_LENGTH_STRING;
1700
							description = Util.ZERO_LENGTH_STRING;
1603
						}
1701
						}
1604
						descriptionValueLabel.setText(description);
1702
						descriptionValueText.setText(description);
1605
						descriptionValueLabel.pack(true);
1606
					} catch (final NotDefinedException e) {
1703
					} catch (final NotDefinedException e) {
1607
						// It's probably okay to just let this one slide.
1704
						// It's probably okay to just let this one slide.
1608
					}
1705
					}
Lines 1619-1626 Link Here
1619
						if (description == null) {
1716
						if (description == null) {
1620
							description = Util.ZERO_LENGTH_STRING;
1717
							description = Util.ZERO_LENGTH_STRING;
1621
						}
1718
						}
1622
						descriptionValueLabel.setText(description);
1719
						descriptionValueText.setText(description);
1623
						descriptionValueLabel.pack(true);
1624
					} catch (final NotDefinedException e) {
1720
					} catch (final NotDefinedException e) {
1625
						// It's probably okay to just let this one slide.
1721
						// It's probably okay to just let this one slide.
1626
					}
1722
					}
Lines 1809-1816 Link Here
1809
		} else {
1905
		} else {
1810
			columns[0].setWidth(292);
1906
			columns[0].setWidth(292);
1811
		}
1907
		}
1812
		columns[1].setWidth(234);
1908
		columns[1].setWidth(150);
1813
		columns[2].setWidth(22);
1909
		columns[2].setWidth(150);
1814
		columns[3].setWidth(22);
1910
		columns[3].setWidth(22);
1911
		columns[4].setWidth(22);
1912
	}
1913
	
1914
  
1915
	/**
1916
	 * Save the state of the receiver.
1917
	 * 
1918
	 * @param dialogSettings
1919
	 */
1920
	public void saveState(IDialogSettings dialogSettings) {
1921
		if (dialogSettings == null) {
1922
			return;
1923
		}
1924
		dialogSettings.put(TAG_FIELD, showAllCheckBox.getSelection());
1925
	}
1926
	
1927
	protected IDialogSettings getDialogSettings() {
1928
		IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
1929
		
1930
		IDialogSettings settings = workbenchSettings
1931
				.getSection(TAG_DIALOG_SECTION);
1932
1933
		if (settings == null) {
1934
			settings = workbenchSettings.addNewSection(TAG_DIALOG_SECTION);
1935
		}
1936
		return settings;
1815
	}
1937
	}
1816
}
1938
}
(-)Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferenceMessages.java (+1 lines)
Lines 27-32 Link Here
27
	public static String AdvancedButton_Text;
27
	public static String AdvancedButton_Text;
28
	public static String BindingLabel_Text;
28
	public static String BindingLabel_Text;
29
	public static String CommandNameColumn_Text;
29
	public static String CommandNameColumn_Text;
30
	public static String CategoryColumn_Text;
30
	public static String CommandNameLabel_Text;
31
	public static String CommandNameLabel_Text;
31
	public static String DeleteSchemeButton_Text;
32
	public static String DeleteSchemeButton_Text;
32
	public static String DescriptionLabel_Text;
33
	public static String DescriptionLabel_Text;
(-)Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.properties (+1 lines)
Lines 14-19 Link Here
14
BindingLabel_Text = Binding:
14
BindingLabel_Text = Binding:
15
CommandNameColumn_Text = Command
15
CommandNameColumn_Text = Command
16
CommandNameLabel_Text = Name:
16
CommandNameLabel_Text = Name:
17
CategoryColumn_Text= Category
17
DeleteSchemeButton_Text = Delete
18
DeleteSchemeButton_Text = Delete
18
DescriptionLabel_Text = Description:
19
DescriptionLabel_Text = Description:
19
RemoveBindingButton_Text = Remove
20
RemoveBindingButton_Text = Remove

Return to bug 176235