Search in sources :

Example 1 with EditDoctypeDialog

use of org.eclipse.wst.xml.ui.internal.dialogs.EditDoctypeDialog in project webtools.sourceediting by eclipse.

the class EditDoctypeAction method showEditDoctypeDialog.

protected EditDoctypeDialog showEditDoctypeDialog(Shell shell) {
    EditDoctypeDialog dialog = null;
    if (doctype != null) {
        dialog = new EditDoctypeDialog(shell, doctype);
        if (title == null) {
            title = XMLUIMessages._UI_LABEL_EDIT_DOCTYPE;
        }
    } else if (document != null) {
        String rootElementName = getRootElementName(document);
        // $NON-NLS-1$ //$NON-NLS-2$
        dialog = new EditDoctypeDialog(shell, rootElementName, "", rootElementName + ".dtd");
        if (title == null) {
            title = XMLUIMessages._UI_MENU_ADD_DTD_INFORMATION_TITLE;
        }
    }
    dialog.setComputeSystemId((doctype == null) || (doctype.getSystemId() == null) || (doctype.getSystemId().trim().length() == 0));
    // !model.getType().equals(IStructuredModel.HTML));
    dialog.setErrorChecking(false);
    dialog.create();
    dialog.getShell().setText(title);
    dialog.setBlockOnOpen(true);
    dialog.setResourceLocation(new Path(resourceLocation));
    dialog.open();
    return dialog;
}
Also used : Path(org.eclipse.core.runtime.Path) EditDoctypeDialog(org.eclipse.wst.xml.ui.internal.dialogs.EditDoctypeDialog)

Example 2 with EditDoctypeDialog

use of org.eclipse.wst.xml.ui.internal.dialogs.EditDoctypeDialog in project webtools.sourceediting by eclipse.

the class EditDoctypeAction method run.

public void run() {
    Shell shell = getDisplay().getActiveShell();
    if (validateEdit(model, shell)) {
        model.beginRecording(this, getUndoDescription());
        // Shell shell =
        // XMLCommonUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
        EditDoctypeDialog dialog = showEditDoctypeDialog(shell);
        if (dialog.getReturnCode() == Window.OK) {
            if (doctype != null) {
                updateDoctype(dialog, doctype);
            } else if (document != null) {
                DocumentType doctype = createDoctype(dialog, document);
                if (doctype != null) {
                    insertDoctype(doctype, document);
                }
            }
        }
        model.endRecording(this);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IDOMDocumentType(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocumentType) DocumentType(org.w3c.dom.DocumentType) EditDoctypeDialog(org.eclipse.wst.xml.ui.internal.dialogs.EditDoctypeDialog)

Aggregations

EditDoctypeDialog (org.eclipse.wst.xml.ui.internal.dialogs.EditDoctypeDialog)2 Path (org.eclipse.core.runtime.Path)1 Shell (org.eclipse.swt.widgets.Shell)1 IDOMDocumentType (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocumentType)1 DocumentType (org.w3c.dom.DocumentType)1