blob: 7de3b44eee20d0854374b937dce09656f4f612c2 (
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
|
/*******************************************************************************
* Copyright (c) 2010, 2013 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
* Wind River Systems - Extracted from o.e.mylyn.commons and adapted for Target Explorer
*******************************************************************************/
package org.eclipse.tcf.te.ui.notifications.internal;
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.tcf.te.ui.notifications.activator.UIPlugin;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* @author Steffen Pingel
*/
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, UIPlugin.getUniqueIdentifier(),
NLS.bind("Extension {0} contributed by {1} does not specify id attribute", element.getNamespaceIdentifier(), getPluginId())); //$NON-NLS-1$
}
else if (label == null) {
return new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
NLS.bind("Extension {0} contributed by {1} does not specify label attribute", element.getNamespaceIdentifier(), getPluginId())); //$NON-NLS-1$
}
return Status.OK_STATUS;
}
}
|