Home | History | Annotate | Download | only in location
      1 /*
      2  * Copyright (C) 2008 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 
     17 package com.android.ddmuilib.location;
     18 
     19 import com.android.ddmuilib.location.GpxParser.Track;
     20 
     21 import org.eclipse.jface.viewers.ILabelProviderListener;
     22 import org.eclipse.jface.viewers.ITableLabelProvider;
     23 import org.eclipse.swt.graphics.Image;
     24 import org.eclipse.swt.widgets.Table;
     25 
     26 import java.util.Date;
     27 
     28 /**
     29  * Label Provider for {@link Table} objects displaying {@link Track} objects.
     30  */
     31 public class TrackLabelProvider implements ITableLabelProvider {
     32 
     33     public Image getColumnImage(Object element, int columnIndex) {
     34         return null;
     35     }
     36 
     37     public String getColumnText(Object element, int columnIndex) {
     38         if (element instanceof Track) {
     39             Track track = (Track)element;
     40             switch (columnIndex) {
     41                 case 0:
     42                     return track.getName();
     43                 case 1:
     44                     return Integer.toString(track.getPointCount());
     45                 case 2:
     46                     long time = track.getFirstPointTime();
     47                     if (time != -1) {
     48                         return new Date(time).toString();
     49                     }
     50                     break;
     51                 case 3:
     52                     time = track.getLastPointTime();
     53                     if (time != -1) {
     54                         return new Date(time).toString();
     55                     }
     56                     break;
     57                 case 4:
     58                     return track.getComment();
     59             }
     60         }
     61 
     62         return null;
     63     }
     64 
     65     public void addListener(ILabelProviderListener listener) {
     66         // pass
     67     }
     68 
     69     public void dispose() {
     70         // pass
     71     }
     72 
     73     public boolean isLabelProperty(Object element, String property) {
     74         // pass
     75         return false;
     76     }
     77 
     78     public void removeListener(ILabelProviderListener listener) {
     79         // pass
     80     }
     81 }
     82