use of org.eclipse.wst.xml.core.internal.catalog.Catalog in project webtools.sourceediting by eclipse.
the class XMLCatalogEntriesView method updateWidgetEnabledState.
protected void updateWidgetEnabledState() {
boolean isEditable = false;
ISelection selection = tableViewer.getSelection();
boolean multipleSelection = false;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
if (structuredSelection.size() > 1) {
multipleSelection = true;
}
Object selectedObject = structuredSelection.getFirstElement();
if (selectedObject instanceof ICatalogElement) {
ICatalogElement[] elements = ((Catalog) workingUserCatalog).getCatalogElements();
// dw List entriesList = new ArrayList(elements.length);
for (int i = 0; i < elements.length; i++) {
ICatalogElement element = elements[i];
isEditable = selectedObject.equals(element);
if (isEditable) {
break;
}
}
}
}
// if (isPageEnabled)
{
editButton.setEnabled(isEditable & !multipleSelection);
deleteButton.setEnabled(isEditable);
}
}
use of org.eclipse.wst.xml.core.internal.catalog.Catalog 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.Catalog in project webtools.sourceediting by eclipse.
the class CatalogWriterTest method testReadAndWriteComplexCatalog.
/*
* Class under test for void read(ICatalog, String)
*/
public void testReadAndWriteComplexCatalog() throws Exception {
// read catalog
String catalogFile = "/data/delegateAndRewrite/catalog11.xml";
URL catalogUrl = TestPlugin.getDefault().getBundle().getEntry(catalogFile);
assertNotNull(catalogUrl);
URL base = FileLocator.resolve(catalogUrl);
Catalog catalog = (Catalog) getCatalog("catalog11", base.toString());
// CatalogReader.read(catalog, catalogFilePath);
assertNotNull(catalog);
// test main catalog - catalog1.xml
// assertEquals("cat1", catalog.getId());
assertEquals(13, catalog.getCatalogElements().length);
// write catalog so we can read it back in
URL resultsFolder = TestPlugin.getDefault().getBundle().getEntry("/");
IPath path = new Path(FileLocator.resolve(resultsFolder).getFile());
String resultCatalogFile = path.append("/catalog11-x.xml").toFile().toURI().toString();
catalog.setLocation(resultCatalogFile);
// write catalog
catalog.save();
// read catalog file from the saved location and test its content
catalog = (Catalog) getCatalog("catalog2", catalog.getLocation());
assertNotNull(catalog);
// test main catalog - catalog1.xml
// assertEquals("cat1", catalog.getId());
assertEquals(13, catalog.getCatalogElements().length);
// test public entries
assertEquals(2, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_PUBLIC).size());
// test system entries
assertEquals(2, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_SYSTEM).size());
// test uri entries
assertEquals(1, CatalogTest.getCatalogEntries(catalog, ICatalogEntry.ENTRY_TYPE_URI).size());
// test next catalog - catalog2.xml
INextCatalog[] nextCatalogEntries = catalog.getNextCatalogs();
assertEquals(1, nextCatalogEntries.length);
INextCatalog nextCatalogEntry = (INextCatalog) nextCatalogEntries[0];
assertNotNull(nextCatalogEntry);
assertEquals("catalog.xml", nextCatalogEntry.getCatalogLocation());
}
Aggregations