Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: ade4b77c78a3d3c902af6eff67a33c0fae215882 (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
package org.eclipse.wst.xsd.ui.internal.commands;

import org.eclipse.draw2d.Label;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.wst.xsd.ui.internal.graph.editparts.ComplexTypeDefinitionEditPart;
import org.eclipse.wst.xsd.ui.internal.graph.editparts.ElementDeclarationEditPart;
import org.eclipse.wst.xsd.ui.internal.graph.editparts.ModelGroupDefinitionEditPart;
import org.eclipse.wst.xsd.ui.internal.graph.editparts.TopLevelComponentEditPart;
import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
import org.eclipse.xsd.XSDConcreteComponent;
import org.eclipse.xsd.XSDNamedComponent;


/**
 * @author kchong
 *
 * <a href="mailto:kchong@ca.ibm.com">kchong@ca.ibm.com</a>
 *
 */
public class RenameCommand
{
  protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
  Label label = new Label();
  XSDNamedComponent namedComponent;
  GraphicalEditPart editPart;
  
  public RenameCommand(XSDNamedComponent namedComponent, GraphicalEditPart editPart)
  {
    this.namedComponent = namedComponent;
    this.editPart = editPart;
  }

  /* (non-Javadoc)
   * @see com.ibm.xsd.edit.actions.AbstractCommand#run()
   */
  public void run()
  {
    if (editPart instanceof ElementDeclarationEditPart)
    {
      ElementDeclarationEditPart elementDeclarationEditPart = (ElementDeclarationEditPart)editPart;
      elementDeclarationEditPart.doEditName();
    }
    else if (editPart instanceof TopLevelComponentEditPart)
    {
      TopLevelComponentEditPart topLevelEditPart = (TopLevelComponentEditPart)editPart;
      topLevelEditPart.doEditName();
    }
    else if (editPart instanceof ComplexTypeDefinitionEditPart)
    {
      ((ComplexTypeDefinitionEditPart)editPart).doEditName();
    }
    else if (editPart instanceof ModelGroupDefinitionEditPart)
    {
      ((ModelGroupDefinitionEditPart)editPart).doEditName();
    }
  }

  /* (non-Javadoc)
   * @see com.ibm.xsd.edit.actions.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent)
   */
  protected boolean adopt(XSDConcreteComponent model)
  {
    return false;
  }

}

Back to the top