1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 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 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tmf
.ui
.project
.wizards
.importtrace
;
15 import org
.eclipse
.core
.resources
.IFolder
;
16 import org
.eclipse
.core
.resources
.IProject
;
17 import org
.eclipse
.core
.runtime
.CoreException
;
18 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
19 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.TmfProjectNature
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceFolder
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTracesFolder
;
23 import org
.eclipse
.swt
.SWT
;
24 import org
.eclipse
.swt
.graphics
.Point
;
25 import org
.eclipse
.swt
.layout
.GridData
;
26 import org
.eclipse
.swt
.layout
.GridLayout
;
27 import org
.eclipse
.swt
.widgets
.Composite
;
28 import org
.eclipse
.ui
.IWorkbench
;
29 import org
.eclipse
.ui
.dialogs
.WizardResourceImportPage
;
32 * The abstract import trace wizard page, the base for the import trace wizard
35 * @author Matthew Khouzam
38 abstract class AbstractImportTraceWizardPage
extends WizardResourceImportPage
{
43 protected static final String BATCH_IMPORT_WIZARD_PAGE
= "BatchImportWizardPage"; //$NON-NLS-1$
46 * The trace folder, something like "/<project name>/Traces/"
48 protected IFolder fTargetFolder
;
51 * The project "/<project name>"
53 protected IProject fProject
;
56 * The batch import trace wizard (parent)
58 private BatchImportTraceWizard fBatchImportTraceWizard
;
62 * the name of the page
64 * The current selection
66 protected AbstractImportTraceWizardPage(String name
, IStructuredSelection selection
) {
67 super(name
, selection
);
74 * The workbench reference.
76 * The current selection
78 public AbstractImportTraceWizardPage(IWorkbench workbench
, IStructuredSelection selection
) {
79 this(BATCH_IMPORT_WIZARD_PAGE
, selection
);
83 // Locate the target trace folder
84 IFolder traceFolder
= null;
85 Object element
= selection
.getFirstElement();
87 if (element
instanceof TmfTraceFolder
) {
88 TmfTraceFolder tmfTraceFolder
= (TmfTraceFolder
) element
;
89 fProject
= (tmfTraceFolder
.getProject().getResource());
90 traceFolder
= tmfTraceFolder
.getResource();
91 } else if (element
instanceof IProject
) {
92 IProject project
= (IProject
) element
;
94 if (project
.hasNature(TmfProjectNature
.ID
)) {
95 traceFolder
= (IFolder
) project
.findMember(TmfTracesFolder
.TRACES_FOLDER_NAME
);
97 } catch (CoreException e
) {
101 // Set the target trace folder
102 if (traceFolder
!= null) {
103 fTargetFolder
= (traceFolder
);
104 String path
= traceFolder
.getFullPath().toOSString();
105 setContainerFieldValue(path
);
111 * The Batch Import Wizard
113 * @return the Batch Import Wizard
115 public BatchImportTraceWizard
getBatchWizard() {
116 return fBatchImportTraceWizard
;
120 public void createControl(Composite parent
) {
121 Composite composite
= new Composite(parent
, SWT
.NULL
);
122 composite
.setLayout(new GridLayout());
123 composite
.setFont(parent
.getFont());
125 final GridData layoutData
= new GridData();
126 parent
.getShell().setLayoutData(layoutData
);
127 parent
.getShell().redraw();
128 this.setControl(composite
);
131 parent
.getShell().setMinimumSize(new Point(525, 400));
132 fBatchImportTraceWizard
= (BatchImportTraceWizard
) getWizard();
135 // the following methods are stubbed out on purpose.
138 protected void createSourceGroup(Composite parent
) {
143 protected ITreeContentProvider
getFileProvider() {
149 protected ITreeContentProvider
getFolderProvider() {