INextCatalog[] nextCatalogs = fXmlCatalog.getNextCatalogs(); for (int i = 0; i < nextCatalogs.length; i++) { INextCatalog catalog = nextCatalogs[i]; ICatalog referencedCatalog = catalog.getReferencedCatalog(); if (referencedCatalog != null) { if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) { ICatalog systemCatalog = referencedCatalog; addXMLCatalogEntries(result, systemCatalog.getCatalogEntries()); else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) { ICatalog userCatalog = referencedCatalog; addXMLCatalogEntries(result, userCatalog.getCatalogEntries());
/** * Stores the values of the controls back to the preference store. */ private boolean storeValues() { // dw Object fileObject = null; try { // update the userCatalog so that its the same as the working // catalog userCatalog.clear(); // TODO add entries from the nested catalogs? userCatalog.addEntriesFromCatalog(workingUserCatalog); // now save the userCatalog userCatalog.save(); } catch (Exception e) { } return true; }
protected ICatalogEntry getEntry() { if (catalogEntry == null) { if ((fCatalogElement != null) && (fCatalogElement.getType() == ICatalogElement.TYPE_ENTRY)) { catalogEntry = (ICatalogEntry) fCatalogElement; } else { if (catalog != null) { catalogEntry = (ICatalogEntry) catalog.createCatalogElement(ICatalogElement.TYPE_ENTRY); } } } return catalogEntry; }
public XMLCatalogPreferencePage() { defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog(); INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs(); for (int i = 0; i < nextCatalogs.length; i++) { INextCatalog catalog = nextCatalogs[i]; ICatalog referencedCatalog = catalog.getReferencedCatalog(); if (referencedCatalog != null) { if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) { systemCatalog = referencedCatalog; } else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) { userCatalog = referencedCatalog; } } } }
protected Object[] getChildrenHelper(ICatalog catalog) { // TODO add entries from the nested catalogs ICatalogEntry[] entries = catalog.getCatalogEntries(); if (entries.length > 0) { Comparator comparator = new Comparator() { public int compare(Object o1, Object o2) { int result = 0; if ((o1 instanceof ICatalogEntry) && (o2 instanceof ICatalogEntry)) { ICatalogEntry entry1 = (ICatalogEntry) o1; ICatalogEntry entry2 = (ICatalogEntry) o2; result = Collator.getInstance().compare(entry1.getKey(), entry2.getKey()); } return result; } }; Arrays.sort(entries, comparator); } Vector result = new Vector(); result.addAll(Arrays.asList(entries)); INextCatalog[] nextCatalogs = catalog.getNextCatalogs(); List nextCatalogsList = Arrays.asList(nextCatalogs); result.addAll(nextCatalogsList); return result.toArray(new ICatalogElement[result.size()]); }
result = catalog.resolvePublic(publicId, systemId); break; case ICatalogEntry.ENTRY_TYPE_SYSTEM: result = catalog.resolveSystem(systemId); break; case ICatalogEntry.ENTRY_TYPE_URI: result = catalog.resolveURI(systemId); break; default:
/** * Helper method to find the physical location of the schema * in the XML Catalog * @param namespaceURI * @return physical location of the schema */ public String locateFileUsingCatalog(String namespaceURI) { retrieveCatalog(); ICatalogEntry[] entries = systemCatalog.getCatalogEntries(); for (int i = 0; i < entries.length; i++) { if (entries[i].getKey().equals(namespaceURI)) return entries[i].getURI(); } return null; }
private void processNextCatalogs(ICatalog catalog, Element parent) { // handle catalog entries INextCatalog[] nextCatalogs = catalog.getNextCatalogs(); Element childElement = null; //dw String attrValue = null; for (int i = 0; i < nextCatalogs.length; i++) { INextCatalog delegate = nextCatalogs[i]; childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_NEXT_CATALOG); if (childElement != null) { parent.appendChild(childElement); String location = delegate.getCatalogLocation(); if (location != null) { childElement.setAttribute(OASISCatalogConstants.ATTR_CATALOG, location); } String id = delegate.getId(); if (id != null) { childElement.setAttribute(OASISCatalogConstants.ATTR_ID, id); } } } }
continue; ICatalogElement catalogElement = catalog.createCatalogElement(type); if (catalogElement instanceof ICatalogEntry) catalog.addCatalogElement(catalogElement);
/** * Creates preference page controls on demand. * * @param parent * the parent for the preference page */ protected Control createContents(Composite parent) { // we create a working copy of the 'User Settings' for the Catalog // that we can modify CatalogSet tempCatalogSet = new CatalogSet(); workingUserCatalog = tempCatalogSet.lookupOrCreateCatalog("working", ""); //$NON-NLS-1$ //$NON-NLS-2$ // TODO: add entries from the nested catalogs as well workingUserCatalog.addEntriesFromCatalog(userCatalog); workingUserCatalog.addListener(this); noDefaultAndApplyButton(); Composite composite = new Composite(parent, SWT.NULL); // WorkbenchHelp.setHelp(composite, new // ControlContextComputer(composite, // XMLBuilderContextIds.XMLP_CATALOG_PAGE)); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); createCatalogEntriesView(composite); createCatalogDetailsView(composite); createAdvancedButton(composite); // catalogEntriesView.updatePage(); applyDialogFont(composite); return composite; }
protected void performEdit() { ISelection selection = tableViewer.getSelection(); Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; if (selectedObject instanceof ICatalogElement) { ICatalogElement oldEntry = (ICatalogElement) selectedObject; ICatalogElement newEntry = (ICatalogElement) ((CatalogElement) oldEntry).clone(); EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_EDIT_DIALOG_TITLE, newEntry); if (dialog.getReturnCode() == Window.OK) { // delete the old value if the 'mapFrom' has changed // workingUserCatalog.removeCatalogElement(oldEntry); // update the new mapping // workingUserCatalog.addCatalogElement(newEntry); tableViewer.setSelection(new StructuredSelection(newEntry)); } } }
private void processNextCatalogElements(IConfigurationElement[] childElementList) { if (catalog == null) return; for (int i = 0; i < childElementList.length; i++) { IConfigurationElement childElement = childElementList[i]; String location = childElement.getAttribute(OASISCatalogConstants.ATTR_CATALOG); // mandatory if (location == null || location.equals("")) //$NON-NLS-1$ { Logger.log(Logger.ERROR, XMLCoreMessages.Catalog_next_catalog_location_uri_not_set); continue; } INextCatalog nextCatalog = new NextCatalog(); String resolvedPath = resolvePath(location); nextCatalog.setCatalogLocation(resolvedPath); String id = childElement.getAttribute(OASISCatalogConstants.ATTR_ID); if (id != null && !id.equals("")) //$NON-NLS-1$ { nextCatalog.setId(id); } catalog.addCatalogElement(nextCatalog); } }
protected Control createDialogArea(Composite parent) { // we create a working copy of the 'User Settings' for the Catalog // that we can modify CatalogSet tempCatalogSet = new CatalogSet(); workingUserCatalog = tempCatalogSet.lookupOrCreateCatalog("working", ""); //$NON-NLS-1$ //$NON-NLS-2$ // TODO: add entries from the nested catalogs as well workingUserCatalog.addEntriesFromCatalog(userCatalog); Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout()); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.heightHint = 500; composite.setLayoutData(gridData); createCatalogEntriesView(composite); createCatalogDetailsView(composite); return composite; }
public SelectFromCatalogDialog(Shell parentShell) { super(parentShell); defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog(); INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs(); for (int i = 0; i < nextCatalogs.length; i++) { INextCatalog catalog = nextCatalogs[i]; ICatalog referencedCatalog = catalog.getReferencedCatalog(); if (referencedCatalog != null) { if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) { systemCatalog = referencedCatalog; } else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) { userCatalog = referencedCatalog; } } } }
if (defaultCatalog != null) { ICatalogEntry[] entries = defaultCatalog.getCatalogEntries(); for (int entry = 0; entry < entries.length; entry++) { ITaglibRecord record = createCatalogRecord(entries[entry]); 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();
resolved = catalog.resolveSystem(systemId); if (resolved == null) resolved = catalog.resolveURI(systemId); resolved = catalog.resolvePublic(publicId, systemId); if (resolved == null) resolved = catalog.resolveURI(publicId);
/** * Returns the String location for the schema with the given namespaceURI by * looking at the XML catalog. We look only in the plugin specified entries of * the catalog. * * @param namespaceURI * @return String representing the location of the schema. */ private String locateFileUsingCatalog(String namespaceURI) { retrieveCatalog(); ICatalogEntry[] entries = systemCatalog.getCatalogEntries(); for (int i = 0; i < entries.length; i++) { if (entries[i].getKey().equals(namespaceURI)) return entries[i].getURI(); } return null; }
protected void performNew() { // ICatalogEntry newEntry = // (ICatalogEntry)workingUserCatalog.createCatalogElement(ICatalogElement.TYPE_ENTRY); EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_NEW_DIALOG_TITLE, workingUserCatalog); ICatalogElement element = dialog.getCatalogElement(); if (dialog.getReturnCode() == Window.OK) { workingUserCatalog.addCatalogElement(element); tableViewer.setSelection(new StructuredSelection(element), true); tableViewer.refresh(); } }
protected void invokeImportDialog() { SelectSingleFileDialog dialog = new SelectSingleFileDialog(getShell(), null, true); String[] extensions = {".xmlcatalog", ".xml"}; //$NON-NLS-1$ //$NON-NLS-2$ dialog.addFilterExtensions(extensions); dialog.create(); dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_TITLE); dialog.setTitle(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_HEADING); dialog.setMessage(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_MESSAGE); dialog.setBlockOnOpen(true); int rc = dialog.open(); if (rc == Window.OK) { IFile file = dialog.getFile(); if (file != null) { String fileName = file.getLocation().toFile().toURI().toString(); try { CatalogSet tempResourceSet = new CatalogSet(); ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName); //$NON-NLS-1$ workingUserCatalog.addEntriesFromCatalog(newCatalog); } catch (Exception e) { // TODO... give error message } } close(); } }
private void retrieveCatalog() { if (systemCatalog != null) return; ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog(); INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs(); for (int i = 0; i < nextCatalogs.length; i++) { INextCatalog catalog = nextCatalogs[i]; ICatalog referencedCatalog = catalog.getReferencedCatalog(); if (referencedCatalog != null) { if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) { systemCatalog = referencedCatalog; } } } }