[Title] Open trace upgrade
authorLee <jy.exe.lee@samsung.com>
Thu, 22 Nov 2012 12:10:46 +0000 (21:10 +0900)
committerLee <jy.exe.lee@samsung.com>
Thu, 22 Nov 2012 12:10:46 +0000 (21:10 +0900)
[Desc.] add detail info
[Issue] redmine #7483

24 files changed:
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/SymbolManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/ExitHandler.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/OpenTraceProgressManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/AnalyzerLabels.properties
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/snapshot/ImageViewer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/profiling/FunctionUsageProfiler.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/OpenTraceDialog.java [deleted file]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/StopLogProcessor.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceDialog.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceInputReader.java [moved from org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/OpenTraceInputReader.java with 98% similarity]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/SaveFilesTable.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/TempFilesTable.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DAAnimation.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/Progress.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DATableComposite.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DefaultTableComparator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/TableComparator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/ImageUtils.java [new file with mode: 0644]

index 3b183a8..91bf184 100644 (file)
@@ -30,7 +30,7 @@ import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
 \r
 public class AnalyzerConstants {\r
        // if log change occurs then increase save data version!!\r
-       public static final String SAVE_DATA_VERSION = "0.5"; //$NON-NLS-1$\r
+       public static final String SAVE_DATA_VERSION = "0.6"; //$NON-NLS-1$\r
        public static final boolean CHECK_INTERNAL = true;\r
 \r
        // /* special character */\r
@@ -65,7 +65,6 @@ public class AnalyzerConstants {
        public final static String PROBE_LIB_TIZEN = "da_probe_tizen.so"; //$NON-NLS-1$\r
        public final static String PROBE_LIB_OSP = "da_probe_osp.so"; //$NON-NLS-1$\r
 \r
-\r
        /* Save Data table */\r
        public static final String LEAK_DATA_TABLE_NAME = "LeakData"; //$NON-NLS-1$\r
        public static final String FAILED_DATA_TABLE_NAME = "FailedData"; //$NON-NLS-1$\r
@@ -108,11 +107,12 @@ public class AnalyzerConstants {
 \r
        /* project save index */\r
        public static final int PROJECT_VERSION_INDEX = 0;\r
-       public static final int PROJECT_APPNAME_INDEX = 1;\r
-       public static final int PROJECT_DEVICE_INDEX = 2;\r
-       public static final int PROJECT_LAST_DATA_INDEX = 3;\r
-       public static final int PROJECT_LAST_TIME_INDEX = 4;\r
-       public static final int PROJECT_TOTAL_SAMPLE_COUNT = 5;\r
+       public static final int PROJECT_CREATE_TIME_INDEX = 1;\r
+       public static final int PROJECT_APPNAME_INDEX = 2;\r
+       public static final int PROJECT_DEVICE_INDEX = 3;\r
+       public static final int PROJECT_LAST_DATA_INDEX = 4;\r
+       public static final int PROJECT_LAST_TIME_INDEX = 5;\r
+       public static final int PROJECT_TOTAL_SAMPLE_COUNT = 6;\r
 \r
        /* save return values */\r
        public static final int ERROR_EXTENSION_FAIL = -1;\r
index bfe4374..a814666 100644 (file)
@@ -303,6 +303,8 @@ public class SymbolManager {
                } catch (UnmanglingException e) {
                        e.printStackTrace();
                        demangled = mangled;
+                       // for debug log
+                       System.out.println("Mangled name :" + mangled);
                }
                return demangled;
        }
index 365027d..deae643 100644 (file)
@@ -34,9 +34,9 @@ import org.tizen.dynamicanalyzer.communicator.DACommunicator;
 import org.tizen.dynamicanalyzer.communicator.IDECommunicator;
 import org.tizen.dynamicanalyzer.logparser.LogInserter;
 import org.tizen.dynamicanalyzer.logparser.LogParser;
-import org.tizen.dynamicanalyzer.ui.toolbar.OpenTraceInputReader;
 import org.tizen.dynamicanalyzer.ui.toolbar.StopLogProcessor;
 import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
+import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceInputReader;
 import org.tizen.dynamicanalyzer.utils.UpdateViewTimer;
 
 public class ExitHandler extends AbstractHandler {
index 4437564..941ccad 100644 (file)
@@ -106,7 +106,9 @@ public class OpenTraceHandler extends AbstractHandler {
                                        return null;\r
                                }\r
                                p.setVersion(AnalyzerConstants.SAVE_DATA_VERSION);\r
-                       } else if (i == AnalyzerConstants.PROJECT_APPNAME_INDEX) {\r
+                       }else if (i == AnalyzerConstants.PROJECT_CREATE_TIME_INDEX) {\r
+                               p.setCreateTime(pInfo.get(i));\r
+                       }else if (i == AnalyzerConstants.PROJECT_APPNAME_INDEX) {\r
                                p.setAppName(pInfo.get(i));\r
                        } else if (i == AnalyzerConstants.PROJECT_DEVICE_INDEX) {\r
                                p.setDevice(pInfo.get(i));\r
index 36bf413..c4b1a31 100644 (file)
@@ -11,7 +11,7 @@ import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
 import org.tizen.dynamicanalyzer.project.Project;
 import org.tizen.dynamicanalyzer.ui.file.chart.FileChartManager;
 import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
-import org.tizen.dynamicanalyzer.ui.toolbar.OpenTraceInputReader;
+import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceInputReader;
 import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
 import org.tizen.dynamicanalyzer.ui.widgets.ProgressDialog;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
@@ -81,7 +81,6 @@ public class OpenTraceProgressManager implements Runnable {
 
                if (null != dialog) {
                        this.percent = percent;
-//                     dialog.setProcessSelection(percent);
                        dialog.setValue(percent);
                        dialog.setProgressMessage(message);
                }
@@ -90,7 +89,6 @@ public class OpenTraceProgressManager implements Runnable {
        public void openTraceComplete() {
                if (null != dialog) {
                        waitingThreads();
-//                     dialog.setProcessSelection(100);
                        dialog.setValue(100);
                        AnalyzerUtil.changePage(TimelinePage.ID);
                        dialog.close();
@@ -114,9 +112,8 @@ public class OpenTraceProgressManager implements Runnable {
                while (true) {
                        try {
                                if ((!FileChartManager.getInstance().isThreadAlive())
-                                               &&!UIDataManager.getInstance().isThreadAlive()
-                                               && !OpenTraceInputReader.isThreadAlive()
-                                                ) {
+                                               && !UIDataManager.getInstance().isThreadAlive()
+                                               && !OpenTraceInputReader.isThreadAlive()) {
                                        break;
                                } else {
                                        Thread.sleep(AnalyzerConstants.LOG_CHECK_INTERVAL);
index 5b1da60..cb5ce6b 100755 (executable)
@@ -114,6 +114,7 @@ public class AnalyzerLabels extends NLS {
        public static String OPEN_TRACE_DLG_TEMP_FILE;
        public static String OPEN_TRACE_DLG_TEMP_FILE_NAME;
        public static String OPEN_TRACE_DLG_TRACE_FILE_NAME;
+       public static String OPEN_TRACE_DLG_TRACE_DATE;
 
        public static String PATH_WARNING;
        public static String OS_WARNING;
index 283fa4f..5446222 100755 (executable)
@@ -82,6 +82,7 @@ OPEN_TRACE_DLG_SAVED_FILE=Saved file
 OPEN_TRACE_DLG_TEMP_FILE=Temporary file
 OPEN_TRACE_DLG_TEMP_FILE_NAME=Temporary file name
 OPEN_TRACE_DLG_TRACE_FILE_NAME=Trace file name
+OPEN_TRACE_DLG_TRACE_DATE=Created time
 
 PATH_WARNING=Please install the Tizen SDK
 OS_WARNING=Not supported OS
index 3ac1225..2c38177 100755 (executable)
@@ -51,6 +51,7 @@ public class Project {
        private final String DEFAULT_TIME_FORMAT = "_yyyy-MM-dd-HH-mm-ss";//$NON-NLS-1$
 
        private String appName = null;
+       private String createTime = null;
        private List<LogCenter> logCenters;
        private Connection connection;
        private String savePath;
@@ -146,6 +147,14 @@ public class Project {
                return lastLogNum;
        }
 
+       public String getCreateTime() {
+               return createTime;
+       }
+
+       public void setCreateTime(String createTime) {
+               this.createTime = createTime;
+       }
+
        public void setLastLogNum(String last) {
                long prev = 0, current = 0;
                try {
@@ -175,7 +184,7 @@ public class Project {
                SimpleDateFormat format = new SimpleDateFormat(DEFAULT_TIME_FORMAT,
                                Locale.KOREA);
                Date date = new Date();
-
+               createTime = date.toString();
                savePath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator + appName
                                + format.format(date);
                File imgFolder = new File(savePath + File.separator
@@ -312,7 +321,8 @@ public class Project {
                                return true;
                        }
                } catch (NullPointerException e) {
-                       System.out.println(appInfo.get(AnalyzerConstants.APP_INFO_PIE_BUILD));
+                       System.out.println(appInfo
+                                       .get(AnalyzerConstants.APP_INFO_PIE_BUILD));
                        e.printStackTrace();
                        return false;
                }
index 5772824..f8cb45c 100755 (executable)
@@ -26,7 +26,9 @@
  */
 package org.tizen.dynamicanalyzer.sql;
 
+import java.io.File;
 import java.sql.Connection;
+import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -36,6 +38,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.common.CommonConstants;
 import org.tizen.dynamicanalyzer.model.LogCenter;
@@ -82,6 +85,18 @@ public class SqlManager {
                dbLock = false;
        }
 
+       public static Connection getConnection(String path) {
+               Connection connection = null;
+               try {
+                       Class.forName("org.sqlite.JDBC"); //$NON-NLS-1$
+                       connection = DriverManager.getConnection("jdbc:sqlite:" //$NON-NLS-1$
+                                       + path + File.separator + AnalyzerConstants.DATABASE_NAME);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return connection;
+       }
+
        public synchronized static void createTable(LogCenter lcenter) {
                lockDB();
                Connection conn = getConnection();
@@ -136,18 +151,28 @@ public class SqlManager {
                        int size = logcs.size();
                        Project project = AnalyzerManager.getProject();
 
+                       /* project version index = 0 */
                        prep.setString(1, project.getVersion());
                        prep.addBatch();
+                       /* project create time index = 1 */
+                       prep.setString(1, project.getCreateTime());
+                       prep.addBatch();
+                       /* project application name index = 2 */
                        prep.setString(1, project.getAppName());
                        prep.addBatch();
+                       /* project device index = 3 */
                        prep.setString(1, project.getDevice());
                        prep.addBatch();
+                       /* project last log number index = 4 */
                        prep.setString(1, project.getLastLogNum());
                        prep.addBatch();
+                       /* project last recording time index = 5 */
                        prep.setLong(1, project.getLastTime());
                        prep.addBatch();
+                       /* project total sample count index = 6 */
                        prep.setInt(1, project.getTotalProfilingSampleCount());
                        prep.addBatch();
+                       /* project logcenters index = reminders */
                        for (int i = 0; i < size; i++) {
                                try {
                                        prep.setString(1, logcs.get(i).getName());
@@ -840,8 +865,8 @@ public class SqlManager {
                        unlockDB();
                        return;
                }
-//             FunctionUsageProfiler profiler = AnalyzerManager
-//                             .getFunctionUserProfiler();
+               // FunctionUsageProfiler profiler = AnalyzerManager
+               // .getFunctionUserProfiler();
                FunctionUsageProfiler profiler = FunctionUsageProfiler.getInstance();
                HashMap<String, ProfilingData> profilingDataMap = profiler
                                .getProfilingDataMap();
@@ -887,8 +912,8 @@ public class SqlManager {
                        unlockDB();
                        return;
                }
-//             FunctionUsageProfiler profiler = AnalyzerManager
-//                             .getFunctionUserProfiler();
+               // FunctionUsageProfiler profiler = AnalyzerManager
+               // .getFunctionUserProfiler();
                FunctionUsageProfiler profiler = FunctionUsageProfiler.getInstance();
                HashMap<String, ProfilingChildData> profilingDataMap = profiler
                                .getChildListMap();
index 9419bb6..efd9183 100644 (file)
@@ -30,6 +30,7 @@ import java.io.File;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Timer;
+import java.util.TimerTask;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.SWTError;
@@ -122,8 +123,16 @@ public class ImageViewer extends Composite {
        private boolean rightEnable = false;
 
        // +2 means outer offset
-       private final int shellMaxWidth = 480 / 2 + 2;
-       private final int shellMaxHeight = 800 / 2 + 2;
+       private final int defaultShellMaxWidth = 480 / 2 + 2;
+       private final int defaultShellMaxHeight = 800 / 2 + 2;
+       private final int defaultChildWidth = 69;
+       private final int defaultChildHeight = 108;
+
+       private int shellMaxWidth = 0;
+       private int shellMaxHeight = 0;
+       private int childWidth = 0;
+       private int childHeight = 0;
+
        private Timer timer = null;
 
        public ImageViewer(Composite parent, int style) {
@@ -399,15 +408,33 @@ public class ImageViewer extends Composite {
        }
 
        private void openChildShell() {
+               if (null == image) {
+                       return;
+               } else {
+                       Rectangle rect = image.getBounds();
+                       if (rect.width > rect.height) {
+                               shellMaxHeight = defaultShellMaxWidth;
+                               shellMaxWidth = defaultShellMaxHeight;
+                               childWidth = defaultChildHeight;
+                               childHeight = defaultChildWidth;
+                               childShellWidth = defaultChildHeight;
+                               childShellHeight = defaultChildWidth;
+                       } else {
+                               shellMaxHeight = defaultShellMaxHeight;
+                               shellMaxWidth = defaultShellMaxWidth;
+                               childWidth = defaultChildWidth;
+                               childHeight = defaultChildHeight;
+                               childShellWidth = defaultChildWidth;
+                               childShellHeight = defaultChildHeight;
+                       }
+               }
                childShell = new Shell(parent.getShell(), SWT.ON_TOP);
                childShell.setLayout(new FillLayout());
                Point p = canvas.toDisplay(0, 0);
 
-               childShellWidth = shellMaxWidth;
-               childShellHeight = shellMaxHeight;
-
                childShell.setSize(childShellWidth, childShellHeight);
                childShell.setLocation(p.x - childShellWidth, p.y);
+
                popup = new Canvas(childShell, SWT.DOUBLE_BUFFERED
                                | SWT.TRANSPARENCY_ALPHA);
 
@@ -417,7 +444,6 @@ public class ImageViewer extends Composite {
                                if (null == image || null == e.gc) {
                                        return;
                                }
-                               // if (ready) {
                                try {
                                        Rectangle bounds = image.getBounds();
                                        int iw = bounds.width;
@@ -448,39 +474,45 @@ public class ImageViewer extends Composite {
                        }
                });
                childShell.open();
-               // if (timer != null) {
-               // timer.cancel();
-               // timer = null;
-               // }
-               // timer = new Timer();
-               // timer.schedule(new TimerTask() {
-               // @Override
-               // public void run() {
-               // Display.getDefault().syncExec(new Runnable() {
-               // @Override
-               // public void run() {
-               // if (null == childShell
-               // || childShellWidth > shellMaxWidth) {
-               // if (timer != null) {
-               // timer.cancel();
-               // timer = null;
-               // }
-               // boolean ready = true;
-               // childShell.redraw();
-               // return;
-               // }
-               // Rectangle rect = canvas.getBounds();
-               // int x = (int) ((float) shellMaxWidth / rect.width) * 50;
-               // int y = (int) ((float) shellMaxHeight / rect.height) * 50;
-               // childShellWidth += x;
-               // childShellHeight += y;
-               // childShell.setSize(childShellWidth, childShellHeight);
-               // Point p = canvas.toDisplay(0, 0);
-               // childShell.setLocation(p.x - childShellWidth, p.y);
-               // childShell.redraw();
-               // }
-               // });
-               // }
-               // }, 10, 5);
+               if (timer != null) {
+                       timer.cancel();
+                       timer = null;
+               }
+               timer = new Timer();
+               timer.schedule(new TimerTask() {
+                       @Override
+                       public void run() {
+                               Display.getDefault().syncExec(new Runnable() {
+                                       @Override
+                                       public void run() {
+                                               if (null == childShell
+                                                               || childShellWidth >= defaultShellMaxWidth) {
+                                                       if (timer != null) {
+                                                               timer.cancel();
+                                                               timer = null;
+                                                       }
+                                                       if (null != childShell && !childShell.isDisposed()) {
+                                                               childShell.redraw();
+                                                       }
+                                                       return;
+                                               }
+                                               int x = (shellMaxWidth - childWidth) / 20;
+                                               int y = (shellMaxHeight - childHeight) / 20;
+                                               childShellWidth += x;
+                                               childShellHeight += y;
+
+                                               childShellWidth = (childShellWidth > defaultShellMaxWidth) ? defaultShellMaxWidth
+                                                               : childShellWidth;
+                                               childShellHeight = (childShellHeight > defaultShellMaxHeight) ? defaultShellMaxHeight
+                                                               : childShellHeight;
+
+                                               childShell.setSize(childShellWidth, childShellHeight);
+                                               Point p = canvas.toDisplay(0, 0);
+                                               childShell.setLocation(p.x - childShellWidth, p.y);
+                                               childShell.redraw();
+                                       }
+                               });
+                       }
+               }, 10, 10);
        }
 }
index 3576280..f4e39c6 100644 (file)
@@ -420,7 +420,6 @@ public class FunctionUsageProfiler implements Runnable {
                        CallStackUnit funcName = addrMap.get(addr);
                        if (null == funcName) {
                                String funcSymbol = callstackLog.get(i + 1);
-                               // funcSymbol = SymbolNameDemangler.nameDemangle(funcSymbol);
                                CallStackUnit cas = new CallStackUnit(addr, funcSymbol);
                                if (null == addrMap.get(addr)) {
                                        addrMap.put(addr, cas);
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/OpenTraceDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/OpenTraceDialog.java
deleted file mode 100644 (file)
index 0030fc8..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- *  Dynamic Analyzer
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: 
- * Jooyoul Lee <jy.exe.lee@samsung.com>
- * Juyoung Kim <j0.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- * Contributors:
- * - S-Core Co., Ltd
- * 
- */
-
-package org.tizen.dynamicanalyzer.ui.toolbar;
-
-import java.io.File;
-import java.util.List;
-
-import org.eclipse.nebula.widgets.grid.Grid;
-import org.eclipse.nebula.widgets.grid.GridColumn;
-import org.eclipse.nebula.widgets.grid.GridItem;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
-import org.tizen.dynamicanalyzer.common.DesignConstants;
-import org.tizen.dynamicanalyzer.logparser.OpenTraceProgressManager;
-import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
-import org.tizen.dynamicanalyzer.ui.widgets.DAMessageBox;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
-
-public class OpenTraceDialog extends DAMessageBox {
-       private static boolean opened = false;
-
-       private Grid saveTable = null;
-       private Grid tempTable = null;
-       private Grid selectedTable = null;
-       private DACustomButton okButton = null;
-       private DACustomButton cancelButton = null;
-
-       public OpenTraceDialog(Shell parent) {
-               super(parent);
-       }
-
-       protected int run() {
-               if (opened) {
-                       result = -1;
-                       return result;
-               }
-               shell.setLayout(new FormLayout());
-               shell.setSize(400, 410);
-               shell.setText(AnalyzerLabels.OPEN_TRACE);
-
-               shell.addDisposeListener(new DisposeListener() {
-
-                       @Override
-                       public void widgetDisposed(DisposeEvent e) {
-                               // TODO Auto-generated method stub
-                               System.out.println("shell disposed!");
-                               opened = false;
-                       }
-               });
-
-               Composite tableComp = new Composite(shell, SWT.NONE);
-               tableComp.setLayout(new FormLayout());
-               FormData data = new FormData();
-               data.top = new FormAttachment(0, 0);
-               data.left = new FormAttachment(0, 0);
-               data.right = new FormAttachment(100, 0);
-               data.height = 337;
-               tableComp.setLayoutData(data);
-               tableComp.setBackground(ColorResources.DIALOG_BG_UPPER);
-
-               Label saveFile = new Label(tableComp, SWT.TRANSPARENT);
-               saveFile.setText(AnalyzerLabels.OPEN_TRACE_DLG_SAVED_FILE);
-               saveFile.setBackground(ColorResources.DIALOG_BG_UPPER);
-               saveFile.setAlignment(SWT.LEFT);
-               saveFile.setForeground(ColorResources.OPEN_TRACE_LABEL_COLOR);
-               saveFile.setFont(FontResources.OPEN_TRACE_INNER_TITLE);
-
-               saveTable = new Grid(tableComp, SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE);
-               saveTable.setItemHeight(18);
-               saveTable.setHeaderVisible(false);
-               saveTable.setLinesVisible(true);
-               saveTable
-                               .setBackground(ColorResources.OPEN_TRACE_TABLE_CONTENT_NORMAL_COLOR1);
-               saveTable.setLineColor(ColorResources.TABLE_LINE);
-               saveTable.setForeground(ColorResources.OPEN_TRACE_SAVE_CONTENTS_COLOR);
-               GridColumn column = new GridColumn(saveTable, SWT.NONE);
-               column.setMoveable(false);
-               column.setText(AnalyzerLabels.OPEN_TRACE_DLG_TRACE_FILE_NAME);
-               column.setWidth(400);
-               saveTable.addSelectionListener(saveTableSelectionListener);
-
-               Label tempFile = new Label(tableComp, SWT.TRANSPARENT);
-               tempFile.setText(AnalyzerLabels.OPEN_TRACE_DLG_TEMP_FILE);
-               tempFile.setBackground(ColorResources.DIALOG_BG_UPPER);
-               tempFile.setAlignment(SWT.LEFT);
-               tempFile.setForeground(ColorResources.OPEN_TRACE_LABEL_COLOR);
-               tempFile.setFont(FontResources.OPEN_TRACE_INNER_TITLE);
-
-               tempTable = new Grid(tableComp, SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE);
-               tempTable.setItemHeight(18);
-               tempTable.setLinesVisible(true);
-               tempTable.setHeaderVisible(false);
-               tempTable
-                               .setBackground(ColorResources.OPEN_TRACE_TABLE_CONTENT_NORMAL_COLOR1);
-               tempTable.setLineColor(ColorResources.TABLE_LINE);
-               tempTable.setForeground(ColorResources.OPEN_TRACE_TEMP_CONTENTS_COLOR);
-               tempTable.addSelectionListener(tempTableSelectionListener);
-
-               GridColumn tempColumn = new GridColumn(tempTable, SWT.NONE);
-               tempColumn.setMoveable(false);
-               tempColumn.setText(AnalyzerLabels.OPEN_TRACE_DLG_TEMP_FILE_NAME);
-               tempColumn.setWidth(400);
-
-               // implement save folders list up
-               List<String> saveFileList = AnalyzerUtil
-                               .getDirs(AnalyzerPaths.DYNAMIC_ANALYZER_SAVE_PATH);
-               int size = saveFileList.size();
-               for (int i = 0; i < size; i++) {
-                       if (!saveFileList.get(i).equals(AnalyzerConstants.TEMP_FOLDER_NAME)) {
-                               GridItem item = new GridItem(saveTable, SWT.NULL);
-                               item.setText(saveFileList.get(i));
-                               item.setData(0);
-                       }
-               }
-
-               List<String> tempFileList = AnalyzerUtil
-                               .getDirs(AnalyzerPaths.TEMP_FOLDER_PATH);
-               size = tempFileList.size();
-               for (int i = 0; i < size; i++) {
-                       GridItem item = new GridItem(tempTable, SWT.NULL);
-                       item.setForeground(AnalyzerUtil.red);
-                       item.setText(tempFileList.get(i));
-                       item.setData(1);
-               }
-
-               data = new FormData();
-               data.top = new FormAttachment(0, 17);
-               data.left = new FormAttachment(0, 7);
-               data.height = 18;
-               saveFile.setLayoutData(data);
-
-               data = new FormData();
-               data.top = new FormAttachment(saveFile, 0);
-               data.left = new FormAttachment(0, 6);
-               data.right = new FormAttachment(100, -6);
-               data.height = 126;
-               saveTable.setLayoutData(data);
-
-               data = new FormData();
-               data.top = new FormAttachment(saveTable, 16);
-               data.left = new FormAttachment(0, 6);
-               data.height = 18;
-               tempFile.setLayoutData(data);
-
-               data = new FormData();
-               data.top = new FormAttachment(tempFile, 0);
-               data.left = new FormAttachment(0, 6);
-               data.right = new FormAttachment(100, -6);
-               data.height = 126;
-               tempTable.setLayoutData(data);
-
-               Composite buttonComp = new Composite(shell, SWT.NONE);
-               FormLayout compLayout = new FormLayout();
-               buttonComp.setLayout(compLayout);
-               buttonComp
-                               .setBackground(ColorResources.OPEN_TRACE_BUTTON_COMPOSITE_BG_COLOR);
-
-               FormData compData = new FormData();
-               compData.top = new FormAttachment(tableComp, 0);
-               compData.left = new FormAttachment(0, 0);
-               compData.right = new FormAttachment(100, 0);
-               compData.height = 51;
-               buttonComp.setLayoutData(compData);
-
-               buttonComp.addPaintListener(new PaintListener() {
-
-                       @Override
-                       public void paintControl(PaintEvent e) {
-                               Composite comp = (Composite) e.widget;
-                               Rectangle rect = comp.getClientArea();
-                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_1);
-                               e.gc.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
-                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_2);
-                               e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width,
-                                               rect.y + 1);
-                       }
-               });
-               okButton = new DAButton(buttonComp, SWT.NONE);
-               okButton.addClickListener(okButtonListener);
-               okButton.setText(AnalyzerLabels.OPEN);
-               okButton.setFont(FontResources.DIALOG_BUTTON_FONT);
-               FormData okData = new FormData();
-               okData.top = new FormAttachment(0, 7);
-               okData.left = new FormAttachment(50,
-                               -(DesignConstants.DA_BUTTON_WIDTH + 4));
-               okData.width = DesignConstants.DA_BUTTON_WIDTH;
-               okData.height = DesignConstants.DA_BUTTON_HEIGHT;
-               okButton.setLayoutData(okData);
-
-               cancelButton = new DAButton(buttonComp, SWT.NONE);
-               cancelButton.addClickListener(cancelButtonListener);
-               cancelButton.setText(AnalyzerLabels.CLOSE);
-               cancelButton.setFont(FontResources.DIALOG_BUTTON_FONT);
-               FormData cancelData = new FormData();
-               cancelData.top = new FormAttachment(0, 7);
-               cancelData.left = new FormAttachment(50, 4);
-               cancelData.width = DesignConstants.DA_BUTTON_WIDTH;
-               cancelData.height = DesignConstants.DA_BUTTON_HEIGHT;
-               cancelButton.setLayoutData(cancelData);
-
-               opened = true;
-               return result;
-       }
-
-       private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
-
-               @Override
-               public void handleClickEvent(DACustomButton button) {
-                       if (null != selectedTable) {
-                               GridItem[] selections = selectedTable.getSelection();
-                               if (null == selections || 0 == selections.length) {
-                                       return;
-                               }
-                               GridItem selection = selections[0];
-                               String openPath = null;
-                               if ((Integer) selection.getData() == 1) {
-                                       openPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator
-                                                       + selection.getText();
-                               } else {
-                                       openPath = AnalyzerPaths.DYNAMIC_ANALYZER_SAVE_PATH
-                                                       + File.separator + selection.getText();
-                               }
-                               OpenTraceProgressManager.getInstance().setSavePath(openPath);
-                               OpenTraceProgressManager.getInstance().startOpenTraceThread();
-                               shell.dispose();
-                       }
-               }
-       };
-
-       private DACustomButtonClickEventListener cancelButtonListener = new DACustomButtonClickEventListener() {
-
-               @Override
-               public void handleClickEvent(DACustomButton button) {
-                       shell.dispose();
-               }
-       };
-
-       private SelectionListener saveTableSelectionListener = new SelectionListener() {
-
-               @Override
-               public void widgetSelected(SelectionEvent e) {
-                       // TODO Auto-generated method stub
-                       selectedTable = saveTable;
-                       int[] sel = new int[0];
-                       tempTable.setSelection(sel);
-               }
-
-               @Override
-               public void widgetDefaultSelected(SelectionEvent e) {
-                       // TODO Auto-generated method stub
-
-               }
-       };
-
-       private SelectionListener tempTableSelectionListener = new SelectionListener() {
-
-               @Override
-               public void widgetSelected(SelectionEvent e) {
-                       selectedTable = tempTable;
-                       int[] sel = new int[0];
-                       saveTable.setSelection(sel);
-               }
-
-               @Override
-               public void widgetDefaultSelected(SelectionEvent e) {
-                       // TODO Auto-generated method stub
-
-               }
-       };
-}
index a9a886d..51ec7f1 100644 (file)
@@ -34,6 +34,7 @@ import org.tizen.dynamicanalyzer.logparser.LogParser;
 import org.tizen.dynamicanalyzer.project.Project;
 import org.tizen.dynamicanalyzer.sql.SqlManager;
 import org.tizen.dynamicanalyzer.ui.info.range.StopProcessManager;
+import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceInputReader;
 import org.tizen.dynamicanalyzer.utils.UpdateViewTimer;
 
 public class StopLogProcessor implements Runnable {
index 1d96cac..399916f 100755 (executable)
@@ -60,6 +60,7 @@ import org.tizen.dynamicanalyzer.resources.FontResources;
 import org.tizen.dynamicanalyzer.resources.ImageResources;
 import org.tizen.dynamicanalyzer.services.RecordStateSourceProvider;
 import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage;
+import org.tizen.dynamicanalyzer.ui.toolbar.opentrace.OpenTraceDialog;
 import org.tizen.dynamicanalyzer.ui.widgets.ComboButtonRenderer;
 import org.tizen.dynamicanalyzer.ui.widgets.DADialog;
 import org.tizen.dynamicanalyzer.ui.widgets.TitleComboPopupRenderer;
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceDialog.java
new file mode 100644 (file)
index 0000000..658a49d
--- /dev/null
@@ -0,0 +1,518 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.dynamicanalyzer.ui.toolbar.opentrace;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.nebula.widgets.grid.Grid;
+import org.eclipse.nebula.widgets.grid.GridItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.common.CommonConstants;
+import org.tizen.dynamicanalyzer.common.DesignConstants;
+import org.tizen.dynamicanalyzer.logparser.OpenTraceProgressManager;
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.sql.SqlManager;
+import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
+import org.tizen.dynamicanalyzer.ui.widgets.DAMessageBox;
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
+import org.tizen.dynamicanalyzer.ui.widgets.table.TableComparator;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
+import org.tizen.dynamicanalyzer.utils.Formatter;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+
+public class OpenTraceDialog extends DAMessageBox {
+       private static boolean opened = false;
+       public static int SAVE_FOLDER = 0;
+       public static int TEMP_FOLDER = 1;
+
+       private DATableComposite saveTable = null;
+       private DATableComposite tempTable = null;
+       private Canvas detail = null;
+       private Grid selectedTable = null;
+       private DACustomButton okButton = null;
+       private DACustomButton cancelButton = null;
+
+       /* for details */
+       private String createTime = CommonConstants.EMPTY;
+       private String device = CommonConstants.EMPTY;
+       private String application = CommonConstants.EMPTY;
+       private String elapsedTime = CommonConstants.ZERO;
+
+       private String[] columnNames = {
+                       AnalyzerLabels.OPEN_TRACE_DLG_TRACE_FILE_NAME,
+                       AnalyzerLabels.OPEN_TRACE_DLG_TRACE_DATE };
+       private int[] columnSizes = { 190, 200 };
+       private boolean[] columnVisibility = { true, true };
+       int[] sortTypes = { AnalyzerConstants.SORT_TYPE_GRID,
+                       AnalyzerConstants.SORT_TYPE_GRID };
+       int[] sourceColumns = { 0, 0 };
+
+       public OpenTraceDialog(Shell parent) {
+               super(parent);
+       }
+
+       protected int run() {
+               if (opened) {
+                       result = -1;
+                       return result;
+               }
+               shell.setLayout(new FormLayout());
+               shell.setSize(400, 410);
+               shell.setText(AnalyzerLabels.OPEN_TRACE);
+
+               shell.addDisposeListener(new DisposeListener() {
+
+                       @Override
+                       public void widgetDisposed(DisposeEvent e) {
+                               System.out.println("shell disposed!");
+                               opened = false;
+                       }
+               });
+
+               Composite tableComp = new Composite(shell, SWT.NONE);
+               tableComp.setLayout(new FormLayout());
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 0);
+               data.left = new FormAttachment(0, 0);
+               data.right = new FormAttachment(100, 0);
+               data.height = 337;
+               tableComp.setLayoutData(data);
+               tableComp.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+               Label saveFile = new Label(tableComp, SWT.TRANSPARENT);
+               saveFile.setText(AnalyzerLabels.OPEN_TRACE_DLG_SAVED_FILE);
+               saveFile.setBackground(ColorResources.DIALOG_BG_UPPER);
+               saveFile.setAlignment(SWT.LEFT);
+               saveFile.setForeground(ColorResources.OPEN_TRACE_LABEL_COLOR);
+               saveFile.setFont(FontResources.OPEN_TRACE_INNER_TITLE);
+
+               saveTable = new SaveFilesTable(tableComp, SWT.BORDER | SWT.V_SCROLL
+                               | SWT.SINGLE);
+               saveTable.setTableName("SaveFiles");
+               saveTable.setComparator(new TableComparator());
+               saveTable.setSortTypes(sortTypes);
+               saveTable.setSourceColumns(sourceColumns);
+               saveTable.setColumns(columnNames);
+               saveTable.setColumnSize(columnSizes);
+               saveTable.setColumnVisibility(columnVisibility);
+
+               saveTable.getTable().addSelectionListener(saveTableSelectionListener);
+               saveTable.getTable().addMouseListener(mouseListener);
+               saveTable.getTable().addKeyListener(keyListener);
+
+               Label tempFile = new Label(tableComp, SWT.TRANSPARENT);
+               tempFile.setText(AnalyzerLabels.OPEN_TRACE_DLG_TEMP_FILE);
+               tempFile.setBackground(ColorResources.DIALOG_BG_UPPER);
+               tempFile.setAlignment(SWT.LEFT);
+               tempFile.setForeground(ColorResources.OPEN_TRACE_LABEL_COLOR);
+               tempFile.setFont(FontResources.OPEN_TRACE_INNER_TITLE);
+
+               tempTable = new TempFilesTable(tableComp, SWT.BORDER | SWT.V_SCROLL
+                               | SWT.SINGLE);
+               tempTable.setTableName("TempFiles");
+               saveTable.setComparator(new TableComparator());
+               tempTable.setSortTypes(sortTypes);
+               tempTable.setSourceColumns(sourceColumns);
+               tempTable.setColumns(columnNames);
+               tempTable.setColumnSize(columnSizes);
+               tempTable.setColumnVisibility(columnVisibility);
+               tempTable.getTable().addSelectionListener(tempTableSelectionListener);
+               tempTable.getTable().addMouseListener(mouseListener);
+               tempTable.getTable().addKeyListener(keyListener);
+
+               Label detailLabel = new Label(tableComp, SWT.TRANSPARENT);
+               detailLabel.setText("Trace details");
+               detailLabel.setBackground(ColorResources.DIALOG_BG_UPPER);
+               detailLabel.setAlignment(SWT.LEFT);
+               detailLabel.setForeground(ColorResources.OPEN_TRACE_LABEL_COLOR);
+               detailLabel.setFont(FontResources.OPEN_TRACE_INNER_TITLE);
+
+               detail = new Canvas(tableComp, SWT.NONE);
+               detail.addPaintListener(detailPaintListener);
+
+               data = new FormData();
+               data.top = new FormAttachment(0, 5);
+               data.left = new FormAttachment(0, 7);
+               data.height = 18;
+               saveFile.setLayoutData(data);
+
+               data = new FormData();
+               data.top = new FormAttachment(saveFile, 0);
+               data.left = new FormAttachment(0, 6);
+               data.right = new FormAttachment(100, -6);
+               data.height = 100;
+               saveTable.setLayoutData(data);
+
+               data = new FormData();
+               data.top = new FormAttachment(saveTable, 10);
+               data.left = new FormAttachment(0, 6);
+               data.height = 18;
+               tempFile.setLayoutData(data);
+
+               data = new FormData();
+               data.top = new FormAttachment(tempFile, 0);
+               data.left = new FormAttachment(0, 6);
+               data.right = new FormAttachment(100, -6);
+               data.height = 100;
+               tempTable.setLayoutData(data);
+
+               data = new FormData();
+               data.top = new FormAttachment(tempTable, 10);
+               data.left = new FormAttachment(0, 6);
+               data.height = 18;
+               detailLabel.setLayoutData(data);
+
+               data = new FormData();
+               data.top = new FormAttachment(detailLabel, 0);
+               data.left = new FormAttachment(0, 6);
+               data.right = new FormAttachment(100, -6);
+               data.height = 50;
+               detail.setLayoutData(data);
+
+               Composite buttonComp = new Composite(shell, SWT.NONE);
+               FormLayout compLayout = new FormLayout();
+               buttonComp.setLayout(compLayout);
+               buttonComp
+                               .setBackground(ColorResources.OPEN_TRACE_BUTTON_COMPOSITE_BG_COLOR);
+
+               FormData compData = new FormData();
+               compData.top = new FormAttachment(tableComp, 0);
+               compData.left = new FormAttachment(0, 0);
+               compData.right = new FormAttachment(100, 0);
+               compData.height = 51;
+               buttonComp.setLayoutData(compData);
+
+               buttonComp.addPaintListener(new PaintListener() {
+
+                       @Override
+                       public void paintControl(PaintEvent e) {
+                               Composite comp = (Composite) e.widget;
+                               Rectangle rect = comp.getClientArea();
+                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_1);
+                               e.gc.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
+                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_2);
+                               e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width,
+                                               rect.y + 1);
+                       }
+               });
+               okButton = new DAButton(buttonComp, SWT.NONE);
+               okButton.addClickListener(okButtonListener);
+               okButton.setText(AnalyzerLabels.OPEN);
+               okButton.setFont(FontResources.DIALOG_BUTTON_FONT);
+               FormData okData = new FormData();
+               okData.top = new FormAttachment(0, 7);
+               okData.left = new FormAttachment(50,
+                               -(DesignConstants.DA_BUTTON_WIDTH + 4));
+               okData.width = DesignConstants.DA_BUTTON_WIDTH;
+               okData.height = DesignConstants.DA_BUTTON_HEIGHT;
+               okButton.setLayoutData(okData);
+
+               cancelButton = new DAButton(buttonComp, SWT.NONE);
+               cancelButton.addClickListener(cancelButtonListener);
+               cancelButton.setText(AnalyzerLabels.CLOSE);
+               cancelButton.setFont(FontResources.DIALOG_BUTTON_FONT);
+               FormData cancelData = new FormData();
+               cancelData.top = new FormAttachment(0, 7);
+               cancelData.left = new FormAttachment(50, 4);
+               cancelData.width = DesignConstants.DA_BUTTON_WIDTH;
+               cancelData.height = DesignConstants.DA_BUTTON_HEIGHT;
+               cancelButton.setLayoutData(cancelData);
+
+               saveTable.updateTable();
+               tempTable.updateTable();
+               opened = true;
+               return result;
+       }
+
+       private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
+
+               @Override
+               public void handleClickEvent(DACustomButton button) {
+                       if (null != selectedTable) {
+                               GridItem[] selections = selectedTable.getSelection();
+                               if (null == selections || 0 == selections.length) {
+                                       return;
+                               }
+                               GridItem selection = selections[0];
+                               String openPath = null;
+                               if ((Integer) selection.getData() == TEMP_FOLDER) {
+                                       openPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator
+                                                       + selection.getText();
+                               } else if ((Integer) selection.getData() == SAVE_FOLDER) {
+                                       openPath = AnalyzerPaths.DYNAMIC_ANALYZER_SAVE_PATH
+                                                       + File.separator + selection.getText();
+                               } else {
+                                       return;
+                               }
+                               OpenTraceProgressManager.getInstance().setSavePath(openPath);
+                               OpenTraceProgressManager.getInstance().startOpenTraceThread();
+                               shell.dispose();
+                       }
+               }
+       };
+
+       private DACustomButtonClickEventListener cancelButtonListener = new DACustomButtonClickEventListener() {
+
+               @Override
+               public void handleClickEvent(DACustomButton button) {
+                       shell.dispose();
+               }
+       };
+
+       private SelectionListener saveTableSelectionListener = new SelectionListener() {
+
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       selectedTable = saveTable.getTable();
+                       int[] sel = new int[0];
+                       tempTable.getTable().setSelection(sel);
+                       updateDetails();
+               }
+
+               @Override
+               public void widgetDefaultSelected(SelectionEvent e) {
+
+               }
+       };
+
+       private SelectionListener tempTableSelectionListener = new SelectionListener() {
+
+               @Override
+               public void widgetSelected(SelectionEvent e) {
+                       selectedTable = tempTable.getTable();
+                       int[] sel = new int[0];
+                       saveTable.getTable().setSelection(sel);
+                       updateDetails();
+               }
+
+               @Override
+               public void widgetDefaultSelected(SelectionEvent e) {
+                       // TODO Auto-generated method stub
+
+               }
+       };
+
+       private MouseListener mouseListener = new MouseListener() {
+
+               @Override
+               public void mouseUp(MouseEvent e) {
+                       // TODO Auto-generated method stub
+
+               }
+
+               @Override
+               public void mouseDown(MouseEvent e) {
+                       // TODO Auto-generated method stub
+
+               }
+
+               @Override
+               public void mouseDoubleClick(MouseEvent e) {
+                       Grid grid = (Grid) e.widget;
+                       GridItem[] items = grid.getSelection();
+                       if (0 == items.length) {
+                               return;
+                       }
+
+                       GridItem item = items[0];
+                       String openPath = null;
+                       if ((Integer) item.getData() == TEMP_FOLDER) {
+                               openPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator
+                                               + item.getText();
+                       } else if ((Integer) item.getData() == SAVE_FOLDER) {
+                               openPath = AnalyzerPaths.DYNAMIC_ANALYZER_SAVE_PATH
+                                               + File.separator + item.getText();
+                       } else {
+                               return;
+                       }
+                       OpenTraceProgressManager.getInstance().setSavePath(openPath);
+                       OpenTraceProgressManager.getInstance().startOpenTraceThread();
+                       shell.dispose();
+               }
+       };
+
+       private KeyListener keyListener = new KeyListener() {
+
+               @Override
+               public void keyReleased(KeyEvent e) {
+                       if (e.keyCode == SWT.DEL) {
+                               Grid grid = (Grid) e.widget;
+                               GridItem[] items = grid.getSelection();
+                               if (0 == items.length) {
+                                       return;
+                               }
+                               int index = grid.getSelectionIndex();
+                               GridItem item = items[0];
+                               String openPath = null;
+                               if ((Integer) item.getData() == TEMP_FOLDER) {
+                                       openPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator
+                                                       + item.getText();
+                               } else if ((Integer) item.getData() == SAVE_FOLDER) {
+                                       openPath = AnalyzerPaths.DYNAMIC_ANALYZER_SAVE_PATH
+                                                       + File.separator + item.getText();
+                               } else {
+                                       return;
+                               }
+                               if (AnalyzerUtil.deleteFile(new File(openPath))) {
+                                       grid.remove(index);
+                               } else {
+                                       // log for debug
+                                       System.out.println("delete save file failed...");
+                               }
+                       }
+
+               }
+
+               @Override
+               public void keyPressed(KeyEvent e) {
+                       // TODO Auto-generated method stub
+
+               }
+       };
+
+       private PaintListener detailPaintListener = new PaintListener() {
+
+               @Override
+               public void paintControl(PaintEvent e) {
+                       Canvas canvas = (Canvas) e.widget;
+                       Rectangle rect = canvas.getClientArea();
+
+                       e.gc.setBackground(ColorResources.WHITE);
+                       e.gc.fillRectangle(rect);
+                       e.gc.setForeground(ColorResources.BLACK);
+                       e.gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1);
+                       e.gc.drawRectangle(rect.x + 2, rect.y + 2, rect.width - 5,
+                                       rect.height - 5);
+
+                       if (!application.isEmpty() && !device.isEmpty()) {
+                               String inputText = "Applicatoin : " + application;
+                               Point textSize = e.gc.textExtent(inputText, SWT.DRAW_MNEMONIC);
+                               int fontHeight = textSize.y;
+
+                               int x = rect.x + 7;
+                               int y = rect.y + 4;
+
+                               e.gc.setForeground(ColorResources.BLACK);
+                               e.gc.drawText(inputText, x, y);
+
+                               inputText = "Device : " + device;
+                               e.gc.drawText(inputText, x + (rect.width - 4) / 2, y);
+                               y += fontHeight;
+
+                               inputText = "Create time : " + createTime;
+                               e.gc.drawText(inputText, x, y);
+                               y += fontHeight;
+
+                               inputText = "Recording time : "
+                                               + Formatter.toTimeFormat(elapsedTime);
+                               e.gc.drawText(inputText, x, y);
+                       }
+               }
+       };
+
+       private void updateDetails() {
+               GridItem[] items = selectedTable.getSelection();
+               if (items.length == 0) {
+                       return;
+               }
+
+               GridItem item = items[0];
+
+               String path = null;
+               if ((Integer) item.getData() == TEMP_FOLDER) {
+                       path = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator
+                                       + item.getText(0);
+               } else if ((Integer) item.getData() == SAVE_FOLDER) {
+                       path = AnalyzerPaths.DYNAMIC_ANALYZER_SAVE_PATH + File.separator
+                                       + item.getText(0);
+               } else {
+                       return;
+               }
+               if (!setDetailsInfo(path)) {
+                       createTime = CommonConstants.EMPTY;
+                       device = CommonConstants.EMPTY;
+                       application = CommonConstants.EMPTY;
+                       elapsedTime = CommonConstants.ZERO;
+               }
+               detail.redraw();
+       }
+
+       private boolean setDetailsInfo(String path) {
+               boolean isSuccess = true;
+               try {
+                       Connection conn = SqlManager.getConnection(path);
+                       Statement stat = conn.createStatement();
+                       String query = "select info from project";
+                       ResultSet rs = stat.executeQuery(query);
+
+                       List<String> pInfo = new ArrayList<String>();
+                       while (rs.next()) {
+                               pInfo.add(rs.getString("info")); //$NON-NLS-1$
+                       }
+                       rs.close();
+                       conn.close();
+
+                       createTime = pInfo.get(AnalyzerConstants.PROJECT_CREATE_TIME_INDEX);
+                       device = pInfo.get(AnalyzerConstants.PROJECT_DEVICE_INDEX);
+                       application = pInfo.get(AnalyzerConstants.PROJECT_APPNAME_INDEX);
+                       elapsedTime = pInfo.get(AnalyzerConstants.PROJECT_LAST_TIME_INDEX);
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       isSuccess = false;
+               }
+               return isSuccess;
+       }
+}
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/SaveFilesTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/SaveFilesTable.java
new file mode 100644 (file)
index 0000000..9fb0dc2
--- /dev/null
@@ -0,0 +1,132 @@
+package org.tizen.dynamicanalyzer.ui.toolbar.opentrace;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.nebula.widgets.grid.GridItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.model.TableInput;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.sql.SqlManager;
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
+
+public class SaveFilesTable extends DATableComposite {
+       private boolean isVaildVersion = true;
+       private final int TRACE_NAME_INDEX = 0;
+       private final int DATE_INDEX = 1;
+       private final int VALIDATE_INDEX = 2;
+       private final int COLUMN_COUNT = 2;
+
+       public SaveFilesTable(Composite parent, int style) {
+               super(parent, style);
+               // TODO Auto-generated constructor stub
+       }
+
+       @Override
+       protected List<TableInput> makeTableInput() {
+               List<String> saveFileList = AnalyzerUtil
+                               .getDirs(AnalyzerPaths.DYNAMIC_ANALYZER_SAVE_PATH);
+               List<TableInput> input = new ArrayList<TableInput>();
+               int size = saveFileList.size();
+               for (int i = 0; i < size; i++) {
+                       // create text
+                       List<String> text = new ArrayList<String>();
+                       if (!saveFileList.get(i).equals(AnalyzerConstants.TEMP_FOLDER_NAME)) {
+                               String path = AnalyzerPaths.DYNAMIC_ANALYZER_SAVE_PATH
+                                               + File.separator + saveFileList.get(i);
+                               String inputText1 = saveFileList.get(i);
+                               String inputText2 = getCreateTime(path);
+
+                               if (inputText1.isEmpty() || null == inputText2
+                                               || inputText2.isEmpty()) {
+                                       continue;
+                               }
+
+                               text.add(inputText1);
+                               text.add(inputText2);
+                               if (isVaildVersion) {
+                                       text.add("Y");
+                               } else {
+                                       text.add("N");
+                               }
+                               TableInput tableInput = new TableInput();
+                               tableInput.setText(text);
+                               input.add(tableInput);
+                       }
+               }
+               return input;
+       }
+
+       @Override
+       public void updateTable() {
+               table.removeAll();
+               List<TableInput> input = makeTableInput();
+               if (null == input) {
+                       return;
+               }
+               if (null != comparator) {
+                       Collections.sort(input, comparator);
+               }
+               int size = input.size();
+               for (int i = 0; i < size; i++) {
+                       List<String> text = input.get(i).getText();
+                       if (text.size() < COLUMN_COUNT
+                                       || text.get(TRACE_NAME_INDEX).isEmpty()
+                                       || null == text.get(DATE_INDEX)
+                                       || text.get(DATE_INDEX).isEmpty()) {
+                               continue;
+                       }
+                       GridItem gridItem = new GridItem(table, SWT.NONE);
+                       gridItem.setData(OpenTraceDialog.SAVE_FOLDER);
+
+                       for (int index = 0; index < COLUMN_COUNT; index++) {
+                               String inputText = text.get(index);
+                               gridItem.setText(index, inputText);
+                       }
+                       if (text.get(VALIDATE_INDEX).equals("N")) {
+                               gridItem.setForeground(ColorResources.RED);
+                               gridItem.setToolTipText(TRACE_NAME_INDEX,
+                                               "invalid save file - old version");
+                               gridItem.setToolTipText(DATE_INDEX,
+                                               "invalid save file - old version");
+                       }
+               }
+               table.update();
+       }
+
+       private String getCreateTime(String savePath) {
+               isVaildVersion = true;
+               try {
+                       Connection conn = SqlManager.getConnection(savePath);
+                       Statement stat = conn.createStatement();
+                       String query = "select info from project";
+                       ResultSet rs = stat.executeQuery(query);
+
+                       List<String> pInfo = new ArrayList<String>();
+                       while (rs.next()) {
+                               pInfo.add(rs.getString("info")); //$NON-NLS-1$
+                       }
+                       rs.close();
+                       conn.close();
+
+                       String version = pInfo.get(AnalyzerConstants.PROJECT_VERSION_INDEX);
+                       if (version.isEmpty()
+                                       || !version.equals(AnalyzerConstants.SAVE_DATA_VERSION)) {
+                               isVaildVersion = false;
+                       }
+                       return pInfo.get(AnalyzerConstants.PROJECT_CREATE_TIME_INDEX);
+               } catch (Exception e) {
+                       isVaildVersion = false;
+               }
+               return null;
+       }
+}
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/TempFilesTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/TempFilesTable.java
new file mode 100644 (file)
index 0000000..240c462
--- /dev/null
@@ -0,0 +1,95 @@
+package org.tizen.dynamicanalyzer.ui.toolbar.opentrace;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.nebula.widgets.grid.GridItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.model.TableInput;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.sql.SqlManager;
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
+
+public class TempFilesTable extends DATableComposite {
+
+       public TempFilesTable(Composite parent, int style) {
+               super(parent, style);
+               // TODO Auto-generated constructor stub
+       }
+
+       @Override
+       protected List<TableInput> makeTableInput() {
+               List<String> tempFileList = AnalyzerUtil
+                               .getDirs(AnalyzerPaths.TEMP_FOLDER_PATH);
+               List<TableInput> input = new ArrayList<TableInput>();
+               int size = tempFileList.size();
+               for (int i = 0; i < size; i++) {
+                       // create text
+                       List<String> text = new ArrayList<String>();
+                       if (!tempFileList.get(i).equals(AnalyzerConstants.TEMP_FOLDER_NAME)) {
+                               String path = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator
+                                               + tempFileList.get(i);
+                               text.add(tempFileList.get(i));
+                               text.add(getCreateTime(path));
+                               TableInput tableInput = new TableInput();
+                               tableInput.setText(text);
+                               input.add(tableInput);
+                       }
+               }
+               return input;
+       }
+
+       @Override
+       public void updateTable() {
+               table.removeAll();
+               List<TableInput> input = makeTableInput();
+               if (null == input) {
+                       return;
+               }
+               if (null != comparator) {
+                       Collections.sort(input, comparator);
+               }
+               int size = input.size();
+               for (int i = 0; i < size; i++) {
+                       GridItem gridItem = new GridItem(table, SWT.NONE);
+                       gridItem.setData(OpenTraceDialog.TEMP_FOLDER);
+                       gridItem.setForeground(ColorResources.RED);
+
+                       List<String> text = input.get(i).getText();
+                       int columnCount = text.size();
+                       for (int index = 0; index < columnCount; index++) {
+                               gridItem.setText(index, text.get(index));
+                       }
+               }
+               table.update();
+       }
+
+       private String getCreateTime(String savePath) {
+               try {
+                       Connection conn = SqlManager.getConnection(savePath);
+                       Statement stat = conn.createStatement();
+                       String query = "select info from project";
+                       ResultSet rs = stat.executeQuery(query);
+
+                       List<String> pInfo = new ArrayList<String>();
+                       while (rs.next()) {
+                               pInfo.add(rs.getString("info")); //$NON-NLS-1$
+                       }
+                       rs.close();
+                       conn.close();
+                       return pInfo.get(AnalyzerConstants.PROJECT_CREATE_TIME_INDEX);
+               } catch (Exception e) {
+
+               }
+               return null;
+       }
+}
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DAAnimation.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DAAnimation.java
new file mode 100644 (file)
index 0000000..19b9bb7
--- /dev/null
@@ -0,0 +1,88 @@
+package org.tizen.dynamicanalyzer.ui.widgets;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+
+public class DAAnimation extends Canvas {
+
+       private List<Image> imageList = null;
+
+       Timer timer = null;
+       long startTime = 0;
+       long interval = 1000;
+
+       int index = 0;
+
+       public DAAnimation(Composite parent, int style) {
+               super(parent, style);
+               this.addPaintListener(paintListener);
+       }
+
+       public DAAnimation(Composite parent, int style, List<Image> images) {
+               this(parent, style);
+               imageList = new ArrayList<Image>();
+               imageList.addAll(images);
+       }
+
+       public void setInterval(long interval) {
+               this.interval = interval;
+       }
+
+       public void start() {
+               startTimer();
+       }
+
+       private PaintListener paintListener = new PaintListener() {
+
+               @Override
+               public void paintControl(PaintEvent e) {
+                       Canvas canvas = (Canvas) e.widget;
+                       Rectangle rect = canvas.getClientArea();
+                       if (index >= imageList.size()) {
+                               index = 0;
+                       }
+                       e.gc.drawImage(imageList.get(index++), rect.x, rect.y);
+                       e.gc.setForeground(ColorResources.WHITE);
+                       e.gc.drawRectangle(rect);
+               }
+       };
+
+       private void startTimer() {
+               if (null != timer)
+                       stopTimer();
+
+               startTime = System.currentTimeMillis();
+               timer = new Timer();
+
+               timer.schedule(new TimerTask() {
+                       @Override
+                       public void run() {
+                               Display.getDefault().syncExec(new Runnable() {
+                                       @Override
+                                       public void run() {
+                                               redraw();
+                                       }
+                               });
+                       }
+               }, new Date(), interval);
+       }
+
+       public void stopTimer() {
+               if (null != timer) {
+                       timer.cancel();
+                       timer = null;
+               }
+       }
+}
index c9edc5b..5478958 100644 (file)
@@ -6,6 +6,7 @@ import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormLayout;
 import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.Composite;
 import org.tizen.dynamicanalyzer.common.CommonConstants;
@@ -32,6 +33,7 @@ public class Progress extends Canvas {
        public Progress(Composite parent, int style) {
                super(parent, style);
                this.addPaintListener(progressPaintListener);
+               this.setLayout(new FormLayout());
        }
 
        public Progress(Composite parent, int style, int progressStyle) {
index 4e53004..2a5dfe5 100644 (file)
@@ -78,7 +78,7 @@ public abstract class DATableComposite extends Composite {
        protected int[] sourceColumns = null;
 
        public DATableComposite(Composite parent, int style) {
-               super(parent, style);
+               this(parent, SWT.NONE, style);
        }
 
        public DATableComposite(Composite parent, int compStyle, int tableStyle) {
@@ -104,6 +104,9 @@ public abstract class DATableComposite extends Composite {
                                GridItem[] ti = ((Grid) e.widget).getSelection();
                                GridItem focusedItem = ((Grid) e.widget).getFocusItem();
                                if (null != focusedItem) {
+                                       if (!(focusedItem.getData() instanceof DATableDataFormat)) {
+                                               return;
+                                       }
                                        DATableDataFormat td = (DATableDataFormat) focusedItem
                                                        .getData();
                                        if (null == td) {
index f585989..a59fb97 100644 (file)
@@ -28,9 +28,11 @@ package org.tizen.dynamicanalyzer.ui.widgets.table;
 
 import java.util.Comparator;
 
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+
 public abstract class DefaultTableComparator implements Comparator<Object> {
 
-       protected int type = 0;
+       protected int type = AnalyzerConstants.SORT_TYPE_GRID;
        protected int column = 0;
        protected boolean dirUp = true;
        protected int sourceColumn = 0;
@@ -51,11 +53,10 @@ public abstract class DefaultTableComparator implements Comparator<Object> {
                this.dirUp = !dirUp;
        }
 
-       public void setSourceColumn(int i)
-       {
+       public void setSourceColumn(int i) {
                sourceColumn = i;
        }
-       
+
        @Override
        public int compare(Object arg0, Object arg1) {
                return userCompare(arg0, arg1);
index 20633bf..e17706a 100644 (file)
@@ -55,8 +55,13 @@ public class TableComparator extends DefaultTableComparator {
                        List<String> text1 = input1.getText();
                        List<String> text2 = input2.getText();
 
+                       try{
                        str1 = text1.get(column);
                        str2 = text2.get(column);
+                       }catch(Exception e)
+                       {
+                               System.out.println();
+                       }
                }
                switch (type) {
                case AnalyzerConstants.SORT_TYPE_NUM:
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/ImageUtils.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/ImageUtils.java
new file mode 100644 (file)
index 0000000..3fd1dcb
--- /dev/null
@@ -0,0 +1,79 @@
+package org.tizen.dynamicanalyzer.utils;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.ImageData;
+
+public class ImageUtils {
+       public static ImageData rotate(ImageData srcData, int direction) {
+               int bytesPerPixel = srcData.bytesPerLine / srcData.width;
+               int destBytesPerLine = (direction == SWT.DOWN) ? srcData.width
+                               * bytesPerPixel : srcData.height * bytesPerPixel;
+               byte[] newData = new byte[(direction == SWT.DOWN) ? srcData.height
+                               * destBytesPerLine : srcData.width * destBytesPerLine];
+               int width = 0, height = 0;
+               for (int srcY = 0; srcY < srcData.height; srcY++) {
+                       for (int srcX = 0; srcX < srcData.width; srcX++) {
+                               int destX = 0, destY = 0, destIndex = 0, srcIndex = 0;
+                               switch (direction) {
+                               case SWT.LEFT: // left 90 degrees
+                                       destX = srcY;
+                                       destY = srcData.width - srcX - 1;
+                                       width = srcData.height;
+                                       height = srcData.width;
+                                       break;
+                               case SWT.RIGHT: // right 90 degrees
+                                       destX = srcData.height - srcY - 1;
+                                       destY = srcX;
+                                       width = srcData.height;
+                                       height = srcData.width;
+                                       break;
+                               case SWT.DOWN: // 180 degrees
+                                       destX = srcData.width - srcX - 1;
+                                       destY = srcData.height - srcY - 1;
+                                       width = srcData.width;
+                                       height = srcData.height;
+                                       break;
+                               }
+                               destIndex = (destY * destBytesPerLine)
+                                               + (destX * bytesPerPixel);
+                               srcIndex = (srcY * srcData.bytesPerLine)
+                                               + (srcX * bytesPerPixel);
+                               System.arraycopy(srcData.data, srcIndex, newData, destIndex,
+                                               bytesPerPixel);
+                       }
+               }
+               // destBytesPerLine is used as scanlinePad to ensure that no padding is
+               // required
+               return new ImageData(width, height, srcData.depth, srcData.palette,
+                               srcData.scanlinePad, newData);
+       }
+
+       public static ImageData flip(ImageData srcData, boolean vertical) {
+               int bytesPerPixel = srcData.bytesPerLine / srcData.width;
+               int destBytesPerLine = srcData.width * bytesPerPixel;
+               byte[] newData = new byte[srcData.data.length];
+               for (int srcY = 0; srcY < srcData.height; srcY++) {
+                       for (int srcX = 0; srcX < srcData.width; srcX++) {
+                               int destX = 0, destY = 0, destIndex = 0, srcIndex = 0;
+                               if (vertical) {
+                                       destX = srcX;
+                                       destY = srcData.height - srcY - 1;
+                               } else {
+                                       destX = srcData.width - srcX - 1;
+                                       destY = srcY;
+                               }
+                               destIndex = (destY * destBytesPerLine)
+                                               + (destX * bytesPerPixel);
+                               srcIndex = (srcY * srcData.bytesPerLine)
+                                               + (srcX * bytesPerPixel);
+                               System.arraycopy(srcData.data, srcIndex, newData, destIndex,
+                                               bytesPerPixel);
+                       }
+               }
+               // destBytesPerLine is used as scanlinePad to ensure that no padding is
+               // required
+               return new ImageData(srcData.width, srcData.height, srcData.depth,
+                               srcData.palette, srcData.scanlinePad, newData);
+       }
+
+}