Runtime

## org.eclipse.gmf.runtime.diagram.core.util
Class ViewRefactorHelper

    java.lang.Object
      org.eclipse.gmf.runtime.diagram.core.util.ViewRefactorHelper

    public class ViewRefactorHelper

extends java.lang.Object

A helper class to perform notational refactoring based on a semantic refactoring. The helper provides a typical or generic implementation of the refactoring operation based on the Notation metamodel. However, if the notations being refactoring use other extended notation metamodels, the implementation of this helper class might need to be extended. This can be achieved by directly subclassing this helper class.

Constructor Summary
`ViewRefactorHelper()` Constructs a new `ViewRefactorHelper` with a given preferences hint
`ViewRefactorHelper(PreferencesHint preferencesHint)` Constructs a new `ViewRefactorHelper` with a given preferences hint

Method Summary
`protected void` `copyDiagramFeatures(Diagram oldDiagram, Diagram newDiagram)` Copies the notational features of the old diagram to the new diagram
`protected void` `copyEdgeFeatures(Edge oldEdge, Edge newEdge)` Copies the notational features of the old edge to the new edge
`protected void` `copyNodeFeatures(Node oldNode, Node newNode)` Copies the notational features of the old node to the new node
`void` `copyViewAppearance(View oldView, View newView, java.util.List excludeStyles)` Copies the appearance of the old view to the new view.
`protected void` `copyViewChild(View oldView, View newView, Node oldChildNode)` If the child view has the same element as the parent and also has a type, it is considered a subview and therefore only its properties are copied to matching subviews (if any) of the new parent.
`protected void` `copyViewChildren(View oldView, View newView)` Copies the notational properties of the old view children to the new view children
`protected void` `copyViewFeatures(View oldView, View newView)` Copies the notational features of the old view to the new view
`protected void` `copyViewStyle(View oldView, View newView, Style oldStyle, java.util.List excludeStyles)` Copies the given style features of the old view to the new view
`protected void` `copyViewStyles(View oldView, View newView)` Copies the style features of the old view to the new view
`protected void` `copyViewStyles(View oldView, View newView, java.util.List excludeStyles)` Copies all styles feature from the old view to the new view
`protected Diagram` `createDiagram(Diagram oldDiagram, org.eclipse.emf.ecore.EObject newElement)` A utility to create a new diagram for the given new element that would replace the given old diagram.
`protected Edge` `createEdge(Edge oldEdge, org.eclipse.emf.ecore.EObject newElement)` A utility to create a new edge for the given new element that would replace the given old edge.
`protected Node` `createNode(Node oldNode, org.eclipse.emf.ecore.EObject newElement)` A utility to create a new node for the given new element that would replace the given old node.
`protected java.lang.String` `getNewViewType(View oldView, org.eclipse.emf.ecore.EObject newElement)` Returns the type of the new view that replaces the old one
`PreferencesHint` `getPreferencesHint()` Returns the preferences hint
`protected java.util.Collection` `getReferencingViews(org.eclipse.emf.ecore.EObject element)` A utility to get all the views of the given element to be refactored.
`void` `refactor(org.eclipse.emf.ecore.EObject oldElement, org.eclipse.emf.ecore.EObject newElement)` Refactors the notations associated with the old element to make them consistent with the new element.
`protected Diagram` `refactorDiagram(Diagram oldDiagram, org.eclipse.emf.ecore.EObject newElement)` Refactors an old diagram to a new one with the given new element
`protected void` `refactorDiagramLinks(Diagram oldDiagram, Diagram newDiagram)`
`protected Edge` `refactorEdge(Edge oldEdge, org.eclipse.emf.ecore.EObject newElement)` Refactors an old edge to a new one with the given new element
`protected void` `refactorGuides(Node oldNode, Node newNode)` Refactors the diagram guides to reference the new node instead of the old one
`protected Node` `refactorNode(Node oldNode, org.eclipse.emf.ecore.EObject newElement)` Refactors an old node to a new one with the given new element

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ViewRefactorHelper

    public ViewRefactorHelper()

  Constructs a new `ViewRefactorHelper` with a given preferences hint

### ViewRefactorHelper

    public ViewRefactorHelper(PreferencesHint preferencesHint)

  Constructs a new `ViewRefactorHelper` with a given preferences hint

  Parameters:
    `preferencesHint` - The preferences hint to be used to perform refactoring

Method Detail

### getPreferencesHint

    public PreferencesHint getPreferencesHint()

  Returns the preferences hint

  Returns:
    The preferences hint

### refactor

    public void refactor(org.eclipse.emf.ecore.EObject oldElement,
                         org.eclipse.emf.ecore.EObject newElement)

  Refactors the notations associated with the old element to make them consistent with the new element.

  Parameters:
    `oldElement` - The semantic element being refactored
    `newElement` - The semantic element that replaces the refactored one

### refactorNode

    protected Node refactorNode(Node oldNode,
                                org.eclipse.emf.ecore.EObject newElement)

  Refactors an old node to a new one with the given new element

  Parameters:
    `oldNode` - The old node being refactored
    `newElement` - The replacing new element
  Returns:
    A new refactored node

### refactorEdge

    protected Edge refactorEdge(Edge oldEdge,
                                org.eclipse.emf.ecore.EObject newElement)

  Refactors an old edge to a new one with the given new element

  Parameters:
    `oldEdge` - The old edge being refactored
    `newElement` - The replacing new element
  Returns:
    A new refactored edge

### refactorDiagram

    protected Diagram refactorDiagram(Diagram oldDiagram,
                                      org.eclipse.emf.ecore.EObject newElement)

  Refactors an old diagram to a new one with the given new element

  Parameters:
    `oldDiagram` - The old diagram being refactored
    `newElement` - The replacing new element
  Returns:
    A new refactored diagram

