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 {
item.setControl(getTabControl(folders, tab));
tab.setTab(item);
- folders.setSelection(item);
+ folders.setSelection(item );
tabs.add(tab);
if (tab.isDefault()) {
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.
*