Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeneviève Bastien2014-05-08 22:05:49 -0400
committerAlexandre Montplaisir2014-05-24 01:53:20 -0400
commit344425d24cf74a3a01be1e3884468414514b9b92 (patch)
tree49a25584e10e1a77d8e78234b50240bca80c27a0
parent5d55376fe1a49a415bb27a510459455bffb2509b (diff)
downloadorg.eclipse.linuxtools-344425d24cf74a3a01be1e3884468414514b9b92.tar.gz
org.eclipse.linuxtools-344425d24cf74a3a01be1e3884468414514b9b92.tar.xz
org.eclipse.linuxtools-344425d24cf74a3a01be1e3884468414514b9b92.zip
TMF: Display a help text for analyses from the helper
When an analysis cannot be executed, it used to show the same message as if the trace was not opened. Now it displays a verbose message explaining why the analysis cannot be executed. Change-Id: I97f1a79ac5c76362ebb9764b95fc8a7af99f963b Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net> Reviewed-on: https://git.eclipse.org/r/26295 Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModuleHelper.java21
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/Messages.java9
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java26
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java79
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/messages.properties3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java4
8 files changed, 113 insertions, 41 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java b/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java
index 2288bb33cc..a22601c631 100644
--- a/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java
+++ b/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java
@@ -17,6 +17,7 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.Activator;
import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlUtils;
import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
@@ -101,6 +102,11 @@ public class TmfAnalysisModuleHelperXml implements IAnalysisModuleHelper {
}
@Override
+ public String getHelpText(@NonNull ITmfTrace trace) {
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
public String getIcon() {
return null;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java
index aa9cdff3e9..b53246213c 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java
@@ -16,6 +16,7 @@ package org.eclipse.linuxtools.tmf.tests.stubs.analysis;
import java.util.Collections;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModuleHelper;
import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement;
@@ -77,6 +78,11 @@ public class AnalysisModuleTestHelper implements IAnalysisModuleHelper {
}
@Override
+ public String getHelpText(@NonNull ITmfTrace trace) {
+ return "";
+ }
+
+ @Override
public String getIcon() {
return "";
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModuleHelper.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModuleHelper.java
index 2529825958..4469e9798f 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModuleHelper.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/IAnalysisModuleHelper.java
@@ -12,6 +12,7 @@
package org.eclipse.linuxtools.tmf.core.analysis;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.osgi.framework.Bundle;
@@ -68,6 +69,22 @@ public interface IAnalysisModuleHelper extends IAnalysisRequirementProvider {
String getHelpText();
/**
+ * Gets a specific help message/documentation for this analysis module
+ * applied on the given trace. This help message can add information on the
+ * status of this analysis for a given trace, whether it can be executed or
+ * not and why.
+ *
+ * This help text will be displayed to the user and may contain information
+ * on what the module does, how to use it and how to correctly generate the
+ * trace to make it available
+ *
+ * @param trace
+ * A trace for which to get specific help message
+ * @return The generic help text
+ */
+ String getHelpText(@NonNull ITmfTrace trace);
+
+ /**
* Gets the icon for this module
*
* @return The icon path
@@ -106,8 +123,8 @@ public interface IAnalysisModuleHelper extends IAnalysisRequirementProvider {
* helper and initializes it with the trace.
*
* After the module is fully created, this method should call
- * {@link TmfAnalysisManager#analysisModuleCreated(IAnalysisModule)} in order
- * for the new module listeners to be executed on this module.
+ * {@link TmfAnalysisManager#analysisModuleCreated(IAnalysisModule)} in
+ * order for the new module listeners to be executed on this module.
*
* @param trace
* The trace to be linked to the module
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/Messages.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/Messages.java
index fb8e1eebb2..3919bf3270 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/Messages.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/Messages.java
@@ -43,6 +43,15 @@ public class Messages extends NLS {
/** The trace to set was null */
public static String TmfAbstractAnalysisModule_NullTrace;
+ /** Additional information on a requirement */
+ public static String TmfAnalysis_RequirementInformation;
+
+ /** Mandatory values of a requirement */
+ public static String TmfAnalysis_RequirementMandatoryValues;
+
+ /** A requirement is not fulfilled */
+ public static String TmfAnalysis_RequirementNotFulfilled;
+
/** Running analysis */
public static String TmfAbstractAnalysisModule_RunningAnalysis;
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java
index 6ac0f8153f..fefb3a4b20 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAbstractAnalysisModule.java
@@ -17,6 +17,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -26,6 +27,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.linuxtools.internal.tmf.core.Activator;
+import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
@@ -403,14 +405,30 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
/**
* Gets the help text specific for a trace who does not have required
- * characteristics for module to execute
+ * characteristics for module to execute. The default implementation uses
+ * the analysis requirements.
*
* @param trace
* The trace to apply the analysis to
* @return Help text
*/
- protected String getTraceCannotExecuteHelpText(ITmfTrace trace) {
- return Messages.TmfAbstractAnalysisModule_AnalysisCannotExecute;
+ protected String getTraceCannotExecuteHelpText(@NonNull ITmfTrace trace) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(NLS.bind(Messages.TmfAbstractAnalysisModule_AnalysisCannotExecute, getName()));
+ for (TmfAnalysisRequirement requirement : getAnalysisRequirements()) {
+ if (!requirement.isFulfilled(trace)) {
+ builder.append("\n\n"); //$NON-NLS-1$
+ builder.append(NLS.bind(Messages.TmfAnalysis_RequirementNotFulfilled, requirement.getType()));
+ builder.append("\n"); //$NON-NLS-1$
+ builder.append(NLS.bind(Messages.TmfAnalysis_RequirementMandatoryValues, requirement.getValues(ValuePriorityLevel.MANDATORY)));
+ Set<String> information = requirement.getInformation();
+ if (!information.isEmpty()) {
+ builder.append("\n"); //$NON-NLS-1$
+ builder.append(NLS.bind(Messages.TmfAnalysis_RequirementInformation, information));
+ }
+ }
+ }
+ return builder.toString();
}
@Override
@@ -425,7 +443,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
}
String text = getShortHelpText(trace);
if (!canExecute(trace)) {
- text = text + getTraceCannotExecuteHelpText(trace);
+ text = text + "\n\n" + getTraceCannotExecuteHelpText(trace); //$NON-NLS-1$
}
return text;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java
index cc6116fb9d..e50762498e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/TmfAnalysisModuleHelperConfigElement.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.ContributorFactoryOSGi;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.linuxtools.internal.tmf.core.Activator;
import org.eclipse.linuxtools.internal.tmf.core.analysis.TmfAnalysisModuleSourceConfigElement;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
@@ -133,23 +134,10 @@ public class TmfAnalysisModuleHelperConfigElement implements IAnalysisModuleHelp
@Override
public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
- /**
- * TODO: This method returns only the requirement of the first
- * applicable tracetype. We may assume that requirements will be the
- * same no matter the trace type, the trace generator will know how to
- * handle those. But this will have to be confirmed when the situation
- * happens.
- */
- for (TraceTypeHelper helper : TmfTraceType.getInstance().getTraceTypeHelpers()) {
- if (appliesToTraceType(helper.getTraceClass())) {
- try {
- return newModule(helper.getTrace()).getAnalysisRequirements();
- } catch (TmfAnalysisException e) {
- Activator.logError("Error in get analysis requirements", e); //$NON-NLS-1$
- }
- }
+ IAnalysisModule module = createModule();
+ if (module != null) {
+ return module.getAnalysisRequirements();
}
-
return Collections.EMPTY_SET;
}
@@ -157,6 +145,18 @@ public class TmfAnalysisModuleHelperConfigElement implements IAnalysisModuleHelp
// Functionalities
// ---------------------------------------
+ private IAnalysisModule createModule() {
+ IAnalysisModule module = null;
+ try {
+ module = (IAnalysisModule) fCe.createExecutableExtension(TmfAnalysisModuleSourceConfigElement.ANALYSIS_MODULE_ATTR);
+ module.setName(getName());
+ module.setId(getId());
+ } catch (CoreException e) {
+ Activator.logError("Error getting analysis modules from configuration files", e); //$NON-NLS-1$
+ }
+ return module;
+ }
+
@Override
public IAnalysisModule newModule(ITmfTrace trace) throws TmfAnalysisException {
@@ -165,28 +165,37 @@ public class TmfAnalysisModuleHelperConfigElement implements IAnalysisModuleHelp
throw new TmfAnalysisException(NLS.bind(Messages.TmfAnalysisModuleHelper_AnalysisDoesNotApply, getName()));
}
- IAnalysisModule module = null;
- try {
- module = (IAnalysisModule) fCe.createExecutableExtension(TmfAnalysisModuleSourceConfigElement.ANALYSIS_MODULE_ATTR);
- module.setName(getName());
- module.setId(getId());
- module.setAutomatic(isAutomatic());
-
- /* Get the module's parameters */
- final IConfigurationElement[] parametersCE = fCe.getChildren(TmfAnalysisModuleSourceConfigElement.PARAMETER_ELEM);
- for (IConfigurationElement element : parametersCE) {
- module.addParameter(element.getAttribute(TmfAnalysisModuleSourceConfigElement.NAME_ATTR));
- String defaultValue = element.getAttribute(TmfAnalysisModuleSourceConfigElement.DEFAULT_VALUE_ATTR);
- if (defaultValue != null) {
- module.setParameter(element.getAttribute(TmfAnalysisModuleSourceConfigElement.NAME_ATTR), defaultValue);
- }
+ IAnalysisModule module = createModule();
+ if (module == null) {
+ return null;
+ }
+
+ module.setAutomatic(isAutomatic());
+
+ /* Get the module's parameters */
+ final IConfigurationElement[] parametersCE = fCe.getChildren(TmfAnalysisModuleSourceConfigElement.PARAMETER_ELEM);
+ for (IConfigurationElement element : parametersCE) {
+ module.addParameter(element.getAttribute(TmfAnalysisModuleSourceConfigElement.NAME_ATTR));
+ String defaultValue = element.getAttribute(TmfAnalysisModuleSourceConfigElement.DEFAULT_VALUE_ATTR);
+ if (defaultValue != null) {
+ module.setParameter(element.getAttribute(TmfAnalysisModuleSourceConfigElement.NAME_ATTR), defaultValue);
}
- module.setTrace(trace);
- TmfAnalysisManager.analysisModuleCreated(module);
- } catch (CoreException e) {
- Activator.logError("Error getting analysis modules from configuration files", e); //$NON-NLS-1$
}
+ module.setTrace(trace);
+ TmfAnalysisManager.analysisModuleCreated(module);
+
return module;
}
+
+ @Override
+ public String getHelpText(@NonNull ITmfTrace trace) {
+ IAnalysisModule module = createModule();
+ if (module != null) {
+ String ret = module.getHelpText(trace);
+ module.dispose();
+ return ret;
+ }
+ return getHelpText();
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/messages.properties b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/messages.properties
index 9744dea254..1cd4123a28 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/analysis/messages.properties
@@ -16,6 +16,9 @@ TmfAbstractAnalysisModule_AnalysisForTrace=Analysis module: {0} for trace {1}
TmfAbstractAnalysisModule_AnalysisModule=Analysis module: {0}
TmfAbstractAnalysisModule_InvalidParameter=Parameter {0} is not valid for analysis module {1}
TmfAbstractAnalysisModule_NullTrace=Setting a null trace to analysis module
+TmfAnalysis_RequirementInformation=Additional information: {0}
+TmfAnalysis_RequirementMandatoryValues=Mandatory values: {0}
+TmfAnalysis_RequirementNotFulfilled=Requirement not fulfilled: {0}
TmfAbstractAnalysisModule_RunningAnalysis=Running analysis {0}
TmfAnalysisManager_ErrorParameterProvider=Error instantiating parameter provider
TmfAnalysisModuleHelper_ImpossibleToCreateModule=Could not instantiate module "{0}"
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java
index 3855d66498..0b479a33df 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java
@@ -198,6 +198,10 @@ public class TmfAnalysisElement extends TmfProjectModelElement implements ITmfSt
return new String();
}
+ if (trace != null) {
+ return helper.getHelpText(trace);
+ }
+
return helper.getHelpText();
}

Back to the top