blob: 3a5f985e85c92ac2f3fa25a0bd5e9d2bd99bcbce (
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
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*******************************************************************************
* Copyright (c) 2000, 2009 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.internal.ui.registry;
import org.eclipse.core.runtime.*;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor;
public class SynchronizeParticipantDescriptor implements ISynchronizeParticipantDescriptor {
public static final String ATT_ID = "id"; //$NON-NLS-1$
public static final String ATT_NAME = "name"; //$NON-NLS-1$
public static final String ATT_ICON = "icon"; //$NON-NLS-1$
public static final String ATT_CLASS = "class"; //$NON-NLS-1$
private static final String ATT_PERSISTENT = "persistent"; //$NON-NLS-1$
public static final String ATT_HELP_CONTEXT_ID = "helpContextId"; //$NON-NLS-1$
private String label;
private String className;
private String id;
private boolean persistent;
private ImageDescriptor imageDescriptor;
private String description;
private String helpContextId;
private IConfigurationElement configElement;
/**
* Create a new ViewDescriptor for an extension.
* @param e the configuration element for an extension
* @param desc the view's description
* @throws CoreException if loading the view descriptor from the registry fails
*/
public SynchronizeParticipantDescriptor(IConfigurationElement e, String desc) throws CoreException {
configElement = e;
description = desc;
loadFromExtension();
}
public IConfigurationElement getConfigurationElement() {
return configElement;
}
/**
* Returns this view's description. This is the value of its <code>"description"</code>
* attribute.
*
* @return the description
*/
@Override
public String getDescription() {
return description;
}
@Override
public String getId() {
return id;
}
@Override
public ImageDescriptor getImageDescriptor() {
if (imageDescriptor != null)
return imageDescriptor;
String iconName = configElement.getAttribute(ATT_ICON);
if (iconName == null)
return null;
imageDescriptor = TeamUIPlugin.getImageDescriptorFromExtension(configElement.getDeclaringExtension(), iconName);
return imageDescriptor;
}
@Override
public String getName() {
return label;
}
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor#isPersistent()
*/
@Override
public boolean isPersistent() {
return persistent;
}
public String getHelpContextId() {
return helpContextId;
}
/**
* Loads a view descriptor from the registry.
*/
private void loadFromExtension() throws CoreException {
String identifier = configElement.getAttribute(ATT_ID);
label = configElement.getAttribute(ATT_NAME);
className = configElement.getAttribute(ATT_CLASS);
String persistentString = configElement.getAttribute(ATT_PERSISTENT);
if(persistentString == null) {
persistent = true;
} else {
persistent = Boolean.valueOf(persistentString).booleanValue();
}
helpContextId = configElement.getAttribute(ATT_HELP_CONTEXT_ID);
// Sanity check.
if ((label == null) || (className == null) || (identifier == null)) {
throw new CoreException(new Status(IStatus.ERROR, configElement.getNamespaceIdentifier(), 0, "Invalid extension (missing label or class name): " + identifier, //$NON-NLS-1$
null));
}
id = identifier;
}
/**
* Returns a string representation of this descriptor. For debugging
* purposes only.
*/
@Override
public String toString() {
return "Synchronize Participant(" + getId() + ")"; //$NON-NLS-2$//$NON-NLS-1$
}
}
|