Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: db87de310bc67ac1ea58cce3b9a5d3f6f42978c9 (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
/*******************************************************************************
 * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany).
 * 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:
 *     Martin Fluegge - initial API and implementation
 ******************************************************************************/
package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies;

import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreDiagramEditorPlugin;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
import org.eclipse.gmf.runtime.notation.View;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Martin Fluegge
 */
public class DawnACoreRootCanonicalEditPolicy extends ACoreRootCanonicalEditPolicy
{

  public DawnACoreRootCanonicalEditPolicy()
  {
    super();
    AcoreDiagramEditorPlugin.getInstance().logInfo("Running DawnAcoreCanonicalEditPolicy instead of original one");
  }

  @Override
  protected CreateViewRequest getCreateViewRequest(List<ViewDescriptor> descriptors)
  {
    List<View> viewChildren = getViewChildren();

    List<ViewDescriptor> tbr = new ArrayList<CreateViewRequest.ViewDescriptor>();

    for (ViewDescriptor desc : descriptors)
    {
      EObject obj = (EObject)((CanonicalElementAdapter)desc.getElementAdapter()).getRealObject();

      boolean found = false;

      for (View view : viewChildren)
      {
        if (view.getElement().equals(obj))
        {
          found = true;
          break;
        }
      }
      if (!found)
      {
        tbr.add(desc);
      }
    }

    descriptors.removeAll(tbr);

    return new CreateViewRequest(descriptors);
  }
  // @Override
  // protected List getSemanticChildrenList()
  // {
  // List semanticChildren = super.getSemanticChildrenList();
  // List<View> viewChildren = getViewChildren();
  //
  // //remove all semantic children that do not have a view because the have one in another resource,
  // //or the child should not have one
  // semanticChildren.removeAll(cleanCanonicalSemanticChildren(viewChildren, semanticChildren));
  // return semanticChildren;
  // }

  // /**
  // * @generated
  // */
  // @Override
  // public void refreshSemantic()
  // {
  // List createdViews = new LinkedList();
  // // createdViews.addAll(refreshSemanticChildren());
  // List createdConnectionViews = new LinkedList();
  // createdConnectionViews.addAll(refreshSemanticConnections());
  // createdConnectionViews.addAll(refreshConnections());
  //
  // if (createdViews.size() > 1)
  // {
  // // perform a layout of the container
  // DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host());
  // executeCommand(new ICommandProxy(layoutCmd));
  // }
  //
  // createdViews.addAll(createdConnectionViews);
  // makeViewsImmutable(createdViews);
  // }
}

Back to the top