Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 313176
Collapse All | Expand All

(-)plugin.xml (-19 / +16 lines)
Lines 217-241 Link Here
217
			commandId="org.eclipse.jpt.ui.xmlFileUpgradeToLatestVersion"
217
			commandId="org.eclipse.jpt.ui.xmlFileUpgradeToLatestVersion"
218
			class="org.eclipse.jpt.ui.internal.commands.UpgradeXmlFileVersionHandler">
218
			class="org.eclipse.jpt.ui.internal.commands.UpgradeXmlFileVersionHandler">
219
			<enabledWhen>
219
			<enabledWhen>
220
				<and>
220
				<iterate>
221
					<count value="1"/>
221
					<or>
222
					<iterate>
222
						<adapt
223
						<or>
223
							type="org.eclipse.jpt.core.context.XmlFile">
224
							<adapt
224
							<test
225
								type="org.eclipse.jpt.core.context.XmlFile">
225
								property="org.eclipse.jpt.core.isLatestSupportedVersion"
226
								<test
226
								value="false"/>
227
									property="org.eclipse.jpt.core.isLatestSupportedVersion"
227
						</adapt>
228
									value="false"/>
228
						<adapt
229
							</adapt>
229
							type="org.eclipse.jpt.core.resource.xml.JpaXmlResource">
230
							<adapt
230
							<test
231
								type="org.eclipse.jpt.core.resource.xml.JpaXmlResource">
231
								property="org.eclipse.jpt.core.isLatestSupportedVersion"
232
								<test
232
								value="false"/>
233
									property="org.eclipse.jpt.core.isLatestSupportedVersion"
233
						</adapt>
234
									value="false"/>
234
					</or>
235
							</adapt>
235
				</iterate>
236
						</or>
237
					</iterate>
238
				</and>
239
			</enabledWhen>
236
			</enabledWhen>
240
		</handler>
237
		</handler>
241
		
238
		
(-)src/org/eclipse/jpt/ui/internal/commands/UpgradeXmlFileVersionHandler.java (-9 / +12 lines)
Lines 27-37 Link Here
27
	public Object execute(ExecutionEvent event) throws ExecutionException {
27
	public Object execute(ExecutionEvent event) throws ExecutionException {
28
		IStructuredSelection selection 
28
		IStructuredSelection selection 
29
			= (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
29
			= (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
30
		
30
31
		// only applies for a singly selected objects that adapt to JpaXmlResource or XmlFile
31
		for (Object selectedObject : selection.toArray()) {
32
		Object selectedObject = selection.getFirstElement();
32
			upgradeXmlFileVersion(selectedObject);
33
		}
34
		return null;
35
	}
36
37
	protected void upgradeXmlFileVersion(Object selectedObject) {
33
		JpaXmlResource xmlResource = 
38
		JpaXmlResource xmlResource = 
34
				(JpaXmlResource) Platform.getAdapterManager().getAdapter(selectedObject, JpaXmlResource.class);
39
			(JpaXmlResource) Platform.getAdapterManager().getAdapter(selectedObject, JpaXmlResource.class);
35
		if (xmlResource == null) {
40
		if (xmlResource == null) {
36
			XmlFile xmlFile = 
41
			XmlFile xmlFile = 
37
				(XmlFile) Platform.getAdapterManager().getAdapter(selectedObject, XmlFile.class);
42
				(XmlFile) Platform.getAdapterManager().getAdapter(selectedObject, XmlFile.class);
Lines 40-60 Link Here
40
			}
45
			}
41
		}
46
		}
42
		if (xmlResource == null) {
47
		if (xmlResource == null) {
43
			return null;
48
			return;
44
		}
49
		}
45
		
50
46
		final JpaRootEObject root = xmlResource.getRootObject();
51
		final JpaRootEObject root = xmlResource.getRootObject();
47
		IContentType contentType = xmlResource.getContentType();
52
		IContentType contentType = xmlResource.getContentType();
48
		JpaProject jpaProject = JptCorePlugin.getJpaProject(xmlResource.getProject());
53
		JpaProject jpaProject = JptCorePlugin.getJpaProject(xmlResource.getProject());
49
		final String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion();
54
		final String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion();
50
		
55
51
		xmlResource.modify(
56
		xmlResource.modify(
52
			new Runnable() {
57
			new Runnable() {
53
				public void run() {
58
				public void run() {
54
					root.setVersion(newVersion);
59
					root.setVersion(newVersion);
55
				}
60
				}
56
			});
61
			});
57
		
58
		return null;
59
	}
62
	}
60
}
63
}

Return to bug 313176