Skip to main content
summaryrefslogtreecommitdiffstats
blob: 799b4e079d57681797207f30f5d55f40c1e216ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
 * 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:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.dawn.transaction;

import org.eclipse.emf.cdo.dawn.resources.DawnPathmapManager;
import org.eclipse.emf.cdo.internal.dawn.bundle.OM;

import org.eclipse.net4j.util.om.trace.ContextTracer;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.transaction.TransactionalCommandStack;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.impl.TransactionChangeRecorder;
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
import org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl;

import org.eclipse.core.commands.operations.IOperationHistory;
import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory;

public class DawnDiagramEditingDomainFactory extends DiagramEditingDomainFactory
{
  private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnDiagramEditingDomainFactory.class);

  private static DawnDiagramEditingDomainFactory instance = new DawnDiagramEditingDomainFactory();

  protected static class DawnDiagramEditingDomain extends DiagramEditingDomain
  {
    public DawnDiagramEditingDomain(AdapterFactory adapterFactory, ResourceSet resourceSet)
    {
      super(adapterFactory, resourceSet);
    }

    public DawnDiagramEditingDomain(AdapterFactory adapterFactory, TransactionalCommandStack stack,
        ResourceSet resourceSet)
    {
      super(adapterFactory, stack, resourceSet);
    }

    public DawnDiagramEditingDomain(AdapterFactory adapterFactory, TransactionalCommandStack stack)
    {
      super(adapterFactory, stack);
    }

    public DawnDiagramEditingDomain(AdapterFactory adapterFactory)
    {
      super(adapterFactory);
    }

    /**
     * override the TransactionChangeRecorder to suppress the write asserts which are not need with CDO
     */
    @Override
    protected TransactionChangeRecorder createChangeRecorder(ResourceSet rset)
    {
      return new DawnTransactionChangeRecorder(this, rset);
    }
  }

  @Override
  public TransactionalEditingDomain createEditingDomain(IOperationHistory history)
  {
    if (TRACER.isEnabled())
    {
      TRACER.trace("Creating DawnTransactionalEditingDomain using DawnDiagramEditingDomainFactory"); //$NON-NLS-1$
    }
    WorkspaceCommandStackImpl stack = new WorkspaceCommandStackImpl(history);

    TransactionalEditingDomain result = new DawnDiagramEditingDomain(new ComposedAdapterFactory(
        ComposedAdapterFactory.Descriptor.Registry.INSTANCE), stack);

    mapResourceSet(result);

    configure(result);
    return result;
  }

  @Override
  public TransactionalEditingDomain createEditingDomain(ResourceSet rset, IOperationHistory history)
  {
    WorkspaceCommandStackImpl stack = new WorkspaceCommandStackImpl(history);

    TransactionalEditingDomain result = new DawnDiagramEditingDomain(new ComposedAdapterFactory(
        ComposedAdapterFactory.Descriptor.Registry.INSTANCE), stack, rset);

    mapResourceSet(result);
    configure(result);
    return result;
  }

  @Override
  protected void configure(final TransactionalEditingDomain domain)
  {
    super.configure(domain);

    final ResourceSet rset = domain.getResourceSet();
    DawnPathmapManager.removePathMapMananger(rset.eAdapters());
    rset.eAdapters().add(new DawnPathmapManager());
  }

  public static WorkspaceEditingDomainFactory getInstance()
  {
    return instance;
  }
}

Back to the top