Merge commit '3a6b7eb9a532100a4cb85e0a81fbc8bd6e91db13' into lttng-luna
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 10 Sep 2013 20:15:51 +0000 (16:15 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 10 Sep 2013 20:28:43 +0000 (16:28 -0400)
These conflicts are a little intense, let's fix them one merge at a time...

Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Conflicts:
lttng/org.eclipse.linuxtools.ctf.core/META-INF/MANIFEST.MF
lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventFactory.java
lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java

Change-Id: If5589c465c299b4f2c718ae25426c5afe446fce1

1  2 
org.eclipse.linuxtools.ctf.core/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventFactory.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfEventsStatistics.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/Messages.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SynchronizeTracesHandler.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/messages.properties

index a5c826b81690007262582adb1e8cc86ee19e2fda,ac876444c0382c469ff67ec9cc8cc5f27cfe379f..0382f319db6948d69f488f7d6af0ccc8ba00470e
@@@ -9,8 -9,9 +9,9 @@@ Bundle-Activator: org.eclipse.linuxtool
  Bundle-ActivationPolicy: lazy
  Bundle-RequiredExecutionEnvironment: JavaSE-1.6
  Require-Bundle: org.eclipse.core.runtime,
 - org.eclipse.linuxtools.ctf.parser;bundle-version="1.0.0"
 + org.eclipse.linuxtools.ctf.parser;bundle-version="3.0.0"
- Export-Package: org.eclipse.linuxtools.ctf.core.event,
+ Export-Package: org.eclipse.linuxtools.ctf.core,
+  org.eclipse.linuxtools.ctf.core.event,
   org.eclipse.linuxtools.ctf.core.event.io,
   org.eclipse.linuxtools.ctf.core.event.types,
   org.eclipse.linuxtools.ctf.core.trace,
index 6e3dbb463a125b23e5df79cf2c83ce9c3bea4879,9178188050b8597adb5f20959ac34cc133b74cde..fc8b905f31b55bc6358d11a747023c833c26e7ab
@@@ -54,8 -58,10 +58,10 @@@ public final class CtfTmfEventFactory 
              String fileName, CtfTmfTrace originTrace) {
  
          /* Prepare what to pass to CtfTmfEvent's constructor */
-         long ts = eventDef.getTimestamp();
-         CtfTmfTimestamp timestamp = originTrace.createTimestamp(originTrace.getCTFTrace().timestampCyclesToNanos(ts));
+         final IEventDeclaration eventDecl = eventDef.getDeclaration();
+         final long ts = eventDef.getTimestamp();
 -        final CtfTmfTimestamp timestamp = new CtfTmfTimestamp(
++        final CtfTmfTimestamp timestamp = originTrace.createTimestamp(
+                 originTrace.getCTFTrace().timestampCyclesToNanos(ts));
  
          int sourceCPU = eventDef.getCPU();
  
index a7dd632233a2b26ae6f15c7f56b49ece368db23e,c2b956e0d9a1ee9e23fb60529b386ee362ee69ad..e4294017718f43b74254a183660b86006f7b6cf2
@@@ -51,14 -44,6 +41,15 @@@ public class Messages extends NLS 
      public static String DropAdapterAssistant_RenameTraceTitle;
      public static String DropAdapterAssistant_RenameTraceMessage;
  
++    public static String SynchronizeTracesHandler_InitError;
 +    public static String SynchronizeTracesHandler_CopyProblem;
 +    public static String SynchronizeTracesHandler_WrongType;
 +    public static String SynchronizeTracesHandler_WrongTraceNumber;
 +    public static String SynchronizeTracesHandler_Title;
 +    public static String SynchronizeTracesHandler_Error;
 +    public static String SynchronizeTracesHandler_ErrorSynchingExperiment;
 +    public static String SynchronizeTracesHandler_ErrorSynchingForTrace;
 +
      static {
          // initialize resource bundle
          NLS.initializeMessages(BUNDLE_NAME, Messages.class);
index 9ac1c4c017de5638ac84399a04548961102c5e52,0000000000000000000000000000000000000000..ea98f53deedf8b343470d1ddeac9f633a7cc51c1
mode 100644,000000..100644
--- /dev/null
@@@ -1,250 -1,0 +1,250 @@@
-                             TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.OpenTraceHandler_InitError + CR + CR + e);
 +/*******************************************************************************
 + * Copyright (c) 2013 É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 implementation and API
 + *******************************************************************************/
 +
 +package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
 +
 +import java.util.ArrayList;
 +import java.util.Iterator;
 +
 +import org.eclipse.core.commands.AbstractHandler;
 +import org.eclipse.core.commands.ExecutionEvent;
 +import org.eclipse.core.commands.ExecutionException;
 +import org.eclipse.core.runtime.CoreException;
 +import org.eclipse.jface.viewers.ISelection;
 +import org.eclipse.jface.viewers.ISelectionProvider;
 +import org.eclipse.jface.viewers.TreeSelection;
 +import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 +import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 +import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
 +import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 +import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
 +import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement;
 +import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
 +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
 +import org.eclipse.linuxtools.tmf.ui.project.model.TraceUtils;
 +import org.eclipse.swt.widgets.Display;
 +import org.eclipse.ui.IWorkbenchPage;
 +import org.eclipse.ui.IWorkbenchPart;
 +import org.eclipse.ui.IWorkbenchWindow;
 +import org.eclipse.ui.PlatformUI;
 +
 +/**
 + * Handles the synchronization of an experiment, when the user selects this
 + * option in the menu
 + */
 +public class SynchronizeTracesHandler extends AbstractHandler {
 +
 +    // ------------------------------------------------------------------------
 +    // Attributes
 +    // ------------------------------------------------------------------------
 +
 +    private TreeSelection fSelection = null;
 +    private static final String CR = System.getProperty("line.separator"); //$NON-NLS-1$
 +
 +    // ------------------------------------------------------------------------
 +    // Validation
 +    // ------------------------------------------------------------------------
 +
 +    @Override
 +    public boolean isEnabled() {
 +        return true;
 +    }
 +
 +    // ------------------------------------------------------------------------
 +    // Execution
 +    // ------------------------------------------------------------------------
 +
 +    @Override
 +    public Object execute(ExecutionEvent event) throws ExecutionException {
 +
 +        // Check if we are closing down
 +        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
 +        if (window == null) {
 +            return null;
 +        }
 +
 +        // Get the selection
 +        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
 +        IWorkbenchPart part = page.getActivePart();
 +        if (part == null) {
 +            return false;
 +        }
 +        ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
 +        if (selectionProvider == null) {
 +            return false;
 +        }
 +        ISelection selection = selectionProvider.getSelection();
 +
 +        // Make sure selection contains only traces
 +        fSelection = null;
 +        final ArrayList<TmfTraceElement> tl = new ArrayList<TmfTraceElement>();
 +        final ArrayList<TmfExperimentElement> uiexperiment = new ArrayList<TmfExperimentElement>();
 +        if (selection instanceof TreeSelection) {
 +            fSelection = (TreeSelection) selection;
 +            Iterator<Object> iterator = fSelection.iterator();
 +            while (iterator.hasNext()) {
 +                Object element = iterator.next();
 +                if (element instanceof TmfTraceElement) {
 +                    tl.add((TmfTraceElement) element);
 +                } else if (element instanceof TmfExperimentElement) {
 +                    TmfExperimentElement exp = (TmfExperimentElement) element;
 +                    uiexperiment.add(exp);
 +                    for (TmfTraceElement trace : exp.getTraces()) {
 +                        tl.add(trace);
 +                    }
 +                }
 +            }
 +        }
 +
 +        if ((uiexperiment.size() == 1) && (tl.size() > 1)) {
 +
 +            Thread thread = new Thread() {
 +                @Override
 +                public void run() {
 +
 +                    final ITmfTrace[] traces = new ITmfTrace[tl.size()];
 +                    final TmfExperimentElement exp = uiexperiment.get(0);
 +
 +                    for (int i = 0; i < tl.size(); i++) {
 +                        ITmfTrace trace = tl.get(i).instantiateTrace();
 +                        ITmfEvent traceEvent = tl.get(i).instantiateEvent();
 +                        if (trace == null) {
 +                            TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_WrongType + tl.get(i).getName());
 +                            for (int j = 0; j < i; j++) {
 +                                traces[j].dispose();
 +                            }
 +                            return;
 +                        }
 +                        try {
 +                            trace.initTrace(tl.get(i).getResource(), tl.get(i).getLocation().getPath(), traceEvent.getClass());
 +                        } catch (TmfTraceException e) {
-                         TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.OpenExperimentHandler_Error + CR + CR + e.getMessage());
++                            TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_InitError + CR + CR + e);
 +                            trace.dispose();
 +                            for (int j = 0; j < i; j++) {
 +                                traces[j].dispose();
 +                            }
 +                            return;
 +                        }
 +                        traces[i] = trace;
 +                    }
 +
 +                    /*
 +                     * FIXME Unlike traces, there is no instanceExperiment, so
 +                     * we call this function here alone. Maybe it would be
 +                     * better to do this on experiment's element constructor?
 +                     */
 +                    exp.refreshSupplementaryFolder();
 +                    final TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, exp.getName(), traces, exp.getResource());
 +
 +                    try {
 +                        final SynchronizationAlgorithm syncAlgo = experiment.synchronizeTraces(true);
 +
 +                        Display.getDefault().asyncExec(new Runnable() {
 +                            @Override
 +                            public void run() {
 +                                /*
 +                                 * For each trace in the experiment, if there is
 +                                 * a transform equation, copy the original
 +                                 * trace, so that a new state system will be
 +                                 * generated with sync time.
 +                                 */
 +                                for (int i = 0; i < tl.size(); i++) {
 +                                    TmfTraceElement traceel = tl.get(i);
 +                                    try {
 +                                        if (syncAlgo.isTraceSynced(traceel.getName())) {
 +
 +                                            /* Find the original trace */
 +                                            TmfTraceElement origtrace = null;
 +                                            for (ITmfProjectModelElement el : traceel.getProject().getTracesFolder().getTraces()) {
 +                                                if (el.getName().equals(traceel.getName())) {
 +                                                    origtrace = (TmfTraceElement) el;
 +                                                }
 +                                            }
 +
 +                                            if (origtrace != null) {
 +                                                /*
 +                                                 * Make sure a trace with the
 +                                                 * new name does not exist
 +                                                 */
 +                                                String newname = traceel.getName();
 +                                                boolean traceexists;
 +                                                do {
 +                                                    traceexists = false;
 +                                                    newname += "_"; //$NON-NLS-1$
 +                                                    for (ITmfProjectModelElement el : traceel.getProject().getTracesFolder().getTraces()) {
 +                                                        if (el.getName().equals(newname)) {
 +                                                            traceexists = true;
 +                                                        }
 +                                                    }
 +                                                } while (traceexists);
 +
 +                                                /* Copy the original trace */
 +                                                TmfTraceElement newtrace = origtrace.copy(newname);
 +
 +                                                if (newtrace != null) {
 +
 +                                                    syncAlgo.renameTrace(origtrace.getName(), newtrace.getName());
 +
 +                                                    /*
 +                                                     * Instantiate the new trace
 +                                                     * and set its sync formula
 +                                                     */
 +                                                    ITmfTrace trace = newtrace.instantiateTrace();
 +                                                    ITmfEvent traceEvent = newtrace.instantiateEvent();
 +
 +                                                    trace.initTrace(newtrace.getResource(), newtrace.getLocation().getPath(), traceEvent.getClass());
 +                                                    trace.setTimestampTransform(syncAlgo.getTimestampTransform(trace));
 +
 +                                                    /*
 +                                                     * Add the new trace to the
 +                                                     * experiment
 +                                                     */
 +                                                    exp.addTrace(newtrace);
 +
 +                                                    /*
 +                                                     * Delete the original trace
 +                                                     * element
 +                                                     */
 +                                                    exp.removeTrace(traceel);
 +                                                } else {
 +                                                    TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_Error + CR + CR + String.format(Messages.SynchronizeTracesHandler_CopyProblem, origtrace.getName()));
 +                                                }
 +                                            }
 +                                        }
 +                                    } catch (CoreException e) {
 +                                        Activator.getDefault().logError(String.format(Messages.SynchronizeTracesHandler_ErrorSynchingForTrace, exp.getName(), traceel.getName()), e);
 +                                        TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_Error + CR + CR + e.getMessage());
 +                                    } catch (TmfTraceException e) {
 +                                        Activator.getDefault().logError(String.format(Messages.SynchronizeTracesHandler_ErrorSynchingForTrace, exp.getName(), traceel.getName()), e);
 +                                        TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_Error + CR + CR + e.getMessage());
 +                                    }
 +                                }
 +                            }
 +                        });
 +
 +                    } catch (TmfTraceException e) {
 +                        Activator.getDefault().logError(String.format(Messages.SynchronizeTracesHandler_ErrorSynchingExperiment, exp.getName()), e);
++                        TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_Error + CR + CR + e.getMessage());
 +                    }
 +                }
 +            };
 +            thread.start();
 +
 +        } else {
 +            TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_WrongTraceNumber);
 +        }
 +
 +        return null;
 +    }
 +
 +}
