Skip to main content
summaryrefslogtreecommitdiffstats
blob: b5543ace6371e991f03d521ba5ca2144ced92cd5 (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
/***************************************************************************************************
 * Copyright (c) 2003, 2004 IBM Corporation and others. 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: IBM Corporation - initial API and implementation
 **************************************************************************************************/
/*
 * Created on Feb 5, 2004
 * 
 * To change the template for this generated file go to Window>Preferences>Java>Code
 * Generation>Code and Comments
 */
package org.eclipse.wst.common.internal.emfworkbench.edit;


import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.common.util.URI;
import org.eclipse.wst.common.frameworks.internal.AbstractRegistryDescriptor;



public class EditModelResource extends AbstractRegistryDescriptor implements Comparable {
	public static final String EDIT_MODEL_URI_ATTR = "URI"; //$NON-NLS-1$
	public static final String AUTO_LOAD_ATTR = "autoload"; //$NON-NLS-1$
	public static final String EDIT_MODEL_RESOURCE_ELEMENT = "editModelResource"; //$NON-NLS-1$

	private static int loadOrderCounter = 1;
	private URI uri;
	private boolean autoload = false;
	//Indicates if this was defined as part of the edit model,
	//as opposed to an extension
	private boolean isCore = true;

	private String extensionID;

	private int loadOrder;

	public EditModelResource(IConfigurationElement element) {
		super(element);
		String strUri = element.getAttribute(EDIT_MODEL_URI_ATTR);
		if (strUri != null)
			EditModelResource.this.uri = URI.createURI(strUri);

		String strLoad = element.getAttribute(AUTO_LOAD_ATTR);
		if (strLoad != null)
			autoload = Boolean.valueOf(strLoad).booleanValue();
		loadOrder = loadOrderCounter++;
	}

	public EditModelResource(IConfigurationElement element, String extensionID) {
		this(element);
		this.extensionID = extensionID;
		isCore = false;
	}

	public URI getURI() {
		return uri;
	}

	public boolean isAutoLoad() {
		return autoload;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.wst.common.frameworks.internal.AbstractRegistryDescriptor#getID()
	 */
	public String getID() {
		return extensionID;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.wst.common.frameworks.internal.AbstractRegistryDescriptor#getPriority()
	 */
	public int getPriority() {
		if (isCore)
			return 0;
		return super.getPriority();
	}

	/**
	 * return whether this resource is defined as part of the edit model definition as opposed to an
	 * extension
	 */
	public boolean isCore() {
		return isCore;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(Object o) {
		if (!(o instanceof EditModelResource))
			return 1;
		EditModelResource res = (EditModelResource) o;
		int value = getPriority() - res.getPriority();
		if (value == 0)
			return loadOrder - res.loadOrder;
		return value;
	}

	/**
	 * @return Returns the loadOrder.
	 */
	public int getLoadOrder() {
		return loadOrder;
	}
}

Back to the top