use of org.eclipse.wst.xml.ui.internal.dialogs.EditSchemaInfoDialog in project webtools.sourceediting by eclipse.
the class EditSchemaInfoAction method run.
public void run() {
Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
if (validateEdit(manager.getModel(), shell)) {
manager.beginNodeAction(this);
// todo... change constructor to take an element
Element element = getElement(node);
if (element != null) {
EditSchemaInfoDialog dialog = new EditSchemaInfoDialog(shell, new Path(resourceLocation));
List namespaceInfoList = namespaceInfoManager.getNamespaceInfoList(element);
List oldNamespaceInfoList = NamespaceInfo.cloneNamespaceInfoList(namespaceInfoList);
// in response to these changes
for (Iterator i = namespaceInfoList.iterator(); i.hasNext(); ) {
NamespaceInfo info = (NamespaceInfo) i.next();
NamespaceInfo oldCopy = new NamespaceInfo(info);
// $NON-NLS-1$
info.setProperty("oldCopy", oldCopy);
}
dialog.setNamespaceInfoList(namespaceInfoList);
dialog.create();
// dialog.getShell().setSize(500, 300);
dialog.getShell().setText(XMLUIMessages._UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE);
dialog.setBlockOnOpen(true);
dialog.open();
if (dialog.getReturnCode() == Window.OK) {
List newInfoList = dialog.getNamespaceInfoList();
namespaceInfoManager.removeNamespaceInfo(element);
namespaceInfoManager.addNamespaceInfo(element, newInfoList, false);
// see if we need to rename any prefixes
Map prefixMapping = createPrefixMapping(oldNamespaceInfoList, namespaceInfoList);
if (prefixMapping.size() > 0) {
try {
manager.getModel().aboutToChangeModel();
ReplacePrefixAction replacePrefixAction = new ReplacePrefixAction(manager, element, prefixMapping);
replacePrefixAction.run();
} finally {
manager.getModel().changedModel();
}
}
}
}
manager.endNodeAction(this);
}
}
Aggregations