use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class CatalogWriter method processCatalogEntries.
private void processCatalogEntries(ICatalog catalog, Element parent) {
ICatalogEntry[] catalogEntries = catalog.getCatalogEntries();
for (int i = 0; i < catalogEntries.length; i++) {
ICatalogEntry entry = catalogEntries[i];
String key = entry.getKey();
String uri = entry.getURI();
Element childElement = null;
switch(entry.getEntryType()) {
case ICatalogEntry.ENTRY_TYPE_PUBLIC:
childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_PUBLIC);
if (childElement != null) {
childElement.setAttribute(OASISCatalogConstants.ATTR_PUBLIC_ID, key);
childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
}
break;
case ICatalogEntry.ENTRY_TYPE_SYSTEM:
childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_SYSTEM);
if (childElement != null) {
childElement.setAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID, key);
childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
}
break;
case ICatalogEntry.ENTRY_TYPE_URI:
childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_URI);
if (childElement != null) {
childElement.setAttribute(OASISCatalogConstants.ATTR_NAME, key);
childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
}
break;
default:
break;
}
if (childElement != null) {
setAttributes(entry, childElement);
parent.appendChild(childElement);
}
}
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class CatalogTest method testCatalog.
public void testCatalog() throws Exception {
Catalog workingUserCatalog = new Catalog(null, "working", null);
assertNotNull(userCatalog);
workingUserCatalog.addEntriesFromCatalog(userCatalog);
ICatalogEntry catalogEntry = (ICatalogEntry) userCatalog.createCatalogElement(ICatalogEntry.ENTRY_TYPE_PUBLIC);
catalogEntry.setKey("testKey");
catalogEntry.setURI("http://testuri");
workingUserCatalog.addCatalogElement(catalogEntry);
userCatalog.addEntriesFromCatalog(workingUserCatalog);
String userCatalogLocation = userCatalog.getLocation();
userCatalog.save();
userCatalog.clear();
userCatalog = getCatalog(XMLCorePlugin.USER_CATALOG_ID, userCatalogLocation);
List entries = getCatalogEntries(userCatalog, ICatalogEntry.ENTRY_TYPE_PUBLIC);
assertEquals(1, entries.size());
ICatalogEntry entry = (ICatalogEntry) entries.get(0);
assertEquals("http://testuri", entry.getURI());
assertEquals("testKey", entry.getKey());
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class AbstractCatalogTest method getCatalogEntries.
protected static List getCatalogEntries(ICatalog catalog, int entryType) {
List result = new ArrayList();
ICatalogEntry[] entries = catalog.getCatalogEntries();
for (int i = 0; i < entries.length; i++) {
ICatalogEntry entry = entries[i];
if (entry.getEntryType() == entryType) {
result.add(entry);
}
}
return result;
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry in project webtools.sourceediting by eclipse.
the class SelectFromCatalogDialog method createCatalogDetailsView.
protected void createCatalogDetailsView(Composite parent) {
Group detailsGroup = new Group(parent, SWT.NONE);
detailsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
detailsGroup.setLayout(new GridLayout());
detailsGroup.setText(XMLCatalogMessages.UI_LABEL_DETAILS);
final XMLCatalogEntryDetailsView detailsView = new XMLCatalogEntryDetailsView(detailsGroup);
ISelectionChangedListener listener = new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
if (selectedObject instanceof ICatalogEntry) {
ICatalogEntry entry = (ICatalogEntry) selectedObject;
detailsView.setCatalogElement(entry);
currentSelectionLocation = entry.getURI();
currentSelectionNamespace = entry.getKey();
} else {
detailsView.setCatalogElement((ICatalogEntry) null);
currentSelectionLocation = "";
currentSelectionNamespace = "";
}
}
};
catalogEntriesView.getViewer().addSelectionChangedListener(listener);
}
Aggregations