diff options
author | vbaciu | 2007-02-02 15:57:48 +0000 |
---|---|---|
committer | vbaciu | 2007-02-02 15:57:48 +0000 |
commit | 0a22813a22dab55649647642c60715c3217f70ed (patch) | |
tree | d0ed26567844a2f147daad78b9dd8dd019f222c9 /bundles | |
parent | 92bf643c1f9fdf0d3791f283b95215c21f42ef92 (diff) | |
download | webtools.sourceediting-0a22813a22dab55649647642c60715c3217f70ed.tar.gz webtools.sourceediting-0a22813a22dab55649647642c60715c3217f70ed.tar.xz webtools.sourceediting-0a22813a22dab55649647642c60715c3217f70ed.zip |
[171825] XML catalog displays an error when mapping a remote URI location
Diffstat (limited to 'bundles')
4 files changed, 53 insertions, 9 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java index 376674e7f3..037b518c53 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java @@ -173,7 +173,7 @@ public class EditCatalogEntryDialog extends Dialog { gd.grabExcessHorizontalSpace = true; resourceLocationField.setLayoutData(gd); - resourceLocationField.setText(getDisplayValue(URIHelper.URIToLocation(getEntry().getURI()))); + resourceLocationField.setText(getDisplayValue(URIUtils.convertURIToLocation(getEntry().getURI()))); // WorkbenchHelp.setHelp(resourceLocationField, // XMLBuilderContextIds.XMLP_ENTRY_URI); @@ -315,7 +315,7 @@ public class EditCatalogEntryDialog extends Dialog { } public void saveData() { - getEntry().setURI(URIHelper.LocationToURI(resourceLocationField.getText())); + getEntry().setURI(URIUtils.convertLocationToURI(resourceLocationField.getText())); getEntry().setKey(keyField.getText()); getEntry().setEntryType(getKeyType()); getEntry().setAttributeValue(ICatalogEntry.ATTR_WEB_URL, checkboxButton.getSelection() ? webAddressField.getText() : null); @@ -559,7 +559,7 @@ public class EditCatalogEntryDialog extends Dialog { catalogLocationField = new Text(group, SWT.SINGLE | SWT.BORDER); catalogLocationField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - catalogLocationField.setText(URIHelper.URIToLocation(getDisplayValue(getNextCatalog().getCatalogLocation()))); + catalogLocationField.setText(URIUtils.convertURIToLocation(getDisplayValue(getNextCatalog().getCatalogLocation()))); // WorkbenchHelp.setHelp(resourceLocationField, // XMLBuilderContextIds.XMLP_ENTRY_URI); catalogLocationField.addModifyListener(modifyListener); @@ -593,7 +593,7 @@ public class EditCatalogEntryDialog extends Dialog { } public void saveData() { - getNextCatalog().setCatalogLocation(URIHelper.LocationToURI(catalogLocationField.getText())); + getNextCatalog().setCatalogLocation(URIUtils.convertLocationToURI(catalogLocationField.getText())); } protected void updateWidgets(Widget widget) { diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/URIUtils.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/URIUtils.java new file mode 100644 index 0000000000..cf5a62c5c7 --- /dev/null +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/URIUtils.java @@ -0,0 +1,44 @@ +package org.eclipse.wst.xml.ui.internal.catalog; + +import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; + +public class URIUtils { + + private static final String PROTOCOL_PATTERN = ":"; + private static final String FILE_PROTOCOL = "file:"; + private static final String PLATFORM_RESOURCE_PROTOCOL = "platform:/resource/"; + private static final String LOCAL_FILE_PROTOCOL_FORWARD_SLASH = "\\\\\\"; + private static final String LOCAL_FILE_PROTOCOL_BACK_SLASH = "///"; + private static final char PATH_SEPARATOR_FORWARD_SLASH = '/'; + private static final char PATH_SEPARATOR_BACK_SLASH = '\\'; + + public static String convertURIToLocation(String uri) { + String location = uri; + if (uri != null) { + if (uri.startsWith(FILE_PROTOCOL)) { + location = org.eclipse.wst.common.uriresolver.internal.URI.createURI(uri).toFileString(); + if (location != null && (location.startsWith(LOCAL_FILE_PROTOCOL_BACK_SLASH) + || location.startsWith(LOCAL_FILE_PROTOCOL_FORWARD_SLASH))) { + location = location.substring(LOCAL_FILE_PROTOCOL_BACK_SLASH.length()); + } + } else if (uri.startsWith(PLATFORM_RESOURCE_PROTOCOL)) { + location = uri.substring(PLATFORM_RESOURCE_PROTOCOL.length()); + } + } + return location; + } + + public static String convertLocationToURI(String location) { + String uri = location; + if (!URIHelper.hasProtocol(location)) { + uri = URIHelper.isAbsolute(location)? org.eclipse.wst.common.uriresolver.internal.URI.createFileURI(location).toString() + : URIHelper.prependPlatformResourceProtocol(location); + } + if (uri.startsWith(FILE_PROTOCOL) && uri.indexOf(PROTOCOL_PATTERN, FILE_PROTOCOL.length()) != -1) { + uri = URIHelper.ensureFileURIProtocolFormat(uri); + } + uri = uri.replace(PATH_SEPARATOR_BACK_SLASH, PATH_SEPARATOR_FORWARD_SLASH); + return uri; + } + +} diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java index 53433e35a0..2f69661356 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java @@ -56,12 +56,12 @@ public class XMLCatalogEntryDetailsView String line0; if (value.startsWith("jar:file:")) { - String jarFile = URIHelper.URIToLocation(URIHelper.ensureURIProtocolFormat(value.substring("jar:".length(), value.indexOf('!')))); - String internalFile = URIHelper.URIToLocation(URIHelper.ensureURIProtocolFormat("file://" + value.substring(value.indexOf('!') + 1))); + String jarFile = URIUtils.convertURIToLocation(URIHelper.ensureURIProtocolFormat(value.substring("jar:".length(), value.indexOf('!')))); + String internalFile = URIUtils.convertURIToLocation(URIHelper.ensureURIProtocolFormat("file://" + value.substring(value.indexOf('!') + 1))); line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + internalFile + " " + XMLCatalogMessages.UI_LABEL_DETAILS_IN_JAR_FILE + " " + jarFile; } else { - value = URIHelper.URIToLocation(value); + value = URIUtils.convertURIToLocation(value); line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + value; //$NON-NLS-1$ } @@ -81,7 +81,7 @@ public class XMLCatalogEntryDetailsView String value = getDisplayValue(nextCatalog != null ? nextCatalog.getCatalogLocation() : ""); //$NON-NLS-1$ String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t" + value; //$NON-NLS-1$ - String line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + URIHelper.URIToLocation(value); + String line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + URIUtils.convertURIToLocation(value); String entireString = "\n" + line0 + "\n" + line1; //$NON-NLS-1$ detailsText.setText(entireString); diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java index b8637f5644..e61bff7a22 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java +++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java @@ -81,7 +81,7 @@ public class XMLCatalogTreeViewer extends TreeViewer { else if (object instanceof INextCatalog) { INextCatalog nextCatalog = (INextCatalog) object; //result = nextCatalog.getCatalogLocation(); - result = URIHelper.URIToLocation(nextCatalog.getCatalogLocation()); + result = URIUtils.convertURIToLocation(nextCatalog.getCatalogLocation()); if (nextCatalog.getCatalogLocation().startsWith("file:")) { result += " (" + XMLCatalogMessages.UI_LABEL_FILE_SYSTEM_RESOURCE + ")"; } else if (nextCatalog.getCatalogLocation().startsWith("platform:")) { |