blob: a800ab11a5d117f4a51c19c0b342cf922cdeaa74 (
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
|
/*******************************************************************************
* Copyright (c) 2010 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.commons.ui.notifications;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* @author Steffen Pingel
* @deprecated use classes in the <code>org.eclipse.mylyn.commons.notifications.core</code> bundle instead
*/
@Deprecated
public class NotificationElement {
protected final IConfigurationElement element;
private ImageDescriptor iconDescriptor;
private final String id;
private final String label;
public NotificationElement(IConfigurationElement element) {
Assert.isNotNull(element);
this.element = element;
this.id = element.getAttribute("id"); //$NON-NLS-1$
this.label = element.getAttribute("label"); //$NON-NLS-1$
}
public String getId() {
return id;
}
public ImageDescriptor getImageDescriptor() {
if (iconDescriptor == null) {
if (element != null) {
String iconPath = element.getAttribute("icon"); //$NON-NLS-1$
if (iconPath != null) {
iconDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(element.getContributor().getName(),
iconPath);
}
}
}
return iconDescriptor;
}
public String getLabel() {
return label;
}
public String getPluginId() {
return element.getContributor().getName();
}
public IStatus validate() {
if (id == null) {
return new Status(IStatus.ERROR, NotificationsPlugin.ID_PLUGIN, NLS.bind(
"Extension {0} contributed by {1} does not specify id attribute", element.getNamespaceIdentifier(), //$NON-NLS-1$
getPluginId())); //NON-NLS-1$
} else if (label == null) {
return new Status(IStatus.ERROR, NotificationsPlugin.ID_PLUGIN, NLS.bind(
"Extension {0} contributed by {1} does not specify label attribute", //$NON-NLS-1$
element.getNamespaceIdentifier(), getPluginId())); //NON-NLS-1$
}
return Status.OK_STATUS;
}
}
|