From fcbab3765828976e26cd913d08a61fbd48d8ba98 Mon Sep 17 00:00:00 2001 From: jaeyong lee Date: Tue, 9 Aug 2016 16:04:57 +0900 Subject: [PATCH] [SRADA-997][SRADA-998] Improve Dlog table popupmenu * add new filtering rule (pid, tid) * fix 'Filter by selected level' fucntion * apply new flat style * code refactoring Change-Id: I5a3b5c2ee5067735b3c8504a26b70f8791891edc --- .../ui/timeline/dlog/DlogTable.java | 197 +++++++++++---------- 1 file changed, 103 insertions(+), 94 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/dlog/DlogTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/dlog/DlogTable.java index d31ee34..5b181ec 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/dlog/DlogTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/dlog/DlogTable.java @@ -39,15 +39,13 @@ import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.common.DASelectionData; import org.tizen.dynamicanalyzer.common.Global; import org.tizen.dynamicanalyzer.model.TableInput; import org.tizen.dynamicanalyzer.resources.ColorResources; +import org.tizen.dynamicanalyzer.resources.FontResources; import org.tizen.dynamicanalyzer.ui.common.UICommonConstants; import org.tizen.dynamicanalyzer.ui.file.FileChartView; import org.tizen.dynamicanalyzer.ui.file.FilePage; @@ -73,11 +71,14 @@ import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; import org.tizen.dynamicanalyzer.utils.Formatter; import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlotIntervalMarker; +import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenu; +import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuItem; +import org.tizen.dynamicanalyzer.widgets.popupMenu.DAPopupMenuListener; import org.tizen.sdblib.util.StringUtil; public class DlogTable extends DATableComposite { - private String[] columnNames = {"Time", "Level", "Pid", "Tid", "Tag", "Message" }; //6col + private String[] columnNames = {"Time", "Level", "PID", "TID", "Tag", "Message" }; //6col private int[] columnSizes = { 70, 50, 60, 60, 80, 600}; private int[] columnAlignment = { SWT.CENTER, SWT.CENTER, SWT.CENTER, SWT.CENTER, SWT.LEFT, SWT.LEFT }; private boolean[] columnVisibility = { true, true, true, true, true, true }; @@ -88,6 +89,17 @@ public class DlogTable extends DATableComposite { private List dlogClone = new ArrayList(); private List filteredDlog = new ArrayList(); private static boolean isFilter = false; + + private static String POPUP_FILTER_BY_LEVEL = "Filter by selected Level"; + private static String POPUP_FILTER_BY_PID = "Filter by selected PID"; + private static String POPUP_FILTER_BY_TID = "Filter by selected TID"; + private static String POPUP_FILTER_BY_TAG = "Filter by selected Tag"; + private static String POPUP_SHOW_ALL_DLOGS = "Show all Dlogs"; + + private static int TABLE_INDEX_LEVEL = 1; + private static int TABLE_INDEX_PID = 2; + private static int TABLE_INDEX_TID = 3; + private static int TABLE_INDEX_TAG = 4; public DlogTable(Composite parent, int compStyle, int tableStyle) { super(parent, compStyle, tableStyle); @@ -103,6 +115,91 @@ public class DlogTable extends DATableComposite { parent.addControlListener(new TableColumnSizePackListener(this, columnSizes)); initDlogListeners(); + initPopupMenu(); + } + + private void initPopupMenu() { + popupMenu = new DAPopupMenu(table); + popupMenu.setFont(FontResources.CONTEXT_MENU_ITEM_FONT); + + DAPopupMenuItem filterByLevelItem = new DAPopupMenuItem(popupMenu); + filterByLevelItem.setText(POPUP_FILTER_BY_LEVEL); + filterByLevelItem.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + GridItem item = table.getItem(new Point(mousePoint.x, mousePoint.y)); + if (null == item) { + return; + } + + String startData = ((DATableDataFormat) item.getData()).getData().get(TABLE_INDEX_LEVEL).toString(); + filterTable(startData, TABLE_INDEX_LEVEL); + } + }); + + DAPopupMenuItem filterByLevelPID = new DAPopupMenuItem(popupMenu); + filterByLevelPID.setText(POPUP_FILTER_BY_PID); + filterByLevelPID.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + GridItem item = table.getItem(new Point(mousePoint.x, mousePoint.y)); + if (null == item) { + return; + } + + String startData = ((DATableDataFormat) item.getData()).getData().get(TABLE_INDEX_PID).toString(); + filterTable(startData, TABLE_INDEX_PID); + } + }); + + DAPopupMenuItem filterByLevelTID = new DAPopupMenuItem(popupMenu); + filterByLevelTID.setText(POPUP_FILTER_BY_TID); + filterByLevelTID.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + GridItem item = table.getItem(new Point(mousePoint.x, mousePoint.y)); + if (null == item) { + return; + } + + String startData = ((DATableDataFormat) item.getData()).getData().get(TABLE_INDEX_TID).toString(); + filterTable(startData, TABLE_INDEX_TID); + } + }); + + DAPopupMenuItem filterByTagItem = new DAPopupMenuItem(popupMenu); + filterByTagItem.setText(POPUP_FILTER_BY_TAG); + filterByTagItem.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + GridItem item = table.getItem(new Point(mousePoint.x, mousePoint.y)); + if (null == item) { + return; + } + + String startData = ((DATableDataFormat) item.getData()).getData().get(TABLE_INDEX_TAG).toString(); + filterTable(startData, TABLE_INDEX_TAG); + } + }); + + + + DAPopupMenuItem allDlogShowItem = new DAPopupMenuItem(popupMenu); + allDlogShowItem.setText(POPUP_SHOW_ALL_DLOGS); + allDlogShowItem.addListener(new DAPopupMenuListener() { + @Override + public void widgetSelected(DAPopupMenuItem menuItem) { + isFilter = false; + table.update(); + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID); + baseView.getTopComposite().updateView(); + } + }); + } + }); } public boolean initDlogListeners(){ @@ -135,93 +232,6 @@ public class DlogTable extends DATableComposite { @Override public void mouseUp(final MouseEvent MouseEvent) { // TODO Auto-generated method stub - - // START : Mouse Right Click on table cell - if(MouseEvent.button == 3){ - - Shell shell = table.getParent().getShell(); - Menu dropmenu = new Menu(shell, SWT.POP_UP); - shell.setMenu(dropmenu); - MenuItem item0 = new MenuItem(dropmenu, SWT.NONE); - MenuItem item1 = new MenuItem(dropmenu, SWT.NONE); - MenuItem item2 = new MenuItem(dropmenu, SWT.NONE); - - item0.setText("Filter by Selected Tag"); - item1.setText("Filter by Selected Level"); - item2.setText("All DLogs show"); - - item0.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - GridItem[] ti = ((Grid) MouseEvent.widget).getSelection(); - if (null == ti || ti.length == 0) { - return; - } - String startData = ((DATableDataFormat) ti[0].getData()).getData().get(4).toString(); - filteringDlog(startData); - - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - } - }); - - item1.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - GridItem[] ti = ((Grid) MouseEvent.widget).getSelection(); - if (null == ti || ti.length == 0) { - return; - } - String startData = ((DATableDataFormat) ti[0].getData()).getData().get(1).toString(); - filteringDlog(startData); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - } - }); - - item2.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - // TODO Auto-generated method stub - isFilter = false; - table.update(); - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - BaseView baseView = (BaseView) WorkbenchUtil.getViewPart(BaseView.ID); - baseView.getTopComposite().updateView(); - } - }); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - } - }); - int X = MouseEvent.x; - int Y = MouseEvent.y; - Point gridPoint = ((Grid) MouseEvent.widget).toDisplay(X, Y); - dropmenu.setLocation( gridPoint.x, gridPoint.y); - dropmenu.setVisible(true); - } - // END : Mouse Right Click on table cell } @Override @@ -319,13 +329,13 @@ public class DlogTable extends DATableComposite { return output; } - private void filteringDlog(String input){ + private void filterTable(String input, int categoryIndex) { filteredDlog.clear(); if(tableClone != null){ for(TableInput table : tableClone){ - if(table.getText().get(4).contains(input)){ + if(table.getText().get(categoryIndex).equals(input)){ filteredDlog.add(table); isFilter = true; } @@ -341,7 +351,6 @@ public class DlogTable extends DATableComposite { }); } - private void DlogTimeMarker(long markerTime){ double startMarkerTime = markerTime -- 2.7.4