Skip to main content
summaryrefslogtreecommitdiffstats
blob: b735003d5e180596dc58a59b26f1d1443fdee83f (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
/*******************************************************************************
 * Copyright (c) 2007, 2010 Oracle. 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:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.core.internal.jpa1.context.orm;

import org.eclipse.jpt.core.context.BaseOverride;
import org.eclipse.jpt.core.context.XmlContextNode;
import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode;
import org.eclipse.jpt.core.resource.orm.XmlOverride;
import org.eclipse.jpt.core.utility.TextRange;


public class AbstractOrmOverride extends AbstractOrmXmlContextNode
{

	protected String name;

	protected final BaseOverride.Owner owner;

	protected XmlOverride resourceOverride;

	public AbstractOrmOverride(XmlContextNode parent, BaseOverride.Owner owner, XmlOverride resourceOverride) {
		super(parent);
		this.owner = owner;
		this.resourceOverride = resourceOverride;
		this.name = getResourceName();
	}
	
	@Override
	public XmlContextNode getParent() {
		return (XmlContextNode) super.getParent();
	}

	public BaseOverride.Owner getOwner() {
		return this.owner;
	}
	
	protected XmlOverride getResourceOverride() {
		return this.resourceOverride;
	}

	protected void update(XmlOverride resourceOverride) {
		this.resourceOverride = resourceOverride;
		this.setName_(this.getResourceName());
	}
	
	
	// ********************* name ****************
	
	public String getName() {
		return this.name;
	}
	
	public void setName(String newName) {
		String oldName = this.name;
		this.name = newName;
		this.resourceOverride.setName(newName);
		firePropertyChanged(BaseOverride.NAME_PROPERTY, oldName, newName);
	}

	protected void setName_(String newName) {
		String oldName = this.name;
		this.name = newName;
		firePropertyChanged(BaseOverride.NAME_PROPERTY, oldName, newName);
	}

	protected String getResourceName() {
		return this.resourceOverride.getName();
	}

	public TextRange getValidationTextRange() {
		TextRange textRange = this.resourceOverride.getValidationTextRange();
		return textRange == null ? getParent().getValidationTextRange() : textRange;
	}

	
	//****************** miscellaneous ********************
	
	@Override
	public void toString(StringBuilder sb) {
		sb.append(this.name);
	}

}

Back to the top