/*******************************************************************************
- * Copyright (c) 2013 Kalray
+ * Copyright (c) 2013, 2014 Kalray, Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
*
* Contributors:
* Xavier Raynaud - Initial API and implementation
+ * Bernd Hufmann - Adapted to new events table column API
*******************************************************************************/
package org.eclipse.linuxtools.internal.tmf.ui.commands;
+import java.util.List;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
-import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.columns.TmfEventTableColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.PlatformUI;
/** Id of the export-to-text command */
public static final String COMMAND_ID = "org.eclipse.linuxtools.tmf.ui.exportToText"; //$NON-NLS-1$
- /**
- * Id used to retrieve the TmfEventsTable that launched this command.
- * This TmfEventsTable is taken from the application context of this handler.
- */
- public static final String TMF_EVENT_TABLE_PARAMETER_ID = "org.eclipse.linuxtools.tmf.ui.exportToText.table"; //$NON-NLS-1$
/**
* Id used to retrieve the header (as a String) of the trace to export.
* This header is from the application context of this handler.
*/
- public static final String TMF_EVENT_TABLE_HEADER_ID = "org.eclipse.linuxtools.tmf.ui.exportToText.header"; //$NON-NLS-1$
+ public static final String TMF_EVENT_TABLE_COLUMNS_ID = "org.eclipse.linuxtools.tmf.ui.exportToText.columns"; //$NON-NLS-1$
/**
* Constructor
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- String header = getHeader(event.getApplicationContext());
- TmfEventsTable table = getTable(event.getApplicationContext());
+ List<TmfEventTableColumn> columns = getColumns(event.getApplicationContext());
ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
ITmfFilter filter = TmfTraceManager.getInstance().getCurrentFilter();
if (trace != null) {
fd.setOverwrite(true);
final String s = fd.open();
if (s != null) {
- Job j = new ExportToTextJob(trace, filter, table, header, s);
+ Job j = new ExportToTextJob(trace, filter, columns, s);
j.setUser(true);
j.schedule();
}
return null;
}
- private static String getHeader(Object evaluationContext) {
- if (evaluationContext instanceof IEvaluationContext) {
- Object s = ((IEvaluationContext) evaluationContext).getVariable(TMF_EVENT_TABLE_HEADER_ID);
- if (s instanceof String) {
- return s.toString();
- }
- }
- return null;
- }
-
- private static TmfEventsTable getTable(Object evaluationContext) {
+ @SuppressWarnings("unchecked")
+ private static List<TmfEventTableColumn> getColumns(Object evaluationContext) {
if (evaluationContext instanceof IEvaluationContext) {
- Object o = ((IEvaluationContext) evaluationContext).getVariable(TMF_EVENT_TABLE_PARAMETER_ID);
- if (o instanceof TmfEventsTable) {
- return (TmfEventsTable) o;
+ Object s = ((IEvaluationContext) evaluationContext).getVariable(TMF_EVENT_TABLE_COLUMNS_ID);
+ if (s instanceof List<?>) {
+ return (List<TmfEventTableColumn>) s;
}
}
return null;