[159368] [158037] [Catalog] Next catalog field should not show encoded URI (patches)
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 bcd38fa..376674e 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
@@ -83,6 +83,7 @@
protected void computeErrorMessage() {
errorMessage = null;
+ warningMessage = null;
if (errorMessage == null) {
String fileName = resourceLocationField.getText();
@@ -93,26 +94,26 @@
String uri = fileName;
if (!URIHelper.hasProtocol(uri)) {
- uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
+ URIHelper.isAbsolute(uri);
+ uri = (URIHelper.isAbsolute(uri)) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
}
if (errorMessage == null && !URIHelper.isReadableURI(uri, false)) {
errorMessage = XMLCatalogMessages.UI_WARNING_URI_NOT_FOUND_COLON + fileName;
}
- }
-
- // Make sure the key is a fully qualified URI
- if (keyField.getText().length() > 0) {
- URI uri = URI.createURI(keyField.getText());
- if (errorMessage == null && (uri.scheme() == null || uri.host() == null || !uri.hasAbsolutePath())) {
- errorMessage = XMLCatalogMessages.UI_WARNING_MUST_BE_FULLY_QUALIFIED_URI;
- }
- }
- else {
+ } else {
// this an error that is not actaully
// reported ... OK is just disabled
errorMessage = ""; //$NON-NLS-1$
}
+
+ // Make sure the key is a fully qualified URI in the cases where the key type is "System ID" or "Schema location"
+ if (keyField.getText().length() > 0 && getKeyType() == ICatalogEntry.ENTRY_TYPE_SYSTEM ) {
+ URI uri = URI.createURI(keyField.getText());
+ if (uri.scheme() == null) {
+ warningMessage = XMLCatalogMessages.UI_WARNING_SHOULD_BE_FULLY_QUALIFIED_URI;
+ }
+ }
}
if (errorMessage == null && checkboxButton.getSelection() && webAddressField.getText().trim().length() == 0) {
@@ -164,14 +165,16 @@
group.setLayout(layout);
Label resourceLocationLabel = new Label(group, SWT.NONE);
- resourceLocationLabel.setText(XMLCatalogMessages.UI_LABEL_URI_COLON);
+ resourceLocationLabel.setText(XMLCatalogMessages.UI_LABEL_LOCATION_COLON);
resourceLocationField = new Text(group, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
resourceLocationField.setLayoutData(gd);
- resourceLocationField.setText(getDisplayValue(getEntry().getURI()));
+
+ resourceLocationField.setText(getDisplayValue(URIHelper.URIToLocation(getEntry().getURI())));
+
// WorkbenchHelp.setHelp(resourceLocationField,
// XMLBuilderContextIds.XMLP_ENTRY_URI);
resourceLocationField.addModifyListener(modifyListener);
@@ -312,11 +315,7 @@
}
public void saveData() {
- String uri = resourceLocationField.getText();
- if (!URIHelper.hasProtocol(uri)) {
- uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
- }
- getEntry().setURI(uri);
+ getEntry().setURI(URIHelper.LocationToURI(resourceLocationField.getText()));
getEntry().setKey(keyField.getText());
getEntry().setEntryType(getKeyType());
getEntry().setAttributeValue(ICatalogEntry.ATTR_WEB_URL, checkboxButton.getSelection() ? webAddressField.getText() : null);
@@ -430,8 +429,10 @@
public void createAndOpen() {
this.create();
- getShell().setText(XMLCatalogMessages.UI_LABEL_SELECT_FILE);
setBlockOnOpen(true);
+ getShell().setText(XMLCatalogMessages.UI_LABEL_FILE_SELECTION);
+ this.setTitle(XMLCatalogMessages.UI_LABEL_SELECT_FILE);
+ this.setMessage(XMLCatalogMessages.UI_LABEL_CHOOSE_FILE_TO_ADD_TO_CATALOG);
open();
}
@@ -444,7 +445,6 @@
filterControl.setLayoutData(gd);
filterControl.setText(XMLCatalogMessages.UI_TEXT_SELECT_FILE_FILTER_CONTROL);
-
filterControl.add(XMLCatalogMessages.UI_TEXT_SELECT_FILE_FILTER_CONTROL);
for (Iterator i = CatalogFileTypeRegistryReader.getXMLCatalogFileTypes().iterator(); i.hasNext();) {
@@ -559,7 +559,7 @@
catalogLocationField = new Text(group, SWT.SINGLE | SWT.BORDER);
catalogLocationField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- catalogLocationField.setText(getDisplayValue(getNextCatalog().getCatalogLocation()));
+ catalogLocationField.setText(URIHelper.URIToLocation(getDisplayValue(getNextCatalog().getCatalogLocation())));
// WorkbenchHelp.setHelp(resourceLocationField,
// XMLBuilderContextIds.XMLP_ENTRY_URI);
catalogLocationField.addModifyListener(modifyListener);
@@ -593,11 +593,7 @@
}
public void saveData() {
- String uri = catalogLocationField.getText();
- if (!URIHelper.hasProtocol(uri)) {
- uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
- }
- getNextCatalog().setCatalogLocation(URIHelper.ensureFileURIProtocolFormat(uri));
+ getNextCatalog().setCatalogLocation(URIHelper.LocationToURI(catalogLocationField.getText()));
}
protected void updateWidgets(Widget widget) {
@@ -651,6 +647,8 @@
protected ICatalogElement fCatalogElement;
protected String errorMessage;
+
+ protected String warningMessage;
protected Button okButton;
@@ -847,7 +845,11 @@
}
protected void updateErrorMessageLabel(Label errorMessageLabel) {
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
+ if(errorMessage != null)
+ errorMessageLabel.setText(errorMessage);
+ else if (warningMessage != null)
+ errorMessageLabel.setText(warningMessage);
+ else errorMessageLabel.setText("");
}
protected void updateOKButtonState() {
@@ -959,7 +961,7 @@
FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE);
String file = dialog.open();
if (control instanceof Text && file != null) {
- ((Text) control).setText(URIHelper.ensureFileURIProtocolFormat(URI.createFileURI(file).toString()));
+ ((Text) control).setText(file);
}
}
}
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 4067b1d..53433e3 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
@@ -19,6 +19,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
@@ -37,7 +38,7 @@
detailsText = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
GridData data = new GridData(GridData.FILL_BOTH);
- data.heightHint = 65;
+ data.heightHint = 85;
detailsText.setLayoutData(data);
verticalScroll = detailsText.getVerticalBar();
@@ -49,8 +50,21 @@
public void setCatalogElement(ICatalogEntry entry)
{
- String value = getDisplayValue(entry != null ? entry.getURI() : ""); //$NON-NLS-1$
+
+ String value = getDisplayValue(entry != null ? entry.getURI() : ""); //$NON-NLS-1$
String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t" + value; //$NON-NLS-1$
+
+ 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)));
+ line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + internalFile + " " + XMLCatalogMessages.UI_LABEL_DETAILS_IN_JAR_FILE + " " + jarFile;
+ }
+ else {
+ value = URIHelper.URIToLocation(value);
+ line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + value; //$NON-NLS-1$
+
+ }
value = entry != null ? getKeyTypeValue(entry) : ""; //$NON-NLS-1$
String line2 = XMLCatalogMessages.UI_KEY_TYPE_DETAILS_COLON + "\t" + value; //$NON-NLS-1$
@@ -58,7 +72,7 @@
value = getDisplayValue(entry != null ? entry.getKey() : ""); //$NON-NLS-1$
String line3 = XMLCatalogMessages.UI_LABEL_DETAILS_KEY_COLON + "\t\t" + value; //$NON-NLS-1$
- String entireString = "\n" + line1 + "\n" + line2 + "\n" + line3; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String entireString = "\n" + line0 + "\n" + line1 + "\n" + line2 + "\n" + line3; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
detailsText.setText(entireString);
}
@@ -67,7 +81,9 @@
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 entireString = "\n" + line1; //$NON-NLS-1$
+ String line0 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t" + URIHelper.URIToLocation(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/XMLCatalogMessages.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java
index 90434df..3461ea5 100644
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java
+++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java
@@ -30,10 +30,12 @@
public static String UI_LABEL_KEY;
public static String UI_LABEL_KEY_COLON;
public static String UI_LABEL_DETAILS_KEY_COLON;
+ public static String UI_LABEL_DETAILS_IN_JAR_FILE;
public static String UI_LABEL_URI;
- public static String UI_LABEL_URI_COLON;
+ public static String UI_LABEL_LOCATION_COLON;
public static String UI_LABEL_CATALOG_URI_COLON;
public static String UI_LABEL_DETAILS_URI_COLON;
+ public static String UI_LABEL_DETAILS_URI_LOCATION;
public static String UI_KEY_TYPE_COLON;
public static String UI_KEY_TYPE_DETAILS_COLON;
public static String UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC;
@@ -43,6 +45,9 @@
public static String UI_KEY_TYPE_DESCRIPTION_URI;
public static String UI_LABEL_SPECIFY_ALTERNATIVE_WEB_URL;
public static String UI_WARNING_URI_MUST_NOT_HAVE_DOTS;
+ public static String UI_LABEL_FILE_SELECTION;
+ public static String UI_LABEL_CHOOSE_FILE_TO_ADD_TO_CATALOG;
+
public static String UI_WARNING_URI_NOT_FOUND_COLON;
public static String UI_WARNING_URI_NOT_FOUND_LONG;
@@ -51,7 +56,7 @@
public static String UI_WARNING_NO_ELEMENT;
public static String UI_WARNING_NO_ELEMENT_DTD_LONG;
public static String UI_WARNING_NO_ELEMENT_XSD_LONG;
- public static String UI_WARNING_MUST_BE_FULLY_QUALIFIED_URI;
+ public static String UI_WARNING_SHOULD_BE_FULLY_QUALIFIED_URI;
//NewModelWizard
@@ -92,7 +97,8 @@
public static String UI_LABEL_DETAILS;
public static String UI_LABEL_USER_SPECIFIED_ENTRIES;
public static String UI_LABEL_PLUGIN_SPECIFIED_ENTRIES;
-
+ public static String UI_LABEL_PLATFORM_RESOURCE;
+ public static String UI_LABEL_FILE_SYSTEM_RESOURCE;
// AdvancedOptionsDialog
public static String UI_BUTTON_IMPORT;
public static String UI_BUTTON_EXPORT;
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties
index 34ca383..05707bc 100644
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties
+++ b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties
@@ -19,12 +19,14 @@
UI_LABEL_KEY = Key
UI_LABEL_KEY_COLON = &Key:
UI_LABEL_DETAILS_KEY_COLON = Key:
+UI_LABEL_DETAILS_IN_JAR_FILE = in jar file
UI_LABEL_URI = URI
-UI_LABEL_URI_COLON = &URI:
-UI_LABEL_CATALOG_URI_COLON = URI of another XML Catalog file:
+UI_LABEL_LOCATION_COLON = &Location:
+UI_LABEL_CATALOG_URI_COLON = Location of another XML Catalog file:
UI_LABEL_DETAILS_URI_COLON = URI:
UI_KEY_TYPE_COLON = Key &Type:
UI_KEY_TYPE_DETAILS_COLON = Key Type:
+UI_LABEL_DETAILS_URI_LOCATION = Location:
UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC = Namespace Name
UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM = Schema Location
UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC = Public ID
@@ -32,9 +34,11 @@
UI_KEY_TYPE_DESCRIPTION_URI = URI
UI_LABEL_SPECIFY_ALTERNATIVE_WEB_URL = Specify &alternative web address
UI_WARNING_URI_MUST_NOT_HAVE_DOTS = URI must not included '.' or '..'
+UI_LABEL_PLATFORM_RESOURCE = Workspace
+UI_LABEL_FILE_SYSTEM_RESOURCE = File System
UI_WARNING_URI_NOT_FOUND_COLON = The specified resource can't be located :
-UI_WARNING_MUST_BE_FULLY_QUALIFIED_URI = The key value must be a fully qualified URI
+UI_WARNING_SHOULD_BE_FULLY_QUALIFIED_URI = Warning: the key value should be a fully qualified URI
UI_WARNING_URI_NOT_FOUND_LONG = The specified file cannot be found. It may have been moved to a different location. If the file is located remotely, a network connection cannot be established to the remote location.
UI_WARNING_INVALID_FILE = The specified file is invalid.
UI_WARNING_INVALID_FILE_LONG = The specified file is invalid. A proper XML file cannot be generated from it. Open the DTD or XML schema file, edit it as necessary, validate it and try again.
@@ -81,7 +85,9 @@
UI_LABEL_DETAILS = Details
UI_LABEL_USER_SPECIFIED_ENTRIES = User Specified Entries
UI_LABEL_PLUGIN_SPECIFIED_ENTRIES = Plugin Specified Entries
-
+UI_LABEL_FILE_SELECTION = File Selection
+UI_LABEL_CHOOSE_FILE_TO_ADD_TO_CATALOG = Choose a file to add to the XML Catalog
+
!AdvancedOptionsDialog
UI_LABEL_DIALOG_DESCRIPTION = Use the buttons below to import or export XML Catalog settings.
UI_BUTTON_IMPORT = Import...
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 cd9c491..f09cf4d 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
@@ -80,7 +80,13 @@
}
else if (object instanceof INextCatalog) {
INextCatalog nextCatalog = (INextCatalog) object;
- result = nextCatalog.getCatalogLocation();
+ //result = nextCatalog.getCatalogLocation();
+ result = URIHelper.URIToLocation(nextCatalog.getCatalogLocation());
+ if (nextCatalog.getCatalogLocation().startsWith("file:")) {
+ result += " (" + XMLCatalogMessages.UI_LABEL_FILE_SYSTEM_RESOURCE + ")";
+ } else if (nextCatalog.getCatalogLocation().startsWith("platform:")) {
+ result += " (" + XMLCatalogMessages.UI_LABEL_PLATFORM_RESOURCE + ")";
+ }
}
return result != null ? result : object.toString();
}