Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/ITmfStyledProjectModelElement.java34
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfAnalysisElement.java38
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java23
3 files changed, 91 insertions, 4 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/ITmfStyledProjectModelElement.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/ITmfStyledProjectModelElement.java
new file mode 100644
index 0000000000..67d9541098
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/ITmfStyledProjectModelElement.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.project.model;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.viewers.StyledString.Styler;
+
+/**
+ * This interface can be implemented by elements to a style to their text.
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public interface ITmfStyledProjectModelElement {
+
+ /**
+ * Return the styler who will apply its style to the text string.
+ *
+ * @return The style object, or 'null' for no special style
+ */
+ @Nullable
+ Styler getStyler();
+
+}
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 c697266c9b..3855d66498 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
@@ -22,11 +22,13 @@ import org.eclipse.core.resources.IFolder;
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;
/**
@@ -35,9 +37,17 @@ 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
@@ -63,6 +73,8 @@ public class TmfAnalysisElement extends TmfProjectModelElement {
@Override
void refreshChildren() {
+ fCanExecute = true;
+
/* Refresh the outputs of this analysis */
Map<String, TmfAnalysisOutputElement> childrenMap = new HashMap<>();
for (TmfAnalysisOutputElement output : getAvailableOutputs()) {
@@ -96,6 +108,11 @@ public class TmfAnalysisElement extends TmfProjectModelElement {
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;
}
@@ -107,6 +124,7 @@ public class TmfAnalysisElement extends TmfProjectModelElement {
}
outputElement.refreshChildren();
}
+
}
/* Remove outputs that are not children of this analysis anymore */
for (TmfAnalysisOutputElement output : childrenMap.values()) {
@@ -115,6 +133,18 @@ public class TmfAnalysisElement extends TmfProjectModelElement {
}
// ------------------------------------------------------------------------
+ // TmfProjectModelElement
+ // ------------------------------------------------------------------------
+
+ @Override
+ public Styler getStyler() {
+ if (!fCanExecute) {
+ return ANALYSIS_CANT_EXECUTE_STYLER;
+ }
+ return null;
+ }
+
+ // ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@@ -151,13 +181,14 @@ public class TmfAnalysisElement extends TmfProjectModelElement {
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);
if (module != null) {
- return module.getHelpText();
+ return module.getHelpText(trace);
}
}
}
@@ -215,4 +246,5 @@ public class TmfAnalysisElement extends TmfProjectModelElement {
TmfOpenTraceHelper.openTraceFromElement(traceElement);
}
}
+
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java
index 4e9d5fc43b..a12fb76bc0 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfNavigatorLabelProvider.java
@@ -19,7 +19,10 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType;
@@ -38,7 +41,7 @@ import org.osgi.framework.Bundle;
* @version 1.0
* @author Francois Chouinard
*/
-public class TmfNavigatorLabelProvider implements ICommonLabelProvider {
+public class TmfNavigatorLabelProvider implements ICommonLabelProvider, IStyledLabelProvider {
// ------------------------------------------------------------------------
// Constants
@@ -247,4 +250,22 @@ public class TmfNavigatorLabelProvider implements ICommonLabelProvider {
public void init(ICommonContentExtensionSite aConfig) {
}
+ /**
+ * @since 3.0
+ */
+ @Override
+ public StyledString getStyledText(Object element) {
+ String text = getText(element);
+ if (text != null) {
+ if (element instanceof ITmfStyledProjectModelElement) {
+ Styler styler = ((ITmfStyledProjectModelElement) element).getStyler();
+ if (styler != null) {
+ return new StyledString(text, styler);
+ }
+ }
+ return new StyledString(text);
+ }
+ return null;
+ }
+
}

Back to the top