From 6d8a61389071bdd7683a2fb3b20775eff47b6bca Mon Sep 17 00:00:00 2001 From: "hyunsik.noh" Date: Wed, 14 Dec 2011 17:06:45 +0900 Subject: [PATCH] [Title] add searching process with various keywords change LogTab dialog ui provide default name for LogTab dialog [Type] Enhancement [Module] common [Priority] Minor --- .../tizen/common/connection/log/AddViewDialog.java | 413 +++++++++++++-------- .../tizen/common/connection/log/LogPanel.java | 47 +-- .../tizen/common/connection/log/LogTab.java | 292 ++++++++++----- 3 files changed, 471 insertions(+), 281 deletions(-) diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/AddViewDialog.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/AddViewDialog.java index 9bf7c5b..dca9d94 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/AddViewDialog.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/AddViewDialog.java @@ -20,11 +20,8 @@ package com.samsung.tizen.common.connection.log; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -34,6 +31,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; @@ -49,7 +47,7 @@ import com.samsung.tizen.sdblib.SmartDevelopmentBridge; public class AddViewDialog extends Dialog { private static final int DLG_WIDTH = 400; - private static final int DLG_HEIGHT = 250; + private static final int DLG_HEIGHT = 300; private Shell parent; @@ -60,16 +58,20 @@ public class AddViewDialog extends Dialog { private boolean bOk = false; private LogTab oldTab = null; - private boolean bMsg = false; - private boolean bPid = false; - private boolean bTag = false; + + private static String TEMPNAME = "LogTab-#"; + private static int cnt = 0; private String tabName = null; private String device = null; - private String keyword = null; + private String pidKeyword = null; + private String tagKeyword = null; + private String msgKeyword = null; private Text tabNameText; - private Text searchText; + private Text tagText; + private Text pidText; + private Text msgText; private Button okButton; public AddViewDialog(Shell parent) { @@ -90,20 +92,10 @@ public class AddViewDialog extends Dialog { if (tab.getFilterDeviceName() == null) return; device = tab.getFilterDeviceName(); - keyword = tab.getFilterWord(); - int bMode = tab.getFilteringMode(); - - if ((bMode & LogTab.FILTER_PID) != 0) { - bPid = true; - } - - if ((bMode & LogTab.FILTER_TAG) != 0) { - bTag = true; - } - - if ((bMode & LogTab.FILTER_MSG) != 0) { - bMsg = true; - } + + pidKeyword = tab.getPidFilter(); + tagKeyword = tab.getTagFilter(); + msgKeyword = tab.getMsgFilter(); oldTab = tab; } @@ -154,23 +146,24 @@ public class AddViewDialog extends Dialog { } }); - Composite top = new Composite(shell, SWT.NONE); + Group top = new Group(shell, SWT.SHADOW_IN); + top.setText("LogTab"); top.setLayoutData(new GridData(GridData.FILL_BOTH)); top.setLayout(new GridLayout(2, false)); Label l = new Label(top, SWT.NONE); - l.setText("TabName : "); + l.setText("Name : "); tabNameText = new Text(top, SWT.SINGLE | SWT.BORDER); if (tabName != null) tabNameText.setText(tabName); tabNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - tabNameText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - tabName = tabNameText.getText(); - validate(); - } - }); +// tabNameText.addModifyListener(new ModifyListener() { +// public void modifyText(ModifyEvent e) { +// tabName = tabNameText.getText(); +// validate(); +// } +// }); l = new Label(top, SWT.NONE); l.setText("Device : "); @@ -201,108 +194,171 @@ public class AddViewDialog extends Dialog { } } - dCombo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (dCombo.getItemCount() != 0) { - // get the selection - device = dCombo.getItem(dCombo.getSelectionIndex()); - validate(); - } - } - }); +// dCombo.addSelectionListener(new SelectionAdapter() { +// @Override +// public void widgetSelected(SelectionEvent e) { +// if (dCombo.getItemCount() != 0) { +// // get the selection +// device = dCombo.getItem(dCombo.getSelectionIndex()); +// validate(); +// } +// } +// }); // separator - l = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); - l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - // center part with the filter parameters - Composite mid = new Composite(shell, SWT.NONE); - mid.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - mid.setLayout(new GridLayout(3, false)); - - final Button btnPid = new Button(mid, SWT.CHECK); - btnPid.setText("Pid"); - if (bPid) - btnPid.setSelection(true); - btnPid.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - if (btnPid.getSelection()) - bPid = true; - else - bPid = false; - validate(); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - final Button btnTag = new Button(mid, SWT.CHECK); - btnTag.setText("Tag"); - if (bTag) - btnTag.setSelection(true); - btnTag.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - if (btnTag.getSelection()) - bTag = true; - else - bTag = false; - validate(); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - final Button btnMsg = new Button(mid, SWT.CHECK); - btnMsg.setText("Message"); - if (bMsg) - btnMsg.setSelection(true); - btnMsg.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - if (btnMsg.getSelection()) - bMsg = true; - else - bMsg = false; - validate(); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - Composite bottom = new Composite(shell, SWT.NONE); - bottom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - bottom.setLayout(new GridLayout(2, false)); - - l = new Label(bottom, SWT.NONE); - l.setText("Search : "); - - searchText = new Text(bottom, SWT.SINGLE | SWT.BORDER); - searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - searchText.setEnabled(false); - if (keyword != null) - searchText.setText(keyword); - searchText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - keyword = searchText.getText(); - validate(); - } - }); +// l = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); +// l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + +// Composite mid = new Composite(shell, SWT.NONE); +// mid.setLayoutData(new GridData(GridData.FILL_BOTH)); +// mid.setLayout(new GridLayout(2, false)); + + + Group mid = new Group(shell, SWT.SHADOW_IN); + mid.setText("Search Keywords"); + mid.setLayoutData(new GridData(GridData.FILL_BOTH)); + mid.setLayout(new GridLayout(2, false)); + + l = new Label(mid, SWT.NONE); + l.setText("Tag : "); + + tagText = new Text(mid, SWT.SINGLE | SWT.BORDER); + if (tagKeyword != null) + tagText.setText(tagKeyword); + tagText.setMessage("Separated by a space/comma"); + tagText.setToolTipText("Search Tag Keywords are separated by a space as well as a comma"); + tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// tagText.addModifyListener(new ModifyListener() { +// public void modifyText(ModifyEvent e) { +// if( tagText.getText().length() != 0) +// tagKeyword = tagText.getText(); +// else +// tagKeyword = null; +// validate(); +// } +// }); + + l = new Label(mid, SWT.NONE); + l.setText("Pid : "); + + pidText = new Text(mid, SWT.SINGLE | SWT.BORDER); + if (pidKeyword != null) + pidText.setText(pidKeyword); + pidText.setMessage("Separated by a space/comma"); + pidText.setToolTipText("Search Pid Keywords are separated by a space as well as a comma"); + pidText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// pidText.addModifyListener(new ModifyListener() { +// public void modifyText(ModifyEvent e) { +// if( pidText.getText().length() != 0) +// pidKeyword = pidText.getText(); +//// validate(); +// } +// }); + + l = new Label(mid, SWT.NONE); + l.setText("Message : "); + + msgText = new Text(mid, SWT.SINGLE | SWT.BORDER); + if (msgKeyword != null) + msgText.setText(msgKeyword); + msgText.setMessage("Separated by a space/comma"); + msgText.setToolTipText("Search Message Keywords are separated by a space as well as a comma"); + msgText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// msgText.addModifyListener(new ModifyListener() { +// public void modifyText(ModifyEvent e) { +// if( msgText.getText().length() != 0) +// msgKeyword = msgText.getText(); +//// validate(); +// } +// }); + +// // center part with the filter parameters +// Composite mid = new Composite(shell, SWT.NONE); +// mid.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// mid.setLayout(new GridLayout(3, false)); +// +// final Button btnPid = new Button(mid, SWT.CHECK); +// btnPid.setText("Pid"); +// if (bPid) +// btnPid.setSelection(true); +// btnPid.addSelectionListener(new SelectionListener() { +// +// @Override +// public void widgetSelected(SelectionEvent e) { +// if (btnPid.getSelection()) +// bPid = true; +// else +// bPid = false; +// validate(); +// } +// +// @Override +// public void widgetDefaultSelected(SelectionEvent e) { +// } +// }); +// +// final Button btnTag = new Button(mid, SWT.CHECK); +// btnTag.setText("Tag"); +// if (bTag) +// btnTag.setSelection(true); +// btnTag.addSelectionListener(new SelectionListener() { +// +// @Override +// public void widgetSelected(SelectionEvent e) { +// if (btnTag.getSelection()) +// bTag = true; +// else +// bTag = false; +// validate(); +// } +// +// @Override +// public void widgetDefaultSelected(SelectionEvent e) { +// } +// }); +// +// final Button btnMsg = new Button(mid, SWT.CHECK); +// btnMsg.setText("Message"); +// if (bMsg) +// btnMsg.setSelection(true); +// btnMsg.addSelectionListener(new SelectionListener() { +// +// @Override +// public void widgetSelected(SelectionEvent e) { +// if (btnMsg.getSelection()) +// bMsg = true; +// else +// bMsg = false; +// validate(); +// } +// +// @Override +// public void widgetDefaultSelected(SelectionEvent e) { +// } +// }); +// +// Composite bottom = new Composite(shell, SWT.NONE); +// bottom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// bottom.setLayout(new GridLayout(2, false)); +// +// l = new Label(bottom, SWT.NONE); +// l.setText("Search : "); +// +// searchText = new Text(bottom, SWT.SINGLE | SWT.BORDER); +// searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// searchText.setEnabled(false); +// if (keyword != null) +// searchText.setText(keyword); +// searchText.addModifyListener(new ModifyListener() { +// public void modifyText(ModifyEvent e) { +// keyword = searchText.getText(); +// validate(); +// } +// }); // separator - l = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); - l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); +// l = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); +// l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // bottom part with the ok/cancel Composite bottomComp = new Composite(shell, SWT.NONE); @@ -312,7 +368,6 @@ public class AddViewDialog extends Dialog { okButton = new Button(bottomComp, SWT.NONE); okButton.setText("OK"); - okButton.setEnabled(false); okButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -330,6 +385,29 @@ public class AddViewDialog extends Dialog { } bOk = true; + + if( tabNameText.getText().length() != 0) + tabName = tabNameText.getText(); + else + tabName = TEMPNAME + cnt++; + + if( tagText.getText().length() != 0) + tagKeyword = tagText.getText(); + else + tagKeyword = null; + + if( pidText.getText().length() != 0) + pidKeyword = pidText.getText(); + else + pidKeyword = null; + + if( msgText.getText().length() != 0) + msgKeyword = msgText.getText(); + else + msgKeyword = null; + + device = dCombo.getItem(dCombo.getSelectionIndex()); + shell.close(); } }); @@ -344,12 +422,12 @@ public class AddViewDialog extends Dialog { } }); - validate(); +// validate(); } - public String getKeyword() { - return keyword; - } +// public String getKeyword() { +// return keyword; +// } public String getName() { return tabName; @@ -358,19 +436,34 @@ public class AddViewDialog extends Dialog { public String getDevice() { return device; } - - public boolean getPidChecked() { - return bPid; + + public String getPidKeyword() + { + return pidKeyword; } - - public boolean getTagChecked() { - return bTag; + + public String getTagKeyword() + { + return tagKeyword; } - - public boolean getMsgChecked() { - return bMsg; + + public String getMsgKeyword() + { + return msgKeyword; } +// public boolean getPidChecked() { +// return bPid; +// } +// +// public boolean getTagChecked() { +// return bTag; +// } +// +// public boolean getMsgChecked() { +// return bMsg; +// } + // /** // * Validates the content of the 2 text fields and enable/disable "ok", // while @@ -388,27 +481,27 @@ public class AddViewDialog extends Dialog { return; } - if (bMsg || bPid || bTag) { - if (!searchText.getEnabled()) - searchText.setEnabled(true); - - if (keyword == null || keyword.equals("")) { - okButton.setEnabled(false); - return; - } - - } else { - if (searchText.getEnabled()) - searchText.setEnabled(false); - } +// if (bMsg || bPid || bTag) { +// if (!searchText.getEnabled()) +// searchText.setEnabled(true); +// +// if (keyword == null || keyword.equals("")) { +// okButton.setEnabled(false); +// return; +// } +// +// } else { +// if (searchText.getEnabled()) +// searchText.setEnabled(false); +// } okButton.setEnabled(true); } public void setName(String name) { this.tabName = name; } - - public void setKeyword(String word) { - this.keyword = word; - } +// +// public void setKeyword(String word) { +// this.keyword = word; +// } } \ No newline at end of file diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java index 7a306d7..8299fdd 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java @@ -276,7 +276,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener { mid.setLayoutData(new GridData(GridData.FILL_BOTH)); mid.setLayout(new FillLayout()); - final Table table = new Table(mid, SWT.MULTI | SWT.FULL_SELECTION); + final Table table = new Table(mid, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.BORDER_SOLID ); table.setHeaderVisible(true); table.setLinesVisible(true); @@ -339,9 +339,9 @@ public class LogPanel extends Panel implements IDeviceChangeListener { public void widgetSelected(SelectionEvent e) { if(filterText.getText() != null) { - tab.setFilterMode((int) Math.pow(2, combo.getSelectionIndex())); - tab.setFilterWord(filterText.getText()); - tab.refill(); + int index = combo.getSelectionIndex(); + if( index != -1) + tab.tableRefill(index, filterText.getText()); } } @@ -351,16 +351,14 @@ public class LogPanel extends Panel implements IDeviceChangeListener { filterText = new Text(bottom, SWT.SINGLE | SWT.BORDER); filterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - filterText.setMessage(" Input Keyword "); + filterText.setMessage("Search Keywords from this table are separated by a space as well as a comma"); filterText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { int index = combo.getSelectionIndex(); if (index != -1) { - tab.setFilterMode((int) Math.pow(2, index)); - tab.setFilterWord(filterText.getText()); - tab.refill(); + tab.tableRefill(index, filterText.getText()); } } }); @@ -559,19 +557,9 @@ public class LogPanel extends Panel implements IDeviceChangeListener { LogTab newTab = createTab(device, dlg.getName()); - int filterMode = 0; - - if (dlg.getMsgChecked()) - filterMode |= LogTab.FILTER_MSG; - if (dlg.getPidChecked()) - filterMode |= LogTab.FILTER_PID; - if (dlg.getTagChecked()) - filterMode |= LogTab.FILTER_TAG; - - if (filterMode != LogTab.FILTER_NONE) - newTab.setFilterWord(dlg.getKeyword()); - - newTab.setFilterMode(filterMode); + newTab.setPidFilter(dlg.getPidKeyword()); + newTab.setTagFilter(dlg.getTagKeyword()); + newTab.setMsgFilter(dlg.getMsgKeyword()); newTab.startLogTab(); @@ -629,19 +617,10 @@ public class LogPanel extends Panel implements IDeviceChangeListener { } } - int filterMode = 0; - - if (dlg.getMsgChecked()) - filterMode |= LogTab.FILTER_MSG; - if (dlg.getPidChecked()) - filterMode |= LogTab.FILTER_PID; - if (dlg.getTagChecked()) - filterMode |= LogTab.FILTER_TAG; - - if (filterMode != LogTab.FILTER_NONE) - oldTab.setFilterWord(dlg.getKeyword()); - - oldTab.setFilterMode(filterMode); + oldTab.setPidFilter(dlg.getPidKeyword()); + oldTab.setTagFilter(dlg.getTagKeyword()); + oldTab.setMsgFilter(dlg.getMsgKeyword()); + if (bRestart) oldTab.startLogTab(); else diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java index 9aa57a7..198463a 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java @@ -43,10 +43,10 @@ public class LogTab { private static final int STRING_BUFFER_LENGTH = 10000; - public static final int FILTER_NONE = 0x0; - public static final int FILTER_PID = 0x1; - public static final int FILTER_TAG = 0x2; - public static final int FILTER_MSG = 0x4; + public static final int FILTER_NONE = 0x0; + public static final int FILTER_PID = 0x1; + public static final int FILTER_TAG = 0x2; + public static final int FILTER_MSG = 0x4; public static final int LEVEL_ALL = 0x1F; public static final int LEVEL_VERBOSE = 0x1; @@ -55,14 +55,20 @@ public class LogTab { public static final int LEVEL_WARNING = 0x8; public static final int LEVEL_ERROR = 0x16; - private int filterMode = FILTER_NONE; + private int filterMode = FILTER_NONE; /** * Single level log level as defined in Log.mLevelChar. Only valid if mMode * is MODE_LEVEL */ private int levelMode = LEVEL_ALL; - private String filterWord = null; + private String[] pidFilter = null; + private String[] tagFilter = null; + private String[] msgFilter = null; + + private String pidFilterString = null; + private String tagFilterString = null; + private String msgFilterString = null; private String filterName = null; private IDevice filterDevice = null; private LogTabOuputReceiver logger = null; @@ -77,8 +83,8 @@ public class LogTab { .compile("^\\[\\s(\\d\\d-\\d\\d\\s\\d\\d:\\d\\d:\\d\\d\\.\\d+)" + //$NON-NLS-1$ "\\s+(\\d*):[\\s]+([0-9a-fA-F]+)\\s([VDIWE])/(.*)\\]$"); //$NON-NLS-1$ - private final ArrayList tableMessages = new ArrayList(); - private final ArrayList newMessages = new ArrayList(); + private ArrayList tableMessages = new ArrayList(); + private ArrayList newMessages = new ArrayList(); // private final ArrayList mfMessages = new // ArrayList(); private LogMessage[] buffer = new LogMessage[STRING_BUFFER_LENGTH]; @@ -115,29 +121,77 @@ public class LogTab { } /** Sets the name of the filter. */ - void setFilterName(String name) { + public void setFilterName(String name) { filterName = name; } + public void setPidFilter(String pid) { + pidFilterString = pid; + if( pid != null) + pidFilter = setFilter(pid.split("[\\s\t,]")); + else + pidFilter = null; + } + + public void setTagFilter(String tag) { + tagFilterString = tag; + if( tag != null) + tagFilter = setFilter(tag.split("[\\s\t,]")); + else + tagFilter = null; + } + + public void setMsgFilter(String msg) { + msgFilterString = msg; + if( msg != null) + msgFilter = setFilter(msg.split("[\\s\t,]")); + else + msgFilter = null; + } + + private String[] setFilter( String[] array) + { + ArrayList result = new ArrayList(); + for( String s : array) + { + if( s.length() > 0 ) + { + result.add(s); + } + } + return result.toArray(new String[(result.size())]); + } + + /** * Returns the UI display name. */ public String getFilterName() { return filterName; } - - public int getLevelMode() - { + + public int getLevelMode() { return levelMode; } - - public String getFilterWord() - { - return filterWord; + + // public String getFilterWord() + // { + // return filterWord; + // } + + public String getPidFilter() { + return pidFilterString; } - - public String getFilterDeviceName() - { + + public String getTagFilter() { + return tagFilterString; + } + + public String getMsgFilter() { + return msgFilterString; + } + + public String getFilterDeviceName() { return filterDevice.getSerialNumber(); } @@ -152,7 +206,7 @@ public class LogTab { public void setTab(TabItem tabItem) { this.tabItem = tabItem; } - + public void setTable(Table table) { this.table = table; } @@ -180,15 +234,15 @@ public class LogTab { tabItem = null; } - /** - * Returns the current filtering mode. - * - * @return A bitmask. Possible values are MODE_PID, MODE_TAG, MODE_LEVEL - */ - public int getFilteringMode() { - return filterMode; - } - + // /** + // * Returns the current filtering mode. + // * + // * @return A bitmask. Possible values are MODE_PID, MODE_TAG, MODE_LEVEL + // */ + // public int getFilteringMode() { + // return filterMode; + // } + /** * Starts a new LogTab and set mCurrentLogTab as the current receiver. * @@ -262,18 +316,18 @@ public class LogTab { // and it'll be destroyed logger = null; -// // reset the content buffer -// for (int i = 0; i < STRING_BUFFER_LENGTH; i++) { -// buffer[i] = null; -// } -// -// // because it's a circular buffer, it's hard to know if -// // the array is empty with both start/end at 0 or if it's -// // full -// // with both start/end at 0 as well. So to mean empty, we -// // use -1 -// indexStart = -1; -// indexEnd = -1; + // // reset the content buffer + // for (int i = 0; i < STRING_BUFFER_LENGTH; i++) { + // buffer[i] = null; + // } + // + // // because it's a circular buffer, it's hard to know if + // // the array is empty with both start/end at 0 or if it's + // // full + // // with both start/end at 0 as well. So to mean empty, we + // // use -1 + // indexStart = -1; + // indexEnd = -1; clear(); // resetFilters(); @@ -288,12 +342,12 @@ public class LogTab { * selection state. */ public void setSelectedState(boolean selected) { -// if (selected) { -// if (tabItem != null) { -// tabItem.setText(filterName); -// } -// mUnreadCount = 0; -// } + // if (selected) { + // if (tabItem != null) { + // tabItem.setText(filterName); + // } + // mUnreadCount = 0; + // } mIsCurrentTabItem = selected; } @@ -346,7 +400,6 @@ public class LogTab { } } - /** * Filters a message. * @@ -366,21 +419,33 @@ public class LogTab { return false; } - if (filterMode != FILTER_NONE && filterWord != null) { - if ((filterMode & FILTER_PID) == FILTER_PID) { - if (Integer.toString(logMessage.data.pid).contains(filterWord)) - return true; + if (pidFilter != null || tagFilter != null || msgFilter != null) { + // if ((filterMode & FILTER_PID) == FILTER_PID) { + if (pidFilter != null) { + for( String filter : pidFilter) + { + if (Integer.toString(logMessage.data.pid).contains( + filter)) + return true; + } } - if ((filterMode & FILTER_TAG) == FILTER_TAG) { - if (logMessage.data.tag.toLowerCase().contains(filterWord.toLowerCase())) - return true; + // if ((filterMode & FILTER_TAG) == FILTER_TAG) { + if (tagFilter != null) { + for( String filter : tagFilter ){ + if (logMessage.data.tag.toLowerCase().contains( + filter.toLowerCase())) + return true; + } } - if ((filterMode & FILTER_MSG) == FILTER_MSG) { - if (logMessage.msg.toLowerCase().contains( - filterWord.toLowerCase())) - return true; + // if ((filterMode & FILTER_MSG) == FILTER_MSG) { + if (msgFilter != null) { + for( String filter : msgFilter){ + if (logMessage.msg.toLowerCase().contains( + filter.toLowerCase())) + return true; + } } return false; } @@ -478,8 +543,8 @@ public class LogTab { private void addTableItem(LogMessage msg) { TableItem item = new TableItem(table, SWT.NONE); item.setText(0, msg.data.time); -// item.setText(1, -// new String(new char[]{msg.data.logLevel.getPriorityLetter()})); + // item.setText(1, + // new String(new char[]{msg.data.logLevel.getPriorityLetter()})); item.setText(2, msg.data.pidString); item.setText(3, msg.data.tag); item.setText(4, msg.msg); @@ -501,7 +566,7 @@ public class LogTab { item.setText(1, "Warn"); } else if (msg.data.logLevel == LogLevel.WARN) { item.setForeground(colors.verboseColor); - item.setText(1, "Verbose"); + item.setText(1, "Verbose"); } } @@ -736,14 +801,12 @@ public class LogTab { } } } - - public void setLevelIcon( Action[] icons) - { - for( int i = 0 ; i<5 ; i++) - { + + public void setLevelIcon(Action[] icons) { + for (int i = 0; i < 5; i++) { int a = levelMode & (0x1 << i); - icons[i].setChecked( a == (int) Math.pow(2, i)); - } + icons[i].setChecked(a == (int) Math.pow(2, i)); + } } public void initTab() { @@ -779,13 +842,71 @@ public class LogTab { synchronized (buffer) { for (LogMessage logMsg : buffer) { if (accept(logMsg)) { + tableMessages.add(logMsg); + newMessages.add(logMsg); + } + } + } + flush(); + } + + public void tableRefill(int index, String tableFilter) { + newMessages.clear(); + lastMessageInfo = null; + if (table.isDisposed() == false) + table.removeAll(); + + synchronized (tableMessages) { + for (LogMessage logMsg : tableMessages) { + if (tableAccept(logMsg, index, tableFilter)) { newMessages.add(logMsg); } } } + flush(); } + boolean tableAccept(LogMessage logMessage, int index, String tableFilter) { + if (logMessage == null) + return false; + + switch(index){ + case 0: + if (tableFilter != null) { + String[] filter = tableFilter.split("[\\s\t,]"); + for (int i = 0; i < filter.length; i++) { + if (Integer.toString(logMessage.data.pid).contains( + filter[i])) + return true; + } + } + break; + case 1: + if (tableFilter != null) { + String[] filter = tableFilter.split("[\\s\t,]"); + for (int i = 0; i < filter.length; i++) { + if (logMessage.data.tag.toLowerCase().contains( + filter[i])) + return true; + } + } + break; + case 2: + if (tableFilter != null) { + String[] filter = tableFilter.split("[\\s\t,]"); + for (int i = 0; i < filter.length; i++) { + if (logMessage.msg.toLowerCase().contains( + filter[i])) + return true; + } + } + break; + + } + return false; + } + public void setLevel(int level, boolean setLevel) { level = (int) Math.pow(2, level); if (setLevel) @@ -799,10 +920,10 @@ public class LogTab { newMessages.clear(); lastMessageInfo = null; tableMessages.clear(); - if( table.isDisposed() == false ) + if (table.isDisposed() == false) table.removeAll(); } - + public void clear() { for (int i = 0; i < STRING_BUFFER_LENGTH; i++) { buffer[i] = null; @@ -814,27 +935,24 @@ public class LogTab { msgClear(); } - public void setFilterWord(String word) { - filterWord = word; - } + // public void setFilterWord(String word) { + // filterWord = word; + // } + // + // public void setFilterMode(int mode) { + // filterMode = mode; + // } - public void setFilterMode(int mode) { - filterMode = mode; - } - - public void setDevice( IDevice device ) - { + public void setDevice(IDevice device) { filterDevice = device; } - - public void setDefault() - { + + public void setDefault() { isDefault = true; } - - public boolean isDefault() - { + + public boolean isDefault() { return isDefault; } - + } \ No newline at end of file -- 2.7.4