author | terytkon |
Thu, 11 Mar 2010 18:39:02 +0200 | |
changeset 0 | 30eb2d538f02 |
permissions | -rw-r--r-- |
0
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
1 |
/* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
3 |
* All rights reserved. |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
8 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
9 |
* Initial Contributors: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
11 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
12 |
* Contributors: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
13 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
14 |
* Description: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
15 |
* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
16 |
*/ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
17 |
package s60cenrep.provider; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
18 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
19 |
import java.util.ArrayList; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
20 |
import java.util.List; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
21 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
22 |
import helpers.MarkerManager; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
23 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
24 |
import org.eclipse.core.runtime.IStatus; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
25 |
import org.eclipse.emf.common.notify.AdapterFactory; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
26 |
import org.eclipse.emf.common.util.ResourceLocator; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
27 |
import org.eclipse.emf.ecore.resource.Resource; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
28 |
import org.eclipse.emf.edit.provider.ComposedImage; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
29 |
import org.eclipse.emf.edit.provider.resource.ResourceItemProvider; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
30 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
31 |
import cenrep.Repository; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
32 |
import cenrep.provider.CRPluginModelEditPlugin; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
33 |
import cenrep.util.CenrepResourceImpl; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
34 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
35 |
public class BrowserResourceItemProvider extends ResourceItemProvider { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
36 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
37 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
38 |
private static Object resourceImageNormal = null; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
39 |
private static Object resourceImageWarning = null; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
40 |
private static Object resourceImageError = null; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
41 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
42 |
public BrowserResourceItemProvider(AdapterFactory adapterFactory) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
43 |
super(adapterFactory); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
44 |
resourceImageNormal = getResourceLocator().getImage("full/obj16/Resource"); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
45 |
List<Object> images = new ArrayList<Object>(2); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
46 |
images.add(resourceImageNormal); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
47 |
images.add(getResourceLocator().getImage("full/ovr16/error_co")); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
48 |
resourceImageError = new ComposedImage(images); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
49 |
images.clear(); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
50 |
images.add(resourceImageNormal); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
51 |
images.add(getResourceLocator().getImage("full/ovr16/warning_co")); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
52 |
resourceImageWarning = new ComposedImage(images); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
53 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
54 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
55 |
@Override |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
56 |
public String getText(Object object) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
57 |
Resource resource = (Resource)object; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
58 |
/* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
59 |
if (resource.getContents().isEmpty()) |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
60 |
return resource.getURI().lastSegment()+" (no content)"; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
61 |
else if (!resource.getErrors().isEmpty()) |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
62 |
{ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
63 |
return resource.getURI().lastSegment()+" ("+resource.getErrors().get(0).getMessage()+")"; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
64 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
65 |
else*/ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
66 |
return resource.getURI().lastSegment(); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
67 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
68 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
69 |
@Override |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
70 |
public Object getImage(Object object) { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
71 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
72 |
if (((CenrepResourceImpl)object).getContents().isEmpty() || !((CenrepResourceImpl)object).getErrors().isEmpty()){ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
73 |
return overlayImage(object, getResourceLocator().getImage("full/obj16/error_tsk")); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
74 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
75 |
else |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
76 |
{ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
77 |
Repository repo = (Repository)((CenrepResourceImpl)object).getContents().get(0); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
78 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
79 |
if (repo!=null) |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
80 |
{ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
81 |
switch (MarkerManager.getInstance().getProblemStatus(repo)) |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
82 |
{ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
83 |
case IStatus.ERROR: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
84 |
return resourceImageError; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
85 |
case IStatus.WARNING: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
86 |
return resourceImageWarning; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
87 |
default: |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
88 |
return resourceImageNormal; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
89 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
90 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
91 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
92 |
else |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
93 |
return resourceImageNormal; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
94 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
95 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
96 |
/* |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
97 |
if (((CenrepResourceImpl)object).getContents().isEmpty() || !((CenrepResourceImpl)object).getErrors().isEmpty()){ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
98 |
return overlayImage(object, getResourceLocator().getImage("full/obj16/error_tsk")); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
99 |
}else{ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
100 |
return super.getImage(object); |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
101 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
102 |
*/ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
103 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
104 |
|
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
105 |
/** |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
106 |
* Return the resource locator for this item provider's resources. |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
107 |
* <!-- begin-user-doc --> |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
108 |
* <!-- end-user-doc --> |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
109 |
* @generated |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
110 |
*/ |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
111 |
@Override |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
112 |
public ResourceLocator getResourceLocator() { |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
113 |
return CRPluginModelEditPlugin.INSTANCE; |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
114 |
} |
30eb2d538f02
Moved all configtools under oss repository and under epl licence.
terytkon
parents:
diff
changeset
|
115 |
} |