blob: a70818a604e7fa6a3c0df519bfc7fbfd01ddb57a (
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
/***************************************************************************************************
* Copyright (c) 2003, 2004 IBM Corporation 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: IBM Corporation - initial API and implementation
**************************************************************************************************/
package org.eclipse.wst.common.frameworks.internal.operation.extensionui;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jem.util.logger.proxy.Logger;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.AbstractRegistryDescriptor;
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.IDMExtendedPageHandler;
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.IDMExtendedWizardPage;
import org.eclipse.wst.common.frameworks.internal.enablement.IdentifiableComparator;
public class DMWizardPageElement extends AbstractRegistryDescriptor implements Comparable {
/** Type designation for an {@link ExtendedEditorPage} */
public static final int EXTENDED_EDITOR_PAGE = 0;
/** Type designation for a nested editor */
public static final int NESTED_EDITOR = 1;
static final String[] EMPTY_STRING_ARRAY = new String[0];
static final String ELEMENT_PAGE_GROUP = "wizardPageGroup"; //$NON-NLS-1$
static final String ATT_PAGE_ID = "pageGroupID"; //$NON-NLS-1$
static final String ATT_WIZARD_ID = "wizardID"; //$NON-NLS-1$
static final String ATT_GROUP_ID = "groupID"; //$NON-NLS-1$
static final String ATT_ALLOWS_EXTENDED_PAGES_AFTER = "allowsExtendedPagesAfter"; //$NON-NLS-1$
static final String ATT_PAGE_INSERTION_ID = "pageGroupInsertionID"; //$NON-NLS-1$
static final String ELEMENT_FACTORY = "factory"; //$NON-NLS-1$
protected DMWizardPageFactoryElement wizardPageFactoryElement;
protected String pluginID;
protected String wizardID;
public String pageGroupID;
protected String wizardFactoryElement;
protected boolean allowsExtendedPagesAfter;
protected String pageInsertionID;
private int loadOrder;
private static int loadOrderCounter;
private int type;
public DMWizardPageElement(IConfigurationElement element1) {
super(element1);
pluginID = element1.getDeclaringExtension().getDeclaringPluginDescriptor().getUniqueIdentifier();
wizardID = element1.getAttribute(ATT_WIZARD_ID);
pageGroupID = element1.getAttribute(ATT_PAGE_ID);
readAllowsExtendedPageAfter(element1);
pageInsertionID = element1.getAttribute(ATT_PAGE_INSERTION_ID);
readFactory(element1);
validateSettings();
loadOrder = loadOrderCounter++;
}
private void validateSettings() {
if (wizardID == null || wizardPageFactoryElement == null) {
Logger.getLogger().logError("Incomplete page extension specification."); //$NON-NLS-1$
}
}
private void readAllowsExtendedPageAfter(IConfigurationElement element1) {
String allowsPageAfterValue = element1.getAttribute(ATT_ALLOWS_EXTENDED_PAGES_AFTER);
allowsExtendedPagesAfter = allowsPageAfterValue == null ? false : Boolean.valueOf(allowsPageAfterValue).booleanValue();
}
private void readFactory(IConfigurationElement element1) {
IConfigurationElement[] factories = element1.getChildren(ELEMENT_FACTORY);
if (factories != null && factories.length > 0) {
wizardPageFactoryElement = new DMWizardPageFactoryElement(factories[0], pageGroupID);
}
}
public IDMExtendedPageHandler createPageHandler(IDataModel dataModel) {
if (wizardPageFactoryElement != null)
return wizardPageFactoryElement.createPageHandler(dataModel);
return null;
}
public IDMExtendedWizardPage[] createPageGroup(IDataModel dataModel) {
if (wizardPageFactoryElement != null)
return wizardPageFactoryElement.createPageGroup(dataModel);
return null;
}
public int compareTo(Object o) {
return IdentifiableComparator.getInstance().compare(this, o);
/*
* if (o == null) return GREATER_THAN; WizardPageElement element = (WizardPageElement) o; if
* (getID() == null && element.getID() == null) return compareLoadOrder(element); if
* (getID() == null) return GREATER_THAN; else if (element.getID() == null) return
* LESS_THAN;
*
* int priority = getPriority(); int elementPriority =element.getPriority();
*
* if (priority == elementPriority) return compareLoadOrder(element); if (priority <
* elementPriority) return GREATER_THAN; if (priority > elementPriority) return LESS_THAN;
* return EQUAL;
*/
}
/**
* @return
*/
public boolean allowsExtendedPagesAfter() {
return allowsExtendedPagesAfter;
}
/**
* @return
*/
public String getPluginID() {
return pluginID;
}
/**
* @return
*/
public String getPageID() {
return pageGroupID;
}
/**
* @return
*/
public String getPageInsertionID() {
return pageInsertionID;
}
/**
* @return
*/
public int getType() {
return type;
}
/**
* @return
*/
public int getLoadOrder() {
return loadOrder;
}
/**
* @return Returns the allowsExtendedPagesAfter.
*/
public boolean isAllowsExtendedPagesAfter() {
return allowsExtendedPagesAfter;
}
/**
* @param allowsExtendedPagesAfter
* The allowsExtendedPagesAfter to set.
*/
public void setAllowsExtendedPagesAfter(boolean allowsExtendedPagesAfter) {
this.allowsExtendedPagesAfter = allowsExtendedPagesAfter;
}
/**
* @return Returns the wizardFactoryElement.
*/
public String getWizardFactoryElement() {
return wizardFactoryElement;
}
/**
* @param wizardFactoryElement
* The wizardFactoryElement to set.
*/
public void setWizardFactoryElement(String wizardFactoryElement) {
this.wizardFactoryElement = wizardFactoryElement;
}
/**
* @return Returns the wizardID.
*/
public String getWizardID() {
return wizardID;
}
/**
* @param wizardID
* The wizardID to set.
*/
public void setWizardID(String wizardID) {
this.wizardID = wizardID;
}
/**
* @return Returns the wizardPageFactoryElement.
*/
public DMWizardPageFactoryElement getWizardPageFactoryElement() {
return wizardPageFactoryElement;
}
/**
* @param wizardPageFactoryElement
* The wizardPageFactoryElement to set.
*/
public void setWizardPageFactoryElement(DMWizardPageFactoryElement wizardPageFactoryElement) {
this.wizardPageFactoryElement = wizardPageFactoryElement;
}
/**
* @param pageID
* The pageID to set.
*/
public void setPageID(String pageID) {
this.pageGroupID = pageID;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.common.frameworks.internal.AbstractRegistryDescriptor#getID()
*/
public String getID() {
return getPageID();
}
}
|