index e8cfa94dd41b63d7a53d3b1fdb8455dace4766b9,4d321ac25bb4514d5fc6fb5efccc40c44108723f..ba2d8e31cef6cf657dc143efffe506affb39ecc7
@@@ -39,13 -27,3 +27,14 @@@ SelectTraceTypeHandler_InvalidTraceTyp
  # Drag and drop
  DropAdapterAssistant_RenameTraceTitle=Confirm rename trace
  DropAdapterAssistant_RenameTraceMessage=A trace with the name ''{0}'' already exists in the target project.\nRename the dropped trace?
 +
 +# Trace synchronization
++SynchronizeTracesHandler_InitError=Error initializing trace
 +SynchronizeTracesHandler_CopyProblem=Couldn't copy the original trace %s
 +SynchronizeTracesHandler_WrongTraceNumber=Experiment must have more than one trace
 +SynchronizeTracesHandler_Title=Synchronize traces
 +SynchronizeTracesHandler_WrongType=Trace is not a kernel trace:\n
 +SynchronizeTracesHandler_Error=Error synchronizing experiment
 +
 +SynchronizeTracesHandler_ErrorSynchingExperiment=Error synchronizing experiment %s
 +SynchronizeTracesHandler_ErrorSynchingForTrace=Error synchronizing experiment %s for trace %s
This page took 0.031509 seconds and 5 git commands to generate.