`
zhaozhongwei
  • 浏览: 52811 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

一些问题

    博客分类:
  • gmf
阅读更多

下面都是从新闻组看到的一些东西,留作以后查看

 

1.could not creat link

Ok. If "true" is returned from XXXCreateCommand.canExecute() then you can try placing a breakpont into XXXViewProvider.createEdge()(in past this method was called "getEdgeViewClass()) operation - this method will be called as a second part of link creation and can be another reason preventing you from second link creation.

 

(also XXXItemSemanticEditPolicy.getCreateRelationshipCommand())

If you have several links with same underlying domain model meta-element then you have to add some (OCL) constraints to make it possible for GMF to destinguish between these links.

 

 

2.How can I make static picture on canvas like the compass in taipan
editor?

It was done by writing custom code - check AquatoryEditPart.createFigure().

 

3.drawback of providers structure

Try raising priorities of View/EditPart providers registered in a plugin.xml generated by GMF for your diagram - this is a drawback of providers structure - anybody can easily break your diagram by itroducing their own provider.. In near future we are going to generate provider-based implementation only in situations then it is necessary.

 

 

4.GMF Editor without FileInput

This could help?

In your DiagramEditor, the method below opens the editor with new EditorInput, you could change it here.

// in Diagram Editor
public static boolean openDiagram(Resource diagram)
throws PartInitException {
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
 >> page.openEditor(new URIEditorInput(diagram.getURI()),
YourDiagramEditor.ID);
return true;
}


.....and make sure the DocumentProvider can handle your new Editor input.

// In Document provider

protected ElementInfo createElementInfo(Object element)
throws CoreException {
if (false == element instanceof URIEditorInput) {
...
}
IEditorInput editorInput = (IEditorInput) element;
IDiagramDocument document = (IDiagramDocument) createDocument(editorInput);

ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
...
}

.... also here you need to hackin to set your content properly, you might
need your version of DiagramDocument


protected void setDocumentContent(IDocument document, IEditorInput element)
throws CoreException {
IDiagramDocument diagramDocument = (IDiagramDocument) document;
TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
......
EObject rootElement = resource.getEObject(uri.fragment());
if (rootElement instanceof Diagram) {
document.setContent((Diagram) rootElement);
return;
}
......





.... Of course the Resource if by default an EMF Resource with certain characteristics. (Like XMI serialization), you could change this by
creating a ResourceFactory and tigh this factory to an extension or protocol.

//plugin.xml

<extension point="org.eclipse.emf.ecore.extension_parser" id="resource-factory">
       <?gmfgen generated="true"?>
       <parser
          type="your extension"
            >>class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory">
       </parser>
    </extension>

....Your factory my need a custom Resource used by the document provider to set the content.

 

 

dnd

http://www.eclipse.org/newsportal/article.php?id=16299&group=eclipse.modeling.gmf#16299

 

 

to be continued...

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics