author | wpaul |
Fri, 07 Aug 2009 13:47:27 -0500 | |
changeset 60 | 3982fab6369e |
parent 52 | 42077b7eab6e |
permissions | -rw-r--r-- |
37 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2008 Nokia and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* Nokia - Initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
||
12 |
package org.eclipse.cdt.debug.internal.ui.views.executables; |
|
13 |
||
14 |
import com.ibm.icu.text.DateFormat; |
|
15 |
import java.util.Date; |
|
16 |
||
17 |
import org.eclipse.cdt.debug.core.executables.Executable; |
|
18 |
import org.eclipse.cdt.debug.core.executables.ExecutablesManager; |
|
19 |
import org.eclipse.core.runtime.IPath; |
|
20 |
import org.eclipse.jface.viewers.ColumnLabelProvider; |
|
21 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
22 |
import org.eclipse.jface.viewers.ITreeContentProvider; |
|
23 |
import org.eclipse.jface.viewers.TreeViewer; |
|
24 |
import org.eclipse.jface.viewers.Viewer; |
|
25 |
import org.eclipse.jface.viewers.ViewerCell; |
|
26 |
||
27 |
class ExecutablesContentProvider extends ColumnLabelProvider implements IStructuredContentProvider, ITreeContentProvider { |
|
28 |
||
29 |
public ExecutablesContentProvider(TreeViewer viewer) { |
|
30 |
} |
|
31 |
||
32 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
|
33 |
} |
|
34 |
||
35 |
public void dispose() { |
|
36 |
} |
|
37 |
||
38 |
public Object[] getElements(final Object inputElement) { |
|
39 |
if (inputElement instanceof ExecutablesManager) { |
|
52
42077b7eab6e
Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents:
51
diff
changeset
|
40 |
ExecutablesManager em = (ExecutablesManager) inputElement; |
42077b7eab6e
Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents:
51
diff
changeset
|
41 |
return em.getExecutables().toArray(); |
37 | 42 |
} |
43 |
return new Object[] {}; |
|
44 |
} |
|
45 |
||
46 |
public Object getParent(Object element) { |
|
47 |
return null; |
|
48 |
} |
|
49 |
||
50 |
public boolean hasChildren(Object element) { |
|
51 |
return false; |
|
52 |
} |
|
53 |
||
54 |
@Override |
|
55 |
public void update(ViewerCell cell) { |
|
56 |
super.update(cell); |
|
57 |
Object element = cell.getElement(); |
|
58 |
if (element instanceof Executable) { |
|
59 |
Executable exe = (Executable) element; |
|
60 |
String cellText = exe.getName(); |
|
61 |
if (cell.getColumnIndex() == 1) |
|
62 |
cellText = exe.getProject().getName(); |
|
63 |
else if (cell.getColumnIndex() == 2) |
|
64 |
cellText = exe.getPath().toOSString(); |
|
65 |
else if (cell.getColumnIndex() == 3) { |
|
66 |
cellText = ""; //$NON-NLS-1$ |
|
67 |
IPath path = exe.getPath(); |
|
68 |
if (path != null && path.toFile().exists()) { |
|
69 |
long fileLength = path.toFile().length(); |
|
70 |
cellText = Long.toString(fileLength); |
|
71 |
} |
|
72 |
cell.setImage(null); |
|
73 |
} else if (cell.getColumnIndex() == 4) { |
|
74 |
cellText = ""; //$NON-NLS-1$ |
|
75 |
IPath path = exe.getPath(); |
|
76 |
if (path != null && path.toFile().exists()) { |
|
77 |
long modified = path.toFile().lastModified(); |
|
78 |
cellText = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date(modified)); |
|
79 |
} |
|
80 |
cell.setImage(null); |
|
81 |
} else if (cell.getColumnIndex() == 5) { |
|
82 |
cellText = ""; //$NON-NLS-1$ |
|
83 |
String fileExtension = exe.getPath().getFileExtension(); |
|
84 |
if (fileExtension != null) |
|
85 |
cellText = fileExtension; |
|
86 |
} |
|
87 |
cell.setText(cellText); |
|
88 |
} |
|
89 |
} |
|
90 |
||
91 |
@Override |
|
92 |
public String getText(Object element) { |
|
93 |
if (element instanceof Executable) { |
|
94 |
return ((Executable) element).getName(); |
|
95 |
} else |
|
96 |
return super.getText(element); |
|
97 |
} |
|
98 |
||
99 |
public Object[] getChildren(Object parentElement) { |
|
100 |
return new Object[] {}; |
|
101 |
} |
|
102 |
||
60
3982fab6369e
fixed executables view merge problems - bug #'s 9562, 9568, 9571.
wpaul
parents:
52
diff
changeset
|
103 |
} |