use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement 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.provisional.ICatalogElement in project webtools.sourceediting by eclipse.
the class XMLCatalogPreferencePage 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).size() == 1 ? ((IStructuredSelection) selection).getFirstElement() : null;
if (selectedObject instanceof ICatalogElement) {
detailsView.setCatalogElement((ICatalogElement) selectedObject);
} else {
detailsView.setCatalogElement(null);
}
}
};
catalogEntriesView.getViewer().addSelectionChangedListener(listener);
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement in project webtools.sourceediting by eclipse.
the class Catalog method addEntriesFromCatalog.
public void addEntriesFromCatalog(ICatalog catalog) {
try {
setNotificationEnabled(false);
if (catalog != null) {
ICatalogElement[] entries = ((Catalog) catalog).getCatalogElements();
for (int i = 0; i < entries.length; i++) {
CatalogElement clone = (CatalogElement) ((CatalogElement) entries[i]).clone();
addCatalogElement(clone);
}
} else {
// $NON-NLS-1$
Logger.log(Logger.ERROR, "argument was null in Catalog.addEntriesFromCatalog");
}
} finally {
setNotificationEnabled(true);
}
internalResolver = null;
notifyChanged();
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement 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