zoukankan      html  css  js  c++  java
  • 关于gmf编辑器的保存操作

    a)    First, in class DiagramDocumentEditor, the method 
    public void doSave(IProgressMonitor progressMonitor) { }
    b)    Second, the method above call the methon:
    protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {}
    this method is in class DiagramDocumentEditor.
    c)AbstractDocumentProvider)中的方法
    public final void saveDocument(IProgressMonitor monitor, final Object element, final IDocument document, final boolean overwrite) throws CoreException {

            
    if (element == null)
                
    return;


            executeOperation(getSaveOperation(element, document, overwrite), monitor);
        }
    d)    在自己的Document provider里面冲载方法
    protected void saveDocumentToFile(IDocument document, IFile file,
                
    boolean overwrite, IProgressMonitor monitor) throws CoreException {}
            
    e)    FileDiagramDocumentProvider种的方法
    protected void saveDocumentToFile(IDocument document, IFile file, boolean overwrite, IProgressMonitor monitor)
            
    throws CoreException {
            Diagram diagram 
    = (Diagram)document.getContent();
            Resource resource 
    = diagram.eResource();
            IFile resourceFile 
    = WorkspaceSynchronizer.getFile(resource);
            
    // if the diagram in the document is referring to another file, then we should
            
    // create a copy of this diagram and save it to the new file, save as scenario.
            if(resourceFile != null && !resourceFile.equals(file)) {
                diagram 
    = copyDiagramResource(diagram, file);
            }
            IDiagramDocument diagramDocument 
    = (IDiagramDocument)document;
            TransactionalEditingDomain domain 
    = diagramDocument.getEditingDomain();
            doSave(domain, file, diagram, 
    null, monitor);
        }

    protected void doSave(TransactionalEditingDomain domain, IFile file,
                Diagram diagram, Map options, IProgressMonitor monitor)
            
    throws CoreException {
            
    if (options == null) {
                DiagramIOUtil.save(domain, file, diagram, DiagramIOUtil
                    .hasUnrecognizedData(diagram.eResource()), monitor);
            } 
    else {
                DiagramIOUtil.save(domain, file, diagram, monitor, options);
            }
    }


    static public void save(TransactionalEditingDomain domain, IFile file, Diagram diagram, boolean bKeepUnrecognizedData, IProgressMonitor progressMonitor) throws CoreException {
            Map options 
    = new HashMap();
            
    if(bKeepUnrecognizedData)
                options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
            save(domain, file, diagram, progressMonitor, options);
        }

    static public void save(TransactionalEditingDomain domain, IFile file, Diagram diagram, IProgressMonitor progressMonitor, Map options) throws CoreException {
            Resource notationModel 
    = ((EObject) diagram).eResource();
            String fileName 
    = file.getFullPath().toOSString();
            notationModel.setURI(URI.createPlatformResourceURI(fileName, 
    true));
            
    try {
                notationModel.save(options);
            } 
    catch (IOException e) {
                
    throw new CoreException(new Status(IStatus.ERROR, EditorPlugin
                    .getPluginId(), EditorStatusCodes.RESOURCE_FAILURE, e
                    .getLocalizedMessage(), 
    null));
            }

            
    if (progressMonitor != null)
                progressMonitor.done();
        }
  • 相关阅读:
    PHP把下划线分隔命名的字符串与驼峰式命名互转
    Cocos2d-JS/Ajax用Protobuf与NodeJS/Java通信
    gulp 实现 js、css,img 合并和压缩
    转:入门Webpack,看这篇就够了
    微信开发教程:用户账号绑定到微信公众号的方法分享
    C#RSA算法实现+如何将公钥为XML格式转为PEM格式,给object-C使用
    php使用openssl进行Rsa长数据加密(117)解密(128) 和 DES 加密解密
    Windows下将nginx安装为服务运行
    转载:Centos7 从零编译配置Memcached
    转载:Centos7 从零编译Nginx+PHP+MySql 二
  • 原文地址:https://www.cnblogs.com/youngerbaby/p/411363.html
Copyright © 2011-2022 走看看