Tmf: Batch Trace Import
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfProjectRegistry.java
CommitLineData
12c155f5 1/*******************************************************************************
b544077e 2 * Copyright (c) 2011, 2012 Ericsson
12c155f5
FC
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
13package org.eclipse.linuxtools.tmf.ui.project.model;
14
15import java.util.HashMap;
16import java.util.Map;
17
18import org.eclipse.core.resources.IProject;
19
20/**
b544077e 21 * Factory class storing TMF tracing projects and creating TMF project model elements.
12c155f5 22 * <p>
b544077e
BH
23 * @version 1.0
24 * @author Francois Chouinard
12c155f5
FC
25 */
26public class TmfProjectRegistry {
27
828e5592 28 // The map of project resource to project model elements
12c155f5
FC
29 private static Map<IProject, TmfProjectElement> registry = new HashMap<IProject, TmfProjectElement>();
30
828e5592
PT
31 /**
32 * Get the project model element for a project resource
33 * @param project the project resource
34 * @return the project model element or null if it does not exist
35 */
12c155f5 36 public static synchronized TmfProjectElement getProject(IProject project) {
828e5592
PT
37 return getProject(project, false);
38 }
39
40 /**
41 * Get the project model element for a project resource
42 * @param project the project resource
43 * @param force a flag controlling whether a new project should be created if it doesn't exist
44 * @return the project model element
45 */
46 public static synchronized TmfProjectElement getProject(IProject project, boolean force) {
12c155f5 47 TmfProjectElement element = registry.get(project);
828e5592 48 if (element == null && force) {
12c155f5
FC
49 registry.put(project, new TmfProjectElement(project.getName(), project, null));
50 element = registry.get(project);
51 }
52 return element;
53 }
54
55}
This page took 0.035301 seconds and 5 git commands to generate.