* @param event the selection change event
*/
protected void handleTableSelectionChanged(SelectionChangedEvent event) {
- int size = ((IStructuredSelection)event.getSelection()).size();
- int idx = fPathMapTable.getTable().getSelectionIndex();
- int count = fPathMapTable.getTable().getItemCount();
- if (size==1) {
- fEditButton.setEnabled(idx>0);
- fUpButton.setEnabled(idx>0);
- fDownButton.setEnabled((idx>=0)&&(idx<count-1));
+ int size = ((IStructuredSelection)event.getSelection()).size(); // Get number of selected items
+ int idx = fPathMapTable.getTable().getSelectionIndex(); // Get the index of the selected item
+ int count = fPathMapTable.getTable().getItemCount(); // Get the number of entries within the pathmap list
+
+ if (size == 1) { // If one pathmap entry is selected
+ fEditButton.setEnabled (idx >= 0); // Enable 'Edit' button if a pathmap entry is selected
+ fUpButton.setEnabled (idx > 0); // Enable 'Up' button only if the selected entry is not the very first one
+ fDownButton.setEnabled ((idx >= 0) && (idx < count-1)); // Enable 'Down' button only if the selected entry is not the very last one
+ }
+ else { // If nothing selected, or more than one entry selected
+ fEditButton.setEnabled (false); // Disable 'Edit' button
+ fUpButton.setEnabled (false); // Disable 'Up' button
+ fDownButton.setEnabled (false); // Disable 'Down' button
}
- fRemoveButton.setEnabled(size > 0);
+ fRemoveButton.setEnabled (size > 0); // Enable 'Remove' if at least on entry is selected
}
/**