use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement in project webtools.sourceediting by eclipse.
the class Catalog method getCatalogElements.
private List getCatalogElements(int type) {
List result = new ArrayList();
ICatalogElement[] elements = (ICatalogElement[]) catalogElements.toArray(new ICatalogElement[catalogElements.size()]);
for (int i = 0; i < elements.length; i++) {
ICatalogElement element = elements[i];
if (element.getType() == type) {
result.add(element);
}
}
return result;
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement in project webtools.sourceediting by eclipse.
the class CatalogElement method clone.
/*
* Since we don't have events notifications for entry properties, clone()
* could allow to copy and edit entry and then replace it in catalog. Entry
* replacement will signal ICatalogEvent @return
*/
public Object clone() {
ICatalogElement element = ownerCatalog.createCatalogElement(type);
String[] attributes = getAttributes();
for (int i = 0; i < attributes.length; i++) {
String attrName = attributes[i];
String attrValue = getAttributeValue(attrName);
element.setAttributeValue(attrName, attrValue);
}
element.setOwnerCatalog(ownerCatalog);
element.setId(id);
element.setBase(base);
return element;
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement in project webtools.sourceediting by eclipse.
the class XMLCatalogEntriesView method performNew.
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();
}
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement in project webtools.sourceediting by eclipse.
the class XMLCatalogEntriesView method performDelete.
protected void performDelete() {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Iterator iterator = structuredSelection.iterator();
while (iterator.hasNext()) {
Object selectedObject = iterator.next();
if (selectedObject instanceof ICatalogElement) {
ICatalogElement catalogElement = (ICatalogElement) selectedObject;
workingUserCatalog.removeCatalogElement(catalogElement);
}
}
}
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement in project webtools.sourceediting by eclipse.
the class XMLCatalogEntriesView method performEdit.
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, workingUserCatalog);
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));
}
}
}
Aggregations