/*******************************************************************************
- * Copyright (c) 2010, 2011, 2012 Ericsson
- *
+ * Copyright (c) 2010, 2012 Ericsson
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
+ * Bernd Hufmann - Implement getParent()
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.project.model;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.ICommonContentProvider;
import org.eclipse.ui.navigator.IPipelinedTreeContentProvider;
import org.eclipse.ui.navigator.PipelinedShapeModification;
import org.eclipse.ui.navigator.PipelinedViewerUpdate;
/**
- * The TMF project content provider for the tree viewer in the project explorer view.
+ * The TMF project content provider for the tree viewer in the project explorer view.
* <p>
* @version 1.0
* @author Francois Chouinard
*/
-public class TmfNavigatorContentProvider implements ICommonContentProvider, IPipelinedTreeContentProvider {
+public class TmfNavigatorContentProvider implements IPipelinedTreeContentProvider {
// ------------------------------------------------------------------------
// ICommonContentProvider
*/
@Override
public Object getParent(Object element) {
+ if (element instanceof IProject) {
+ IProject project = (IProject) element;
+ return project.getParent();
+ }
+
+ if (element instanceof TmfTraceFolder) {
+ TmfTraceFolder folder = (TmfTraceFolder) element;
+ // Return the corresponding IProject as parent because from CNF point of view the IProject is the parent.
+ // The IProject is needed e.g. for link with Editor to work correctly.
+ return folder.getParent().getResource();
+ }
+
+ if (element instanceof TmfTraceElement) {
+ TmfTraceElement traceElement = (TmfTraceElement) element;
+ return traceElement.getParent();
+ }
+
+ if (element instanceof TmfExperimentFolder) {
+ TmfExperimentFolder folder = (TmfExperimentFolder) element;
+ // Return the corresponding IProject as parent because from CNF point of view the IProject is the parent.
+ // The IProject is needed e.g. for link with Editor to work correctly.
+ return folder.getParent().getResource();
+ }
+
+ if (element instanceof TmfExperimentElement) {
+ TmfExperimentElement expElement = (TmfExperimentElement) element;
+ return expElement.getParent();
+ }
return null;
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
@Override
public void restoreState(IMemento aMemento) {
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set)
*/
@Override
- @SuppressWarnings({ "rawtypes", "unchecked" })
public void getPipelinedChildren(Object parent, Set currentChildren) {
customizeTmfElements(getChildren(parent), currentChildren);
}
* @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set)
*/
@Override
- @SuppressWarnings({ "rawtypes", "unchecked" })
public void getPipelinedElements(Object input, Set currentElements) {
customizeTmfElements(getElements(input), currentElements);
}
/**
* Add/replace the ITmfProjectElement to the list of children
- *
+ *
* @param elements
* the list returned by getChildren()
* @param children
* the current children
*/
- private void customizeTmfElements(Object[] elements, Set<Object> children) {
+ private static void customizeTmfElements(Object[] elements,
+ Set<Object> children) {
if (elements != null && children != null) {
for (Object element : elements) {
if (element instanceof ITmfProjectModelElement) {