/*******************************************************************************
- * Copyright (c) 2013 École Polytechnique de Montréal
+ * Copyright (c) 2013, 2014 École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
*
* Contributors:
* Geneviève Bastien - Initial API and implementation
+ * Patrick Tasse - Add support for folder elements
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.project.model;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleHelper;
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisOutput;
import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisManager;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.swt.graphics.TextStyle;
import org.osgi.framework.Bundle;
/**
* @author Geneviève Bastien
* @since 3.0
*/
-public class TmfAnalysisElement extends TmfProjectModelElement {
+public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfStyledProjectModelElement {
+
+ private static final Styler ANALYSIS_CANT_EXECUTE_STYLER = new Styler() {
+ @Override
+ public void applyStyles(TextStyle textStyle) {
+ textStyle.strikeout = true;
+ }
+ };
private final String fAnalysisId;
+ private boolean fCanExecute = true;
/**
* Constructor
@Override
void refreshChildren() {
+ fCanExecute = true;
+
/* Refresh the outputs of this analysis */
Map<String, TmfAnalysisOutputElement> childrenMap = new HashMap<>();
for (TmfAnalysisOutputElement output : getAvailableOutputs()) {
* instantiated when the trace is opened
*/
ITmfProjectModelElement parent = getParent();
- if (parent instanceof TmfTraceElement) {
- ITmfTrace trace = ((TmfTraceElement) parent).getTrace();
+ if (parent instanceof TmfCommonProjectElement) {
+ ITmfTrace trace = ((TmfCommonProjectElement) parent).getTrace();
if (trace == null) {
deleteOutputs();
return;
IAnalysisModule module = trace.getAnalysisModule(fAnalysisId);
if (module == null) {
deleteOutputs();
+ /*
+ * Trace is opened, but the analysis is null, so it does not
+ * apply
+ */
+ fCanExecute = false;
return;
}
}
outputElement.refreshChildren();
}
+
}
/* Remove outputs that are not children of this analysis anymore */
for (TmfAnalysisOutputElement output : childrenMap.values()) {
}
}
+ // ------------------------------------------------------------------------
+ // TmfProjectModelElement
+ // ------------------------------------------------------------------------
+
+ @Override
+ public Styler getStyler() {
+ if (!fCanExecute) {
+ return ANALYSIS_CANT_EXECUTE_STYLER;
+ }
+ return null;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
return outputs;
}
- @Override
- public TmfProjectElement getProject() {
- return getParent().getProject();
- }
-
/**
* Gets the analysis id of this module
*
public String getHelpMessage() {
ITmfProjectModelElement parent = getParent();
+ ITmfTrace trace = null;
if (parent instanceof TmfTraceElement) {
TmfTraceElement traceElement = (TmfTraceElement) parent;
- ITmfTrace trace = traceElement.getTrace();
+ trace = traceElement.getTrace();
if (trace != null) {
IAnalysisModule module = trace.getAnalysisModule(fAnalysisId);
- return module.getHelpText();
+ if (module != null) {
+ return module.getHelpText(trace);
+ }
}
}
return new String();
}
+ if (trace != null) {
+ return helper.getHelpText(trace);
+ }
+
return helper.getHelpText();
}
TmfOpenTraceHelper.openTraceFromElement(traceElement);
}
}
+
}