|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.internal.pi.address.actions; |
|
19 |
|
20 import java.io.File; |
|
21 |
|
22 import org.eclipse.jface.action.IAction; |
|
23 import org.eclipse.jface.viewers.ISelection; |
|
24 import org.eclipse.ui.IWorkbenchWindow; |
|
25 import org.eclipse.ui.IWorkbenchWindowActionDelegate; |
|
26 |
|
27 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository; |
|
28 import com.nokia.carbide.cpp.internal.pi.model.ParsedTraceData; |
|
29 import com.nokia.carbide.cpp.internal.pi.model.TraceDataRepository; |
|
30 import com.nokia.carbide.cpp.internal.pi.utils.PIUtilities; |
|
31 import com.nokia.carbide.cpp.pi.address.AddressPlugin; |
|
32 import com.nokia.carbide.cpp.pi.address.GppTrace; |
|
33 import com.nokia.carbide.cpp.pi.address.GppTraceCsvPrinter; |
|
34 |
|
35 |
|
36 public class ExportDelegate implements IWorkbenchWindowActionDelegate { |
|
37 |
|
38 private IWorkbenchWindow window; |
|
39 |
|
40 public void dispose() { |
|
41 } |
|
42 |
|
43 public void init(IWorkbenchWindow window) { |
|
44 this.window = window; |
|
45 } |
|
46 |
|
47 public void run(IAction action) { |
|
48 // get the active page |
|
49 if (window == null) |
|
50 return; |
|
51 |
|
52 ParsedTraceData ptd = TraceDataRepository.getInstance().getTrace(NpiInstanceRepository.getInstance().activeUid(), |
|
53 AddressPlugin.getDefault().getTraceClass()); |
|
54 if (ptd != null) |
|
55 { |
|
56 final GppTrace gppTraceTmp = (GppTrace)ptd.traceData; |
|
57 |
|
58 new Thread() |
|
59 { |
|
60 public void run() |
|
61 { |
|
62 try |
|
63 { |
|
64 File report = PIUtilities.getAFile(true,"csv"); //$NON-NLS-1$ |
|
65 if (report != null) |
|
66 { |
|
67 GppTraceCsvPrinter csvPrinter = new GppTraceCsvPrinter(gppTraceTmp); |
|
68 String csvPrint = csvPrinter.getCsvPrint(); |
|
69 if (csvPrint != null) |
|
70 { |
|
71 PIUtilities.saveCsvPrint(report, csvPrint); |
|
72 } |
|
73 } |
|
74 } |
|
75 catch (Exception e) |
|
76 { |
|
77 e.printStackTrace(); |
|
78 } |
|
79 } |
|
80 }.start(); |
|
81 } |
|
82 } |
|
83 |
|
84 public void selectionChanged(IAction action, ISelection selection) { |
|
85 } |
|
86 |
|
87 } |