* Contributors:
* Bernd Hufmann - Initial API and implementation
* Bernd Hufmann - Added handling of streamed traces
+ * Marc-Andre Laperle - Use common method to get opened tmf projects
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy;
-import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
+import org.eclipse.linuxtools.tmf.ui.project.model.TraceUtils;
import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
try {
createRemoteComposite();
- } catch (CoreException e) {
- createErrorComposite(parent, e.fillInStackTrace());
- return fDialogComposite;
} catch (SystemMessageException e) {
createErrorComposite(parent, e.fillInStackTrace());
return fDialogComposite;
errorText.setLayoutData(new GridData(GridData.FILL_BOTH));
}
- private void createRemoteComposite() throws CoreException, SystemMessageException{
+ private void createRemoteComposite() throws SystemMessageException{
Group contextGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
contextGroup.setText(Messages.TraceControl_ImportDialogTracesGroupName);
GridLayout layout = new GridLayout(1, true);
fProjects = new ArrayList<IProject>();
List<String> projectNames = new ArrayList<String>();
- for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
- if (project.isOpen() && project.hasNature(TmfProjectNature.ID)) {
- fProjects.add(project);
- projectNames.add(project.getName());
- }
+ for (IProject project : TraceUtils.getOpenedTmfProjects()) {
+ fProjects.add(project);
+ projectNames.add(project.getName());
}
fCombo = new CCombo(projectGroup, SWT.READ_ONLY);
/*******************************************************************************
- * Copyright (c) 2013 École Polytechnique de Montréal
+ * Copyright (c) 2013 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
*
* Contributors:
* Geneviève Bastien - Initial API and implementation
+ * Marc-Andre Laperle - Add method to get opened tmf projects
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.project.model;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.ui.PlatformUI;
}
});
}
+
+ /**
+ * Get the opened (accessible) projects with Tmf nature
+ *
+ * @return the Tmf projects
+ * @since 2.2
+ */
+ public static List<IProject> getOpenedTmfProjects() {
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ List<IProject> tmfProjects = new ArrayList<IProject>();
+ for (IProject project : projects) {
+ try {
+ if (project.isAccessible() && project.getNature(TmfProjectNature.ID) != null) {
+ tmfProjects.add(project);
+ }
+ } catch (CoreException e) {
+ Activator.getDefault().logError("Error getting opened tmf projects", e); //$NON-NLS-1$
+ }
+ }
+ return tmfProjects;
+ }
}
*
* Contributors:
* Matthew Khouzam - Initial API and implementation
+ * Marc-Andre Laperle - Use common method to get opened tmf projects
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
+import org.eclipse.linuxtools.tmf.ui.project.model.TraceUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
optionPane.setLayout(new GridLayout());
optionPane.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-
fProjects = new List(optionPane, SWT.NONE);
fProjects.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- for (IProject project : projects) {
- try {
- if (project.getNature(TmfProjectNature.ID) != null) {
- final String name = project.getName();
- fProjectsMap.put(name, project);
- fProjects.add(name);
- }
- } catch (CoreException e) {
- // TODO: add a logger to activator and then log it
- }
+ for (IProject project : TraceUtils.getOpenedTmfProjects()) {
+ final String name = project.getName();
+ fProjectsMap.put(name, project);
+ fProjects.add(name);
}
fProjects.getSelection();