Search in sources :

Example 21 with NamespaceInfo

use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.

the class NamespaceInfoTable method performNew.

public void performNew() {
    NamespaceInfo info = new NamespaceInfo();
    EditNamespaceInfoDialog dialog = invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, info);
    if (dialog.getReturnCode() == Window.OK) {
        namespaceInfoList.add(info);
        performDelayedUpdate();
    }
}
Also used : NamespaceInfo(org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo)

Example 22 with NamespaceInfo

use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.

the class NamespaceInfoTable method performEdit.

public void performEdit() {
    ISelection selection = tableViewer.getSelection();
    Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
    if (selectedObject instanceof NamespaceInfo) {
        invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, (NamespaceInfo) selectedObject);
        performDelayedUpdate();
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NamespaceInfo(org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo)

Example 23 with NamespaceInfo

use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.

the class CommonAddNamespacesControl method getNamespaceInfoList.

public List getNamespaceInfoList() {
    List list = new ArrayList();
    if (radio1.getSelection()) {
        TableItem[] items = tableViewer.getTable().getItems();
        for (int i = 0; i < items.length; i++) {
            TableItem item = items[i];
            if (item.getChecked()) {
                list.add(item.getData());
            }
        }
    } else {
        NamespaceInfo info = new NamespaceInfo();
        info.prefix = editNamespaceControl.prefixField.getText();
        info.uri = editNamespaceControl.uriField.getText();
        info.locationHint = editNamespaceControl.locationHintField.getText();
        list.add(info);
    }
    return list;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NamespaceInfo(org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo)

Example 24 with NamespaceInfo

use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.

the class CommonEditNamespacesDialog method updateButtonEnabledState.

public void updateButtonEnabledState() {
    Object selection = getSelection(tableViewer.getSelection());
    NamespaceInfo info = (NamespaceInfo) selection;
    editButton.setEnabled(info != null);
    // $NON-NLS-1$
    deleteButton.setEnabled((info != null) && (info.getProperty("unremovable") == null));
}
Also used : NamespaceInfo(org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo)

Example 25 with NamespaceInfo

use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.

the class EditNamespaceInfoDialog method performBrowse.

protected void performBrowse() {
    // $NON-NLS-1$
    String[] extensions = { ".xsd" };
    SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(getShell(), extensions);
    dialog.create();
    dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE);
    dialog.setBlockOnOpen(true);
    dialog.open();
    if (dialog.getReturnCode() == Window.OK) {
        String grammarURI = null;
        IFile file = dialog.getFile();
        String id = dialog.getId();
        if (file != null) {
            String uri = null;
            if (resourceLocation != null) {
                IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(resourceLocation);
                if (resource != null) {
                    IPath location = resource.getLocation();
                    if (location != null) {
                        uri = URIHelper.getRelativeURI(file.getLocation(), location);
                    }
                } else {
                    uri = URIHelper.getRelativeURI(file.getLocation(), resourceLocation);
                }
                grammarURI = file.getLocation().toOSString();
            } else {
                uri = file.getLocation().toOSString();
                grammarURI = uri;
            }
            locationHintField.setText(uri);
        } else if (id != null) {
            locationHintField.setText(id);
            URIResolver resolver = URIResolverPlugin.createResolver();
            grammarURI = resolver.resolve(null, id, id);
        }
        // $NON-NLS-1$
        CMDocument document = ContentModelManager.getInstance().createCMDocument(URIHelper.getURIForFilePath(grammarURI), "xsd");
        if (document != null) {
            // $NON-NLS-1$
            List namespaceInfoList = (List) document.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo");
            if (namespaceInfoList != null) {
                NamespaceInfo info = (NamespaceInfo) namespaceInfoList.get(0);
                if (info != null) {
                    if ((uriField.getText().trim().length() == 0) && (info.uri != null)) {
                        uriField.setText(info.uri);
                    }
                    if ((prefixField.getText().trim().length() == 0) && (info.prefix != null)) {
                        prefixField.setText(info.prefix);
                    }
                }
            }
        }
    }
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) URIResolver(org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver) List(java.util.List) NamespaceInfo(org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo) IResource(org.eclipse.core.resources.IResource)

Aggregations

NamespaceInfo (org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo)30 List (java.util.List)9 Iterator (java.util.Iterator)8 Element (org.w3c.dom.Element)6 NamespaceTable (org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceTable)5 ArrayList (java.util.ArrayList)4 Hashtable (java.util.Hashtable)4 Map (java.util.Map)4 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)4 IFile (org.eclipse.core.resources.IFile)3 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)3 NodeList (org.w3c.dom.NodeList)3 Path (org.eclipse.core.runtime.Path)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Shell (org.eclipse.swt.widgets.Shell)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IPathEditorInput (org.eclipse.ui.IPathEditorInput)2 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)2 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)2