Search in sources :

Example 1 with EditSchemaInfoDialog

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);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) Shell(org.eclipse.swt.widgets.Shell) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) NodeList(org.w3c.dom.NodeList) List(java.util.List) EditSchemaInfoDialog(org.eclipse.wst.xml.ui.internal.dialogs.EditSchemaInfoDialog) NamespaceInfo(org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo) Map(java.util.Map)

Aggregations

Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Path (org.eclipse.core.runtime.Path)1 Shell (org.eclipse.swt.widgets.Shell)1 NamespaceInfo (org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo)1 EditSchemaInfoDialog (org.eclipse.wst.xml.ui.internal.dialogs.EditSchemaInfoDialog)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1