Home » Language IDEs » ServerTools (WTP) » XML validation will not work in used XMLEditor
XML validation will not work in used XMLEditor [message #186976] |
Thu, 25 January 2007 14:51 |
Eclipse User |
|
|
|
Originally posted by: durchgedreht.gmx.de
Hi,
when using the XMLEditor as in my last post, the right click "validate"
will not recognize XML structure errors (e.g. <test> </tes> will not be
recognized).
This should not be normal, should it?
Do I have to add anything? I thought it would be the hole XML Editor with
all of its features.
Thanks,
Dennis
--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
|
|
|
Re: XML validation will not work in used XMLEditor [message #186984 is a reply to message #186976] |
Thu, 25 January 2007 14:53 |
Eclipse User |
|
|
|
Originally posted by: durchgedreht.gmx.de
For Info: The Crl+Space completion will work, so having written <test>
will show </test> on completion. But no validation? Maybe it is not in the
Problems View anymore???
Thanks,
Dennis
Am 25.01.2007, 15:51 Uhr, schrieb Dennis Meyer <durchgedreht@gmx.de>:
> Hi,
> when using the XMLEditor as in my last post, the right click "validate"
> will not recognize XML structure errors (e.g. <test> </tes> will not be
> recognized).
> This should not be normal, should it?
>
> Do I have to add anything? I thought it would be the hole XML Editor
> with all of its features.
>
> Thanks,
> Dennis
>
--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
|
|
| |
Re: XML validation will not work in used XMLEditor [message #187100 is a reply to message #187041] |
Fri, 26 January 2007 14:07 |
Eclipse User |
|
|
|
Originally posted by: durchgedreht.gmx.de
Hi Craig,
thanks for that info (is useful as well). But I even don't get that X's =
=
markers. Maybe I'm wrong using my own extension? I'm using *.jdx and try=
=
to use the XML contenttype.
-------------------------------------
INTERESTING SOURCE CODE:
-------------------------------------
/**
* Creates the xml source editor
*/
void createXMLEditorPage() {
try {
editor =3D new StructuredTextEditor();
int index =3D addPage(editor, getEditorInput());
setPageText(index, editor.getTitle());
} catch (PartInitException e) {
ErrorDialog.openError(
getSite().getShell(),
"Error creating nested text editor",
null,
e.getStatus());
}
}
=
/**
* @see =
org.eclipse.ui.part.MultiPageEditorPart#createSite(org.eclip se.ui.IEdito=
rPart)
*/
protected IEditorSite createSite(IEditorPart page) {
IEditorSite site =3D null;
if (page =3D=3D editor) {
site =3D new MultiPageEditorSite(this, page) {
@SuppressWarnings("restriction")
public String getId() {
// Sets this ID so nested editor is configured for XML source
return ContentTypeIdForXML.ContentTypeID_XML + ".source"; =
//$NON-NLS-1$;
}
};
}
else {
site =3D super.createSite(page);
}
return site;
}
-------------------------------------
FULL SOURCE CODE:
Note that I used the tutorial at:
http://www.eclipse.org/webtools/wst/components/sse/tutorials /multipage-e=
ditor-tutorial.html
-------------------------------------
package org.jdeluxe.editors;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.StringWriter;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FontDialog;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.part.MultiPageEditorSite;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import =
org.eclipse.wst.xml.core.internal.provisional.contenttype.Co ntentTypeIdF=
orXML;
/**
* An example showing how to create a multi-page editor.
* This example has 3 pages:
* <ul>
* <li>page 0 contains a nested text editor.
* <li>page 1 allows you to change the font used in page 2
* <li>page 2 shows the words in page 0 in sorted order
* </ul>
*/
public class JdeluxeMultiPageEditor extends MultiPageEditorPart implemen=
ts =
IResourceChangeListener{
/** The text editor used in XML source editor */
private StructuredTextEditor editor;
/** The font chosen in page 1. */
private Font font;
/** The text widget used in page 2. */
private StyledText text;
/**
* Creates a multi-page editor example.
*/
public JdeluxeMultiPageEditor() {
super();
System.out.println("Start test");
getXmlDb();
System.out.println("end test");
ResourcesPlugin.getWorkspace().addResourceChangeListener(thi s);
}
=
/**
* Creates page 0 of the multi-page editor,
* which shows the sorted text.
*/
void createPage0() {
Composite composite =3D new Composite(getContainer(), SWT.NONE);
FillLayout layout =3D new FillLayout();
composite.setLayout(layout);
text =3D new StyledText(composite, SWT.H_SCROLL | SWT.V_SCROLL);
text.setEditable(false);
=
int index =3D addPage(composite);
setPageText(index, "Preview");
}
=
/**
* Creates the xml source editor
*/
void createXMLEditorPage() {
try {
editor =3D new StructuredTextEditor();
int index =3D addPage(editor, getEditorInput());
setPageText(index, editor.getTitle());
} catch (PartInitException e) {
ErrorDialog.openError(
getSite().getShell(),
"Error creating nested text editor",
null,
e.getStatus());
}
}
=
/**
* Creates page 1 of the multi-page editor,
* which allows you to change the font used in page 2.
*/
void createPage2() {
Composite composite =3D new Composite(getContainer(), SWT.NONE);
GridLayout layout =3D new GridLayout();
composite.setLayout(layout);
layout.numColumns =3D 2;
Button fontButton =3D new Button(composite, SWT.NONE);
GridData gd =3D new GridData(GridData.BEGINNING);
gd.horizontalSpan =3D 2;
fontButton.setLayoutData(gd);
fontButton.setText("Change Font...");
=
fontButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setFont();
}
});
int index =3D addPage(composite);
setPageText(index, "Properties");
}
=
/**
* Creates the pages of the multi-page editor.
*/
protected void createPages() {
createPage0();
createXMLEditorPage();
createPage2();
}
=
/**
* The <code>MultiPageEditorPart</code> implementation of this
* <code>IWorkbenchPart</code> method disposes all nested editors.
* Subclasses may extend.
*/
public void dispose() {
ResourcesPlugin.getWorkspace().removeResourceChangeListener( this);
super.dispose();
}
/**
* Saves the multi-page editor's document.
*/
public void doSave(IProgressMonitor monitor) {
getEditor(1).doSave(monitor);
}
/**
* Saves the multi-page editor's document as another file.
* Also updates the text for page 0's tab, and updates this multi-page =
=
editor's input
* to correspond to the nested editor's.
*/
public void doSaveAs() {
IEditorPart editor =3D getEditor(1);
editor.doSaveAs();
setPageText(1, editor.getTitle());
setInput(editor.getEditorInput());
}
/* (non-Javadoc)
* Method declared on IEditorPart
*/
public void gotoMarker(IMarker marker) {
setActivePage(1);
IDE.gotoMarker(getEditor(1), marker);
}
/**
* The <code>MultiPageEditorExample</code> implementation of this metho=
d
* checks that the input is an instance of <code>IFileEditorInput</code=
>.
*/
public void init(IEditorSite site, IEditorInput editorInput)
throws PartInitException {
if (!(editorInput instanceof IFileEditorInput))
throw new PartInitException("Invalid Input: Must be IFileEditorInput"=
);
super.init(site, editorInput);
}
/* (non-Javadoc)
* Method declared on IEditorPart.
*/
public boolean isSaveAsAllowed() {
return true;
}
/**
* Calculates the contents of page 2 when the it is activated.
*/
protected void pageChange(int newPageIndex) {
super.pageChange(newPageIndex);
if (newPageIndex =3D=3D 2) {
sortWords();
}
}
/**
* Closes all project files on project close.
*/
public void resourceChanged(final IResourceChangeEvent event){
if(event.getType() =3D=3D IResourceChangeEvent.PRE_CLOSE){
Display.getDefault().asyncExec(new Runnable(){
public void run(){
IWorkbenchPage[] pages =3D getSite().getWorkbenchWindow().getPages(=
);
for (int i =3D 0; i<pages.length; i++){
if(((FileEditorInput)editor.getEditorInput()).getFile().getP roject=
().equals(event.getResource())){
IEditorPart editorPart =3D =
pages[i].findEditor(editor.getEditorInput());
pages[i].closeEditor(editorPart,true);
}
}
}
});
}
}
/**
* Sets the font related data to be applied to the text in page 2.
*/
void setFont() {
FontDialog fontDialog =3D new FontDialog(getSite().getShell());
fontDialog.setFontList(text.getFont().getFontData());
FontData fontData =3D fontDialog.open();
if (fontData !=3D null) {
if (font !=3D null)
font.dispose();
font =3D new Font(text.getDisplay(), fontData);
text.setFont(font);
}
}
/**
* Sorts the words in page 0, and shows them in page 2.
*/
void sortWords() {
String editorText =3D
editor.getDocumentProvider().getDocument(editor.getEditorInp ut()).get=
();
StringTokenizer tokenizer =3D
new StringTokenizer(editorText, " =
\t\n\r\f!@#\u0024%^&*()-_=3D+`~[]{};:'\",.<>/?|\\");
ArrayList editorWords =3D new ArrayList();
while (tokenizer.hasMoreTokens()) {
editorWords.add(tokenizer.nextToken());
}
Collections.sort(editorWords, Collator.getInstance());
StringWriter displayText =3D new StringWriter();
for (int i =3D 0; i < editorWords.size(); i++) {
displayText.write(((String) editorWords.get(i)));
displayText.write(System.getProperty("line.separator"));
}
text.setText(displayText.toString());
}
=
=
/**
* @see =
org.eclipse.ui.part.MultiPageEditorPart#createSite(org.eclip se.ui.IEdito=
rPart)
*/
protected IEditorSite createSite(IEditorPart page) {
IEditorSite site =3D null;
if (page =3D=3D editor) {
site =3D new MultiPageEditorSite(this, page) {
@SuppressWarnings("restriction")
public String getId() {
// Sets this ID so nested editor is configured for XML source
return ContentTypeIdForXML.ContentTypeID_XML + ".source"; =
//$NON-NLS-1$;
}
};
}
else {
site =3D super.createSite(page);
}
return site;
}
=
private void getXmlDb(){
}
}
|
|
| |
Re: XML validation will not work in used XMLEditor [message #187258 is a reply to message #186976] |
Mon, 29 January 2007 13:13 |
|
Dennis Meyer wrote:
> Hi,
> when using the XMLEditor as in my last post, the right click "validate"
> will not recognize XML structure errors (e.g. <test> </tes> will not be
> recognized).
> This should not be normal, should it?
>
> Do I have to add anything? I thought it would be the hole XML Editor
> with all of its features.
No, it's simply bug 86385. The editor handles your custom filename
extension, but the validation framework does not. The problem
markers are generated through the validation framework.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=86385
--
Nitin Dahyabhai
Structured Source Editor
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
Goto Forum:
Current Time: Thu Sep 26 14:26:55 GMT 2024
Powered by FUDForum. Page generated in 0.04834 seconds
|