### refactorDiagramLinks

    protected void refactorDiagramLinks(Diagram oldDiagram,
                                        Diagram newDiagram)

### copyNodeFeatures

    protected void copyNodeFeatures(Node oldNode,
                                    Node newNode)

  Copies the notational features of the old node to the new node

  Parameters:
    `oldNode` - The old node to copy features from
    `newNode` - The new node to copy features to

### copyEdgeFeatures

    protected void copyEdgeFeatures(Edge oldEdge,
                                    Edge newEdge)

  Copies the notational features of the old edge to the new edge

  Parameters:
    `oldEdge` - The old edge to copy features from
    `newEdge` - The new edge to copy features to

### copyDiagramFeatures

    protected void copyDiagramFeatures(Diagram oldDiagram,
                                       Diagram newDiagram)

  Copies the notational features of the old diagram to the new diagram

  Parameters:
    `oldDiagram` - The old diagram to copy features from
    `newDiagram` - The new diagram to copy features to

### copyViewFeatures

    protected void copyViewFeatures(View oldView,
                                    View newView)

  Copies the notational features of the old view to the new view

  Parameters:
    `oldView` - The old view to copy features from
    `newView` - The new view to copy features to

### copyViewAppearance

    public void copyViewAppearance(View oldView,
                                   View newView,
                                   java.util.List excludeStyles)

  Copies the appearance of the old view to the new view. Typically this means copying the visibility and the styles of the root and it's children.

  Parameters:
    `oldView` - The old view to copy style features from
    `newView` - The new view to copy style features to
    `excludeStyles` - the `List` of `Style.eClass` types to exclude from the copy operation.

### copyViewStyles

    protected void copyViewStyles(View oldView,
                                  View newView)

  Copies the style features of the old view to the new view

  Parameters:
    `oldView` - The old view to copy style features from
    `newView` - The new view to copy style features to

### copyViewStyles

    protected void copyViewStyles(View oldView,
                                  View newView,
                                  java.util.List excludeStyles)

  Copies all styles feature from the old view to the new view

  Parameters:
    `oldView` - The old view to copy style features from
    `newView` - The new view to copy style features to
    `excludeStyles` - the `List` of `Style.eClass` types to exclude from the copy operation.

### copyViewStyle

    protected void copyViewStyle(View oldView,
                                 View newView,
                                 Style oldStyle,
                                 java.util.List excludeStyles)

  Copies the given style features of the old view to the new view

  Parameters:
    `oldView` - The old view to copy style features from
    `newView` - The new view to copy style features to
    `oldStyle` - The old style to copy
    `excludeStyles` - the list of `Style.eClass` types to exclude

### copyViewChildren

    protected void copyViewChildren(View oldView,
                                    View newView)

  Copies the notational properties of the old view children to the new view children

  Parameters:
    `oldView` - The old view to copy children notational features from
    `newView` - The new view to copy children notational features to

### copyViewChild

    protected void copyViewChild(View oldView,
                                 View newView,
                                 Node oldChildNode)

  If the child view has the same element as the parent and also has a type, it is considered a subview and therefore only its properties are copied to matching subviews (if any) of the new parent. Otherwise, the default behavior is for the child view to be moved to the new parent

  Parameters:
    `oldView` - The old view to copy children notational features from
    `newView` - The new view to copy children notational features to
    `oldChildNode` - A child node of the old view

### refactorGuides

    protected final void refactorGuides(Node oldNode,
                                        Node newNode)

  Refactors the diagram guides to reference the new node instead of the old one

  Parameters:
    `oldNode` - The old node being refactored
    `newNode` - The replacing new node

### getReferencingViews

    protected java.util.Collection getReferencingViews(org.eclipse.emf.ecore.EObject element)

  A utility to get all the views of the given element to be refactored. The implementation of method delegated to a reverse look up map to get those views. Override if you have a more efficient way of getting those view or to cover more or less views.

  Parameters:
    `element` - The element referenced by views to be refactored
  Returns:
    A collection of views that reference the given element to refactor

### createNode

    protected Node createNode(Node oldNode,
                              org.eclipse.emf.ecore.EObject newElement)

  A utility to create a new node for the given new element that would replace the given old node. The method uses default parameters to create the new node for the element. Override and change this method if you think this is not the proper way to create a node of this new element.

  Parameters:
    `oldNode` - The old node being refactored
    `newElement` - The new element to create a node on
  Returns:
    A new node that references the given new element

### createEdge

    protected Edge createEdge(Edge oldEdge,
                              org.eclipse.emf.ecore.EObject newElement)

  A utility to create a new edge for the given new element that would replace the given old edge. The method uses default parameters to create the new edge for the element. Override and change this method if you think this is not the proper way to create a edge of this new element.

  Parameters:
    `oldEdge` - The old edge being refactored
    `newElement` - The new element to create a edge on
  Returns:
    A new edge that references the given new element

### createDiagram

    protected Diagram createDiagram(Diagram oldDiagram,
                                    org.eclipse.emf.ecore.EObject newElement)

  A utility to create a new diagram for the given new element that would replace the given old diagram. The method uses default parameters to create the new diagram for the element. Override and change this method if you think this is not the proper way to create a diagram of this new element.

  Parameters:
    `oldDiagram` - The old diagram being refactored
    `newElement` - The new element to create a diagram on
  Returns:
    A new diagram that references the given new element

### getNewViewType

    protected java.lang.String getNewViewType(View oldView,
                                              org.eclipse.emf.ecore.EObject newElement)

  Returns the type of the new view that replaces the old one

  Parameters:
    `oldView` - The old view being replaced
    `newElement` - The new element of the new view
  Returns:
    The type of the new view

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.