• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.ddmuilib.logcat;
17 
18 import org.eclipse.jface.viewers.ITableLabelProvider;
19 import org.eclipse.jface.viewers.LabelProvider;
20 import org.eclipse.swt.graphics.Image;
21 
22 /**
23  * A JFace label provider for the LogCat filters. It expects elements of type
24  * {@link LogCatFilter}.
25  */
26 public final class LogCatFilterLabelProvider extends LabelProvider implements ITableLabelProvider {
getColumnImage(Object arg0, int arg1)27     public Image getColumnImage(Object arg0, int arg1) {
28         return null;
29     }
30 
31     /**
32      * Implements {@link ITableLabelProvider#getColumnText(Object, int)}.
33      * @param element an instance of {@link LogCatFilter}
34      * @param index index of the column
35      * @return text to use in the column
36      */
getColumnText(Object element, int index)37     public String getColumnText(Object element, int index) {
38         if (!(element instanceof LogCatFilter)) {
39             return null;
40         }
41 
42         LogCatFilter f = (LogCatFilter) element;
43 
44         if (f.getUnreadCount() == 0) {
45             return f.getName();
46         } else {
47             return String.format("%s (%d)", f.getName(), f.getUnreadCount());
48         }
49     }
50 }
51