use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class XMLHyperlinkDetector method createHyperlink.
/**
* Create the appropriate hyperlink
*
* @param uriString
* @param hyperlinkRegion
* @return IHyperlink
*/
private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
IHyperlink link = null;
ICatalogEntry entry = getCatalogEntry(uriString);
if (entry != null) {
link = new CatalogEntryHyperlink(hyperlinkRegion, entry);
} else {
// try to locate the file in the workspace
File systemFile = getFileFromUriString(uriString);
if (systemFile != null) {
String systemPath = systemFile.getPath();
IFile file = getFile(systemPath);
if (file != null) {
// this is a WorkspaceFileHyperlink since file exists in
// workspace
link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
} else {
// this is an ExternalFileHyperlink since file does not
// exist in workspace
link = new ExternalFileHyperlink(hyperlinkRegion, systemFile);
}
}
}
return link;
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class BugFixesTest method testInvalidSchemaWithNamespaceInCatalog.
/**
* Test /BugFixes/XSDRegisteredWithCatalog/InvalidSchemaWithNamespaceInCatalog.xsd
*/
public void testInvalidSchemaWithNamespaceInCatalog() {
String testname = "InvalidSchemaWithNamespaceInCatalog";
String testfile = PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd";
String loglocation = PLUGIN_ABSOLUTE_PATH + GENERATED_RESULTS_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd-log";
String idealloglocation = PLUGIN_ABSOLUTE_PATH + IDEAL_RESULTS_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd-log";
createSimpleProject("Project", new String[] { testfile });
ICatalog catalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
for (int i = 0; i < nextCatalogs.length; i++) {
INextCatalog nextCatalog = nextCatalogs[i];
if (XMLCorePlugin.USER_CATALOG_ID.equals(nextCatalog.getId())) {
ICatalog userCatalog = nextCatalog.getReferencedCatalog();
if (userCatalog != null) {
ICatalogEntry catalogEntry = (ICatalogEntry) userCatalog.createCatalogElement(ICatalogEntry.ENTRY_TYPE_PUBLIC);
catalogEntry.setKey("http://www.eclipse.org/webtools/Catalogue");
catalogEntry.setURI("platform:/resource/Project/InvalidSchemaInXMLCatalog.xsd");
userCatalog.addCatalogElement(catalogEntry);
runTest("platform:/resource/Project/InvalidSchemaWithNamespaceInCatalog.xsd", loglocation, idealloglocation);
catalog.removeCatalogElement(catalogEntry);
}
}
}
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class BugFixesTest method testInvalidSchemaInXMLCatalog.
/**
* Test /BugFixes/InvalidSchemaInXMLCatalog/InvalidSchemaInXMLCatalog.xsd
*/
public void testInvalidSchemaInXMLCatalog() {
String testname = "InvalidSchemaInXMLCatalog";
String testfile = PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd";
String loglocation = PLUGIN_ABSOLUTE_PATH + GENERATED_RESULTS_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd-log";
String idealloglocation = PLUGIN_ABSOLUTE_PATH + IDEAL_RESULTS_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd-log";
createSimpleProject("Project", new String[] { testfile });
ICatalog catalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
for (int i = 0; i < nextCatalogs.length; i++) {
INextCatalog nextCatalog = nextCatalogs[i];
if (XMLCorePlugin.USER_CATALOG_ID.equals(nextCatalog.getId())) {
ICatalog userCatalog = nextCatalog.getReferencedCatalog();
if (userCatalog != null) {
ICatalogEntry catalogEntry = (ICatalogEntry) userCatalog.createCatalogElement(ICatalogEntry.ENTRY_TYPE_PUBLIC);
catalogEntry.setKey("testKey");
catalogEntry.setURI("http://testuri");
userCatalog.addCatalogElement(catalogEntry);
runTest("platform:/resource/Project/InvalidSchemaInXMLCatalog.xsd", /*FILE_PROTOCOL + file.getLocation().toString()*/
loglocation, idealloglocation);
catalog.removeCatalogElement(catalogEntry);
}
}
}
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class ProjectDescription method getCatalogRecords.
private Collection getCatalogRecords() {
if (fCatalogRecords == null) {
List records = new ArrayList();
ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
if (defaultCatalog != null) {
// Process default catalog
ICatalogEntry[] entries = defaultCatalog.getCatalogEntries();
for (int entry = 0; entry < entries.length; entry++) {
ITaglibRecord record = createCatalogRecord(entries[entry]);
records.add(record);
}
// Process declared OASIS nextCatalogs catalog
INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
for (int nextCatalog = 0; nextCatalog < nextCatalogs.length; nextCatalog++) {
ICatalog catalog = nextCatalogs[nextCatalog].getReferencedCatalog();
ICatalogEntry[] entries2 = catalog.getCatalogEntries();
for (int entry = 0; entry < entries2.length; entry++) {
String uri = entries2[entry].getURI();
if (uri != null) {
uri = uri.toLowerCase(Locale.US);
if (uri.endsWith((".jar")) || uri.endsWith((".tld"))) {
ITaglibRecord record = createCatalogRecord(entries2[entry]);
if (record != null) {
records.add(record);
}
}
}
}
}
}
fCatalogRecords = records;
}
return fCatalogRecords;
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class CatalogContributorRegistryReader method processMappingInfoElements.
private void processMappingInfoElements(IConfigurationElement[] childElementList) {
if (catalog == null)
return;
for (int i = 0; i < childElementList.length; i++) {
IConfigurationElement childElement = childElementList[i];
String name = childElement.getName();
String key = null;
int type = ICatalogEntry.ENTRY_TYPE_PUBLIC;
if (OASISCatalogConstants.TAG_PUBLIC.equals(name)) {
key = childElement.getAttribute(OASISCatalogConstants.ATTR_PUBLIC_ID);
} else if (OASISCatalogConstants.TAG_SYSTEM.equals(name)) {
key = childElement.getAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID);
type = ICatalogEntry.ENTRY_TYPE_SYSTEM;
} else if (OASISCatalogConstants.TAG_URI.equals(name)) {
key = childElement.getAttribute(OASISCatalogConstants.ATTR_NAME);
type = ICatalogEntry.ENTRY_TYPE_URI;
} else if (OASISCatalogConstants.TAG_NEXT_CATALOG.equals(name)) {
processNextCatalogElements(new IConfigurationElement[] { childElement });
continue;
}
if (// $NON-NLS-1$
key == null || key.equals("")) {
Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_entry_key_not_set);
continue;
}
// mandatory
String entryURI = childElement.getAttribute(OASISCatalogConstants.ATTR_URI);
if (// $NON-NLS-1$
entryURI == null || entryURI.equals("")) {
Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_entry_uri_not_set);
continue;
}
ICatalogElement catalogElement = catalog.createCatalogElement(type);
if (catalogElement instanceof ICatalogEntry) {
ICatalogEntry entry = (ICatalogEntry) catalogElement;
entry.setKey(key);
String resolvedPath = resolvePath(entryURI);
entry.setURI(resolvedPath);
// optional
String id = childElement.getAttribute(OASISCatalogConstants.ATTR_ID);
if (// $NON-NLS-1$
id != null && !id.equals("")) {
entry.setId(id);
}
}
// process any other attributes
for (int j = 0; j < childElement.getAttributeNames().length; j++) {
String attrName = childElement.getAttributeNames()[j];
if (!attrName.equals(OASISCatalogConstants.ATTR_URI) && !attrName.equals(OASISCatalogConstants.ATTR_NAME) && !attrName.equals(OASISCatalogConstants.ATTR_PUBLIC_ID) && !attrName.equals(OASISCatalogConstants.ATTR_SYSTEM_ID) && !attrName.equals(OASISCatalogConstants.ATTR_CATALOG) && !attrName.equals(OASISCatalogConstants.ATTR_ID) && !attrName.equals(OASISCatalogConstants.ATTR_BASE)) {
String attrValue = childElement.getAttribute(attrName);
if (// $NON-NLS-1$
attrValue != null && !attrValue.equals("")) {
catalogElement.setAttributeValue(attrName, attrValue);
}
}
}
catalog.addCatalogElement(catalogElement);
}
}
Aggregations