+
+ /**
+ * Get the trace folder from the selection
+ *
+ * @param selection
+ * the selection
+ *
+ * @return the enclosing project or null if selection is no enclosed by a
+ * project
+ */
+ public static TmfTraceFolder getTraceFolderFromSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Object firstElement = structuredSelection.getFirstElement();
+ if (firstElement instanceof ITmfProjectModelElement) {
+ ITmfProjectModelElement element = (ITmfProjectModelElement) firstElement;
+ while (element != null) {
+ if (element instanceof TmfTraceFolder) {
+ return (TmfTraceFolder) element;
+ }
+ element = element.getParent();
+ }
+ }
+ }
+ return null;
+ }