blob: 456165c2bfffb33c438e28d0f9b27d9b8ce643f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*******************************************************************************
* Copyright (c) 2004, 2011 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.views;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.core.Category;
import org.eclipse.mylyn.internal.tasks.ui.ConnectorBrand;
import org.eclipse.mylyn.internal.tasks.ui.IBrandManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.DisconnectRepositoryAction;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.swt.graphics.Image;
/**
* @author Mik Kersten
*/
public class TaskRepositoryLabelProvider implements ILabelProvider {
//extends LabelProvider implements ITableLabelProvider {
public Image getColumnImage(Object obj, int index) {
if (index == 0) {
return getImage(obj);
} else {
return null;
}
}
public Image getImage(Object object) {
if (object instanceof Category) {
return CommonImages.getImage(TasksUiImages.CATEGORY);
} else if (object instanceof AbstractRepositoryConnector) {
AbstractRepositoryConnector repositoryConnector = (AbstractRepositoryConnector) object;
Image image = getBrandManager().getDefaultBrandingIcon(repositoryConnector.getConnectorKind());
if (image != null) {
return image;
} else {
return CommonImages.getImage(TasksUiImages.REPOSITORY);
}
} else if (object instanceof ConnectorBrand) {
ConnectorBrand connectorBrand = (ConnectorBrand) object;
Image image = getBrandManager().getBrandingIcon(connectorBrand.getConnector().getConnectorKind(),
connectorBrand.getBrandId());
if (image != null) {
return image;
} else {
return CommonImages.getImage(TasksUiImages.REPOSITORY);
}
} else if (object instanceof TaskRepository) {
if (((TaskRepository) object).isOffline()) {
return CommonImages.getImage(TasksUiImages.REPOSITORY_OFFLINE);
} else {
return CommonImages.getImage(TasksUiImages.REPOSITORY);
}
}
return null;
}
public String getText(Object object) {
if (object instanceof TaskRepository) {
TaskRepository repository = (TaskRepository) object;
StringBuilder label = new StringBuilder();
label.append(repository.getRepositoryLabel());
if (repository.isOffline()) {
label.append(" [" + DisconnectRepositoryAction.LABEL + "]"); //$NON-NLS-1$ //$NON-NLS-2$
}
return label.toString();
} else if (object instanceof AbstractRepositoryConnector) {
return ((AbstractRepositoryConnector) object).getLabel();
} else if (object instanceof ConnectorBrand) {
ConnectorBrand connectorBrand = (ConnectorBrand) object;
return getBrandManager().getConnectorLabel(connectorBrand.getConnector(), connectorBrand.getBrandId());
} else if (object instanceof Category) {
return ((Category) object).getLabel();
} else {
return null;
}
}
protected IBrandManager getBrandManager() {
return TasksUiPlugin.getDefault().getBrandManager();
}
public void addListener(ILabelProviderListener listener) {
// ignore
}
public void dispose() {
// ignore
}
public boolean isLabelProperty(Object element, String property) {
// ignore
return false;
}
public void removeListener(ILabelProviderListener listener) {
// ignore
}
}
|