-
Notifications
You must be signed in to change notification settings - Fork 385
/
RenameInNameSpaceRecord.java
104 lines (89 loc) · 2.62 KB
/
RenameInNameSpaceRecord.java
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
/*******************************************************************************
* Copyright (c) 2004 Actuate Corporation.
* 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:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.birt.report.model.command;
import org.eclipse.birt.report.model.activity.SimpleRecord;
import org.eclipse.birt.report.model.api.activity.NotificationEvent;
import org.eclipse.birt.report.model.api.command.NameEvent;
import org.eclipse.birt.report.model.core.DesignElement;
import org.eclipse.birt.report.model.core.Module;
import org.eclipse.birt.report.model.core.NameSpace;
import org.eclipse.birt.report.model.core.namespace.INameHelper;
import org.eclipse.birt.report.model.core.namespace.NameExecutor;
/**
* Record for renaming element in name space.
*/
class RenameInNameSpaceRecord extends SimpleRecord
{
private DesignElement element = null;
private String oldName = null;
private String newName = null;
private String nameSpaceID;
private INameHelper nameHelper = null;
/**
* Constructs the record for renaming element in name space.
*
* @param module
*
* @param element
* the element for renaming
* @param oldName
* old name
* @param newName
* new name
*/
RenameInNameSpaceRecord( Module module, DesignElement element,
String oldName, String newName )
{
this.element = element;
this.oldName = oldName;
this.newName = newName;
NameExecutor executor = new NameExecutor( module, element );
this.nameHelper = executor.getNameHelper( );
this.nameSpaceID = executor.getNameSpaceId( );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.birt.report.model.activity.SimpleRecord#perform(boolean)
*/
protected void perform( boolean undo )
{
NameSpace ns = nameHelper.getNameSpace( nameSpaceID );
if ( undo )
{
ns.rename( element, newName, oldName );
}
else
{
ns.rename( element, oldName, newName );
}
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.birt.report.model.activity.AbstractElementRecord#getTarget()
*/
public DesignElement getTarget( )
{
return nameHelper.getElement( );
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.birt.report.model.activity.AbstractElementRecord#getEvent()
*/
public NotificationEvent getEvent( )
{
return new NameEvent( element, oldName, newName );
}
}