1 /*******************************************************************************
2 * Copyright (c) 2009 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
.lttng
.ui
.views
.project
.dialogs
;
15 import org
.eclipse
.core
.resources
.IFolder
;
16 import org
.eclipse
.core
.resources
.IResource
;
17 import org
.eclipse
.core
.resources
.IWorkspace
;
18 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
19 import org
.eclipse
.core
.runtime
.CoreException
;
20 import org
.eclipse
.core
.runtime
.IPath
;
21 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
22 import org
.eclipse
.jface
.wizard
.Wizard
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.model
.LTTngExperimentEntry
;
24 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.model
.LTTngProject
;
25 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.model
.LTTngTraceEntry
;
26 import org
.eclipse
.ui
.IImportWizard
;
27 import org
.eclipse
.ui
.IWorkbench
;
30 * <b><u>AddTraceWizard</u></b>
32 * TODO: Implement me. Please.
34 public class AddTraceWizard
extends Wizard
implements IImportWizard
{
36 @SuppressWarnings("unused")
37 private IWorkbench fWorkbench
;
38 private LTTngProject fProject
;
39 private IStructuredSelection fSelection
;
40 private AddTraceWizardPage fMainPage
;
45 public AddTraceWizard(LTTngProject project
) {
50 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
52 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
53 fWorkbench
= workbench
;
54 fSelection
= selection
;
55 setWindowTitle("Adding traces to experiment");
59 * @see org.eclipse.jface.wizard.Wizard#addPages()
62 public void addPages() {
64 fMainPage
= new AddTraceWizardPage(fProject
, "Some string");
66 fMainPage
.init(fSelection
);
70 * @see org.eclipse.jface.wizard.Wizard#performFinish()
73 public boolean performFinish() {
75 Object selection
= fSelection
.getFirstElement();
76 if (!(selection
instanceof LTTngExperimentEntry
)) {
80 IWorkspace workspace
= ResourcesPlugin
.getWorkspace();
82 LTTngExperimentEntry experiment
= (LTTngExperimentEntry
) selection
;
83 IFolder experimentFolder
= experiment
.getFolder();
85 LTTngTraceEntry
[] traces
= fMainPage
.getSelection();
86 for (LTTngTraceEntry trace
: traces
) {
88 IFolder folder
= experimentFolder
.getFolder(trace
.getName());
89 IPath location
= trace
.getResource().getLocation();
90 if (workspace
.validateLinkLocation(folder
, location
).isOK()) {
91 folder
.createLink(location
, IResource
.REPLACE
, null);
92 experiment
.addTrace(trace
);
95 System
.out
.println("Problem");
97 } catch (CoreException e
) {
98 // TODO Auto-generated catch block