--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.analysis.ondemand;
+
+/**
+ * Reports are the output of on-demand analysis ran on a particular trace.
+ * Several runs of the same ODA should produce different report objects
+ * (although their contents could be the same).
+ *
+ * They are meant to be standalone objects, but should normally keep track of
+ * which analysis and trace created them.
+ *
+ * Unlike on-demand analyses, a report is specific to its trace.
+ *
+ * @author Alexandre Montplaisir
+ * @since 2.0
+ */
+public interface IOnDemandAnalysisReport {
+
+ /**
+ * Get the name of this report.
+ *
+ * @return The name of this report
+ */
+ String getName();
+}
return fViewsElement;
}
+ /**
+ * Get the child element "Reports".
+ *
+ * @return The Reports child element
+ * @since 2.0
+ */
+ public TmfReportsElement getChildElementReports() {
+ return fReportsElement;
+ }
+
/**
* Returns the trace type ID.
*
public static final @NonNull Image DEFAULT_EXPERIMENT_ICON;
public static final @NonNull Image DEFAULT_ANALYSIS_ICON;
public static final @NonNull Image DEFAULT_VIEW_ICON;
+ public static final @NonNull Image DEFAULT_REPORT_ICON;
public static final @NonNull Image FOLDER_ICON;
public static final @NonNull Image VIEWS_ICON;
private static final String VIEW_ICON_FILE = "icons/obj16/node_obj.gif"; //$NON-NLS-1$
private static final String ONDEMAND_ANALYSES_ICON_FILE = "icons/obj16/debugt_obj.gif"; //$NON-NLS-1$
private static final String REPORTS_ICON_FILE = "icons/obj16/arraypartition_obj.gif"; //$NON-NLS-1$
+ private static final String DEFAULT_REPORT_ICON_FILE = "icons/etool16/copy_edit.gif"; //$NON-NLS-1$
// ------------------------------------------------------------------------
// Initialization
DEFAULT_EXPERIMENT_ICON = checkNotNull(loadIcon(bundle, EXPERIMENT_ICON_FILE));
DEFAULT_ANALYSIS_ICON = checkNotNull(loadIcon(bundle, ANALYSIS_ICON_FILE));
DEFAULT_VIEW_ICON = checkNotNull(loadIcon(bundle, VIEW_ICON_FILE));
+ DEFAULT_REPORT_ICON = checkNotNull(loadIcon(bundle, DEFAULT_REPORT_ICON_FILE));
}
public static @Nullable Image loadIcon(Bundle bundle, String url) {
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.project.model;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tracecompass.tmf.core.analysis.ondemand.IOnDemandAnalysisReport;
+
+/**
+ * Project model element containing a report, which is the result of the
+ * execution of an on-demand analysis.
+ *
+ * @author Alexandre Montplaisir
+ * @since 2.0
+ */
+public class TmfReportElement extends TmfProjectModelElement {
+
+ private final IOnDemandAnalysisReport fReport;
+
+ /**
+ * Constructor
+ *
+ * @param reportName
+ * Name of this report element
+ * @param resource
+ * The resource to be associated with this element
+ * @param parent
+ * The parent element
+ * @param report
+ * The report object represented by this element
+ */
+ protected TmfReportElement(String reportName, IResource resource,
+ TmfReportsElement parent, IOnDemandAnalysisReport report) {
+ super(reportName, resource, parent);
+ fReport = report;
+ }
+
+ @Override
+ public TmfReportsElement getParent() {
+ /* Type enforced at constructor */
+ return (TmfReportsElement) super.getParent();
+ }
+
+ @Override
+ public Image getIcon() {
+ return TmfProjectModelIcons.DEFAULT_REPORT_ICON;
+ }
+
+ @Override
+ protected void refreshChildren() {
+ /* No children */
+ }
+
+ /**
+ * Get the report object of this element.
+ *
+ * @return The report
+ */
+ public IOnDemandAnalysisReport getReport() {
+ return fReport;
+ }
+}
package org.eclipse.tracecompass.tmf.ui.project.model;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.tracecompass.tmf.core.analysis.ondemand.IOnDemandAnalysisReport;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
/**
* Project model element for the "Reports" element, which lists the analysis
private static final String ELEMENT_NAME = Messages.TmfReportsElement_Name;
+ private final BiMap<String, IOnDemandAnalysisReport> fCurrentReports = HashBiMap.create();
+
/**
* Constructor
*
/* No children at the moment */
}
+ /**
+ * Add a new report under this element.
+ *
+ * @param report
+ * The report to add
+ */
+ public void addReport(IOnDemandAnalysisReport report) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IPath nodePath = getResource().getFullPath();
+
+ /* Append #2,#3,... to the name if needed */
+ String reportDisplayName = report.getName();
+ int i = 1;
+ while (fCurrentReports.containsKey(reportDisplayName)) {
+ i++;
+ reportDisplayName = report.getName() + " #" + i; //$NON-NLS-1$
+ }
+
+ fCurrentReports.put(reportDisplayName, report);
+
+ IFolder analysisRes = checkNotNull(root.getFolder(nodePath.append(reportDisplayName)));
+ TmfReportElement elem = new TmfReportElement(reportDisplayName, analysisRes, this, report);
+ addChild(elem);
+ refresh();
+ }
+
+ /**
+ * Remove a report from under this element.
+ *
+ * @param report
+ * The report to remove
+ */
+ public void removeReport(IOnDemandAnalysisReport report) {
+ String displayName = fCurrentReports.inverse().get(report);
+ fCurrentReports.values().remove(report);
+
+ ITmfProjectModelElement elementToRemove = getChildren().stream()
+ .filter(elem -> elem.getName().equals(displayName))
+ .findFirst().orElse(null);
+ removeChild(elementToRemove);
+ refresh();
+ }
}