|
1 /* |
|
2 * Copyright (c) 2007 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 |
|
19 package com.nokia.s60tools.appdep.ui.views.data; |
|
20 |
|
21 import java.text.DateFormat; |
|
22 import java.util.Date; |
|
23 |
|
24 import com.nokia.s60tools.appdep.core.ITargetPlatform; |
|
25 |
|
26 /** |
|
27 * Represents a single component item in the |
|
28 * list showing available components for |
|
29 * the currently selected target(s). |
|
30 */ |
|
31 public class ComponentListNode{ |
|
32 |
|
33 // |
|
34 // Column sorting indices for table column sorter |
|
35 // |
|
36 public static final int NAME_COLUMN_INDEX = 0; |
|
37 public static final int TARGET_TYPE_COLUMN_INDEX = 1; |
|
38 public static final int DATE_CACHED_COLUMN_INDEX = 2; |
|
39 |
|
40 /** |
|
41 * Component name |
|
42 */ |
|
43 private final String name; |
|
44 /** |
|
45 * Target platform. |
|
46 */ |
|
47 private final ITargetPlatform buildTargetType; |
|
48 /** |
|
49 * Last modification timestamp (unix time seconds) for component when cached. |
|
50 */ |
|
51 private final long cachedComponentModificationTimestamp; |
|
52 |
|
53 /** |
|
54 * Using SHORT length date string representation. |
|
55 * Using static member in order to prevent fetching of country/locale information |
|
56 * for each date formatting operation. |
|
57 */ |
|
58 private static final DateFormat dtFormat = DateFormat.getDateInstance(DateFormat.SHORT); |
|
59 |
|
60 /** |
|
61 * Using MEDIUM length time string representation. |
|
62 * Using static member in order to prevent fetching of country/locale information |
|
63 * for each date formatting operation. |
|
64 */ |
|
65 private DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM);; |
|
66 |
|
67 /** |
|
68 * @param name Component name |
|
69 * @param buildTargetType Target platform. |
|
70 * @param cachedComponentModificationTimestamp last modification time for component |
|
71 */ |
|
72 public ComponentListNode(String name, ITargetPlatform buildTargetType, long cachedComponentModificationTimestamp){ |
|
73 this.name = name; |
|
74 this.buildTargetType = buildTargetType; |
|
75 this.cachedComponentModificationTimestamp = cachedComponentModificationTimestamp; |
|
76 } |
|
77 |
|
78 /* (non-Javadoc) |
|
79 * @see java.lang.Object#toString() |
|
80 */ |
|
81 public String toString(){ |
|
82 return name; |
|
83 } |
|
84 |
|
85 /** |
|
86 * Gets build target type for the component as string. |
|
87 * @return build target type for the component as string. |
|
88 */ |
|
89 public String getBuildTargetTypeAsString() { |
|
90 return buildTargetType.getId(); |
|
91 } |
|
92 |
|
93 /** |
|
94 * Gets last modification time for component when cached. |
|
95 * @return last modification time for component when cached |
|
96 */ |
|
97 public long getCachedComponentModificationTimestamp() { |
|
98 return cachedComponentModificationTimestamp; |
|
99 } |
|
100 |
|
101 /** |
|
102 * Gets last modification time for component when cached as string representation. |
|
103 * @return last modification time for component when cached as string |
|
104 */ |
|
105 public String getCachedComponentModificationTimestampAsString() { |
|
106 Date dt = new Date(cachedComponentModificationTimestamp); |
|
107 String dateStr = dtFormat.format(dt); |
|
108 String timeStr = timeFormat.format(dt); |
|
109 return dateStr + " " + timeStr; //$NON-NLS-1$ |
|
110 } |
|
111 |
|
112 /** |
|
113 * Gets component name. |
|
114 * @return component name. |
|
115 */ |
|
116 public String getComponentName() { |
|
117 return name; |
|
118 } |
|
119 |
|
120 /** |
|
121 * Gets build target type for the component. |
|
122 * @return build target type for the component. |
|
123 */ |
|
124 public ITargetPlatform getBuildTargetType() { |
|
125 return buildTargetType; |
|
126 } |
|
127 |
|
128 } |