[Title] set all level icon selected in logview
authorhyunsik.noh <hyunsik.noh@samsung.com>
Thu, 8 Dec 2011 02:18:05 +0000 (11:18 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Thu, 8 Dec 2011 02:18:05 +0000 (11:18 +0900)
fix to keep level status on each logtab
[Type] Enhancement
[Module] common
[Priority] Minor

com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogPanel.java
com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/log/LogTab.java
com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ui/LogView.java

index cdc6d21..12b9671 100644 (file)
@@ -156,16 +156,13 @@ public class LogPanel extends Panel implements IDeviceChangeListener {
                folders.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
-                               if (currentTab != null) {
-                                       currentTab.setSelectedState(false);
-                               }
+
                                currentTab = getCurrentLogTab();
-                               if (currentTab == null)
-                                       return;
-                               currentTab.setSelectedState(true);
-                               // updateColumns(currentTab.getTable());
+                               if( currentTab == null)
+                                       return ;
                                currentTab.initTab();
-                               // selectionChanged(currentTab);
+                               currentTab.setLevelIcon(levelActions);
+                               
                                if (currentTab.isDefault()) {
                                        setActionEnabled(LogPanel.ENABLE_DEFAULT);
                                } else {
@@ -237,7 +234,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener {
                item.setControl(getTabControl(folders, tab));
                tab.setTab(item);
 
-               folders.setSelection(item);
+               folders.setSelection(item       );
                tabs.add(tab);
 
                if (tab.isDefault()) {
@@ -450,360 +447,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener {
                                new Transfer[] { TextTransfer.getInstance() });
        }
 
-       // public void resetUI(boolean inUiThread) {
-       //
-       // // the ui is static we just empty it.
-       // if (table.isDisposed() == false) {
-       // if (inUiThread) {
-       // emptyTables();
-       // } else {
-       // Display d = table.getDisplay();
-       //
-       // // run sync as we need to update right now.
-       // d.syncExec(new Runnable() {
-       // public void run() {
-       // if (table.isDisposed() == false) {
-       // emptyTables();
-       // }
-       // }
-       // });
-       // }
-       // }
-       // }
-
-       // /**
-       // * Process new Log lines coming from {@link LogCatOuputReceiver}.
-       // * @param lines the new lines
-       // */
-       // protected void processLogLines(String[] lines) {
-       // // WARNING: this will not work if the string contains more line than
-       // // the buffer holds.
-       //
-       // if (lines.length > STRING_BUFFER_LENGTH) {
-       // Log.e("LogCat", "Receiving more lines than STRING_BUFFER_LENGTH");
-       // }
-       //
-       // // parse the lines and create LogMessage that are stored in a
-       // temporary list
-       // final ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>();
-       //
-       // synchronized (mBuffer) {
-       // for (String line : lines) {
-       // // ignore empty lines.
-       // if (line.length() > 0) {
-       // // check for header lines.
-       // Matcher matcher = sLogPattern.matcher(line);
-       // if (matcher.matches()) {
-       // // this is a header line, parse the header and keep it around.
-       // mLastMessageInfo = new LogMessageInfo();
-       //
-       // mLastMessageInfo.time = matcher.group(1);
-       // mLastMessageInfo.pidString = matcher.group(2);
-       // mLastMessageInfo.pid = Integer.valueOf(mLastMessageInfo.pidString);
-       // mLastMessageInfo.logLevel =
-       // LogLevel.getByLetterString(matcher.group(4));
-       // mLastMessageInfo.tag = matcher.group(5).trim();
-       // } else {
-       // // This is not a header line.
-       // // Create a new LogMessage and process it.
-       // LogMessage mc = new LogMessage();
-       //
-       // if (mLastMessageInfo == null) {
-       // return ;
-       // }
-       //
-       // // If someone printed a log message with
-       // // embedded '\n' characters, there will
-       // // one header line followed by multiple text lines.
-       // // Use the last header that we saw.
-       // mc.data = mLastMessageInfo;
-       //
-       // // tabs seem to display as only 1 tab so we replace the leading tabs
-       // // by 4 spaces.
-       //                              mc.msg = line.replaceAll("\t", "    "); //$NON-NLS-1$ //$NON-NLS-2$
-       //
-       // // process the new LogMessage.
-       // processNewMessage(mc);
-       //
-       // // store the new LogMessage
-       // newMessages.add(mc);
-       // }
-       // }
-       // }
-       //
-       // // if we don't have a pending Runnable that will do the refresh, we
-       // ask the Display
-       // // to run one in the UI thread.
-       // if (mPendingAsyncRefresh == false) {
-       // mPendingAsyncRefresh = true;
-       //
-       // try {
-       // Display display = table.getDisplay();
-       //
-       // // run in sync because this will update the buffer start/end indices
-       // display.asyncExec(new Runnable() {
-       // public void run() {
-       // asyncRefresh();
-       // }
-       // });
-       // } catch (SWTException e) {
-       // // display is disposed, we're probably quitting. Let's stop.
-       // stopLogCat(false);
-       // }
-       // }
-       // }
-       // }
-       //
-       // /**
-       // * Processes a new Message.
-       // * <p/>This adds the new message to the buffer, and gives it to the
-       // existing filters.
-       // * @param newMessage
-       // */
-       // private void processNewMessage(LogMessage newMessage) {
-       // // // if we are in auto filtering mode, make sure we have
-       // // // a filter for this
-       //
-       // // compute the index where the message goes.
-       // // was the buffer empty?
-       // int messageIndex = -1;
-       // if (mBufferStart == -1) {
-       // messageIndex = mBufferStart = 0;
-       // mBufferEnd = 1;
-       // } else {
-       // messageIndex = mBufferEnd;
-       //
-       // // check we aren't overwriting start
-       // if (mBufferEnd == mBufferStart) {
-       // mBufferStart = (mBufferStart + 1) % STRING_BUFFER_LENGTH;
-       // }
-       //
-       // // increment the next usable slot index
-       // mBufferEnd = (mBufferEnd + 1) % STRING_BUFFER_LENGTH;
-       // }
-       //
-       // LogMessage oldMessage = null;
-       //
-       // // record the message that was there before
-       // if (mBuffer[messageIndex] != null) {
-       // oldMessage = mBuffer[messageIndex];
-       // }
-       //
-       // // then add the new one
-       // mBuffer[messageIndex] = newMessage;
-       //
-       // synchronized (mfMessages) {
-       // if (oldMessage != null)
-       // {
-       // if( mfMessages.size() > STRING_BUFFER_LENGTH)
-       // {
-       // int index = mfMessages.indexOf(oldMessage);
-       // if (index != -1) {
-       // // TODO check that index will always be -1 or 0, as only the oldest
-       // message is ever removed.
-       // mfMessages.remove(index);
-       // mRemovedMessageCount++;
-       // }
-       // }
-       // }
-       // }
-       //
-       // boolean filter = accept(newMessage);
-       // if (filter) {
-       // // at this point the message is accepted, we add it to the list
-       // mfMessages.add(newMessage);
-       // mNewMessages.add( newMessage );
-       // // autosave( newMessage );
-       // }
-       //
-       // }
-       //
-       // /**
-       // * Refill the default filter. Not to be called directly.
-       // * @see initFilter()
-       // */
-       // public void refill() {
-       // msgClear();
-       //
-       // synchronized( mBuffer )
-       // {
-       // for( LogMessage logMsg : mBuffer)
-       // {
-       // if( accept (logMsg))
-       // {
-       // mNewMessages.add(logMsg);
-       // // autosave( logMsg );
-       // }
-       // }
-       // }
-       // flush();
-       // }
-       //
-       // public void msgClear() {
-       // mRemovedMessageCount = 0;
-       // mNewMessages.clear();
-       // mfMessages.clear();
-       // table.removeAll();
-       // }
-
-       // private void emptyTables() {
-       // table.removeAll();
-       // }
-       //
-       // /**
-       // * Takes all the accepted messages and display them.
-       // * This must be called from a UI thread.
-       // */
-       // public void flush() {
-       // // if scroll bar is at the bottom, we will scroll
-       // ScrollBar bar = table.getVerticalBar();
-       // boolean scroll = bar.getMaximum() == bar.getSelection() +
-       // bar.getThumb();
-       //
-       // // if we are not going to scroll, get the current first item being
-       // shown.
-       // int topIndex = table.getTopIndex();
-       //
-       // // disable drawing
-       // table.setRedraw(false);
-       //
-       // int totalCount = mNewMessages.size();
-       //
-       // try {
-       // // remove the items of the old messages.
-       // for (int i = 0 ; i < mRemovedMessageCount && table.getItemCount() > 0
-       // ; i++) {
-       // table.remove(0);
-       // }
-       //
-       // // add the new items
-       // for (int i = 0 ; i < totalCount ; i++) {
-       // LogMessage msg = mNewMessages.get(i);
-       // addTableItem(msg);
-       // }
-       // } catch (SWTException e) {
-       // // log the error and keep going. Content of the logcat table maybe
-       // unexpected
-       // // but at least ddms won't crash.
-       // Log.e("LogFilter", e);
-       // }
-       //
-       // // redraw
-       // table.setRedraw(true);
-       //
-       // // scroll if needed, by showing the last item
-       // if (scroll) {
-       // totalCount = table.getItemCount();
-       // if (totalCount > 0) {
-       // table.showItem(table.getItem(totalCount-1));
-       // }
-       // } else if (mRemovedMessageCount > 0) {
-       // // we need to make sure the topIndex is still visible.
-       // // Because really old items are removed from the list, this could make
-       // it disappear
-       // // if we don't change the scroll value at all.
-       //
-       // topIndex -= mRemovedMessageCount;
-       // if (topIndex < 0) {
-       // // looks like it disappeared. Lets just show the first item
-       // table.showItem(table.getItem(0));
-       // } else {
-       // table.showItem(table.getItem(topIndex));
-       // }
-       // }
-       //
-       // mNewMessages.clear();
-       // mRemovedMessageCount = 0;
-       //
-       // // if( autoFile!=null)
-       // // try {
-       // // autoFile.flush();
-       // // } catch (IOException e) {
-       // // e.printStackTrace();
-       // // }
-       // }
-       //
-       // /**
-       // * Add a TableItem for the index-th item of the buffer
-       // * @param filter The index of the table in which to insert the item.
-       // */
-       // 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(2, msg.data.pidString);
-       // item.setText(3, msg.data.tag);
-       // item.setText(4, msg.msg);
-       //
-       // // add the buffer index as data
-       // item.setData(msg);
-       //
-       // if (msg.data.logLevel == LogLevel.INFO) {
-       // item.setForeground(mColors.infoColor);
-       // } else if (msg.data.logLevel == LogLevel.DEBUG) {
-       // item.setForeground(mColors.debugColor);
-       // } else if (msg.data.logLevel == LogLevel.ERROR) {
-       // item.setForeground(mColors.errorColor);
-       // } else if (msg.data.logLevel == LogLevel.WARN) {
-       // item.setForeground(mColors.warningColor);
-       // } else {
-       // item.setForeground(mColors.verboseColor);
-       // }
-       // }
-
-       // public void setLevel( int level, boolean setLevel )
-       // {
-       // level = (int) Math.pow(2, level);
-       // if( setLevel )
-       // mLevelMode |= level;
-       // else
-       // mLevelMode &= (~level);
-       // }
 
-       // /**
-       // * Filters a message.
-       // * @param logMessage the Message
-       // * @return true if the message is accepted by the filter.
-       // */
-       // boolean accept(LogMessage logMessage) {
-       //
-       // if( logMessage == null )
-       // return false;
-       //
-       // if( mLevelMode != LEVEL_NONE )
-       // {
-       // int a = 0;
-       // a = ( mLevelMode & (0x1 << (logMessage.data.logLevel.getPriority() - 2
-       // )));
-       //
-       // if( a == 0 )
-       // return false;
-       // }
-       //
-       // if( mFilterMode != FILTER_NONE && filterWord != null)
-       // {
-       // if( (mFilterMode & FILTER_PID) != 0 )
-       // {
-       // if( !Integer.toString(logMessage.data.pid).contains(filterWord))
-       // return false;
-       // }
-       //
-       // if( (mFilterMode & FILTER_TAG) != 0 )
-       // {
-       // if( !logMessage.data.tag.contains(filterWord))
-       // return false;
-       // }
-       //
-       // if( (mFilterMode & FILTER_MSG) != 0)
-       // {
-       // if( !logMessage.msg.toLowerCase().contains(filterWord.toLowerCase()))
-       // return false;
-       // }
-       // }
-       // return true;
-       // }
-       //
        /**
         * saves the current selection in a text file.
         * 
index 3ac1e2c..27589f6 100644 (file)
@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.eclipse.jface.action.Action;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.SWTException;
 import org.eclipse.swt.widgets.Display;
@@ -29,7 +30,7 @@ public class LogTab {
        public static final int FILTER_TAG = 0x2;
        public static final int FILTER_MSG = 0x4;
 
-       public static final int LEVEL_NONE = 0x0;
+       public static final int LEVEL_ALL = 0x1F;
        public static final int LEVEL_VERBOSE = 0x1;
        public static final int LEVEL_DEBUG = 0x2;
        public static final int LEVEL_INFO = 0x4;
@@ -41,7 +42,7 @@ public class LogTab {
         * Single level log level as defined in Log.mLevelChar. Only valid if mMode
         * is MODE_LEVEL
         */
-       private int levelMode = LEVEL_NONE;
+       private int levelMode = LEVEL_ALL;
 
        private String filterWord = null;
        private String filterName = null;
@@ -107,6 +108,11 @@ public class LogTab {
                return filterName;
        }
        
+       public int getLevelMode()
+       {
+               return levelMode;
+       }
+       
        public String getFilterWord()
        {
                return filterWord;
@@ -264,12 +270,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;
        }
 
@@ -334,7 +340,7 @@ public class LogTab {
                if (logMessage == null)
                        return false;
 
-               if (levelMode != LEVEL_NONE) {
+               if (levelMode != LEVEL_ALL) {
                        int a = 0;
                        a = (levelMode & (0x1 << (logMessage.data.logLevel.getPriority() - 2)));
 
@@ -711,6 +717,15 @@ public class LogTab {
                        }
                }
        }
+       
+       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));
+               }               
+       }
 
        public void initTab() {
 
index c67ba6f..5cd1ba1 100644 (file)
@@ -278,7 +278,7 @@ public final class LogView extends ViewPart {
                                        }
                                }
                        };
-
+                       logLevelActions[i].setChecked(true);
                        logLevelActions[i].setToolTipText(name);
                        logLevelActions[i].setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin(logLevelIcons[i]));
                }