import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
import org.tizen.dynamicanalyzer.model.FindProperty;
import org.tizen.dynamicanalyzer.model.TableInput;
import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
public abstract class DAWindowingTableComposite extends DATableComposite {
- private static final String queryto_GetItemCount = "select count(*) from %s where %s";
- private static final String queryto_GetLimitedItem = "select limit %s %s %s from %s where %s";
+ private static final String queryto_GetItemCount = "select count(*) from %s where %s";//$NON-NLS-1$
+ private static final String queryto_GetSelectionVScrollbarIndex = "select count(*) from %s where (%s <= %s)";//$NON-NLS-1$
+ private static final String queryto_GetLimitedItem = "select limit %s %s %s from %s where %s";//$NON-NLS-1$
protected Composite scrollComp;
protected ScrollBar vScrollbar;
private List<LogData> queriedLogData = null;
private List<List<Object>> queriedObjectData = null;
- public DAWindowingTableComposite(Composite parent, int compStyle,
- int tableStyle) {
+ public DAWindowingTableComposite(Composite parent, int compStyle, int tableStyle) {
super(parent, compStyle, tableStyle);
}
@Override
public void widgetSelected(SelectionEvent e) {
GridItem[] ti = ((Grid) e.widget).getSelection();
- if (null == ti || ti.length == 0
- || !(ti[0].getData() instanceof DATableDataFormat)) {
+ if (null == ti || ti.length == 0 || !(ti[0].getData() instanceof DATableDataFormat)) {
return;
}
GridItem focusedItem = ((Grid) e.widget).getFocusItem();
if (!(focusedItem.getData() instanceof DATableDataFormat)) {
return;
}
- DATableDataFormat td = (DATableDataFormat) focusedItem
- .getData();
+ DATableDataFormat td = (DATableDataFormat) focusedItem.getData();
if (null == td) {
return;
}
selectionStartTime = td.getLogData().getTime();
selectionEndTime = td.getLogData().getTime();
} else {
- selectionStartTime = (Long) td.getData().get(
- timeColumnIndex);
+ selectionStartTime = (Long) td.getData().get(timeColumnIndex);
selectionEndTime = selectionStartTime;
}
if (ctrlPressed) {
ctrlPressed = false;
if (findEnabled) {
- Shell shell = WorkbenchUtil.getWorkbenchWindow()
- .getShell();
+ Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
FindDialog dialog = new FindDialog(shell, me);
dialog.open();
}
}
protected int getTableLength() {
- return (this.tableAreaHeigth - table.getHeaderHeight())
- / (table.getItemHeight() + 1);
+ return (this.tableAreaHeigth - table.getHeaderHeight()) / (table.getItemHeight() + 1);
}
public void updateHScrollBar(int tableWidth) {
- System.out.println("width : " + tableWidth);
hScrollbar.setMaximum(totalColumnSize);
hScrollbar.setThumb(tableWidth);
hScrollbar.setVisible(true);
for (int i = 0; i < size; i++) {
GridItem gridItem = new GridItem(table, SWT.NONE);
- DATableDataFormat gridData = (DATableDataFormat) output.get(i)
- .getData();
+ DATableDataFormat gridData = (DATableDataFormat) output.get(i).getData();
gridItem.setData(gridData);
List<String> text = output.get(i).getText();
if (totalItemCount == 0) { // open or never trace
String tablename = getDBTableName();
if (tablename != null && !tablename.isEmpty()) {
- String query = String.format(queryto_GetItemCount,
- getDBTableName(), getSelectQueryCountOption());
- List<List<Object>> result = SqlConnectionManager
- .executeQuery(query);
+ String query = String.format(queryto_GetItemCount, getDBTableName(),
+ getSelectQueryCountOption());
+ List<List<Object>> result = SqlConnectionManager.executeQuery(query);
if (result != null) {
Object object = result.get(0).get(0);
if (object instanceof Integer) {
}
}
- if ((isLogData && queriedLogData == null)
- || (!isLogData && queriedObjectData == null)) {
+ if ((isLogData && queriedLogData == null) || (!isLogData && queriedObjectData == null)) {
return null;
}
for (int i = 0; i < columnsize; i++) {
columnString.append(columnNames.get(i));
if (i < columnsize - 1)
- columnString.append(", ");
+ columnString.append(", ");//$NON-NLS-1$
}
- String query = String.format(queryto_GetLimitedItem, scrollSelection,
- selectedEndIndex + 1, columnString.toString(), tableName,
- getSelectQueryOption());
+ String query = String.format(queryto_GetLimitedItem, scrollSelection, selectedEndIndex + 1,
+ columnString.toString(), tableName, getSelectQueryOption());
return SqlConnectionManager.executeQuery(query);
}
if (itemCount <= selectedEndIndex) {
selectedEndIndex = itemCount;
}
- List<LogData> outputList = SqlManager.getInstance().selectTableData(
- tableName, getDBTableColumnNames(), scrollSelection,
- selectedEndIndex + 1, getSelectQueryOption());
+ List<LogData> outputList = SqlManager.getInstance().selectTableData(tableName,
+ getDBTableColumnNames(), scrollSelection, selectedEndIndex + 1,
+ getSelectQueryOption());
return outputList;
}
if (null != item) {
long inputTime;
if (isLogData) {
- LogData data = ((DATableDataFormat) item.getData())
- .getLogData();
+ LogData data = ((DATableDataFormat) item.getData()).getLogData();
inputTime = data.getTime();
} else {
- inputTime = (Long) ((DATableDataFormat) item.getData())
- .getData().get(timeColumnIndex);
+ inputTime = (Long) ((DATableDataFormat) item.getData()).getData().get(
+ timeColumnIndex);
}
if (type == START_TIME) {
selectionStartTime = startTime;
selectionEndTime = endTime;
- int selectionIndex = SqlManager.getInstance().getSelectionIndex(
- tableName, getTimeColumnName(), selectionStartTime,
- getSelectQueryCountOption());
- vScrollbar.setSelection(selectionIndex - 1);
+ String query = String.format(queryto_GetSelectionVScrollbarIndex, tableName,
+ getTimeColumnName(), Long.toString(startTime));
+ if (!getSelectQueryCountOption().equals(CommonConstants.EMPTY)) {
+ query += " and " + CommonConstants.OPEN_BRACKET + getSelectQueryCountOption()//$NON-NLS-1$
+ + CommonConstants.CLOSE_BRACKET;
+ }
+
+ List<List<Object>> resultList = SqlConnectionManager.executeQuery(query);
+ if (resultList.size() == 0 || resultList.get(0).size() == 0) {
+ return;
+ }
+ String strSelectionIndex = String.valueOf((Long) resultList.get(0).get(0));
+ int intSelectionIndex = Integer.parseInt(strSelectionIndex);
+ if (intSelectionIndex > 0) {
+ vScrollbar.setSelection(intSelectionIndex - 1);
+ } else {
+ vScrollbar.setSelection(0);
+ }
}
}