1 /*******************************************************************************
2 * Copyright (c) 2011 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
;
15 import java
.util
.HashMap
;
18 import org
.eclipse
.core
.resources
.IProject
;
21 * <b><u>TmfProjectRegistry</u></b>
24 public class TmfProjectRegistry
{
26 // The map of project resource to project model elements
27 private static Map
<IProject
, TmfProjectElement
> registry
= new HashMap
<IProject
, TmfProjectElement
>();
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
34 public static synchronized TmfProjectElement
getProject(IProject project
) {
35 return getProject(project
, false);
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
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
);