tmf: internalize the trace import wizards
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / project / wizards / importtrace / AbstractImportTraceWizardPage.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
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 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.tmf.ui.project.wizards.importtrace;
14
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;
30
31 /**
32 * The abstract import trace wizard page, the base for the import trace wizard
33 * pages.
34 *
35 * @author Matthew Khouzam
36 * @since 2.0
37 */
38 abstract class AbstractImportTraceWizardPage extends WizardResourceImportPage {
39
40 /**
41 * Import String
42 */
43 protected static final String BATCH_IMPORT_WIZARD_PAGE = "BatchImportWizardPage"; //$NON-NLS-1$
44
45 /**
46 * The trace folder, something like "/<project name>/Traces/"
47 */
48 protected IFolder fTargetFolder;
49
50 /**
51 * The project "/<project name>"
52 */
53 protected IProject fProject;
54
55 /**
56 * The batch import trace wizard (parent)
57 */
58 private BatchImportTraceWizard fBatchImportTraceWizard;
59
60 /**
61 * @param name
62 * the name of the page
63 * @param selection
64 * The current selection
65 */
66 protected AbstractImportTraceWizardPage(String name, IStructuredSelection selection) {
67 super(name, selection);
68 }
69
70 /**
71 * Constructor
72 *
73 * @param workbench
74 * The workbench reference.
75 * @param selection
76 * The current selection
77 */
78 public AbstractImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) {
79 this(BATCH_IMPORT_WIZARD_PAGE, selection);
80 setTitle(null);
81 setDescription(null);
82
83 // Locate the target trace folder
84 IFolder traceFolder = null;
85 Object element = selection.getFirstElement();
86
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;
93 try {
94 if (project.hasNature(TmfProjectNature.ID)) {
95 traceFolder = (IFolder) project.findMember(TmfTracesFolder.TRACES_FOLDER_NAME);
96 }
97 } catch (CoreException e) {
98 }
99 }
100
101 // Set the target trace folder
102 if (traceFolder != null) {
103 fTargetFolder = (traceFolder);
104 String path = traceFolder.getFullPath().toOSString();
105 setContainerFieldValue(path);
106 }
107
108 }
109
110 /**
111 * The Batch Import Wizard
112 *
113 * @return the Batch Import Wizard
114 */
115 public BatchImportTraceWizard getBatchWizard() {
116 return fBatchImportTraceWizard;
117 }
118
119 @Override
120 public void createControl(Composite parent) {
121 Composite composite = new Composite(parent, SWT.NULL);
122 composite.setLayout(new GridLayout());
123 composite.setFont(parent.getFont());
124 // arbitrary size
125 final GridData layoutData = new GridData();
126 parent.getShell().setLayoutData(layoutData);
127 parent.getShell().redraw();
128 this.setControl(composite);
129
130 // arbitrary sizes
131 parent.getShell().setMinimumSize(new Point(525, 400));
132 fBatchImportTraceWizard = (BatchImportTraceWizard) getWizard();
133 }
134
135 // the following methods are stubbed out on purpose.
136
137 @Override
138 protected void createSourceGroup(Composite parent) {
139 // do nothing
140 }
141
142 @Override
143 protected ITreeContentProvider getFileProvider() {
144 // do nothing
145 return null;
146 }
147
148 @Override
149 protected ITreeContentProvider getFolderProvider() {
150 // do nothing
151 return null;
152 }
153
154 }
This page took 0.035833 seconds and 5 git commands to generate.