tmf: Import trace package without manifest
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TraceUtils.java
CommitLineData
05e0d2e9 1/*******************************************************************************
d600c18f 2 * Copyright (c) 2013 École Polytechnique de Montréal and others
05e0d2e9
GB
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 * Geneviève Bastien - Initial API and implementation
d600c18f 11 * Marc-Andre Laperle - Add method to get opened tmf projects
05e0d2e9
GB
12 *******************************************************************************/
13
14package org.eclipse.linuxtools.tmf.ui.project.model;
15
d600c18f
MAL
16import java.util.ArrayList;
17import java.util.List;
18
19import org.eclipse.core.resources.IProject;
20import org.eclipse.core.resources.ResourcesPlugin;
21import org.eclipse.core.runtime.CoreException;
22import org.eclipse.linuxtools.internal.tmf.ui.Activator;
23import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
05e0d2e9
GB
24import org.eclipse.swt.widgets.Display;
25import org.eclipse.swt.widgets.MessageBox;
26import org.eclipse.ui.PlatformUI;
27
28/**
29 * Utility class for common tmf.ui functionalities
30 *
31 * @since 2.1
32 */
33public class TraceUtils {
34
35 /**
36 * Displays an error message in a box
37 *
38 * @param boxTitle
39 * The message box title
40 * @param errorMsg
41 * The error message to display
42 */
43 public static void displayErrorMsg(final String boxTitle, final String errorMsg) {
44 Display.getDefault().asyncExec(new Runnable() {
45 @Override
46 public void run() {
47 final MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
48 mb.setText(boxTitle);
49 mb.setMessage(errorMsg);
50 mb.open();
51 }
52 });
53 }
d600c18f
MAL
54
55 /**
56 * Get the opened (accessible) projects with Tmf nature
57 *
58 * @return the Tmf projects
59 * @since 2.2
60 */
61 public static List<IProject> getOpenedTmfProjects() {
62 IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
63 List<IProject> tmfProjects = new ArrayList<IProject>();
64 for (IProject project : projects) {
65 try {
66 if (project.isAccessible() && project.getNature(TmfProjectNature.ID) != null) {
67 tmfProjects.add(project);
68 }
69 } catch (CoreException e) {
70 Activator.getDefault().logError("Error getting opened tmf projects", e); //$NON-NLS-1$
71 }
72 }
73 return tmfProjects;
74 }
05e0d2e9 75}
This page took 0.027354 seconds and 5 git commands to generate.