From: hyeran74.kim Date: Mon, 26 May 2014 05:35:34 +0000 (+0900) Subject: File : UI/UX was modified X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=879ec5868c3d2f9a2d3e5b7677017fe1f6374c17;p=sdk%2Ftools%2Fdynamic-analyzer.git File : UI/UX was modified Change-Id: Ic338164c67404368c74344eeaf79681431bd7328 Signed-off-by: hyeran74.kim --- diff --git a/org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/resources/ColorResources.java b/org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/resources/ColorResources.java index f930fda..c58e719 100755 --- a/org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/resources/ColorResources.java +++ b/org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/resources/ColorResources.java @@ -281,6 +281,11 @@ public class ColorResources { public static Color FILE_AREA_NOT_ACCESS_END = getColor("file_not_access_end"); //$NON-NLS-1$ public static Color FILE_ACCESS_READ = getColor("file_access_read"); //$NON-NLS-1$ public static Color FILE_ACCESS_WRITE = getColor("file_access_write"); //$NON-NLS-1$ + public static Color FILE_LOCK_ACQUIRED = getColor("file_lock_acquired"); //$NON-NLS-1$ + public static Color FILE_LOCK_WAITING = getColor("file_lock_waiting"); //$NON-NLS-1$ + public static Color FILE_OTHER_OPERATION = getColor("file_other_operation"); //$NON-NLS-1$ + public static Color FILE_OPENED = getColor("file_opened"); //$NON-NLS-1$ + public static Color FILE_DUPLICATE_OPENED = getColor("file_duplicate_opened"); //$NON-NLS-1$ /** Network chart colors **/ public static Color NETWORK_API_USED = getColor("network_api_used"); //$NON-NLS-1$ diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogCenterConstants.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogCenterConstants.java index cd5528e..58ff762 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogCenterConstants.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogCenterConstants.java @@ -123,6 +123,8 @@ public class LogCenterConstants { public static final int FD_API_TYPE_DICTORY = 6; public static final int FD_API_TYPE_PERMISSION = 7; public static final int FD_API_TYPE_OTHERS = 8; + public static final int FD_API_TYPE_LOCK_START = 14; + public static final int FD_API_TYPE_LOCK_END = 15; /* Log Network */ public static final int SOCKET_API_FD_OPEN = 0; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/FilePageLabels.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/FilePageLabels.java index fee6c08..2a98e51 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/FilePageLabels.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/FilePageLabels.java @@ -66,6 +66,14 @@ public class FilePageLabels extends NLS { public static String FILE_CHART_TOOLTIP_OPEND; public static String FILE_CHART_TOOLTIP_USED; + public static String FILE_CHART_TOOLTIP_WRITE; + public static String FILE_CHART_TOOLTIP_READ; + public static String FILE_CHART_TOOLTIP_LOCK; + + public static String FILE_API_DB; + public static String FILE_STATUS_DB; + public static String FILE_ACCESS_DB; + public static String TIME_MS; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/FilePageLabels.properties b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/FilePageLabels.properties index 7c4abc8..150568f 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/FilePageLabels.properties +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/FilePageLabels.properties @@ -29,8 +29,16 @@ FILE_CHART_API=API List FILE_CHART_ACCESS=ACCESS FILE_CHART_TOOLTIP_CLOSED=CLOSED -FILE_CHART_TOOLTIP_OPEND=OPEND +FILE_CHART_TOOLTIP_OPEND=OPENED FILE_CHART_TOOLTIP_USED=USED + +FILE_CHART_TOOLTIP_WRITE=WRITE +FILE_CHART_TOOLTIP_READ=READ +FILE_CHART_TOOLTIP_LOCK=LOCK + +FILE_API_DB=FILE_API_DB +FILE_STATUS_DB=FILE_STATUS_DB +FILE_ACCESS_DB=FILE_ACCESS_DB TIME_MS = ms diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileAccessDB.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileAccessDB.java new file mode 100644 index 0000000..9b5e40a --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileAccessDB.java @@ -0,0 +1,176 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran Lim + * Juyoung Kim + * + * 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.file.data; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.database.DBColumn; +import org.tizen.dynamicanalyzer.database.DBConstants; +import org.tizen.dynamicanalyzer.database.DBTable; +import org.tizen.dynamicanalyzer.database.SqlConnectionManager; +import org.tizen.dynamicanalyzer.nl.FilePageLabels; +import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB.COLUMN; +import org.tizen.dynamicanalyzer.ui.file.model.FileAccess; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSeriesType; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; + +// read, write, lock +public class FileAccessDB extends DBTable { + private static final String TABLE_NAME = FilePageLabels.FILE_ACCESS_DB; + + public static enum COLUMN { + DENTRY(0, "dentry"), + PID(1, "pid"), + TID(2, "tid"), + FILE_PATH(3, "filePath"), + FD(4, "fd"), + API_TYPE(5, "apiType"), + START_TIME(6, "startTime"), + END_TIME(7, "endTime"), + ERRNO(8, "errNo"), + FILE_SIZE(9, "fileSize"); + + private final int value; + private final String name; + private COLUMN(int value, String name) { + this.value = value; + this.name = name; + } + + public int getValue() { + return value; + } + + public String getName() { + return name; + } + } + + public FileAccessDB() { + addColumn(new DBColumn(COLUMN.DENTRY.getName(), DBConstants.NOT_NULL, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.PID.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.TID.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.FILE_PATH.getName(), DBConstants.EMPTY, DBConstants.BIG_TEXT)); + addColumn(new DBColumn(COLUMN.FD.getName(), DBConstants.EMPTY, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.API_TYPE.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.START_TIME.getName(), DBConstants.NOT_NULL, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.END_TIME.getName(), DBConstants.NOT_NULL, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.ERRNO.getName(), DBConstants.EMPTY, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.FILE_SIZE.getName(), DBConstants.EMPTY, DBConstants.LONG)); + } + + @Override + public String getTableName() { + return TABLE_NAME; + } + + private static final String selectAll = selectAll(); + private static final String SELECT_QUERY = "select " + + selectAll + + " from " + TABLE_NAME; //$NON-NLS-1$ + + public void insert(FileAccess insertData) { + List> insertDataList = new ArrayList>(); + insertDataList.add(insertData.getDBData()); + insertData(insertDataList); + } + + public List select(double visibleStartTime, + double visibleEndTime) { + double selectStartTime = visibleStartTime + * TimelineConstants.MEGA_DOUBLE; + double selectEndTime = visibleEndTime * TimelineConstants.MEGA_DOUBLE; + + String query = String.format(SELECT_QUERY, selectStartTime, + selectEndTime); + + List> result = SqlConnectionManager.executeQuery(query); + if (null == result || result.size() == 0 || result.get(0).size() == 0) { + return null; + } + + List accessList = new ArrayList(); + for (List data : result) { + accessList.add(new FileAccess(data)); + } + return accessList; + } + + public static String selectAll() { + StringBuffer selectAllColumn = new StringBuffer(); + selectAllColumn.append(COLUMN.DENTRY.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.PID.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.TID.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.FILE_PATH.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.FD.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.API_TYPE.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.START_TIME.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.END_TIME.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.ERRNO.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.FILE_SIZE.getName()); + return selectAllColumn.toString(); + } + + @Override + public boolean prepare(PreparedStatement prep, List rowData) { + boolean isPrepared = true; + + int columnsize = getColumnSize(); + if (columnsize != rowData.size()) { + isPrepared = false; + } else { + try { + prep.setLong(1, (Long)(rowData.get(COLUMN.DENTRY.getValue()))); + prep.setInt(2, (Integer)(rowData.get(COLUMN.PID.getValue()))); + prep.setInt(3, (Integer)(rowData.get(COLUMN.TID.getValue()))); + prep.setString(4, (String)(rowData.get(COLUMN.FILE_PATH.getValue()))); + prep.setLong(5, (Long)(rowData.get(COLUMN.FD.getValue()))); + prep.setInt(6, (Integer)(rowData.get(COLUMN.API_TYPE.getValue()))); + prep.setLong(7, (Long)(rowData.get(COLUMN.START_TIME.getValue()))); + prep.setLong(8, (Long)(rowData.get(COLUMN.END_TIME.getValue()))); + prep.setLong(9, (Long)(rowData.get(COLUMN.ERRNO.getValue()))); + prep.setLong(10, (Long)(rowData.get(COLUMN.FILE_SIZE.getValue()))); + } catch (SQLException e) { + e.printStackTrace(); + isPrepared = false; + } + } + return isPrepared; + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileApiDB.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileApiDB.java new file mode 100644 index 0000000..1f29023 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileApiDB.java @@ -0,0 +1,292 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran Lim + * Juyoung Kim + * + * 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.file.data; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.database.DBColumn; +import org.tizen.dynamicanalyzer.database.DBConstants; +import org.tizen.dynamicanalyzer.database.DBTable; +import org.tizen.dynamicanalyzer.database.SqlConnectionManager; +import org.tizen.dynamicanalyzer.nl.FilePageLabels; +import org.tizen.dynamicanalyzer.ui.file.data.FileAccessDB.COLUMN; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; + +public class FileApiDB extends DBTable { + private static final String TABLE_NAME = FilePageLabels.FILE_API_DB; + + public static enum COLUMN { + SEQ(0, "seq"), + DENTRY(1, "dentry"), + FILE_PATH(2, "filePath"), + PID(3, "pid"), + TID(4, "tid"), + FD(5, "fd"), + API_TYPE(6, "apiType"), + EVENT_TIME(7, "eventTime"), + API_NAME(8, "apiName"), + ERRNO(9, "errNo"), + IO_SIZE(10, "ioSize"), + FILE_SIZE(11, "fileSize"), + RETURN_VALUE(12, "returnValue"), + ARGS(13, "args"), + TARGET(14, "target"); + + private final int value; + private final String name; + + private COLUMN(int value, String name) { + this.value = value; + this.name = name; + } + + public int getValue() { + return value; + } + + public String getName() { + return name; + } + } + + @Override + public String getTableName() { + return TABLE_NAME; + } + + public FileApiDB() { + addColumn(new DBColumn(COLUMN.SEQ.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.DENTRY.getName(), DBConstants.NOT_NULL, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.FILE_PATH.getName(), DBConstants.NOT_NULL, DBConstants.BIG_TEXT)); + addColumn(new DBColumn(COLUMN.PID.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.TID.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.FD.getName(), DBConstants.EMPTY, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.API_TYPE.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.EVENT_TIME.getName(), DBConstants.NOT_NULL, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.API_NAME.getName(), DBConstants.EMPTY, DBConstants.BIG_TEXT)); + addColumn(new DBColumn(COLUMN.ERRNO.getName(), DBConstants.EMPTY, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.IO_SIZE.getName(), DBConstants.EMPTY, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.FILE_SIZE.getName(), DBConstants.EMPTY, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.RETURN_VALUE.getName(), DBConstants.EMPTY, DBConstants.BIG_TEXT)); + addColumn(new DBColumn(COLUMN.ARGS.getName(), DBConstants.EMPTY, DBConstants.BIG_TEXT)); + addColumn(new DBColumn(COLUMN.TARGET.getName(), DBConstants.NOT_NULL, DBConstants.BOOLEAN)); + } + + private static final String selectAllColumn = selectAll(); + private static final String SELECT_API_SERIES = "select " + + selectAllColumn + +" from " + + TABLE_NAME + " where %s <= " + + COLUMN.EVENT_TIME.getName() + " and " + + COLUMN.EVENT_TIME.getName() + + " <= %s" + " and " + + COLUMN.TARGET.getName() + " = true"; + + private static final String SELECT_APIS_FOR_CHILD = "select " + + selectAllColumn + +" from " + + TABLE_NAME + " where " + + COLUMN.DENTRY.getName() + " = '%d'" + " and " + + COLUMN.PID.getName() + " = '%d'" + " and " + + COLUMN.TID.getName() + " = '%d'" + " and " + + COLUMN.TARGET.getName() + " = 'true'"; + + private static final String SELECT_APIS_FOR_PARENT= "select " + + selectAllColumn + + " from " + + TABLE_NAME + " where " + + COLUMN.DENTRY.getName() + " = '%d'" + " and " + + COLUMN.TARGET.getName() + " = 'true'"; + + private static final String SELECT_FILE_EVENT_BY_SEQ = "select " + + selectAllColumn + + " from " + + TABLE_NAME + " where " + + COLUMN.SEQ.getName() + " = '%d'"+ " and " + + COLUMN.TARGET.getName() + " = 'true'"; + + private static final String SELECT_FAILED_APIS_FOR_CHAILD = "select " + + selectAllColumn + + " from " + + TABLE_NAME + " where " + + COLUMN.DENTRY.getName() + " = '%d'" + " and " + + COLUMN.PID.getName() + " = '%d'" + " and " + + COLUMN.TID.getName() + " = '%d'" + " and " + + COLUMN.ERRNO.getName() + " != '0'" + " and " + + COLUMN.TARGET.getName() + " = 'true'"; + + private static final String SELECT_FAILED_APIS_FOR_PARENT = "select " + + selectAllColumn + + " from " + + TABLE_NAME + " where " + + COLUMN.DENTRY.getName() + " = '%d'" + " and " + + COLUMN.ERRNO.getName() + " != '0'" + " and " + + COLUMN.TARGET.getName() + " = 'true'"; + + public void insert(List> insertData) { + insertData(insertData); + } + + // for updating api series chart + public List selectAPISeries(double visibleStartTime, + double visibleEndTime) { + double selectStartTime = visibleStartTime * TimelineConstants.MEGA_DOUBLE; + double selectEndTime = visibleEndTime * TimelineConstants.MEGA_DOUBLE; + + String query = String.format(SELECT_API_SERIES, selectStartTime, selectEndTime); + + List> result = SqlConnectionManager.executeQuery(query); + if (null == result || result.size() == 0 || result.get(0).size() == 0) { + return null; + } + List apiList = new ArrayList(); + for (List data : result) { + apiList.add(new FileEvent(data)); + } + return apiList; + } + + // for updating api table view + public List selectAPITable(long dentry, int pid, int tid, + boolean isParentChart) { + String query = String.format(SELECT_APIS_FOR_CHILD, dentry, pid, tid); + if (isParentChart) { + query = String + .format(SELECT_APIS_FOR_PARENT, dentry); + } + List> result = SqlConnectionManager.executeQuery(query); + if (null == result || result.size() == 0 || result.get(0).size() == 0) { + return null; + } + List apiList = new ArrayList(); + for (List data : result) { + apiList.add(new FileEvent(data)); + } + return apiList; + } + + public List selectFailedAPI(long dentry, int pid, int tid, + boolean isParentChart) { + String query = String.format(SELECT_FAILED_APIS_FOR_CHAILD, dentry, pid, tid); + if (isParentChart) { + query = String + .format(SELECT_FAILED_APIS_FOR_PARENT, dentry); + } + List> result = SqlConnectionManager.executeQuery(query); + if (null == result || result.size() == 0 || result.get(0).size() == 0) { + return null; + } + List apiList = new ArrayList(); + for (List data : result) { + apiList.add(new FileEvent(data)); + } + return apiList; + } + + public List selectFileEventBySeq(long seq) { + String query = String.format(SELECT_FILE_EVENT_BY_SEQ, seq); + List> result = SqlConnectionManager.executeQuery(query); + if (null == result || result.size() == 0 || result.get(0).size() == 0) { + return null; + } + List apiList = new ArrayList(); + for (List data : result) { + apiList.add(new FileEvent(data)); + } + return apiList; + } + + public static String selectAll() { + StringBuffer selectAllColumn = new StringBuffer(); + selectAllColumn.append(COLUMN.SEQ.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.DENTRY.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.FILE_PATH.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.PID.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.TID.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.FD.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.API_TYPE.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.EVENT_TIME.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.API_NAME.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.ERRNO.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.IO_SIZE.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.FILE_SIZE.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.RETURN_VALUE.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.ARGS.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.TARGET.getName()); + return selectAllColumn.toString(); + } + + @Override + public boolean prepare(PreparedStatement prep, List rowData) { + boolean isPrepared = true; + + int columnsize = getColumnSize(); + if (columnsize != rowData.size()) { + isPrepared = false; + } else { + try { + prep.setInt(1, (Integer)(rowData.get(COLUMN.SEQ.getValue()))); + prep.setLong(2, (Long)(rowData.get(COLUMN.DENTRY.getValue()))); + prep.setString(3, (String)(rowData.get(COLUMN.FILE_PATH.getValue()))); + prep.setInt(4, (Integer)(rowData.get(COLUMN.PID.getValue()))); + prep.setInt(5, (Integer)(rowData.get(COLUMN.TID.getValue()))); + prep.setLong(6, (Long)(rowData.get(COLUMN.FD.getValue()))); + prep.setInt(7, (Integer)(rowData.get(COLUMN.API_TYPE.getValue()))); + prep.setLong(8, (Long)(rowData.get(COLUMN.EVENT_TIME.getValue()))); + prep.setString(9, (String)(rowData.get(COLUMN.API_NAME.getValue()))); + prep.setLong(10, (Long)(rowData.get(COLUMN.ERRNO.getValue()))); + prep.setLong(11, (Long)(rowData.get(COLUMN.IO_SIZE.getValue()))); + prep.setLong(12, (Long)(rowData.get(COLUMN.FILE_SIZE.getValue()))); + prep.setString(13, (String)(rowData.get(COLUMN.RETURN_VALUE.getValue()))); + prep.setString(14, (String)(rowData.get(COLUMN.ARGS.getValue()))); + prep.setBoolean(15, (Boolean)(rowData.get(COLUMN.TARGET.getValue()))); + } catch (SQLException e) { + e.printStackTrace(); + isPrepared = false; + } + } + return isPrepared; + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileStatusDB.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileStatusDB.java new file mode 100644 index 0000000..dd3283c --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/data/FileStatusDB.java @@ -0,0 +1,166 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran Lim + * Juyoung Kim + * + * 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.file.data; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.database.DBColumn; +import org.tizen.dynamicanalyzer.database.DBConstants; +import org.tizen.dynamicanalyzer.database.DBTable; +import org.tizen.dynamicanalyzer.database.SqlConnectionManager; +import org.tizen.dynamicanalyzer.nl.FilePageLabels; +import org.tizen.dynamicanalyzer.ui.file.data.FileAccessDB.COLUMN; +import org.tizen.dynamicanalyzer.ui.file.model.FileAccess; +import org.tizen.dynamicanalyzer.ui.file.model.FileStatus; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; + +// open, close +public class FileStatusDB extends DBTable { + private static final String TABLE_NAME = FilePageLabels.FILE_STATUS_DB; + + public static enum COLUMN { + DENTRY(0, "dentry"), + PID(1, "pid"), + TID(2, "tid"), + FILE_PATH(3, "filePath"), + FD(4, "FD"), + API_TYPE(5, "apiType"), + EVENT_TIME(6, "eventTime"), + ERRNO(7, "errNo"); + + private final int value; + private final String name; + private COLUMN(int value, String name) { + this.value = value; + this.name = name; + } + + public int getValue() { + return value; + } + + public String getName() { + return name; + } + } + + public FileStatusDB() { + addColumn(new DBColumn(COLUMN.DENTRY.getName(), DBConstants.NOT_NULL, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.PID.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.TID.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.FILE_PATH.getName(), DBConstants.NOT_NULL, DBConstants.BIG_TEXT)); + addColumn(new DBColumn(COLUMN.FD.getName(), DBConstants.EMPTY, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.API_TYPE.getName(), DBConstants.NOT_NULL, DBConstants.INTEGER)); + addColumn(new DBColumn(COLUMN.EVENT_TIME.getName(), DBConstants.NOT_NULL, DBConstants.LONG)); + addColumn(new DBColumn(COLUMN.ERRNO.getName(), DBConstants.NOT_NULL, DBConstants.LONG)); + } + + @Override + public String getTableName() { + return TABLE_NAME; + } + + private static final String selectAll = selectAll(); + private static final String SELECT_QUERY = "select " + + selectAll + + " from " + TABLE_NAME; //$NON-NLS-1$ + + public void insert(FileStatus insertData) { + List> insertDataList = new ArrayList>(); + insertDataList.add(insertData.getDBData()); + insertData(insertDataList); + } + + public List select(double visibleStartTime, + double visibleEndTime) { + double selectStartTime = visibleStartTime + * TimelineConstants.MEGA_DOUBLE; + double selectEndTime = visibleEndTime * TimelineConstants.MEGA_DOUBLE; + + String query = String.format(SELECT_QUERY, selectStartTime, + selectEndTime); + + List> result = SqlConnectionManager.executeQuery(query); + if (null == result || result.size() == 0 || result.get(0).size() == 0) { + return null; + } + + List statusList = new ArrayList(); + for (List data : result) { + statusList.add(new FileStatus(data)); + } + return statusList; + } + + public static String selectAll() { + StringBuffer selectAllColumn = new StringBuffer(); + selectAllColumn.append(COLUMN.DENTRY.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.PID.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.TID.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.FILE_PATH.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.FD.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.API_TYPE.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.EVENT_TIME.getName()); + selectAllColumn.append(","); + selectAllColumn.append(COLUMN.ERRNO.getName()); + return selectAllColumn.toString(); + } + + @Override + public boolean prepare(PreparedStatement prep, List rowData) { + boolean isPrepared = true; + + int columnsize = getColumnSize(); + if (columnsize != rowData.size()) { + isPrepared = false; + } else { + try { + prep.setLong(1, (Long)(rowData.get(COLUMN.DENTRY.getValue()))); + prep.setInt(2, (Integer)(rowData.get(COLUMN.PID.getValue()))); + prep.setInt(3, (Integer)(rowData.get(COLUMN.TID.getValue()))); + prep.setString(4, (String)(rowData.get(COLUMN.FILE_PATH.getValue()))); + prep.setLong(5, (Long)(rowData.get(COLUMN.FD.getValue()))); + prep.setInt(6, (Integer)(rowData.get(COLUMN.API_TYPE.getValue()))); + prep.setLong(7, (Long)(rowData.get(COLUMN.EVENT_TIME.getValue()))); + prep.setLong(8, (Long)(rowData.get(COLUMN.ERRNO.getValue()))); + } catch (SQLException e) { + e.printStackTrace(); + isPrepared = false; + } + } + return isPrepared; + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileChartDataMaker.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileChartDataMaker.java new file mode 100644 index 0000000..63a7b92 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileChartDataMaker.java @@ -0,0 +1,368 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran Lim + * Juyoung Kim + * + * 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.file.manager; + + +import java.util.ArrayList; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.common.path.PathManager; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; +import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; +import org.tizen.dynamicanalyzer.nl.ConfigureLabels; +import org.tizen.dynamicanalyzer.resources.ImageResources; +import org.tizen.dynamicanalyzer.swap.model.data.FileData; +import org.tizen.dynamicanalyzer.swap.model.data.LogData; +import org.tizen.dynamicanalyzer.ui.file.data.FileAccessDB; +import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB; +import org.tizen.dynamicanalyzer.ui.file.data.FileStatusDB; +import org.tizen.dynamicanalyzer.ui.file.model.FileAccess; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; +import org.tizen.dynamicanalyzer.ui.file.model.FileStatus; +import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkAPIType; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSeriesType; +import org.tizen.dynamicanalyzer.ui.summary.failed.FailedChecker; +import org.tizen.dynamicanalyzer.ui.summary.failed.FailedData; +import org.tizen.dynamicanalyzer.ui.summary.leaks.LeakDetector; +import org.tizen.dynamicanalyzer.ui.summary.warning.WarningChecker; +import org.tizen.dynamicanalyzer.ui.timeline.chart.FileChart; +import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; +import org.tizen.dynamicanalyzer.ui.toolbar.configuration.ConfigurationDialogDataManager; +import org.tizen.dynamicanalyzer.util.DALogger; +import org.tizen.dynamicanalyzer.util.WorkbenchUtil; +import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard; +import org.tizen.dynamicanalyzer.widgets.da.base.DADialog; + +public class FileChartDataMaker { + private static final DALogger DA_LOG = DALogger.getInstance(); + + private FailedChecker failedChecker = null; + private WarningChecker warningChecker = null; + private int timeLineFileChartFDCount = 0; + + private List fileStatusList = new ArrayList(); + private List fileAccessList = new ArrayList(); + private Map fileAccessorMap = new HashMap(); + + private Map fileReadingCount = new HashMap(); + private Map fileWritingCount = new HashMap(); + private Map isFileLocking = new HashMap(); + + private Queue> queue = new ConcurrentLinkedQueue>(); + + public FileChartDataMaker(FailedChecker failedChecker, + LeakDetector leakDetector, WarningChecker warningChecker) { + this.failedChecker = failedChecker; + this.warningChecker = warningChecker; + } + + public void clear(){ + fileStatusList.clear(); + fileAccessList.clear(); + fileAccessorMap.clear(); + fileReadingCount.clear(); + fileWritingCount.clear(); + isFileLocking.clear(); + } + + public void makeData(List inputs) { + if (!AnalyzerManager.isRunning()) { + return; + } + + List fileEventQueue = new ArrayList(); + + FileChart timeLineFileChart = FileChart.getInstance(); + int size = inputs.size(); + FileEvent event = null; + String key = null; + + ArrayList> fileApiList = new ArrayList>(); + for (int i = 0; i < size; i++) { + FileData input = (FileData) inputs.get(i); + if (ConfigurationDialogDataManager.getInstance() + .getfeatureValue( + ConfigureLabels.INCLUDE_INSIDE_CALL_FILE) == 0) { + if (input.isInternal()) { + continue; + } + } + if (isPrintLog(input) || isOpenMainLog(input)) { + continue; + } + int seqNum = input.getSeq(); + // TODO get dentry + long dentry = 50000; + int pid = input.getPid(); + int tid = input.getTid(); + String filePath = input.getFilePath(); + long fd = input.getFdValue(); + int apiType = input.getFdApiType(); + long eventTime = input.getTime(); ; + String apiName = input.getApiName(); + long errNo = input.getErrno(); + long fileSize = input.getFileSize(); + String arg = input.getArgs(); + String returnVal = input.getReturn(); + + DA_LOG.info("seqNum:" + seqNum); + DA_LOG.info("apiName:" + apiName); + DA_LOG.info("errNo:" + errNo); + + // check error + if (errNo != 0) { + FailedData failedData = new FailedData(input); + this.failedChecker.getFailedList().add(failedData); + } else if (apiName.equals("fdopen")) { //$NON-NLS-1$ + DA_LOG.debug("fdopen"); + continue; + } + + event = new FileEvent(seqNum, dentry, filePath, pid, tid, fd, + apiType, apiName, eventTime, fileSize, arg, returnVal, errNo, true); + key = createKey(pid, tid); + + // check fileAccessList, fileStatusList, fileAccessorMap size + checkHeapMemory(); + + switch(apiType){ + case LogCenterConstants.FD_API_TYPE_OPEN: + if (errNo == 0) { + timeLineFileChartFDCount++; + timeLineFileChart.setFDCount(1, eventTime); + addFileAccessor(key, event.getDentry()); + addStatusData(new FileStatus(dentry, pid, tid, filePath, apiType, eventTime, errNo)); + } + break; + case LogCenterConstants.FD_API_TYPE_CLOSE: + if (errNo == 0) { + timeLineFileChartFDCount--; + if (timeLineFileChartFDCount >= 0) { + timeLineFileChart.setFDCount(-1, eventTime); + } else { + timeLineFileChartFDCount = 0; + } + addStatusData(new FileStatus(dentry, pid, tid, filePath, apiType, eventTime, errNo)); + } + break; + case LogCenterConstants.FD_API_TYPE_READ_START: + FileAccess readAccess = new FileAccess(dentry, filePath, pid, tid, apiType, eventTime); + addReadingCount(dentry, readAccess); + addStartAccessData(readAccess); + break; + case LogCenterConstants.FD_API_TYPE_READ_END: + timeLineFileChart.setReadByte((int) fileSize, eventTime); + deleteReadingCount(dentry); + addEndAccessData(dentry, pid, tid, filePath, eventTime, fileSize, + LogCenterConstants.FD_API_TYPE_READ_START); + break; + case LogCenterConstants.FD_API_TYPE_WRITE_START: + FileAccess writeAccess = new FileAccess(dentry, filePath, pid, tid, apiType, eventTime); + addWritingCount(dentry, writeAccess); + addStartAccessData(writeAccess); + break; + case LogCenterConstants.FD_API_TYPE_WRITE_END: + timeLineFileChart.setWriteByte((int) fileSize, eventTime); + deleteWritingCount(dentry); + addEndAccessData(dentry, pid, tid, filePath, eventTime, fileSize, + LogCenterConstants.FD_API_TYPE_WRITE_START); + break; + case LogCenterConstants.FD_API_TYPE_LOCK_START: + isFileLocking.put(dentry, true); + addStartAccessData(new FileAccess(dentry, filePath, pid, tid, apiType, eventTime)); + break; + case LogCenterConstants.FD_API_TYPE_LOCK_END: + isFileLocking.put(dentry, false); + addEndAccessData(dentry, pid, tid, filePath, eventTime, fileSize, + LogCenterConstants.FD_API_TYPE_WRITE_START); + break; + } + fileEventQueue.add(event); + + } + if(fileEventQueue.size() > 0) { + queue.add(fileEventQueue); + for(FileEvent data : fileEventQueue) { + fileApiList.add(data.getDBData()); + } + FileChartManager.getInstance().getApiDB().insert((List>)fileApiList); + } + } + + public void addStatusData(FileStatus data) { + fileStatusList.add(data); + FileChartManager.getInstance().getStatusDB().insert(data); + } + + public void addStartAccessData(FileAccess data) { + fileAccessList.add(data); + } + + public void addEndAccessData(long dentry, int pid, int tid, String filePath, + long endTime, long fileSize, int apiType) { + for (int i = 0; i < fileAccessList.size(); i++) { + FileAccess data = fileAccessList.get(i); + if (data.getDentry() == dentry + && data.getFilePath().equalsIgnoreCase(filePath) + && data.getPid() == pid + && data.getTid() == tid + && data.getApiType() == apiType + && data.getEndTime() <= 0){ + data.setEndTime(endTime); + data.setFileSize(fileSize); + FileChartManager.getInstance().getAccessDB().insert(data); + break; + } + } + } + + private String createKey(int pid, int tid) { + StringBuffer key = new StringBuffer(); + key.append(pid); + key.append(":"); + key.append(tid); + + return key.toString(); + } + + private void addFileAccessor(String key, long value) { + if(fileAccessorMap.get(key) == null) { + fileAccessorMap.put(key, value); + } + } + + private void addReadingCount(long key, FileAccess readAccess) { + if(fileReadingCount.get(key) != null ) { + if(fileReadingCount.get(key) > 0) { + int count = fileReadingCount.get(key); + fileReadingCount.put(key, count++); + readAccess.setAlreadyReading(true); + } + } else { + fileReadingCount.put(key, 1); + } + } + + private void deleteReadingCount(long key) { + int count = fileReadingCount.get(key); + if(count > 0) { + fileReadingCount.put(key, count--); + } + } + + private void addWritingCount(long key, FileAccess writeAccess) { + if(fileWritingCount.get(key) != null ) { + if(fileWritingCount.get(key) > 0) { + int count = fileWritingCount.get(key); + fileWritingCount.put(key, count++); + } + } else { + fileWritingCount.put(key, 1); + } + } + + private void deleteWritingCount(long key) { + int count = fileWritingCount.get(key); + if(count > 0) { + fileWritingCount.put(key, count--); + } + } + + public List getFileEventList() { + return queue.poll(); + } + + public List getFileAccessList() { + return fileAccessList; + } + + public List getFileStatusList() { + return fileStatusList; + } + + private void checkHeapMemory() { + if ( (fileAccessList.size() > 10000 + || fileStatusList.size() > 100000) + || fileAccessorMap.size() > 100000) { + ToolbarArea.getInstance().stopTrace(); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + final Shell shell = WorkbenchUtil.getWorkbenchWindow() + .getShell(); + DADialog dialog = new DADialog(shell, SWT.NONE, 550, 153); + dialog.setIcon(ImageResources.DIALOG_WARNING_ICON); + dialog.setMessage(AnalyzerLabels.HEAP_MEMORY_WARNING_PRE + + PathManager.DA_INSTALL_PATH + + AnalyzerLabels.HEAP_MEMORY_WARNING_POST); + dialog.open(); + } + }); + } + } + + private boolean isPrintLog(FileData input) { + String apiName = input.getApiName(); + if (apiName.contains("print")) {//$NON-NLS-1$ + return true; + } + return false; + } + + private boolean isOpenMainLog(FileData input) { + String filePath = input.getFilePath(); + if (filePath.contains(CommonConstants.SLASH)) { + String[] splitApiFilePath = filePath.split(CommonConstants.SLASH); + String strApiFilePath = new String( + splitApiFilePath[splitApiFilePath.length - 1].trim()); + if (AnalyzerManager.getProject().getPkgId().equals(strApiFilePath)) { + return true; + } + } + return false; + } + + public void setFileAccessList(List fileAccessList) { + this.fileAccessList = fileAccessList; + } + + public void setFileStatusList(List fileStatusList) { + this.fileStatusList = fileStatusList; + } + +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileChartManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileChartManager.java new file mode 100644 index 0000000..dc39b4a --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileChartManager.java @@ -0,0 +1,158 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran Lim + * Juyoung Kim + * + * 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.file.manager; + +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants; +import org.tizen.dynamicanalyzer.swap.logparser.LogPackage; +import org.tizen.dynamicanalyzer.swap.logparser.Logs; +import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager; +import org.tizen.dynamicanalyzer.swap.model.data.LogData; +import org.tizen.dynamicanalyzer.swap.model.data.ProfileData; +import org.tizen.dynamicanalyzer.ui.file.FileChartData; +import org.tizen.dynamicanalyzer.ui.file.data.FileAccessDB; +import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB; +import org.tizen.dynamicanalyzer.ui.file.data.FileStatusDB; +import org.tizen.dynamicanalyzer.ui.file.manager.FileChartDataMaker; +import org.tizen.dynamicanalyzer.ui.file.model.FileAccess; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; +import org.tizen.dynamicanalyzer.ui.file.model.FileStatus; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSeriesType; +import org.tizen.dynamicanalyzer.util.DALogger; + + +public class FileChartManager extends PageDataManager { + private static final DALogger DA_LOG = DALogger.getInstance(); + + private static FileChartManager instance = null; + private static FileChartDataMaker dataMaker = null; + + private FileAccessDB accessDB = null; + private FileApiDB apiDB = null; + private FileStatusDB statusDB = null; + + private List eventList = new ArrayList(); + private List selectedTableAPIList = new ArrayList(); + + private FileChartManager() { + dataMaker = new FileChartDataMaker( + AnalyzerManager.getFailedChecker(), + AnalyzerManager.getLeakDetector(), + AnalyzerManager.getWarningChecker()); + + initDB(); + } + + public synchronized static FileChartManager getInstance() { + if (null == instance) { + instance = new FileChartManager(); + } + return instance; + } + + public void initDB() { + accessDB = new FileAccessDB(); + addDBTable(accessDB); + apiDB = new FileApiDB(); + addDBTable(apiDB); + statusDB = new FileStatusDB(); + addDBTable(statusDB); + } + + public void clear() { + accessDB = null; + apiDB = null; + statusDB = null; + eventList = new ArrayList(); + selectedTableAPIList = new ArrayList(); + } + + public FileAccessDB getAccessDB(){ + return accessDB; + } + + public FileApiDB getApiDB() { + return apiDB; + } + + public FileStatusDB getStatusDB() { + return statusDB; + } + + /*** make network data thread ***/ + @Override + public void run() { + while (!AnalyzerManager.isExit()) { + LogPackage pack = pollPack(); + if (pack == null) // stop thread + break; + + // TODO Change to get data from syscalls message and probe message + Logs logs = pack.getLogs(DataChannelConstants.MSG_PROBE_FILE); + if (null != logs && logs.getRawLogs().size() != 0) { + List inputs = logs.getLogs(); + dataMaker.makeData(inputs); + } + + } + DA_LOG.info(getName() + " thread end!!"); + } + + public void openProcess() { + // TODO + } + + @Override + protected void onThreadStop() { + // TODO + } + + public FileChartDataMaker getFileChartDataMaker() { + return dataMaker; + } + + public void addFileEventQueue(FileEvent data){ + eventList.add(data); + } + + public List getFileEventQueue() { + return eventList; + } + + public List getSelectedTableAPIList() { + return selectedTableAPIList; + } + + public void setSelectedTableAPIList( + List selectedTableAPIList) { + this.selectedTableAPIList = selectedTableAPIList; + } + +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileAccess.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileAccess.java new file mode 100644 index 0000000..ce5ac1a --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileAccess.java @@ -0,0 +1,203 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran Lim + * Juyoung Kim + * + * 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.file.model; + +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.ui.file.data.FileAccessDB; + +public class FileAccess { + private long dentry = -1; + private String filePath = null; + private int pid = -1; + private int tid = -1; + private long fd = -1; + private int apiType = -1; // only read, write, lock event + private long startTime = -1; + private long endTime = -1; + private long erroNo = 0; + private long fileSize = -1; + + private boolean isAlreadyReading = false; + private boolean isAlreadyWriting = false; + private boolean isAlreadyLocking = false; + + public FileAccess(long dentry, String filePath, int pid, int tid, + int apiType, long startTime) { + this.dentry = dentry; + this.filePath = filePath; + this.pid = pid; + this.tid = tid; + this.apiType = apiType; + this.startTime = startTime; + } + + public FileAccess(long dentry, String filePath, int pid, int tid, long fd, + int apiType, long startTime) { + this.dentry = dentry; + this.filePath = filePath; + this.pid = pid; + this.tid = tid; + this.fd = fd; + this.apiType = apiType; + this.startTime = startTime; + } + + public List getDBData() { + List data = new ArrayList(); + data.add(new Long(this.dentry)); + data.add(new Integer(this.pid)); + data.add(new Integer(this.tid)); + data.add(this.filePath); + data.add(new Long(this.fd)); + data.add(new Integer(this.apiType)); + data.add(new Long(this.startTime)); + data.add(new Long(this.endTime)); + data.add(new Long(this.erroNo)); + data.add(new Long(this.fileSize)); + return data; + } + + public FileAccess(List data) { + this.dentry = (Long)data.get(FileAccessDB.COLUMN.DENTRY.getValue()); + this.pid = (Integer)data.get(FileAccessDB.COLUMN.PID.getValue()); + this.tid = (Integer)data.get(FileAccessDB.COLUMN.TID.getValue()); + this.filePath = (String)data.get(FileAccessDB.COLUMN.FILE_PATH.getValue()); + this.fd = (Long)data.get(FileAccessDB.COLUMN.FD.getValue()); + this.apiType = (Integer)data.get(FileAccessDB.COLUMN.API_TYPE.getValue()); + this.startTime = (Long)data.get(FileAccessDB.COLUMN.START_TIME.getValue()); + this.endTime = (Long)data.get(FileAccessDB.COLUMN.END_TIME.getValue()); + this.erroNo = (Long)data.get(FileAccessDB.COLUMN.ERRNO.getValue()); + this.fileSize = (Long)data.get(FileAccessDB.COLUMN.FILE_SIZE.getValue()); + } + + public long getDentry() { + return dentry; + } + + public void setDentry(long dentry) { + this.dentry = dentry; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public int getTid() { + return tid; + } + + public void setTid(int tid) { + this.tid = tid; + } + + public long getFd() { + return fd; + } + + public void setFd(long fd) { + this.fd = fd; + } + + public int getApiType() { + return apiType; + } + + public void setApiType(int apiType) { + this.apiType = apiType; + } + + public long getStartTime() { + return startTime; + } + + public void setStartTime(long startTime) { + this.startTime = startTime; + } + + public long getEndTime() { + return endTime; + } + + public void setEndTime(long endTime) { + this.endTime = endTime; + } + + public boolean isAlreadyReading() { + return isAlreadyReading; + } + + public void setAlreadyReading(boolean isAlreadyReading) { + this.isAlreadyReading = isAlreadyReading; + } + + public boolean isAlreadyWriting() { + return isAlreadyWriting; + } + + public void setAlreadyWriting(boolean isAlreadyWriting) { + this.isAlreadyWriting = isAlreadyWriting; + } + + public boolean isAlreadyLocking() { + return isAlreadyLocking; + } + + public void setAlreadyLocking(boolean isAlreadyLocking) { + this.isAlreadyLocking = isAlreadyLocking; + } + + public long getErroNo() { + return erroNo; + } + + public void setErroNo(long erroNo) { + this.erroNo = erroNo; + } + + public long getFileSize() { + return fileSize; + } + + public void setFileSize(long fileSize) { + this.fileSize = fileSize; + } + +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileEvent.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileEvent.java new file mode 100644 index 0000000..dd40136 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileEvent.java @@ -0,0 +1,275 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.model; + +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; +import org.tizen.dynamicanalyzer.swap.model.data.FileData; +import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; + +// file log data +public class FileEvent extends FileData{ + private int seqNo = -1; + private long dentry = -1; + private String filePath = null; + private int pid = -1; + private int tid = -1; + private long fd = -1; + private int apiType = -1; + private long eventTime = -1; + private String apiName = null; + private long errNo = -1; + private long ioSize =-1; + private long fileSize = -1; + private String returnVal = null; + private String args = null; + private boolean target = true; + + private long readSize = -1; + private long writeSize = -1; + + public FileEvent(int seqNo, String filePath, int pid, int tid, + long fd, int apiType, long eventTime, long fileSize) { + this.filePath = filePath; + this.pid = pid; + this.tid = tid; + this.fd = fd; + this.apiType = apiType; + this.eventTime = eventTime; + this.fileSize = fileSize; + } + + public FileEvent(int seqNo, long dentry, String filePath, int pid, int tid, + long fd, int apiType, String apiName, long eventTime, long fileSize, + String args, String returnVal, long errNo, boolean target){ + this.seqNo = seqNo; + this.dentry = dentry; + this.filePath = filePath; + this.pid = pid; + this.tid = tid; + this.fd = fd; + this.apiType = apiType; + this.apiName = apiName; + this.eventTime = eventTime; + this.fileSize = fileSize; + this.args = args; + this.returnVal = returnVal; + this.errNo = errNo; + this.target = target; + } + + public FileEvent(List data) { + this.seqNo = (Integer)data.get(FileApiDB.COLUMN.SEQ.getValue()); + this.dentry = (Long)data.get(FileApiDB.COLUMN.DENTRY.getValue()); + this.filePath = (String)data.get(FileApiDB.COLUMN.FILE_PATH.getValue()); + this.pid = (Integer)data.get(FileApiDB.COLUMN.PID.getValue()); + this.tid = (Integer)data.get(FileApiDB.COLUMN.TID.getValue()); + this.fd = (Long)data.get(FileApiDB.COLUMN.FD.getValue()); + this.apiType = (Integer)data.get(FileApiDB.COLUMN.API_TYPE.getValue()); + this.apiName = (String)data.get(FileApiDB.COLUMN.API_NAME.getValue()); + this.eventTime = (Long)data.get(FileApiDB.COLUMN.EVENT_TIME.getValue()); + this.fileSize = (Long)data.get(FileApiDB.COLUMN.FILE_SIZE.getValue()); + this.returnVal = (String)data.get(FileApiDB.COLUMN.RETURN_VALUE.getValue()); + this.args = (String)data.get(FileApiDB.COLUMN.ARGS.getValue()); + this.errNo = (Long)data.get(FileApiDB.COLUMN.ERRNO.getValue()); + this.target = (Boolean)data.get(FileApiDB.COLUMN.TARGET.getValue()); + } + + public List getDBData() { + List data = new ArrayList(); + data.add(this.seqNo); + data.add(this.dentry); + data.add(this.filePath); + data.add(this.pid); + data.add(this.tid); + data.add(this.fd); + data.add(this.apiType); + data.add(this.eventTime); + data.add(this.apiName); + data.add(this.errNo); + data.add(this.ioSize); + data.add(this.fileSize); + data.add(this.returnVal); + data.add(this.args); + data.add(this.target); + return data; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getFileName() { + String[] splitPath = this.filePath.split("\\/"); //$NON-NLS-1$ + String fileName = new String(splitPath[splitPath.length - 1]); + return fileName; + } + + public long getDentry() { + return dentry; + } + + public void setDentry(long dentry) { + this.dentry = dentry; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public int getTid() { + return tid; + } + + public void setTid(int tid) { + this.tid = tid; + } + + public long getFd() { + return fd; + } + + public void setFd(long fd) { + this.fd = fd; + } + + public int getApiType() { + return apiType; + } + + public void setApiType(int apiType) { + this.apiType = apiType; + } + + public long getEventTime() { + return Math.round(eventTime); + } + + public void setEventTime(long eventTime) { + this.eventTime = eventTime; + } + + public long getTime() { + return Math.round(eventTime); + } + + public void setTime(long eventTime) { + this.eventTime = eventTime; + } + + public long getErrNo() { + return errNo; + } + + public void setErrNo(long errNo) { + this.errNo = errNo; + } + + public int getSeqNo() { + return seqNo; + } + + public void setSeqNo(int seqNo) { + this.seqNo = seqNo; + } + + public long getIoSize() { + return ioSize; + } + + public void setIoSize(long ioSize) { + this.ioSize = ioSize; + } + + public long getFileSize() { + return fileSize; + } + + public void setFileSize(long fileSize) { + this.fileSize = fileSize; + } + + public String getReturnVal() { + return returnVal; + } + + public void setReturnVal(String returnVal) { + this.returnVal = returnVal; + } + + public String getArgs() { + return args; + } + + public void setArgs(String args) { + this.args = args; + } + + public long getReadSize() { + return readSize; + } + + public void setReadSize(long readSize) { + this.readSize = readSize; + } + + public long getWriteSize() { + return writeSize; + } + + public void setWriteSize(long writeSize) { + this.writeSize = writeSize; + } + + public String getApiName() { + return apiName; + } + + public void setApiName(String apiName) { + this.apiName = apiName; + } + + public boolean isTarget() { + return target; + } + + public void setTarget(boolean target) { + this.target = target; + } + +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileSelectedData.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileSelectedData.java new file mode 100644 index 0000000..2785655 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileSelectedData.java @@ -0,0 +1,105 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.model; + +import org.tizen.dynamicanalyzer.swap.model.data.FileData; + +public class FileSelectedData { + private long dentry = -1; + private int pid = -1; + private int tid = -1; + private boolean isParentChart = false; + private String filePath = null; + private long fileSize = 0; + + public FileSelectedData(long dentry, int pid, int tid, boolean isParentChart) { + this.dentry = dentry; + this.pid = pid; + this.tid = tid; + this.isParentChart = isParentChart; + } + + public FileSelectedData(long dentry, int pid, int tid, + boolean isParentChart, String filePath, long fileSize) { + this.dentry = dentry; + this.pid = pid; + this.tid = tid; + this.isParentChart = isParentChart; + this.filePath = filePath; + this.fileSize = fileSize; + } + + public long getDentry() { + return dentry; + } + + public void setDentry(long dentry) { + this.dentry = dentry; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public int getTid() { + return tid; + } + + public void setTid(int tid) { + this.tid = tid; + } + + public boolean isParentChart() { + return isParentChart; + } + + public void setParentChart(boolean isParentChart) { + this.isParentChart = isParentChart; + } + + public String getFilePath(){ + return filePath; + } + + public String getFileName() { + String[] splitPath = this.filePath.split("\\/"); //$NON-NLS-1$ + String fileName = new String(splitPath[splitPath.length - 1]); + return fileName; + } + + public long getFileSize() { + return fileSize; + } + + public void getFileSize(long fileSize) { + this.fileSize = fileSize; + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileStatus.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileStatus.java new file mode 100644 index 0000000..4bb09bd --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/model/FileStatus.java @@ -0,0 +1,144 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.model; + +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.ui.file.data.FileAccessDB; +import org.tizen.dynamicanalyzer.ui.file.data.FileStatusDB; + +public class FileStatus { + private long dentry = -1; + private String filePath = null; + private int pid = -1; + private int tid = -1; + private long fd = -1; + private int apiType = -1; // only open, close event + private long eventTime = -1; + private long errNo = 0; + + public FileStatus(long dentry, int pid, int tid, String filePath, + int apiType, long eventTime, long errNo) { + this.dentry = dentry; + this.filePath = filePath; + this.pid = pid; + this.tid = tid; + this.apiType = apiType; + this.eventTime = eventTime; + this.errNo = errNo; + } + + public List getDBData() { + List data = new ArrayList(); + data.add(this.dentry); + data.add(this.pid); + data.add(this.tid); + data.add(this.filePath); + data.add(this.fd); + data.add(this.apiType); + data.add(this.eventTime); + data.add(this.errNo); + return data; + } + + public FileStatus(List data) { + this.dentry = (Long)data.get(FileStatusDB.COLUMN.DENTRY.getValue()); + this.pid = (Integer)data.get(FileStatusDB.COLUMN.PID.getValue()); + this.tid = (Integer)data.get(FileStatusDB.COLUMN.TID.getValue()); + this.filePath = (String)data.get(FileStatusDB.COLUMN.FILE_PATH.getValue()); + this.fd = (Long)data.get(FileStatusDB.COLUMN.FD.getValue()); + this.apiType = (Integer)data.get(FileStatusDB.COLUMN.API_TYPE.getValue()); + this.eventTime = (Long)data.get(FileStatusDB.COLUMN.EVENT_TIME.getValue()); + this.errNo = (Long)data.get(FileStatusDB.COLUMN.ERRNO.getValue()); + } + + public long getDentry() { + return dentry; + } + + public void setDentry(long dentry) { + this.dentry = dentry; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public int getTid() { + return tid; + } + + public void setTid(int tid) { + this.tid = tid; + } + + public long getFd() { + return fd; + } + + public void setFd(long fd) { + this.fd = fd; + } + + public int getApiType() { + return apiType; + } + + public long getEventTime() { + return eventTime; + } + + public void setEventTime(long eventTime) { + this.eventTime = eventTime; + } + + public void setApiType(int apiType) { + this.apiType = apiType; + } + + public void setErrNo(long errNo) { + this.errNo = errNo; + } + + public long getErrNo() { + return errNo; + } + +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileApiListTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileApiListTable.java new file mode 100644 index 0000000..fd02458 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileApiListTable.java @@ -0,0 +1,255 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.view; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.eclipse.nebula.widgets.grid.GridItem; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Composite; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.common.DASelectionData; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.error.ErrorCodeManager; +import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; +import org.tizen.dynamicanalyzer.model.TableInput; +import org.tizen.dynamicanalyzer.swap.model.data.FileData; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; +import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; +import org.tizen.dynamicanalyzer.ui.widgets.table.DAApiListTableComposite; +import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat; +import org.tizen.dynamicanalyzer.utils.Formatter; +import org.tizen.dynamicanalyzer.ui.file.FilePage; +import org.tizen.dynamicanalyzer.ui.file.manager.FileChartManager; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; + +public class FileApiListTable extends DAApiListTableComposite { + public FileApiListTable(Composite parent, int compStyle, int tableStyle) { + super(parent, compStyle, tableStyle); + table.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + + GridItem[] items = table.getSelection(); + if (null == items) { + return; + } + long startTime = 0; + long endTime = 0; + + DATableDataFormat dataFormat; + long itemTime; + for (int i = 0; i < items.length; i++) { + dataFormat = (DATableDataFormat) items[i].getData(); + itemTime = dataFormat.getLogData().getTime(); + if (0 == startTime) { + startTime = itemTime; + } + if (startTime > itemTime) { + startTime = itemTime; + } + if (endTime < itemTime) { + endTime = itemTime; + } + } + DASelectionData selData = new DASelectionData( + FilePage.apilistViewID, startTime, endTime, items, + table); + AnalyzerManager.getCurrentPage().updateView(selData); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + } + + @Override + protected List makeTableInput() { + FileApiListView view = (FileApiListView) AnalyzerManager + .getCurrentPage().getView(FilePage.apilistViewID); + + long rangeStartTime = view.getRangeStartTime(); + long rangeEndTime = view.getRangeEndTime(); + + HashMap findStartAPITableIndexHashMap = new HashMap(); + List removeTableIndex = new ArrayList(); + List input = new ArrayList(); + + List contents = FileChartManager.getInstance().getSelectedTableAPIList(); + if(contents == null) { + return null; + } + for (int i = 0; i < contents.size(); i++) { + FileEvent contentTemp = contents.get(i); + int selectedPid = ToolbarArea.getInstance().getSelectedPid(); + if (selectedPid != 0) { + if (selectedPid != contentTemp.getPid()) { + continue; + } + } + List contentText = new ArrayList(); + List contentData = new ArrayList(); + + Integer startLogIndex = 0; + int fdApiType = contentTemp.getApiType(); + + int seq = contentTemp.getSeqNo(); + contentText.add(0, Integer.toString(seq)); + contentData.add(Integer.toString(seq)); + long time = contentTemp.getEventTime(); + + boolean isExistStartTimeLog = false; + if (fdApiType == LogCenterConstants.FD_API_TYPE_READ_START + || fdApiType == LogCenterConstants.FD_API_TYPE_WRITE_START) { + String keString = contentTemp.getApiName() + + contentTemp.getPid() + contentTemp.getTid(); + findStartAPITableIndexHashMap.put(keString, i); + + } else if (fdApiType == LogCenterConstants.FD_API_TYPE_READ_END + || fdApiType == LogCenterConstants.FD_API_TYPE_WRITE_END) { + String keString = contentTemp.getApiName() + + contentTemp.getPid() + contentTemp.getTid(); + startLogIndex = findStartAPITableIndexHashMap.get(keString); + if (null != startLogIndex) { + contentText.add(input.get(startLogIndex.intValue()) + .getText().get(1)); // start time + contentData.add(input.get(startLogIndex.intValue()) + .getText().get(1)); + + long startTime = contents.get(startLogIndex.intValue()).getEventTime(); + String timeFormat = Formatter + .toTimeFormat(time - startTime); + String removeTimeFormat = timeFormat.replace( + "00:", CommonConstants.EMPTY);//$NON-NLS-1$ + + contentText.add(removeTimeFormat); // elapsed time + contentData.add(Long.toString(time - startTime)); + + isExistStartTimeLog = true; + removeTableIndex.add(startLogIndex.intValue()); + } else { + contentText.add(Formatter.toTimeFormat(contentTemp + .getEventTime())); // start// + contentData.add(Long.toString(contentTemp.getEventTime())); + contentText.add("00.000");//$NON-NLS-1$ + contentData.add("00.000");//$NON-NLS-1$ + } + } + + if (!isExistStartTimeLog) { + contentText.add(Formatter.toTimeFormat(time)); // start time + contentData.add(Long.toString(time)); + contentText.add("00.000");//$NON-NLS-1$ //elapsed time + contentData.add("00.000");//$NON-NLS-1$ + } + + contentText.add(Integer.toString(contentTemp.getPid())); + contentData.add(Integer.toString(contentTemp.getPid())); + + contentText.add(Integer.toString(contentTemp.getTid())); + contentData.add(Integer.toString(contentTemp.getTid())); + + contentText.add(contentTemp.getApiName()); + contentData.add(contentTemp.getApiName()); + + contentText.add(contentTemp.getArgs()); + contentData.add(contentTemp.getArgs()); + + contentText.add(contentTemp.getReturnVal()); + contentData.add(contentTemp.getReturnVal()); + + String errMsg = ErrorCodeManager.getInatance() + .getErrorCode(contentTemp.getErrNo()).name(); + if (null == errMsg) { + errMsg = "undefined error code"; //$NON-NLS-1$ + } + contentText.add(errMsg); + contentData.add(errMsg); + contentText.add(Long.toString(contentTemp.getFileSize())); + contentData.add(Long.toString(contentTemp.getFileSize())); + + DATableDataFormat tableData = new DATableDataFormat( + contentTemp.getSeqNo()); + tableData.setLogData(contentTemp); + tableData.getData().addAll(contentData); + TableInput tableInput = new TableInput(); + tableInput.setText(contentText); + tableInput.setData(tableData); + if (!errMsg.contains("SUCCESS")) {//$NON-NLS-1$ + tableInput.setFailed(true); + } + input.add(tableInput); + + if (time >= rangeStartTime && time <= rangeEndTime) { + tableInput.setInRange(true); + } + } + int removeCount = 0; + for (int index : removeTableIndex) { + int removeIndex = index - removeCount; + if (removeIndex > 0) { + input.remove(removeIndex); + removeCount++; + } + } + return input; + } + + protected void actionSetStartEnd(int type) { + GridItem item = table.getItem(mousePoint); + if (null != item) { + FileData data = (FileData) ((DATableDataFormat) item.getData()) + .getLogData(); + long time = data.getTime(); + double startTime = -1; + double endTime = -1; + + if (type == START_TIME) { + rangeDataManager.setMarkerStartTime(time); + startTime = time / TimelineConstants.MEGA_DOUBLE; + endTime = rangeDataManager.getMarkerEndTime() + / TimelineConstants.MEGA_DOUBLE; + + } else if (type == END_TIME) { + rangeDataManager.setMarkerEndTime(time); + endTime = time / TimelineConstants.MEGA_DOUBLE; + startTime = rangeDataManager.getMarkerStartTime() + / TimelineConstants.MEGA_DOUBLE; + } + + FileChartView chartview = (FileChartView) (AnalyzerManager + .getCurrentPage().getView(FilePage.chartViewID)); + + chartview.setRangeMarker(startTime, endTime); + } + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileApiListView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileApiListView.java new file mode 100644 index 0000000..4e05582 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileApiListView.java @@ -0,0 +1,199 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.view; + +import java.util.List; + +import org.eclipse.nebula.widgets.grid.Grid; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.tizen.dynamicanalyzer.common.AnalyzerConstants; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.common.DASelectionData; +import org.tizen.dynamicanalyzer.nl.FilePageLabels; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.swap.model.data.LogData; +import org.tizen.dynamicanalyzer.ui.file.FileChartData; +import org.tizen.dynamicanalyzer.ui.file.FilePage; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; +import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData; +import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSelectionType; +import org.tizen.dynamicanalyzer.ui.range.RangeDataManager; +import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; +import org.tizen.dynamicanalyzer.ui.widgets.table.TableColumnSizePackListener; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData; +import org.tizen.dynamicanalyzer.ui.file.manager.FileChartManager; + +public class FileApiListView extends DAViewComposite { + private long analysisStartTime = 0; + private long analysisEndTime = 0; + private int preSelectionPId = 1; + private long preAnalysisStartTime = 0; + private long preAnalysisEndTime = 0; + private boolean isChangedSelected = true; + private FileSelectedData selectedData = null; + + private String[] columnNames = { FilePageLabels.FILE_API_LIST_VIEW_INDEX, + FilePageLabels.FILE_API_LIST_VIEW_START_TIME, + FilePageLabels.FILE_API_LIST_VIEW_ELAPSED_TIME, + FilePageLabels.FILE_API_LIST_VIEW_PID, + FilePageLabels.FILE_API_LIST_VIEW_THREAD_ID, + FilePageLabels.FILE_API_LIST_VIEW_API, + FilePageLabels.FILE_API_LIST_VIEW_PARAMETER, + FilePageLabels.FILE_API_LIST_VIEW_RETURN, + FilePageLabels.FILE_API_LIST_VIEW_ERRNO }; + + private int[] columnSizes = { 40, 70, 100, 40, 40, 120, 250, 70, 100 }; + private int[] columnAlignment = { SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, + SWT.RIGHT, SWT.RIGHT, SWT.LEFT, SWT.LEFT, SWT.LEFT, SWT.LEFT }; + + int[] sortTypes = { AnalyzerConstants.SORT_TYPE_NUM, + AnalyzerConstants.SORT_TYPE_STRING, + AnalyzerConstants.SORT_TYPE_STRING, + AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM, + AnalyzerConstants.SORT_TYPE_STRING, + AnalyzerConstants.SORT_TYPE_STRING, + AnalyzerConstants.SORT_TYPE_STRING, + AnalyzerConstants.SORT_TYPE_STRING }; + + FileApiListTable tableComp = null; + FileChartManager manager = FileChartManager.getInstance(); + + public FileApiListView(Composite parent, int style) { + super(parent, style, true); + this.setLayout(new FillLayout()); + + setTitle(FilePageLabels.FILE_API_LIST_VIEW_TITLE); + + Composite contents = getContentArea(); + contents.setBackground(ColorResources.WINDOW_BG_COLOR); + contents.setLayout(new FillLayout()); + tableComp = new FileApiListTable(contents, SWT.NONE, SWT.MULTI + | SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); + tableComp.setSortTypes(sortTypes); + tableComp.setColumnAlignment(columnAlignment); + tableComp.setColumns(columnNames); + tableComp.setColumnSize(columnSizes); + tableComp.setTableName(FilePageLabels.FILE_API_LIST_VIEW_TITLE); + contents.addControlListener(new TableColumnSizePackListener(tableComp, + columnSizes)); + } + + @Override + public void updateView() { + if (null == tableComp || selectedData == null) { + return; + } + + long newAnalysisStartTime = 0; + long newAnalysisEndTime = 0; + + if (RangeDataManager.getInstance().isBeingAnalyzed()) { + newAnalysisStartTime = RangeDataManager.getInstance() + .getAnalysisStartTime(); + newAnalysisEndTime = RangeDataManager.getInstance() + .getAnalysisEndTime(); + } else { + newAnalysisStartTime = 0; + newAnalysisEndTime = 0; + } + + if (newAnalysisStartTime != analysisStartTime + || newAnalysisEndTime != analysisEndTime) { + analysisStartTime = newAnalysisStartTime; + analysisEndTime = newAnalysisEndTime; + tableComp.updateTable(); + return; + } + + int selectedPid = ToolbarArea.getInstance().getSelectedPid(); + if (preSelectionPId != -1 && preSelectionPId != selectedPid) { + tableComp.updateTable(); + } + preSelectionPId = selectedPid; + + List events = manager.getApiDB().selectAPITable( + selectedData.getDentry(), selectedData.getPid(), + selectedData.getTid(), selectedData.isParentChart()); + if (tableComp.getTable().getItemCount() > 0 + && events.size() != tableComp.getTable().getItemCount()) { + manager.setSelectedTableAPIList(events); + tableComp.updateTable(); + } + } + + @Override + public Control getControl() { + return tableComp; + } + + @Override + public void clear() { + tableComp.getTable().removeAll(); + } + + @Override + public void updateView(DAViewData data) { + DASelectionData selData = (DASelectionData) data; + long selectionStartTime = selData.getStartTime(); + long selectionEndTime = selData.getEndTime(); + if (selData.getData() instanceof FileSelectedData) { + selectedData = (FileSelectedData) selData.getData(); + if (null == selectedData) { + return; + } + manager.setSelectedTableAPIList( + manager.getApiDB(). + selectAPITable(selectedData.getDentry(), + selectedData.getPid(), + selectedData.getTid(), + selectedData.isParentChart())); + + tableComp.updateTable(); + tableComp.setSelectionByTime(selectionStartTime, + selectionEndTime); + isChangedSelected = true; + } + } + + + public FileSelectedData getSelectedData() { + return selectedData; + } + + public long getRangeStartTime() { + return analysisStartTime; + } + + public long getRangeEndTime() { + return analysisEndTime; + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChart.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChart.java new file mode 100644 index 0000000..789047f --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChart.java @@ -0,0 +1,427 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.view; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.graphics.Color; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; +import org.tizen.dynamicanalyzer.nl.FilePageLabels; +import org.tizen.dynamicanalyzer.nl.NetworkPageLabels; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.swap.channel.data.ApiNameManager; +import org.tizen.dynamicanalyzer.ui.file.FileChartData; +import org.tizen.dynamicanalyzer.ui.file.model.FileAccess; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; +import org.tizen.dynamicanalyzer.ui.file.model.FileStatus; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkAPIType; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSeriesType; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; +import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; +import org.tizen.dynamicanalyzer.widgets.chart.DAChart; +import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries; +import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem; +import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem; + +public class FileChart { + List child = new ArrayList(); + + private DAChartBoardItem item; + private DAChart chart; + private String chartName; + + private DAChartSeries statusSeries; + private DAChartSeries lockSeries; + private DAChartSeries accessSeries; + + private long dentry = -1; + private String filePath = null; + private int pid = -1; + private int tid = -1; + private long fileSize = 0; + + private List statusList = new ArrayList(); // only open, close event + + private boolean isOpenedFile = false; + private boolean isLockedFile = false; + private boolean isWriting = false; + private boolean isReading = false; + + private double fileOpenedTime = 0; + private long fileClosedTime = 0; + private long fileLastUsedTime = 0; + private long fileTotalUsedTime = 0; + + public FileChart(String filePath) { + this.filePath = filePath; + } + + public FileChart(long dentry) { + this.dentry = dentry; + } + + public FileChart(String filePath, int pid, int tid) { + this.filePath = filePath; + this.pid = pid; + this.tid = tid; + } + + public FileChart(long dentry, int pid, int tid, String filePath, long fileSize) { + this.dentry = dentry; + this.filePath = filePath; + this.pid = pid; + this.tid = tid; + this.fileSize = fileSize; + } + + public void setItem(DAChartBoardItem item) { + this.item = item; + this.chart = item.getChart(); + lockSeries = chart.getSeries(FilePageLabels.FILE_CHART_API); + accessSeries = chart.getSeries(FilePageLabels.FILE_CHART_ACCESS); + statusSeries = chart.getSeries(FilePageLabels.FILE_CHART_SERIES); + } + + public void clearSeries() { + if(isParentChart()){ + statusSeries.clear(); + }else{ + lockSeries.clear(); + accessSeries.clear(); + } + } + + // TODO check + public void updateApiSeries(List apiList){ + for(FileEvent event : apiList) { + if(event.getDentry() != this.dentry || + event.getPid() != this.pid || + event.getTid() != this.tid) { + continue; + } + double time = event.getEventTime() / TimelineConstants.MEGA_DOUBLE; + String apiName = event.getApiName(); + Color color = ColorResources.FILE_OTHER_OPERATION; + if (event.getErrNo() != 0) { + color = ColorResources.FILE_API_FAILED; + } else { + int id = event.getApiType(); + if( id == LogCenterConstants.FD_API_TYPE_READ_START + || id == LogCenterConstants.FD_API_TYPE_READ_END + || id == LogCenterConstants.FD_API_TYPE_WRITE_START + || id == LogCenterConstants.FD_API_TYPE_WRITE_END + || id == LogCenterConstants.FD_API_TYPE_LOCK_START + || id == LogCenterConstants.FD_API_TYPE_LOCK_END) { + continue; + } + } + DAChartSeriesItem seriesItem = new DAChartSeriesItem(time, + DAChartSeriesItem.SERIES_AREA_BAR, color, color, apiName); + accessSeries.addSeriesItem(seriesItem); + + } + chart.redraw(); + } + + // TODO check + public void updateAccessSeries(List accessList) { + for(FileAccess data : accessList) { + if(data.getDentry() != this.dentry || + data.getPid() != this.pid || + data.getTid() != this.tid || + data.getErroNo() != 0) { + continue; + } + + double startTime = data.getStartTime() / TimelineConstants.MEGA_DOUBLE; + double endTime = data.getEndTime() / TimelineConstants.MEGA_DOUBLE; + + switch(data.getApiType()){ + case LogCenterConstants.FD_API_TYPE_READ_START: + if(data.isAlreadyReading()) { + accessSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_START, + ColorResources.FILE_ACCESS_READ, + ColorResources.FILE_ACCESS_READ, true, + FilePageLabels.FILE_CHART_TOOLTIP_READ)); + if(endTime > 0) { // if endTime <= 0, still accessing + accessSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_END, + ColorResources.FILE_ACCESS_READ, + ColorResources.FILE_ACCESS_READ, true, + FilePageLabels.FILE_CHART_TOOLTIP_READ)); + } + }else{ + accessSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_START, + ColorResources.FILE_ACCESS_READ, + ColorResources.FILE_ACCESS_READ, false, + FilePageLabels.FILE_CHART_TOOLTIP_READ)); + if(endTime > 0) { + accessSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_END, + ColorResources.FILE_ACCESS_READ, + ColorResources.FILE_ACCESS_READ, false, + FilePageLabels.FILE_CHART_TOOLTIP_READ)); + } + } + break; + case LogCenterConstants.FD_API_TYPE_WRITE_START: + if(data.isAlreadyWriting()) { + accessSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_START, + ColorResources.FILE_ACCESS_WRITE, + ColorResources.FILE_ACCESS_WRITE, true, + FilePageLabels.FILE_CHART_TOOLTIP_WRITE)); + if(endTime > 0) { // if endTime <= 0, still accessing + accessSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_END, + ColorResources.FILE_ACCESS_WRITE, + ColorResources.FILE_ACCESS_WRITE, true, + FilePageLabels.FILE_CHART_TOOLTIP_WRITE)); + } + }else{ + accessSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_START, + ColorResources.FILE_ACCESS_WRITE, + ColorResources.FILE_ACCESS_WRITE, false, + FilePageLabels.FILE_CHART_TOOLTIP_WRITE)); + if(endTime > 0) { + accessSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_END, + ColorResources.FILE_ACCESS_WRITE, + ColorResources.FILE_ACCESS_WRITE, false, + FilePageLabels.FILE_CHART_TOOLTIP_WRITE)); + } + } + break; + case LogCenterConstants.FD_API_TYPE_LOCK_START: + lockSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_START, + ColorResources.FILE_LOCK_ACQUIRED, + ColorResources.FILE_LOCK_ACQUIRED, false, + FilePageLabels.FILE_CHART_TOOLTIP_LOCK)); + if(endTime > 0){ + lockSeries.addSeriesItem(new DAChartSeriesItem( + startTime, DAChartSeriesItem.SERIES_AREA_START, + ColorResources.FILE_LOCK_ACQUIRED, + ColorResources.FILE_LOCK_ACQUIRED, false, + FilePageLabels.FILE_CHART_TOOLTIP_LOCK)); + } + break; + } + } + chart.redraw(); + } + + // TODO only parent, open/close, duplicated open/close + public void updateStatusSeries(List statusList) { + int openNum = 0; + int closeNum = 0; + + for(FileStatus data : statusList) { + if(data.getDentry() != this.dentry + || data.getErrNo() != 0) { + continue; + } + double time = data.getEventTime() / TimelineConstants.MEGA_DOUBLE; + switch(data.getApiType()){ + case LogCenterConstants.FD_API_TYPE_OPEN: + if(openNum > 0){ // duplicated open + statusSeries.addSeriesItem(new DAChartSeriesItem( + time, DAChartSeriesItem.SERIES_AREA_START, + ColorResources.FILE_DUPLICATE_OPENED, + ColorResources.FILE_DUPLICATE_OPENED, + FilePageLabels.FILE_CHART_TOOLTIP_OPEND)); + }else{ + openNum++; + setFileOpenedTime(time); + statusSeries.addSeriesItem(new DAChartSeriesItem( + time, DAChartSeriesItem.SERIES_AREA_START, + ColorResources.FILE_OPENED, + ColorResources.FILE_OPENED, + FilePageLabels.FILE_CHART_TOOLTIP_OPEND)); + } + break; + case LogCenterConstants.FD_API_TYPE_CLOSE: + closeNum++; + if(openNum == closeNum) { + statusSeries.addSeriesItem(new DAChartSeriesItem( + time, DAChartSeriesItem.SERIES_AREA_END, + ColorResources.FILE_OPENED, + ColorResources.FILE_OPENED, + FilePageLabels.FILE_CHART_TOOLTIP_CLOSED)); + + }else if((openNum-closeNum) == 1){ // duplicated close + statusSeries.addSeriesItem(new DAChartSeriesItem( + time, DAChartSeriesItem.SERIES_AREA_END, + ColorResources.FILE_DUPLICATE_OPENED, + ColorResources.FILE_OPENED, + FilePageLabels.FILE_CHART_TOOLTIP_CLOSED)); + } + break; + } + } + chart.redraw(); + } + + public boolean isParentChart() { + if (child.size() > 0) { + return true; + } else { + return false; + } + } + + public FileChart getChildChart(FileEvent event) { + int size = child.size(); + FileChart row; + for (int i = 0; i < size; i++) { + row = child.get(i); + if (row.getPid() == event.getPid() + && row.getTid() == event.getTid()){ + return row; + } + } + return null; + } + public DAChartBoardItem getItem() { + return item; + } + + public List getChild() { + return child; + } + + public void addChild(FileChart child) { + this.child.add(child); + } + + public String getChartName() { + return chartName; + } + + public void setChartName(String chartName) { + this.chartName = chartName; + } + + public String getFilePath() { + return filePath; + } + + public String getFileName() { + String[] splitPath = this.filePath.split("\\/"); //$NON-NLS-1$ + String fileName = new String(splitPath[splitPath.length - 1]); + return fileName; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public List getStatusList() { + return statusList; + } + + public void addStatus(FileEvent event) { + statusList.add(event); + } + + public boolean isOpenedFile() { + return isOpenedFile; + } + + public void setOpenedFile(boolean isOpenedFile) { + this.isOpenedFile = isOpenedFile; + } + + public boolean isLockedFile() { + return isLockedFile; + } + + public void setLockedFile(boolean isLockedFile) { + this.isLockedFile = isLockedFile; + } + + public boolean isWriting() { + return isWriting; + } + + public void setWriting(boolean isWriting) { + this.isWriting = isWriting; + } + + public boolean isReading() { + return isReading; + } + + public void setReading(boolean isReading) { + this.isReading = isReading; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public int getTid() { + return tid; + } + + public void setTid(int tid) { + this.tid = tid; + } + + public long getDentry() { + return dentry; + } + + public void setDentry(long dentry) { + this.dentry = dentry; + } + + public void setFileOpenedTime(double time) { + this.fileOpenedTime = time; + } + + public double getFileOpenedTime() { + return fileOpenedTime; + } + + public long getFileSize() { + return fileSize; + } + + public void getFileSize(long fileSize) { + this.fileSize = fileSize; + } +} \ No newline at end of file diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartBoard.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartBoard.java new file mode 100644 index 0000000..3ef9a8e --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartBoard.java @@ -0,0 +1,413 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.view; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.swt.widgets.Composite; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; +import org.tizen.dynamicanalyzer.nl.FilePageLabels; +import org.tizen.dynamicanalyzer.nl.NetworkPageLabels; +import org.tizen.dynamicanalyzer.nl.ThreadPageLabels; +import org.tizen.dynamicanalyzer.nl.TimelineChartLabels; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.resources.FontResources; +import org.tizen.dynamicanalyzer.resources.ImageResources; +import org.tizen.dynamicanalyzer.ui.common.PopupAnalysisMenuItemClickListener; +import org.tizen.dynamicanalyzer.ui.common.PopupClearMenuItemClickListener; +import org.tizen.dynamicanalyzer.ui.common.PopupEndMenuItemClickListener; +import org.tizen.dynamicanalyzer.ui.common.PopupFromSelectionMenuItemClickListener; +import org.tizen.dynamicanalyzer.ui.common.PopupStartMenuItemClickListener; +import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener; +import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter; +import org.tizen.dynamicanalyzer.ui.file.FileChartData; +import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB; +import org.tizen.dynamicanalyzer.ui.file.manager.FileChartDataMaker; +import org.tizen.dynamicanalyzer.ui.file.manager.FileChartManager; +import org.tizen.dynamicanalyzer.ui.file.model.FileAccess; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; +import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData; +import org.tizen.dynamicanalyzer.ui.file.model.FileStatus; +import org.tizen.dynamicanalyzer.ui.network.NetworkChart; +import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkAPIType; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSelectionType; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSeriesType; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; +import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; +import org.tizen.dynamicanalyzer.widgets.chart.DAChart; +import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot; +import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker; +import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotTooltip; +import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot.AutoRangeType; +import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeries; +import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard; +import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem; +import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu; +import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem; + +public class FileChartBoard extends DAChartBoard{ + + private List chartList = new ArrayList(); + private FileChartManager fileChartManager = FileChartManager.getInstance(); + private Map fileAccessorMap = new HashMap(); + private FileChartDataMaker dataMaker; + private FileApiDB apiDB; + + public FileChartBoard(Composite parent, String title) { + super(parent, title); + dataMaker = fileChartManager.getFileChartDataMaker(); + //TODO + //apiDB = dataMaker.getApiDB(); + apiDB = fileChartManager.getApiDB(); + initIntervalMarkers(); + } + + @Override + protected void callBackScaleChanged() { + super.callBackScaleChanged(); + updateChart(); + } + + @Override + protected void callBackScrollChanged() { + super.callBackScrollChanged(); + updateChart(); + } + + @Override + protected void callBackSizeChanged() { + layout(true, true); + super.callBackSizeChanged(); + } + + public void updateChart() { + clearSeries(); + createChartList(); + updateStatusSeries(); + updateAccessSeries(); + updateApiSeries(); + } + + public void clear() { + super.clear(); + chartList.clear(); + initIntervalMarkers(); + } + + public void clearSeries() { + if (null == chartList) { + return; + } + for (FileChart chart : chartList) { + chart.clearSeries(); + } + } + + // create chart rows + private void createChartList() { + FileChart parent = null; + FileChart child = null; + long dentry = -1; + String key = null; + + List eventList = dataMaker.getFileEventList(); + if(eventList == null){ + return; + } + for(FileEvent event : eventList) { + key = createKey(event.getPid(), event.getTid()); + if(event.getApiType() == LogCenterConstants.FD_API_TYPE_OPEN){ + if(fileAccessorMap.get(key) == null) { + fileAccessorMap.put(key, event.getDentry()); + } + } + dentry = fileAccessorMap.get(key); + parent = getParentChart(dentry); + if (parent == null) { + parent = new FileChart(dentry); + //TODO target process'file name only + parent.setFilePath(event.getFilePath()); + child = new FileChart(dentry, event.getPid(), event.getTid(), event.getFilePath(), + event.getFileSize()); + parent.addChild(child); + createChartItem(null, parent); + createChartItem(parent, child); + chartList.add(parent); + chartList.add(child); + } else { + child = parent.getChildChart(event); + if(child == null){ + child = new FileChart(dentry, event.getPid(), event.getTid(), event.getFilePath(), + event.getFileSize()); + parent.addChild(child); + createChartItem(parent, child); + chartList.add(child); + } + } + } + } + + private void createChartItem(FileChart parent, FileChart fileChart) { + DAChartBoardItem item; + DAChart chart; + + if(parent != null){ // child chart row + DAChartBoardItem parentItem = parent.getItem(); + item = new DAChartBoardItem (parentItem, "0x"//$NON-NLS-1$ + + Long.toHexString(fileChart.getPid()) + "(PID)" + + CommonConstants.NEW_LINE + + Long.toHexString(fileChart.getTid()) + "(TID)" + ); + chart = item.getChart(); + item.setData(new FileSelectedData(fileChart.getDentry(), fileChart + .getPid(), fileChart.getTid(), false)); + initFileChart(chart, false); + } else { // parent chart row + String fileName = fileChart.getFileName(); + String title = fileName; + if (fileName.length() > 12) { + title = fileName.substring(0, 12) + + CommonConstants.NEW_LINE + + fileName.substring(12, fileName.length()); + } + item = new DAChartBoardItem(this, title); + item.setData(new FileSelectedData(fileChart.getDentry(), fileChart + .getPid(), fileChart.getTid(), true, fileChart + .getFilePath(), fileChart.getFileSize())); + chart = item.getChart(); + initFileChart(chart, true); + } + + fileChart.setItem(item); + chart.redraw(); + } + + // update file open status + private void updateStatusSeries() { + if(chartList.size() > 0) { + List statusList = getVisibleSatausList(); + for (FileChart chart : chartList) { + if(!chart.isParentChart()) { + continue; + } + chart.updateStatusSeries(statusList); + } + } + } + + // update file access status + private void updateAccessSeries() { + if(chartList.size() >0) { + List accessList = getVisibleAccessList(); + for (FileChart chart : chartList) { + chart.updateAccessSeries(accessList); + } + } + } + + // update file api + private void updateApiSeries() { + if(chartList.size() >0) { + List apiList = apiDB.selectAPISeries(getVisibleStartTime(), + getVisibleEndTime()); + if (null == apiList) { + return; + } + for (FileChart chart : chartList) { + if(chart.isParentChart()){ + continue; + } + chart.updateApiSeries(apiList); + } + } + } + + private FileChart getParentChart(long dentry) { + for (FileChart chart : chartList) { + if (chart.getDentry() == dentry + && chart.isParentChart()) { + return chart; + } + } + return null; + } + + private String createKey(int pid, int tid) { + StringBuffer key = new StringBuffer(pid); + key.append(":"); + key.append(tid); + return key.toString(); + } + + private List getVisibleSatausList() { + return dataMaker.getFileStatusList(); + } + + private List getVisibleAccessList() { + List data = new ArrayList(); + for(FileAccess access : dataMaker.getFileAccessList()){ + double startTime = access.getStartTime() / TimelineConstants.MEGA_DOUBLE; + double endTime = access.getEndTime() / TimelineConstants.MEGA_DOUBLE; + if ( startTime >= getVisibleStartTime() + && startTime <= getVisibleEndTime()) { + data.add(access); + } else if (endTime >= getVisibleStartTime() + && endTime <= getVisibleEndTime()) { + data.add(access); + } else if (endTime <= 0) { // ing + data.add(access); + } + } + return data; + } + + public int[] getChartIndex(FileEvent event) { + FileChart data = null; + for (int i = 0; i < chartList.size(); i++) { + data = chartList.get(i); + if (data.isParentChart() + && data.getDentry() == event.getDentry()) { + for(int j = 0; j < data.getChild().size(); j++) { + FileChart child = data.getChild().get(i); + if(child.getPid() == event.getPid() + && child.getTid() == event.getTid()){ + return new int[] {i, j}; + } + } + } + } + return new int[] { 0, 0 }; + } + + private void initFileChart(DAChart chart, boolean isParent) { + if (null == chart) { + return; + } + DAChartPlot plot = chart.getPlot(); + if (null == plot) { + return; + } + if (isParent) { + DAChartSeries statusSeries = new DAChartSeries( + FilePageLabels.FILE_CHART_SERIES, + DAChartSeries.SERIES_STYLE_STATE_AREA, ColorResources.WHITE); + chart.addSeries(statusSeries); + plot.setBackgroundImage(ImageResources.BG_GRADIENT); + } else { + DAChartSeries lockSeries = new DAChartSeries( + FilePageLabels.FILE_CHART_API, + DAChartSeries.SERIES_STYLE_STATE_AREA, ColorResources.YELLOW); + chart.addSeries(lockSeries); + + DAChartSeries accessSeries = new DAChartSeries( + FilePageLabels.FILE_CHART_ACCESS, + DAChartSeries.SERIES_STYLE_EVENT_AREA, ColorResources.WHITE); + chart.addSeries(accessSeries); + plot.setBackgroundImage(ImageResources.BG_CHILD_GRADIENT); + } + + plot.setAutoHeightRange(AutoRangeType.MANUAL); + plot.setAxisFont(FontResources.CHART_AXIS_FONT); + plot.setAxisRangeY(0, 101); + plot.setAxisRangeX(getVisibleStartTime(), getVisibleEndTime()); + + DAChartPlotTooltip tooltip = new DAChartPlotTooltip(-1); + tooltip.setFont(FontResources.CHART_TOOLTIP_FONT); + plot.setTooltip(tooltip); + + DAPopupMenu popupMenu = new DAPopupMenu(chart); + popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT); + DAPopupMenuItem startItem = new DAPopupMenuItem(popupMenu, + DAPopupMenuItem.NONE); + startItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_START); + startItem.addListener(new PopupStartMenuItemClickListener(startItem, + this)); + + DAPopupMenuItem endItem = new DAPopupMenuItem(popupMenu, + DAPopupMenuItem.NONE); + endItem.setText(TimelineChartLabels.RANGE_CONTEXT_SET_END); + endItem.addListener(new PopupEndMenuItemClickListener(endItem, this)); + + DAPopupMenuItem fromSelectionItem = new DAPopupMenuItem(popupMenu, + DAPopupMenuItem.NONE); + fromSelectionItem + .setText(TimelineChartLabels.RANGE_CONTEXT_SET_FROM_SELECTION); + fromSelectionItem + .addListener(new PopupFromSelectionMenuItemClickListener( + fromSelectionItem, this)); + + DAPopupMenuItem analysisItem = new DAPopupMenuItem(popupMenu, + DAPopupMenuItem.NONE); + analysisItem.setText(TimelineChartLabels.RANGE_CONTEXT_ANALYSIS); + analysisItem.addListener(new PopupAnalysisMenuItemClickListener()); + + DAPopupMenuItem clearItem = new DAPopupMenuItem(popupMenu, + DAPopupMenuItem.NONE); + clearItem.setText(TimelineChartLabels.RANGE_CONTEXT_CLEAR); + clearItem.addListener(new PopupClearMenuItemClickListener()); + + TimelineChartMouseEventListener timelineChartMouseEventListener = new TimelineChartMouseEventListener( + popupMenu, getTimeline()); + chart.addMouseListener(timelineChartMouseEventListener); + chart.addMouseMoveListener(timelineChartMouseEventListener); + chart.addMouseTrackListener(new TimelineChartMouseTrackAdapter( + getTimeline())); + plot.setMarkers(getMarkers()); + } + + private void initIntervalMarkers() { + // selection marker + DAChartPlotIntervalMarker selectionMarker = new DAChartPlotIntervalMarker( + -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA); + selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE); + selectionMarker.setAlpha((int) (255 * 0.25)); + addIntervalMarker(selectionMarker); + + // range analysis marker + DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker( + -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA); + rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW); + rangeAnalyzeMarker.setAlpha((int) (255 * 0.25)); + addIntervalMarker(rangeAnalyzeMarker); + + // range marker + DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker( + -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE); + rangeMarker.setForegroundColor(ColorResources.RED); + rangeMarker.setAlpha((int) (255 * 0.25)); + addIntervalMarker(rangeMarker); + } + + public int getChartSize(){ + return chartList.size(); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartView.java new file mode 100644 index 0000000..34ed11b --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartView.java @@ -0,0 +1,256 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.view; + +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StackLayout; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.common.DASelectionData; +import org.tizen.dynamicanalyzer.nl.FilePageLabels; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.resources.FontResources; +import org.tizen.dynamicanalyzer.resources.ImageResources; +import org.tizen.dynamicanalyzer.swap.model.data.LogData; +import org.tizen.dynamicanalyzer.ui.common.SetRangeMarkerMouseMoveListener; +import org.tizen.dynamicanalyzer.ui.common.UICommonConstants; +import org.tizen.dynamicanalyzer.ui.file.FilePage; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; +import org.tizen.dynamicanalyzer.ui.file.manager.FileChartManager; +import org.tizen.dynamicanalyzer.ui.range.RangeDataManager; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; +import org.tizen.dynamicanalyzer.ui.timeline.logparser.LifecycleLogParser; +import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; +import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker; +import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoard; +import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardItem; +import org.tizen.dynamicanalyzer.widgets.chartBoard.DAChartBoardSelectionListener; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData; +import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline; + +public class FileChartView extends DAViewComposite { + public final static int FILE_CHART_HEIGHT = 40; + + private final Composite contents; + private FileChartBoard fileChartBoard; + private final StackLayout stackLayout; + private DAChartBoardItem lastSelectedItemForSummary = null; + + private final RangeDataManager rangeDataManager = RangeDataManager + .getInstance(); + private FileChartManager chartManager = FileChartManager.getInstance(); + + public FileChartView(Composite parent, int style) { + super(parent, style, false); + this.setLayout(new FillLayout()); + + setTitle(FilePageLabels.FILE_CHART_FILE); + + contents = getContentArea(); + contents.setBackground(ColorResources.WINDOW_BG_COLOR); + stackLayout = new StackLayout(); + contents.setLayout(stackLayout); + fileChartBoard = new FileChartBoard(contents, FilePageLabels.FILE_CHART_FILE); + fileChartBoard.setNameFont(FontResources.CHART_NAME_FONT); + fileChartBoard.addSelectionListener(new DAChartBoardSelectionListener() { + @Override + public void handleSelectionEvent(DAChartBoardItem item) { + lastSelectedItemForSummary = item; + AnalyzerManager + .getCurrentPage().updateView( + new DASelectionData( + FilePage.chartViewID, + (long) (((DAChartPlotIntervalMarker) fileChartBoard + .getMarkers() + .get(UICommonConstants.SELECTION_MARKER_INDEX)) + .getStartVal() * TimelineConstants.MEGA_DOUBLE), + (long) (((DAChartPlotIntervalMarker) fileChartBoard + .getMarkers() + .get(UICommonConstants.SELECTION_MARKER_INDEX)) + .getEndVal() * TimelineConstants.MEGA_DOUBLE), + item.getData(), null)); + } + }); + + initIntervalMarkers(fileChartBoard); + + stackLayout.topControl = fileChartBoard; + Composite textBoxLabel = new Composite(fileChartBoard.getTitleComp(), + SWT.NONE); + textBoxLabel.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + Composite composite = (Composite) e.widget; + Rectangle rect = composite.getClientArea(); + + e.gc.drawImage(ImageResources.TIMELINE_DROPDOWN_NORMAL, rect.x, + rect.y); + e.gc.setFont(FontResources.COMBO); + e.gc.setForeground(ColorResources.BLACK); + e.gc.drawString(FilePageLabels.FILE_CHART_FILE, rect.x + 30, + rect.y + 2, true); + } + }); + + DATimeline timeline = fileChartBoard.getTimeline(); + + timeline.setTimeTickFont(FontResources.TIMELINE_TICK_FONT); + timeline.setTimeBalloonFont(FontResources.TIMELINE_BALLOON_FONT); + + LifecycleLogParser.getInstance().registerLifecycleBar( + fileChartBoard.getLifecycleBar()); + LifecycleLogParser.getInstance().registerTimeline(timeline); + + timeline.addMouseMoveListener(new SetRangeMarkerMouseMoveListener( + rangeDataManager, fileChartBoard, timeline)); + } + + @Override + public void updateView() { + fileChartBoard.updateChart(); + + fileChartBoard.setTotalEndTime(ToolbarArea.getInstance().getTime()); + + fileChartBoard.setTimelineMarkerStartTime(rangeDataManager + .getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE); + fileChartBoard.setTimelineMarkerEndTime(rangeDataManager.getMarkerEndTime() + / TimelineConstants.MEGA_DOUBLE); + + if (RangeDataManager.getInstance().isBeingAnalyzed()) { + ((DAChartPlotIntervalMarker) fileChartBoard.getMarkers().get( + UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)) + .setInterval(rangeDataManager.getAnalysisStartTime() + / TimelineConstants.MEGA_DOUBLE, + rangeDataManager.getAnalysisEndTime() + / TimelineConstants.MEGA_DOUBLE); + } else { + ((DAChartPlotIntervalMarker) fileChartBoard.getMarkers().get( + UICommonConstants.RANGE_ANALYSIS_MARKER_INDEX)) + .setInterval(-1, -1); + } + + ((DAChartPlotIntervalMarker) fileChartBoard.getMarkers().get( + UICommonConstants.RANGE_MARKER_INDEX)).setInterval( + rangeDataManager.getMarkerStartTime() + / TimelineConstants.MEGA_DOUBLE, + rangeDataManager.getMarkerEndTime() + / TimelineConstants.MEGA_DOUBLE); + + } + + @Override + public void updateView(DAViewData data) { + fileChartBoard.updateChart(); + if (data instanceof DASelectionData) { + DASelectionData selData = (DASelectionData) data; + long dataTime = -1; + + if (selData.isLogData()) { + Object obData = selData.getData(); + if (null != obData && (obData instanceof LogData)) { // summary + LogData ldata = (LogData) obData; + dataTime = ldata.getTime(); + + int seq = ldata.getSeq(); + List event = chartManager.getApiDB().selectFileEventBySeq(seq); + int selectedIndex[] = fileChartBoard.getChartIndex(event.get(0)); + fileChartBoard.selectItem(selectedIndex[0], selectedIndex[1]); + + if (null != lastSelectedItemForSummary) { + AnalyzerManager.getCurrentPage().updateView( + new DASelectionData(FilePage.chartViewID, + dataTime, dataTime, + lastSelectedItemForSummary.getData(), + null)); + } + } + } else { + dataTime = selData.getStartTime(); + } + double startTime = dataTime / TimelineConstants.MEGA_DOUBLE; + double endTime = selData.getEndTime() / TimelineConstants.MEGA_DOUBLE; + + DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker)fileChartBoard + .getMarkers().get(UICommonConstants.SELECTION_MARKER_INDEX); + intervalMarker.setInterval(startTime, endTime); + + } + } + + @Override + public void clear() { + fileChartBoard.clear(); + initIntervalMarkers(fileChartBoard); + chartManager.getFileChartDataMaker().clear(); + } + + @Override + public Control getControl() { + return fileChartBoard; + } + + private void initIntervalMarkers(DAChartBoard board) { + // selection marker + DAChartPlotIntervalMarker selectionMarker = new DAChartPlotIntervalMarker( + -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA); + selectionMarker.setBackgroundColor(ColorResources.SELECTION_RANGE); + selectionMarker.setAlpha((int) (255 * 0.25)); + board.addIntervalMarker(selectionMarker); + + // range analysis marker + DAChartPlotIntervalMarker rangeAnalyzeMarker = new DAChartPlotIntervalMarker( + -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_AREA); + rangeAnalyzeMarker.setBackgroundColor(ColorResources.YELLOW); + rangeAnalyzeMarker.setAlpha((int) (255 * 0.25)); + board.addIntervalMarker(rangeAnalyzeMarker); + + // range marker + DAChartPlotIntervalMarker rangeMarker = new DAChartPlotIntervalMarker( + -1, -1, DAChartPlotIntervalMarker.INTERVAL_MARKER_STYLE_LINE); + rangeMarker.setForegroundColor(ColorResources.RED); + rangeMarker.setAlpha((int) (255 * 0.25)); + board.addIntervalMarker(rangeMarker); + } + + public void setRangeMarker(double starttime, double endtime) { + fileChartBoard.setTimelineMarkerStartTime(starttime); + fileChartBoard.setTimelineMarkerEndTime(endtime); + + ((DAChartPlotIntervalMarker) fileChartBoard.getMarkers().get( + UICommonConstants.RANGE_MARKER_INDEX)).setInterval( + starttime, endtime); + } + +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileDetailInfoView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileDetailInfoView.java new file mode 100644 index 0000000..2dc5266 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileDetailInfoView.java @@ -0,0 +1,211 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeran kim + * Juyoung Kim + * + * 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.file.view; + +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.tizen.dynamicanalyzer.common.AnalyzerManager; +import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; +import org.tizen.dynamicanalyzer.nl.FilePageLabels; +import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.resources.FontResources; +import org.tizen.dynamicanalyzer.ui.file.FilePage; +import org.tizen.dynamicanalyzer.ui.file.manager.FileChartManager; +import org.tizen.dynamicanalyzer.ui.file.model.FileEvent; +import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData; +import org.tizen.dynamicanalyzer.utils.Formatter; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite; +import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData; + +public class FileDetailInfoView extends DAViewComposite { + private Canvas canvas = null; + private String fileName = AnalyzerLabels.EMPTY_STRING; + private String filePath = AnalyzerLabels.EMPTY_STRING; + private long fileSize = 0; + private long readSize = 0; + private long writeSize = 0; + private long totalUseTime = 0; + private int apiCount = 0; + private int failedApiCount = 0; + + private FileChartManager fileChartManager = FileChartManager.getInstance(); + + private void init() { + fileName = AnalyzerLabels.EMPTY_STRING; + filePath = AnalyzerLabels.EMPTY_STRING; + fileSize = 0; + readSize = 0; + writeSize = 0; + totalUseTime = 0; + apiCount = 0; + failedApiCount = 0; + } + + public FileDetailInfoView(Composite parent, int style) { + super(parent, style, true); + this.setLayout(new FillLayout()); + + setTitle(FilePageLabels.FILE_DETAILS_TITLE); + + Composite contents = getContentArea(); + contents.setBackground(ColorResources.VIEW_BG_COLOR); + contents.setLayout(new FillLayout()); + canvas = new Canvas(contents, SWT.TRANSPARENT); + canvas.addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + int x = 0; + int y = 0; + Rectangle rect = canvas.getBounds(); + e.gc.setBackground(ColorResources.VIEW_BG_COLOR); + e.gc.fillRectangle(rect.x, rect.y, rect.width, rect.height); + e.gc.setForeground(ColorResources.TABLE_CONTENTS_FONT_COLOR); + e.gc.setFont(FontResources.DETAIL_INFO_FONT); + + String fName = FilePageLabels.FILE_DETAILS_FILE_NAME + fileName; + Point textSize = e.gc.textExtent(fName, SWT.DRAW_MNEMONIC); + if (textSize.x > rect.width) { + fName = FilePageLabels.FILE_DETAILS_FILE_NAME_NEWLINE + + fileName; + } + int fontHeight = textSize.y + 5; + e.gc.drawString(fName, x += 10, y += fontHeight); + + // file path bolck + { + String pathLabel = FilePageLabels.FILE_DETAILS_FILE_PATH; + e.gc.drawString(pathLabel, x, y + fontHeight); + Point pathSize = e.gc.textExtent(pathLabel, + SWT.DRAW_MNEMONIC); + int xPos = x + pathSize.x; + int width = rect.width - xPos; + String text = filePath; + if (text.length() > 0) { + while (text.length() > 0) { + Point tSize = e.gc.textExtent(text, + SWT.DRAW_MNEMONIC); + String inputText = AnalyzerLabels.EMPTY_STRING; + if (tSize.x > width) { + int strLen = (width * text.length()) / tSize.x; + inputText += text.substring(0, strLen - 1); + text = text.substring(strLen - 1, text.length()); + } else { + inputText += text; + text = AnalyzerLabels.EMPTY_STRING; + } + e.gc.drawString(inputText, xPos, y += fontHeight); + } + } else { + y += fontHeight; + } + } + + e.gc.drawString( + FilePageLabels.FILE_DETAILS_TOTAL_SIZE + + Long.toString(fileSize), x, y += fontHeight); + e.gc.drawString( + FilePageLabels.FILE_DETAILS_READ_SIZE + + Long.toString(readSize), x, y += fontHeight); + e.gc.drawString( + FilePageLabels.FILE_DETAILS_WRITE_SIZE + + Long.toString(writeSize), x, y += fontHeight); + e.gc.drawString(FilePageLabels.FILE_DETAILS_TOTAL_USE_TIME + + Formatter.toTimeFormat(totalUseTime) + + FilePageLabels.TIME_MS, x, y += fontHeight); + e.gc.drawString( + FilePageLabels.FILE_DETAILS_API_COUNT + + Integer.toString(apiCount), x, + y += fontHeight); + e.gc.drawString(FilePageLabels.FILE_DETAILS_FAILED_API_COUNT + + Integer.toString(failedApiCount), x, y += fontHeight); + } + }); + } + + @Override + public void updateView(DAViewData data) { + updateData(); + } + + @Override + public void updateView() { + updateData(); + } + + private void updateData() { + FileApiListView view = (FileApiListView) AnalyzerManager + .getCurrentPage().getView(FilePage.apilistViewID); + FileSelectedData selectData = view.getSelectedData(); + + if (null == selectData) { + return; + } + List events = null; + events = fileChartManager.getApiDB() + .selectAPITable(selectData.getDentry(), + selectData.getPid(), selectData.getTid(), selectData.isParentChart()); + if(events != null) { + filePath = events.get(0).getFilePath(); + fileName = events.get(0).getFileName(); + fileSize = events.get(0).getFileSize(); + apiCount = events.size(); + } + events = fileChartManager.getApiDB() + .selectFailedAPI(selectData.getDentry(), + selectData.getPid(), selectData.getTid(), selectData.isParentChart()); + if(events != null) { + failedApiCount = events.size(); + } + // TODO define What totalUseTime + // totalUseTime = (long) selectData.getFileTotalUseTime(); + // readSize = selectData.getReadSize(); + // writeSize = selectData.getWriteSize(); + + canvas.redraw(); + } + + @Override + public Control getControl() { + return canvas; + } + + @Override + public void clear() { + init(); + canvas.redraw(); + } +}