Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfProjectRegistry.java
1 /*******************************************************************************
2 * Copyright (c) 2011 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.project.model;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.eclipse.core.resources.IProject;
19
20 /**
21 * <b><u>TmfProjectRegistry</u></b>
22 * <p>
23 */
24 public class TmfProjectRegistry {
25
26 // The map of project resource to project model elements
27 private static Map<IProject, TmfProjectElement> registry = new HashMap<IProject, TmfProjectElement>();
28
29 /**
30 * Get the project model element for a project resource
31 * @param project the project resource
32 * @return the project model element or null if it does not exist
33 */
34 public static synchronized TmfProjectElement getProject(IProject project) {
35 return getProject(project, false);
36 }
37
38 /**
39 * Get the project model element for a project resource
40 * @param project the project resource
41 * @param force a flag controlling whether a new project should be created if it doesn't exist
42 * @return the project model element
43 */
44 public static synchronized TmfProjectElement getProject(IProject project, boolean force) {
45 TmfProjectElement element = registry.get(project);
46 if (element == null && force) {
47 registry.put(project, new TmfProjectElement(project.getName(), project, null));
48 element = registry.get(project);
49 }
50 return element;
51 }
52
53 }
This page took 0.050976 seconds and 5 git commands to generate.