crashanalysis/crashanalyser/com.nokia.s60tools.crashanalyser/src/com/nokia/s60tools/crashanalyser/ui/views/MainViewLabelProvider.java
changeset 0 5ad7ad99af01
equal deleted inserted replaced
-1:000000000000 0:5ad7ad99af01
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.s60tools.crashanalyser.ui.views;
       
    19 
       
    20 import org.eclipse.jface.viewers.ITableLabelProvider;
       
    21 import org.eclipse.jface.viewers.LabelProvider;
       
    22 import org.eclipse.swt.graphics.Image;
       
    23 import com.nokia.s60tools.crashanalyser.model.CrashFileBundle;
       
    24 import com.nokia.s60tools.crashanalyser.resources.ImageKeys;
       
    25 import com.nokia.s60tools.crashanalyser.resources.ImageResourceManager;
       
    26 
       
    27 /**
       
    28  * Label provider for MainView's table. Provides a correct image
       
    29  * for a row in MainView. Provides also a text for each column in a row.
       
    30  *
       
    31  */
       
    32 public class MainViewLabelProvider extends LabelProvider implements
       
    33 		ITableLabelProvider {
       
    34 	
       
    35 	/**
       
    36 	 * Returns text for a column defined by index
       
    37 	 */
       
    38 	public String getColumnText(Object obj, int index) {
       
    39 		CrashFileBundle cFileBundle = (CrashFileBundle)obj;
       
    40 		return cFileBundle.getText(index);
       
    41 	}
       
    42 	
       
    43 	/**
       
    44 	 * Returns an image for first column only. Returns null
       
    45 	 * for other columns.
       
    46 	 */
       
    47 	public Image getColumnImage(Object obj, int index) {
       
    48 		if (index == CrashFileBundle.INDEX_TIME)
       
    49 			return getImage(obj);
       
    50 		else
       
    51 			return null;
       
    52 	}
       
    53 	
       
    54 	/**
       
    55 	 * Returns a correct image for a CrashFileBundle type. 
       
    56 	 * Correct image depends on which types of files CrashFileBundle contains.
       
    57 	 */
       
    58 	public Image getImage(Object obj) {
       
    59 		CrashFileBundle cFile = (CrashFileBundle)obj;
       
    60 
       
    61 		// empty file does not need an image
       
    62 		if (cFile.isEmpty()) {
       
    63 			return null;
       
    64 		// image for emulator panic
       
    65 		} else if (cFile.isEmulatorPanic()) {
       
    66 			return ImageResourceManager.getImage(ImageKeys.EMULATOR_PANIC);
       
    67 		// decoded file
       
    68 		} else if (cFile.isFullyDecoded()) {
       
    69 			return ImageResourceManager.getImage(ImageKeys.DECODED_FILE);
       
    70 		// summary file
       
    71 		} else if (cFile.isPartiallyDecoded()) {
       
    72 			return ImageResourceManager.getImage(ImageKeys.PARTIALLY_DECODED_FILE);
       
    73 		// undecoded file
       
    74 		} else {
       
    75 			return ImageResourceManager.getImage(ImageKeys.CODED_FILE);
       
    76 		}
       
    77 	}
       
    78 }