Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2eacc29b7db6f770f0a82a779a91f1726934084d (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*******************************************************************************
 * Copyright (c) 2000, 2018 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.text.templates.persistence;

import org.eclipse.jface.text.templates.Template;


/**
 * TemplatePersistenceData stores information about a template. It uniquely
 * references contributed templates via their id. Contributed templates may be
 * deleted or modified. All template may be enabled or not.
 * <p>
 * Clients may use this class, although this is not usually needed except when
 * implementing a custom template preference page or template store. This class
 * is not intended to be subclassed.
 * </p>
 *
 * @since 3.0
 * @noextend This class is not intended to be subclassed by clients.
 * @deprecated See {@link org.eclipse.text.templates.TemplatePersistenceData}
 */
@Deprecated
public class TemplatePersistenceData extends org.eclipse.text.templates.TemplatePersistenceData {

	org.eclipse.text.templates.TemplatePersistenceData ref;

	/**
	 * In some cases, we must continue to respect the deprecated TemplatePresistenceData
	 * even though we are given {@link org.eclipse.text.templates.TemplatePersistenceData}.
	 *
	 * @param data The {@link org.eclipse.text.templates.TemplatePersistenceData} that will
	 * underlie this object.
	 * @since 3.14
	 */
	public TemplatePersistenceData(org.eclipse.text.templates.TemplatePersistenceData data) {
		super(data.getTemplate(), data.isEnabled(), data.getId()); // these are ignored
		this.ref= data;
	}

	public TemplatePersistenceData(Template template, boolean enabled) {
		super(template, enabled);
	}

	public TemplatePersistenceData(Template template, boolean enabled, String id) {
		super(template, enabled, id);
	}

	@Override
	public String getId() {
		return (ref != null) ? ref.getId() : super.getId();
	}

	@Override
	public boolean isDeleted() {
		return (ref != null) ? ref.isDeleted() : super.isDeleted();
	}

	@Override
	public void setDeleted(boolean isDeleted) {
		if (ref != null) {
			ref.setDeleted(isDeleted);
		} else {
			super.setDeleted(isDeleted);
		}
	}

	@Override
	public Template getTemplate() {
		return (ref != null) ? ref.getTemplate() : super.getTemplate();
	}

	@Override
	public void setTemplate(Template template) {
		if (ref != null) {
			ref.setTemplate(template);
		} else {
			super.setTemplate(template);
		}
	}

	@Override
	public boolean isCustom() {
		return (ref != null) ? ref.isCustom() : super.isCustom();
	}

	@Override
	public boolean isModified() {
		return (ref != null) ? ref.isModified() : super.isModified();
	}

	@Override
	public boolean isUserAdded() {
		return (ref != null) ? ref.isUserAdded() : super.isUserAdded();
	}

	@Override
	public void revert() {
		if (ref != null) {
			ref.revert();
		} else {
			super.revert();
		}
	}

	@Override
	public boolean isEnabled() {
		return (ref != null) ? ref.isEnabled() : super.isEnabled();
	}

	@Override
	public void setEnabled(boolean isEnabled) {
		if (ref != null) {
			ref.setEnabled(isEnabled);
		} else {
			super.setEnabled(isEnabled);
		}
	}

	@Override
	public boolean equals(Object other) {
		return (ref != null) ? ref.equals(other) : super.equals(other);
	}

	@Override
	public int hashCode() {
		return (ref != null) ? ref.hashCode() : super.hashCode();
	}

}

Back to the top