1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal and others
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 * Geneviève Bastien - Initial API and implementation
11 * Marc-Andre Laperle - Add method to get opened tmf projects
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
;
16 import java
.util
.ArrayList
;
17 import java
.util
.List
;
19 import org
.eclipse
.core
.resources
.IProject
;
20 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
21 import org
.eclipse
.core
.runtime
.CoreException
;
22 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.TmfProjectNature
;
24 import org
.eclipse
.swt
.widgets
.Display
;
25 import org
.eclipse
.swt
.widgets
.MessageBox
;
26 import org
.eclipse
.ui
.PlatformUI
;
29 * Utility class for common tmf.ui functionalities
33 public class TraceUtils
{
36 * Displays an error message in a box
39 * The message box title
41 * The error message to display
43 public static void displayErrorMsg(final String boxTitle
, final String errorMsg
) {
44 Display
.getDefault().asyncExec(new Runnable() {
47 final MessageBox mb
= new MessageBox(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
49 mb
.setMessage(errorMsg
);
56 * Get the opened (accessible) projects with Tmf nature
58 * @return the Tmf projects
61 public static List
<IProject
> getOpenedTmfProjects() {
62 IProject
[] projects
= ResourcesPlugin
.getWorkspace().getRoot().getProjects();
63 List
<IProject
> tmfProjects
= new ArrayList
<>();
64 for (IProject project
: projects
) {
66 if (project
.isAccessible() && project
.getNature(TmfProjectNature
.ID
) != null) {
67 tmfProjects
.add(project
);
69 } catch (CoreException e
) {
70 Activator
.getDefault().logError("Error getting opened tmf projects", e
); //$NON-NLS-1$
This page took 0.036551 seconds and 5 git commands to generate.