From c9192e375844e45ccb74ee69150717a31385564f Mon Sep 17 00:00:00 2001 From: Siva Velusamy Date: Thu, 29 Sep 2011 14:34:39 -0700 Subject: Provide a way to show/hide the filters column. Change-Id: I7c94daa006987a0983cdb3cee02a35f6e678d86e --- .../com/android/ddmuilib/logcat/LogCatPanel.java | 48 +++++++++++++++++---- ddms/libs/ddmuilib/src/images/displayfilters.png | Bin 0 -> 242 bytes 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 ddms/libs/ddmuilib/src/images/displayfilters.png (limited to 'ddms') diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java index 607b5b2..b34b756 100644 --- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java +++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java @@ -99,6 +99,7 @@ public final class LogCatPanel extends SelectionDependentPanel } private static final String LOGCAT_VIEW_COLSIZE_PREFKEY_PREFIX = "logcat.view.colsize."; + private static final String DISPLAY_FILTERS_COLUMN_PREFKEY = "logcat.view.display.filters"; /** Default message to show in the message search field. */ private static final String DEFAULT_SEARCH_MESSAGE = @@ -116,6 +117,10 @@ public final class LogCatPanel extends SelectionDependentPanel private static final String IMAGE_EDIT_FILTER = "edit.png"; //$NON-NLS-1$ private static final String IMAGE_SAVE_LOG_TO_FILE = "save.png"; //$NON-NLS-1$ private static final String IMAGE_CLEAR_LOG = "clear.png"; //$NON-NLS-1$ + private static final String IMAGE_DISPLAY_FILTERS = "displayfilters.png"; //$NON-NLS-1$ + + private static final int[] WEIGHTS_SHOW_FILTERS = new int[] {15, 85}; + private static final int[] WEIGHTS_LOGCAT_ONLY = new int[] {0, 100}; private LogCatReceiver mReceiver; private IPreferenceStore mPrefStore; @@ -136,6 +141,8 @@ public final class LogCatPanel extends SelectionDependentPanel private String mLogFileExportFolder; private LogCatMessageLabelProvider mLogCatMessageLabelProvider; + private SashForm mSash; + /** * Construct a logcat panel. * @param prefStore preference store where UI preferences will be saved @@ -170,6 +177,7 @@ public final class LogCatPanel extends SelectionDependentPanel DEFAULT_LOGCAT_FONTDATA); mPrefStore.setDefault(LogCatMessageList.MAX_MESSAGES_PREFKEY, LogCatMessageList.MAX_MESSAGES_DEFAULT); + mPrefStore.setDefault(DISPLAY_FILTERS_COLUMN_PREFKEY, true); } private void initializePreferenceUpdateListeners() { @@ -251,14 +259,13 @@ public final class LogCatPanel extends SelectionDependentPanel } private void createViews(Composite parent) { - SashForm sash = createSash(parent); + mSash = createSash(parent); - createListOfFilters(sash); - createLogTableView(sash); + createListOfFilters(mSash); + createLogTableView(mSash); - /* allocate widths of the two columns 20%:80% */ - /* FIXME: save/restore sash widths */ - sash.setWeights(new int[] {20, 80}); + boolean showFilters = mPrefStore.getBoolean(DISPLAY_FILTERS_COLUMN_PREFKEY); + updateFiltersColumn(showFilters); } private SashForm createSash(Composite parent) { @@ -520,12 +527,37 @@ public final class LogCatPanel extends SelectionDependentPanel clearLog.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { - mReceiver.clearMessages(); - refreshLogCatTable(); + if (mReceiver != null) { + mReceiver.clearMessages(); + refreshLogCatTable(); + } + } + }); + + final ToolItem showFiltersColumn = new ToolItem(toolBar, SWT.CHECK); + showFiltersColumn.setImage( + ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_DISPLAY_FILTERS, + toolBar.getDisplay())); + showFiltersColumn.setSelection(mPrefStore.getBoolean(DISPLAY_FILTERS_COLUMN_PREFKEY)); + showFiltersColumn.setToolTipText("Display Saved Filters View"); + showFiltersColumn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + boolean showFilters = showFiltersColumn.getSelection(); + mPrefStore.setValue(DISPLAY_FILTERS_COLUMN_PREFKEY, showFilters); + updateFiltersColumn(showFilters); } }); } + private void updateFiltersColumn(boolean showFilters) { + if (showFilters) { + mSash.setWeights(WEIGHTS_SHOW_FILTERS); + } else { + mSash.setWeights(WEIGHTS_LOGCAT_ONLY); + } + } + /** * Save logcat messages selected in the table to a file. */ diff --git a/ddms/libs/ddmuilib/src/images/displayfilters.png b/ddms/libs/ddmuilib/src/images/displayfilters.png new file mode 100644 index 0000000..d110c2c Binary files /dev/null and b/ddms/libs/ddmuilib/src/images/displayfilters.png differ -- cgit v1.1