[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Exception when generating diagram code from .gmfgen

Alex Shatalin a Ãcrit :
Hello Olivier,

unfortunatly, I got the same exception error with this modification
in my xpt file :(
I have to read it more carefully. :-) I thought exception was thrown by xpand editor.. Sorry.

ÂDEFINE throwIncorrectInputException FOR gmfgen::GenDiagram-Â
If you posted here whole content of aspects/xpt/editor/DocumentProvider.xpt (xutom template) I do not see the reason for this template at all - it is just copying original template contents..
I suggest you to remove "DEFINE uriEditorInputClassFQName", "DEFINE fileEditorInputClassFQName" and call it using fully-qualified names like:
ÂEXPAND xpt::editor::DocumentProvider::uriEditorInputClassFQName ....


-----------------
Alex Shatalin


Hi,

I paste here the DocumentProvider.xpt

/*
 * Copyright (c) 2007 Borland Software Corporation
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Alexander Shatalin (Borland) - initial API and implementation
 */

ÂIMPORT "http://www.eclipse.org/gmf/2006/GenModel"Â;
ÂEXTENSION xpt::editor::UtilsÂ

ÂAROUND doSaveDocument FOR gmfgen::GenDiagram-Â
ÂEXPAND xpt::Common::generatedMemberCommentÂ
protected void doSaveDocument(org.eclipse.core.runtime.IProgressMonitor monitor, Object element, org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument document, boolean overwrite) throws org.eclipse.core.runtime.CoreException {
ResourceSetInfo info = getResourceSetInfo(element);
if (info != null) {
if (!overwrite && !info.isSynchronized()) {
throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, ÂeditorGen.plugin.getActivatorQualifiedClassName()Â.ID,
ÂIF null == editorGen.applicationÂorg.eclipse.core.resources.IResourceStatus.OUT_OF_SYNC_LOCALÂELSEÂorg.eclipse.core.runtime.IStatus.ERRORÂENDIFÂ,


ÂEXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentUnsynchronizedFileSaveError()) FOR editorGenÂ,
null));
}
ÂIF null == editorGen.application-Â
info.stopResourceListening();
ÂENDIF-Â
fireElementStateChanging(element);
java.util.List resources = info.getResourceSet().getResources();
try {
monitor.beginTask(ÂEXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentSaveDiagramTask()) FOR editorGenÂ, resources.size() + 1 + 1); //"Saving diagram"
monitor.subTask("Validating on save");
org.eclipse.gmf.runtime.notation.Diagram diagram = (org.eclipse.gmf.runtime.notation.Diagram) document.getContent();
ValidateAction.runValidation(diagram); // delegate validation
monitor.worked(1);

for (java.util.Iterator it = resources.iterator(); it.hasNext();) {
org.eclipse.emf.ecore.resource.Resource nextResource = (org.eclipse.emf.ecore.resource.Resource) it.next();
monitor.setTaskName(org.eclipse.osgi.util.NLS.bind(
ÂEXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentSaveNextResourceTask()) FOR editorGenÂ,
nextResource.getURI()));
if (nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) {
try {
nextResource.save(ÂEXPAND xpt::Common::getSaveOptionsÂ);
} catch (java.io.IOException e) {
fireElementStateChangeFailed(element);
throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, ÂeditorGen.plugin.getActivatorQualifiedClassName()Â.ID, org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null));
}
}
monitor.worked(1);
}
monitor.done();
info.setModificationStamp(computeModificationStamp(info));
} catch (RuntimeException x) {
fireElementStateChangeFailed(element);
throw x;
} ÂIF null == editorGen.application finally {
info.startResourceListening();
} ÂENDIFÂ
} else {
org.eclipse.emf.common.util.URI newResoruceURI;
java.util.List affectedFiles = null;
ÂIF null == editorGen.applicationÂif (element instanceof ÂEXPAND fileEditorInputClassFQNameÂ) {
org.eclipse.core.resources.IFile newFile = ((ÂEXPAND fileEditorInputClassFQNameÂ) element).getFile();
affectedFiles = java.util.Collections.singletonList(newFile);
newResoruceURI = org.eclipse.emf.common.util.URI.createPlatformResourceURI(newFile.getFullPath().toString(), true);
} else ÂENDIFÂif(element instanceof ÂEXPAND uriEditorInputClassFQNameÂ) {
newResoruceURI = ((ÂEXPAND uriEditorInputClassFQNameÂ) element).getURI();
} else {
fireElementStateChangeFailed(element);
ÂEXPAND throwIncorrectInputException-Â
}
if (false == document instanceof org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) {
fireElementStateChangeFailed(element);
throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, ÂeditorGen.plugin.getActivatorQualifiedClassName()Â.ID, 0,
"Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); ÂEXPAND xpt::Common::nonNLS(1)Â ÂEXPAND xpt::Common::nonNLS(2)Â
}
org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument diagramDocument = (org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument) document;
final org.eclipse.emf.ecore.resource.Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource(newResoruceURI);
final org.eclipse.gmf.runtime.notation.Diagram diagramCopy = (org.eclipse.gmf.runtime.notation.Diagram) org.eclipse.emf.ecore.util.EcoreUtil.copy(diagramDocument.getDiagram());
try {
new org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand(diagramDocument.getEditingDomain(), org.eclipse.osgi.util.NLS.bind(ÂEXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentSaveAs()) FOR editorGenÂ, diagramCopy.getName()), affectedFiles) {
protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
newResource.getContents().add(diagramCopy);
return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult();
}
}.execute(monitor, null);
newResource.save(ÂEXPAND xpt::Common::getSaveOptionsÂ);
} catch (org.eclipse.core.commands.ExecutionException e) {
fireElementStateChangeFailed(element);
throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, ÂeditorGen.plugin.getActivatorQualifiedClassName()Â.ID, 0, e.getLocalizedMessage(), null));
} catch (java.io.IOException e) {
fireElementStateChangeFailed(element);
throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, ÂeditorGen.plugin.getActivatorQualifiedClassName()Â.ID, 0, e.getLocalizedMessage(), null));
}
newResource.unload();
}
}
ÂENDAROUNDÂ


ÂDEFINE throwIncorrectInputException FOR gmfgen::GenDiagram-Â
throw new org.eclipse.core.runtime.CoreException(new org.eclipse.core.runtime.Status(org.eclipse.core.runtime.IStatus.ERROR, ÂeditorGen.plugin.getActivatorQualifiedClassName()Â.ID, 0,
org.eclipse.osgi.util.NLS.bind(
ÂEXPAND xpt::Externalizer::accessorCall(i18nKeyForDocumentProviderIncorrectInputError()) FOR editorGenÂ,
new Object[] {element, ÂIF null == editorGen.applicationÂ"ÂEXPAND fileEditorInputClassFQNameÂ", ÂENDIFÂ"ÂEXPAND uriEditorInputClassFQNameÂ"}), ÂEXPAND xpt::Common::nonNLS(1)ÂÂIF null == editorGen.application ÂEXPAND xpt::Common::nonNLS(2)ÂÂENDIFÂ
null));
ÂENDDEFINEÂ



ÂDEFINE fileEditorInputClassFQName FOR gmfgen::GenDiagramÂorg.eclipse.ui.part.FileEditorInputÂENDDEFINEÂ


ÂDEFINE uriEditorInputClassFQName FOR gmfgen::GenDiagramÂorg.eclipse.emf.common.ui.URIEditorInputÂENDDEFINEÂ



If I understood you correctly, this template do nothing at all. It juste copy things ? I'll try to modify things as you said but I didn't know the xpt usage.

Goodbye,