Skip to content
Snippets Groups Projects
Commit 8ad7699e authored by Kisslinger's avatar Kisslinger
Browse files

Small enhancement to allow subclasses to limit accepted selections. Hope this...

Small enhancement to allow subclasses to limit accepted selections. Hope this is OK, else please contact me
refs 692
parent fdc13274
No related branches found
No related tags found
No related merge requests found
......@@ -306,7 +306,8 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
// find the path to the element
ITreeSelection selection = (ITreeSelection) gui.getElementTreeViewer()
.getSelection();
if (selection.getPaths() == null || selection.getPaths().length != 1) {
if (selection.getPaths() == null || selection.getPaths().length != 1
|| !acceptElement(selection.getPaths()[0].getLastSegment())) {
selectedPath = null;
getButton(OK_ID).setEnabled(false);
} else {
......@@ -315,6 +316,19 @@ public class ElementTreeSingleSelectDialog extends TitleAreaDialog {
}
}
/**
* This method can be overwritten by subclasses to accept only elements of a
* certain kind. For not-accepted elements the OK-field is disabled.
*
* The default implementation accepts all elements.
*
* @param element
* the element which is currently selected
*/
public boolean acceptElement(Object element) {
return true;
}
/**
* Create the tree path from one of the given root elements to the child
* element. The content provider will be used to compute the direct parent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment