Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4d9940c47a5d800106424ab00398f668a6303ac4 (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
/*****************************************************************************
 * Copyright (c) 2013 CEA LIST.
 *
 * 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:
 *  Remi Schnekenburger (CEA LIST) - Initial API and implementation
 *  Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436952
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.core.resource;

import java.util.List;
import java.util.Set;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;

/**
 * Abstract Implementation of the {@link IModel} interface.
 */
public abstract class AbstractModel implements IModel {

	/** Default encoding */
	public static final String ENCODING = "UTF-8"; //$NON-NLS-1$

	/** The associated ModelManager */
	protected ModelSet modelSet;

	/** List of attached snippets */
	protected ModelSnippetList snippets = new ModelSnippetList();

	/** list of Models (referenced by identifiers) that should be loaded before this one can be loaded */
	protected List<String> afterLoadModelIdentifiers;

	/** list of Models (referenced by identifiers) that should not be loaded before this one is unloaded */
	protected List<String> unloadBeforeModelIdentifiers;

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void init(ModelSet modelSet) {
		this.modelSet = modelSet;
	}

	/**
	 * Returns the ModelSet given during initialization
	 *
	 * @return the ModelSet given during initialization
	 */
	protected ModelSet getModelManager() {
		return modelSet;
	}

	/**
	 * Returns the associated ResourceSet containing the resources of this model.
	 *
	 * @return the associated ResourceSet containing the resources of this model.
	 */
	protected ResourceSet getResourceSet() {
		return modelSet;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public abstract String getIdentifier();

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void addModelSnippet(IModelSnippet snippet) {
		snippets.add(snippet);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void setAfterLoadModelDependencies(List<String> afterLoadModelIdentifiers) {
		this.afterLoadModelIdentifiers = afterLoadModelIdentifiers;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<String> getAfterLoadModelIdentifiers() {
		return afterLoadModelIdentifiers;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void setBeforeUnloadDependencies(List<String> unloadBeforeModelIdentifiers) {
		this.unloadBeforeModelIdentifiers = unloadBeforeModelIdentifiers;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<String> getUnloadBeforeModelIdentifiers() {
		return unloadBeforeModelIdentifiers;
	}

	@Override
	public void unload() {
		this.modelSet = null;
		snippets.clear();
	}

	@Override
	public boolean isModelFor(Object element) {
		return false;
	}


	/**
	 * @see org.eclipse.papyrus.infra.core.resource.IModel#cleanModel(java.util.Set)
	 *
	 * @param toDeleteOnSave
	 */
	@Override
	public void cleanModel(Set<URI> resourcesToDelete) {
		// Nothing to do

	}
}

Back to the top