1 /*******************************************************************************
2 * Copyright (c) 2009, 2016 Ericsson 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 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Got rid of dependency on internal platform class
12 * Francois Chouinard - Complete re-design
13 * Anna Dushistova(Montavista) - [383047] NPE while importing a CFT trace
14 * Matthew Khouzam - Moved out some common functions
15 * Patrick Tasse - Add sorting of file system elements
16 * Bernd Hufmann - Re-design of trace selection and trace validation
17 * Marc-Andre Laperle - Preserve folder structure on import
18 * Marc-Andre Laperle - Extract archives during import
19 * Marc-Andre Laperle - Add support for Gzip (non-Tar)
20 *******************************************************************************/
22 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
;
25 import java
.lang
.reflect
.InvocationTargetException
;
26 import java
.util
.ArrayList
;
27 import java
.util
.Collection
;
28 import java
.util
.LinkedList
;
29 import java
.util
.List
;
31 import org
.eclipse
.core
.resources
.IContainer
;
32 import org
.eclipse
.core
.resources
.IFolder
;
33 import org
.eclipse
.core
.resources
.IProject
;
34 import org
.eclipse
.core
.resources
.IResource
;
35 import org
.eclipse
.core
.resources
.IWorkspace
;
36 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
37 import org
.eclipse
.core
.runtime
.CoreException
;
38 import org
.eclipse
.core
.runtime
.IPath
;
39 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
40 import org
.eclipse
.core
.runtime
.IStatus
;
41 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
42 import org
.eclipse
.core
.runtime
.Path
;
43 import org
.eclipse
.core
.runtime
.Platform
;
44 import org
.eclipse
.core
.runtime
.Status
;
45 import org
.eclipse
.core
.runtime
.SubMonitor
;
46 import org
.eclipse
.jface
.dialogs
.IDialogSettings
;
47 import org
.eclipse
.jface
.layout
.PixelConverter
;
48 import org
.eclipse
.jface
.operation
.IRunnableWithProgress
;
49 import org
.eclipse
.jface
.viewers
.CheckStateChangedEvent
;
50 import org
.eclipse
.jface
.viewers
.ICheckStateListener
;
51 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
52 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
53 import org
.eclipse
.osgi
.util
.NLS
;
54 import org
.eclipse
.swt
.SWT
;
55 import org
.eclipse
.swt
.custom
.BusyIndicator
;
56 import org
.eclipse
.swt
.events
.FocusAdapter
;
57 import org
.eclipse
.swt
.events
.FocusEvent
;
58 import org
.eclipse
.swt
.events
.ModifyEvent
;
59 import org
.eclipse
.swt
.events
.ModifyListener
;
60 import org
.eclipse
.swt
.events
.SelectionAdapter
;
61 import org
.eclipse
.swt
.events
.SelectionEvent
;
62 import org
.eclipse
.swt
.events
.TraverseEvent
;
63 import org
.eclipse
.swt
.events
.TraverseListener
;
64 import org
.eclipse
.swt
.layout
.GridData
;
65 import org
.eclipse
.swt
.layout
.GridLayout
;
66 import org
.eclipse
.swt
.widgets
.Button
;
67 import org
.eclipse
.swt
.widgets
.Combo
;
68 import org
.eclipse
.swt
.widgets
.Composite
;
69 import org
.eclipse
.swt
.widgets
.DirectoryDialog
;
70 import org
.eclipse
.swt
.widgets
.Event
;
71 import org
.eclipse
.swt
.widgets
.FileDialog
;
72 import org
.eclipse
.swt
.widgets
.Group
;
73 import org
.eclipse
.swt
.widgets
.Label
;
74 import org
.eclipse
.swt
.widgets
.Text
;
75 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Activator
;
76 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.operations
.NewExperimentOperation
;
77 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.operations
.SelectTracesOperation
;
78 import org
.eclipse
.tracecompass
.tmf
.core
.TmfCommonConstants
;
79 import org
.eclipse
.tracecompass
.tmf
.core
.TmfProjectNature
;
80 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TmfTraceType
;
81 import org
.eclipse
.tracecompass
.tmf
.core
.util
.Pair
;
82 import org
.eclipse
.tracecompass
.tmf
.ui
.dialog
.TmfFileDialogFactory
;
83 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfExperimentElement
;
84 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfExperimentFolder
;
85 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectElement
;
86 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
87 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTraceFolder
;
88 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfTracesFolder
;
89 import org
.eclipse
.ui
.dialogs
.FileSystemElement
;
90 import org
.eclipse
.ui
.dialogs
.WizardResourceImportPage
;
91 import org
.eclipse
.ui
.ide
.dialogs
.IElementFilter
;
92 import org
.eclipse
.ui
.ide
.dialogs
.ResourceTreeAndListGroup
;
93 import org
.eclipse
.ui
.internal
.ide
.DialogUtil
;
94 import org
.eclipse
.ui
.model
.WorkbenchContentProvider
;
95 import org
.eclipse
.ui
.model
.WorkbenchLabelProvider
;
96 import org
.eclipse
.ui
.model
.WorkbenchViewerComparator
;
99 * A variant of the standard resource import wizard for importing traces to
100 * given tracing project. If no project or tracing project was selected the
101 * wizard imports it to the default tracing project which is created if
104 * In our case traces could be files or a directory structure. This wizard
105 * supports both cases. It imports traces for a selected trace type or, if no
106 * trace type is selected, it tries to detect the trace type automatically.
107 * However, the automatic detection is a best-effort and cannot guarantee that
108 * the detection is successful. The reason for this is that there might be
109 * multiple trace types that can be assigned to a single trace.
112 * @author Francois Chouinard
114 @SuppressWarnings("restriction")
115 public class ImportTraceWizardPage
extends WizardResourceImportPage
{
117 // ------------------------------------------------------------------------
119 // ------------------------------------------------------------------------
120 private static final String IMPORT_WIZARD_PAGE_NAME
= "ImportTraceWizardPage"; //$NON-NLS-1$
121 private static final String IMPORT_WIZARD_ROOT_DIRECTORY_ID
= ".import_root_directory_id"; //$NON-NLS-1$ ;
122 private static final String IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID
= ".import_archive_file_name_id"; //$NON-NLS-1$
123 private static final String IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID
= ".import_unrecognized_traces_id"; //$NON-NLS-1$
124 private static final String IMPORT_WIZARD_PRESERVE_FOLDERS_ID
= ".import_preserve_folders_id"; //$NON-NLS-1$
125 private static final String IMPORT_WIZARD_IMPORT_FROM_DIRECTORY_ID
= ".import_from_directory"; //$NON-NLS-1$
126 private static final String IMPORT_WIZARD_CREATE_EXPERIMENT_ID
= ".create_experiment"; //$NON-NLS-1$
128 // constant from WizardArchiveFileResourceImportPage1
129 private static final String
[] FILE_IMPORT_MASK
= { "*.jar;*.zip;*.tar;*.tar.gz;*.tgz;*.gz", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
132 * A special trace type value to communicate that automatic trace type
133 * detection will occur instead of setting a specific trace type when
134 * importing the traces.
136 public static final String TRACE_TYPE_AUTO_DETECT
= Messages
.ImportTraceWizard_AutoDetection
;
139 * Preserve the folder structure of the import traces.
141 public static final int OPTION_PRESERVE_FOLDER_STRUCTURE
= 1 << 1;
143 * Create links to the trace files instead of copies.
145 public static final int OPTION_CREATE_LINKS_IN_WORKSPACE
= 1 << 2;
147 * Import files that were not recognized as the selected trace type.
149 public static final int OPTION_IMPORT_UNRECOGNIZED_TRACES
= 1 << 3;
151 * Overwrite existing resources without prompting.
153 public static final int OPTION_OVERWRITE_EXISTING_RESOURCES
= 1 << 4;
155 * Create an experiment with imported traces.
157 public static final int OPTION_CREATE_EXPERIMENT
= 1 << 5;
159 // ------------------------------------------------------------------------
161 // ------------------------------------------------------------------------
163 // Target import directory ('Traces' folder)
164 private IFolder fTargetFolder
;
165 // Target Trace folder element
166 private TmfTraceFolder fTraceFolderElement
;
167 // The workspace experiment folder
168 private TmfExperimentFolder fExperimentFolderElement
;
169 private String fPreviousSource
;
170 // Flag to handle destination folder change event
171 private Boolean fIsDestinationChanged
= false;
172 private final Object fSyncObject
= new Object();
173 // Combo box containing trace types
174 private Combo fTraceTypes
;
175 // Button to ignore unrecognized traces or not
176 private Button fImportUnrecognizedButton
;
177 // Button to overwrite existing resources or not
178 private Button fOverwriteExistingResourcesCheckbox
;
179 // Button to link or copy traces to workspace
180 private Button fCreateLinksInWorkspaceButton
;
181 // Button to preserve folder structure
182 private Button fPreserveFolderStructureButton
;
183 // Button to create an experiment
184 private Button fCreateExperimentCheckbox
;
185 // Text box for experiment name
186 private Text fExperimentNameText
;
187 private boolean entryChanged
= false;
188 // The import from directory radio button
189 private Button fImportFromDirectoryRadio
;
190 // The import from archive radio button
191 private Button fImportFromArchiveRadio
;
192 // Flag to remember the "create links" checkbox when it gets disabled by
193 // the import from archive radio button
194 private Boolean fPreviousCreateLinksValue
= true;
196 /** The archive name field */
197 protected Combo fArchiveNameField
;
198 /** The archive browse button. */
199 protected Button fArchiveBrowseButton
;
200 /** The directory name field */
201 protected Combo directoryNameField
;
202 /** The directory browse button. */
203 protected Button directoryBrowseButton
;
205 private ResourceTreeAndListGroup fSelectionGroup
;
207 // Keep trace of the selection root so that we can dispose its related
209 private TraceFileSystemElement fSelectionGroupRoot
;
211 // ------------------------------------------------------------------------
213 // ------------------------------------------------------------------------
216 * Constructor. Creates the trace wizard page.
219 * The name of the page.
221 * The current selection
223 protected ImportTraceWizardPage(String name
, IStructuredSelection selection
) {
224 super(name
, selection
);
225 setTitle(Messages
.ImportTraceWizard_FileSystemTitle
);
226 setDescription(Messages
.ImportTraceWizard_ImportTrace
);
228 // Locate the target trace folder
229 IFolder traceFolder
= null;
230 Object element
= selection
.getFirstElement();
232 if (element
instanceof TmfTraceFolder
) {
233 fTraceFolderElement
= (TmfTraceFolder
) element
;
234 traceFolder
= fTraceFolderElement
.getResource();
235 } else if (element
instanceof IProject
) {
236 IProject project
= (IProject
) element
;
238 if (project
.hasNature(TmfProjectNature
.ID
)) {
239 TmfProjectElement projectElement
= TmfProjectRegistry
.getProject(project
, true);
240 fTraceFolderElement
= projectElement
.getTracesFolder();
241 traceFolder
= project
.getFolder(TmfTracesFolder
.TRACES_FOLDER_NAME
);
243 } catch (CoreException e
) {
247 // If no tracing project was selected or trace folder doesn't exist use
248 // default tracing project
249 if (traceFolder
== null) {
250 IProject project
= TmfProjectRegistry
.createProject(
251 TmfCommonConstants
.DEFAULT_TRACE_PROJECT_NAME
, null, new NullProgressMonitor());
252 TmfProjectElement projectElement
= TmfProjectRegistry
.getProject(project
, true);
253 fTraceFolderElement
= projectElement
.getTracesFolder();
254 traceFolder
= project
.getFolder(TmfTracesFolder
.TRACES_FOLDER_NAME
);
257 // Set the target trace folder
258 if (traceFolder
!= null) {
259 fTargetFolder
= traceFolder
;
260 String path
= traceFolder
.getFullPath().toString();
261 setContainerFieldValue(path
);
264 TmfProjectElement project
= fTraceFolderElement
.getProject();
265 fExperimentFolderElement
= project
.getExperimentsFolder();
272 * The current selection
274 public ImportTraceWizardPage(IStructuredSelection selection
) {
275 this(IMPORT_WIZARD_PAGE_NAME
, selection
);
279 * Create the import source selection widget. (Copied from
280 * WizardResourceImportPage but instead always uses the internal
281 * ResourceTreeAndListGroup to keep compatibility with Kepler)
284 protected void createFileSelectionGroup(Composite parent
) {
286 // Just create with a dummy root.
287 fSelectionGroup
= new ResourceTreeAndListGroup(parent
,
288 new FileSystemElement("Dummy", null, true), //$NON-NLS-1$
289 getFolderProvider(), new WorkbenchLabelProvider(),
290 getFileProvider(), new WorkbenchLabelProvider(), SWT
.NONE
,
291 DialogUtil
.inRegularFontMode(parent
));
293 ICheckStateListener listener
= new ICheckStateListener() {
295 public void checkStateChanged(CheckStateChangedEvent event
) {
296 updateWidgetEnablements();
300 WorkbenchViewerComparator comparator
= new WorkbenchViewerComparator();
301 fSelectionGroup
.setTreeComparator(comparator
);
302 fSelectionGroup
.setListComparator(comparator
);
303 fSelectionGroup
.addCheckStateListener(listener
);
307 // ------------------------------------------------------------------------
308 // WizardResourceImportPage
309 // ------------------------------------------------------------------------
312 protected void createSourceGroup(Composite parent
) {
313 createSourceSelectionGroup(parent
);
314 createFileSelectionGroup(parent
);
315 createTraceTypeGroup(parent
);
316 validateSourceGroup();
320 protected ITreeContentProvider
getFileProvider() {
321 return new WorkbenchContentProvider() {
323 public Object
[] getChildren(Object object
) {
324 if (object
instanceof TraceFileSystemElement
) {
325 TraceFileSystemElement element
= (TraceFileSystemElement
) object
;
326 return element
.getFiles().getChildren(element
);
328 return new Object
[0];
334 protected ITreeContentProvider
getFolderProvider() {
335 return new WorkbenchContentProvider() {
337 public Object
[] getChildren(Object o
) {
338 if (o
instanceof TraceFileSystemElement
) {
339 TraceFileSystemElement element
= (TraceFileSystemElement
) o
;
340 return element
.getFolders().getChildren();
342 return new Object
[0];
346 public boolean hasChildren(Object o
) {
347 if (o
instanceof TraceFileSystemElement
) {
348 TraceFileSystemElement element
= (TraceFileSystemElement
) o
;
349 if (element
.isPopulated()) {
350 return getChildren(element
).length
> 0;
352 // If we have not populated then wait until asked
360 // ------------------------------------------------------------------------
361 // Directory Selection Group (forked WizardFileSystemResourceImportPage1)
362 // ------------------------------------------------------------------------
365 * creates the source selection group.
368 * the parent composite
370 protected void createSourceSelectionGroup(Composite parent
) {
372 Composite sourceGroup
= new Composite(parent
, SWT
.NONE
);
373 GridLayout layout
= new GridLayout();
374 layout
.numColumns
= 3;
375 layout
.makeColumnsEqualWidth
= false;
376 layout
.marginWidth
= 0;
377 sourceGroup
.setLayout(layout
);
378 sourceGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
380 // import from directory radio button
381 fImportFromDirectoryRadio
= new Button(sourceGroup
, SWT
.RADIO
);
382 fImportFromDirectoryRadio
.setText(Messages
.ImportTraceWizard_DirectoryLocation
);
384 // import location entry combo
385 directoryNameField
= createPathSelectionCombo(sourceGroup
);
386 createDirectoryBrowseButton(sourceGroup
);
388 // import from archive radio button
389 fImportFromArchiveRadio
= new Button(sourceGroup
, SWT
.RADIO
);
390 fImportFromArchiveRadio
.setText(Messages
.ImportTraceWizard_ArchiveLocation
);
392 // import location entry combo
393 fArchiveNameField
= createPathSelectionCombo(sourceGroup
);
394 createArchiveBrowseButton(sourceGroup
);
396 fImportFromDirectoryRadio
.setSelection(true);
397 fArchiveNameField
.setEnabled(false);
398 fArchiveBrowseButton
.setEnabled(false);
400 fImportFromDirectoryRadio
.addSelectionListener(new SelectionAdapter() {
402 public void widgetSelected(SelectionEvent e
) {
403 directoryRadioSelected();
407 fImportFromArchiveRadio
.addSelectionListener(new SelectionAdapter() {
409 public void widgetSelected(SelectionEvent e
) {
410 archiveRadioSelected();
416 * Select or deselect all files in the file selection group
419 * whether or not the files should be checked
421 protected void setFileSelectionGroupChecked(boolean checked
) {
422 if (fSelectionGroup
!= null) {
423 fSelectionGroup
.setAllSelections(checked
);
428 * Create a combo that will be used to select a path to specify the source
429 * of the import. The parent is assumed to have a GridLayout.
432 * the parent composite
433 * @return the created path selection combo
435 protected Combo
createPathSelectionCombo(Composite parent
) {
436 Combo pathSelectionCombo
= new Combo(parent
, SWT
.BORDER
);
438 GridData layoutData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
);
439 layoutData
.widthHint
= new PixelConverter(pathSelectionCombo
).convertWidthInCharsToPixels(25);
440 pathSelectionCombo
.setLayoutData(layoutData
);
442 TraverseListener traverseListener
= new TraverseListener() {
444 public void keyTraversed(TraverseEvent e
) {
445 if (e
.detail
== SWT
.TRAVERSE_RETURN
) {
447 entryChanged
= false;
448 updateFromSourceField();
453 FocusAdapter focusAdapter
= new FocusAdapter() {
455 public void focusLost(FocusEvent e
) {
456 // Clear the flag to prevent constant update
458 entryChanged
= false;
459 updateFromSourceField();
464 SelectionAdapter selectionAdapter
= new SelectionAdapter() {
466 public void widgetSelected(SelectionEvent e
) {
467 entryChanged
= false;
468 updateFromSourceField();
472 ModifyListener modifyListner
= new ModifyListener() {
474 public void modifyText(ModifyEvent e
) {
479 pathSelectionCombo
.addModifyListener(modifyListner
);
480 pathSelectionCombo
.addTraverseListener(traverseListener
);
481 pathSelectionCombo
.addFocusListener(focusAdapter
);
482 pathSelectionCombo
.addSelectionListener(selectionAdapter
);
484 return pathSelectionCombo
;
488 * Create the directory browse button.
491 * the parent composite
493 protected void createDirectoryBrowseButton(Composite parent
) {
494 directoryBrowseButton
= createPathSelectionBrowseButton(parent
);
495 directoryBrowseButton
.addSelectionListener(new SelectionAdapter() {
497 public void widgetSelected(SelectionEvent e
) {
498 handleSourceDirectoryBrowseButtonPressed();
504 * Create the archive browse button.
507 * the parent composite
509 protected void createArchiveBrowseButton(Composite parent
) {
510 fArchiveBrowseButton
= createPathSelectionBrowseButton(parent
);
511 fArchiveBrowseButton
.addSelectionListener(new SelectionAdapter() {
513 public void widgetSelected(SelectionEvent e
) {
514 handleArchiveBrowseButtonPressed(FILE_IMPORT_MASK
);
520 * Create a browse button that will be used to browse for a path to specify
521 * the source of the import. The parent is assumed to have a GridLayout.
524 * the parent composite
525 * @return the created path selection combo
527 protected Button
createPathSelectionBrowseButton(Composite parent
) {
528 Button pathSelectionBrowseButton
= new Button(parent
, SWT
.PUSH
);
529 pathSelectionBrowseButton
.setText(Messages
.ImportTraceWizard_BrowseButton
);
530 setButtonLayoutData(pathSelectionBrowseButton
);
532 return pathSelectionBrowseButton
;
535 private void archiveRadioSelected() {
536 if (!isImportFromDirectory()) {
537 directoryNameField
.setEnabled(false);
538 directoryBrowseButton
.setEnabled(false);
539 fArchiveNameField
.setEnabled(true);
540 fArchiveBrowseButton
.setEnabled(true);
541 updateFromSourceField();
542 fArchiveNameField
.setFocus();
543 if (fCreateLinksInWorkspaceButton
!= null) {
544 fPreviousCreateLinksValue
= fCreateLinksInWorkspaceButton
.getSelection();
545 fCreateLinksInWorkspaceButton
.setSelection(false);
546 fCreateLinksInWorkspaceButton
.setEnabled(false);
551 private void directoryRadioSelected() {
552 if (isImportFromDirectory()) {
553 directoryNameField
.setEnabled(true);
554 directoryBrowseButton
.setEnabled(true);
555 fArchiveNameField
.setEnabled(false);
556 fArchiveBrowseButton
.setEnabled(false);
557 updateFromSourceField();
558 directoryNameField
.setFocus();
559 if (fCreateLinksInWorkspaceButton
!= null) {
560 fCreateLinksInWorkspaceButton
.setSelection(fPreviousCreateLinksValue
);
561 fCreateLinksInWorkspaceButton
.setEnabled(true);
566 // ------------------------------------------------------------------------
567 // Browse for the source directory
568 // ------------------------------------------------------------------------
571 public void handleEvent(Event event
) {
572 if (event
.widget
== directoryBrowseButton
) {
573 handleSourceDirectoryBrowseButtonPressed();
576 // Avoid overwriting destination path without repeatedly trigger
577 // call of handleEvent();
578 synchronized (fSyncObject
) {
579 if (fIsDestinationChanged
== false) {
580 event
.display
.asyncExec(new Runnable() {
583 synchronized (fSyncObject
) {
584 fIsDestinationChanged
= true;
585 String path
= fTargetFolder
.getFullPath().toString();
586 setContainerFieldValue(path
);
591 fIsDestinationChanged
= false;
594 super.handleEvent(event
);
598 protected void handleContainerBrowseButtonPressed() {
599 // Do nothing so that destination directory cannot be changed.
603 * Handle the button pressed event
605 protected void handleSourceDirectoryBrowseButtonPressed() {
606 String currentSource
= directoryNameField
.getText();
607 DirectoryDialog dialog
= new DirectoryDialog(directoryNameField
.getShell(), SWT
.SAVE
| SWT
.SHEET
);
608 dialog
.setText(Messages
.ImportTraceWizard_SelectTraceDirectoryTitle
);
609 dialog
.setMessage(Messages
.ImportTraceWizard_SelectTraceDirectoryMessage
);
610 dialog
.setFilterPath(getSourceDirectoryName(currentSource
));
612 String selectedDirectory
= dialog
.open();
613 if (selectedDirectory
!= null) {
614 // Just quit if the directory is not valid
615 if ((getSourceDirectory(selectedDirectory
) == null) || selectedDirectory
.equals(currentSource
)) {
618 // If it is valid then proceed to populate
619 setErrorMessage(null);
620 setSourcePath(selectedDirectory
);
625 * Handle the button pressed event
628 * file extensions used to filter files shown to the user
630 protected void handleArchiveBrowseButtonPressed(String
[] extensions
) {
631 FileDialog dialog
= TmfFileDialogFactory
.create(fArchiveNameField
.getShell(), SWT
.SHEET
);
632 dialog
.setFilterExtensions(extensions
);
633 dialog
.setText(Messages
.ImportTraceWizard_SelectTraceArchiveTitle
);
634 String fileName
= fArchiveNameField
.getText().trim();
635 if (!fileName
.isEmpty()) {
636 File path
= new File(fileName
).getParentFile();
637 if (path
!= null && path
.exists()) {
638 dialog
.setFilterPath(path
.toString());
642 String selectedArchive
= dialog
.open();
643 if (selectedArchive
!= null) {
644 setErrorMessage(null);
645 setSourcePath(selectedArchive
);
646 updateWidgetEnablements();
650 private File
getSourceDirectory() {
651 if (directoryNameField
== null) {
654 return getSourceDirectory(directoryNameField
.getText());
657 private File
getSourceArchiveFile() {
658 if (fArchiveNameField
== null) {
662 return getSourceArchiveFile(fArchiveNameField
.getText());
665 private String
getSourceContainerPath() {
666 if (isImportFromDirectory()) {
667 File sourceDirectory
= getSourceDirectory();
668 if (sourceDirectory
!= null) {
669 return sourceDirectory
.getAbsolutePath();
672 File sourceArchiveFile
= getSourceArchiveFile();
673 if (sourceArchiveFile
!= null) {
674 return sourceArchiveFile
.getParent();
679 private static File
getSourceDirectory(String path
) {
680 File sourceDirectory
= new File(getSourceDirectoryName(path
));
681 if (!sourceDirectory
.exists() || !sourceDirectory
.isDirectory()) {
685 return sourceDirectory
;
688 private static File
getSourceArchiveFile(String path
) {
689 File sourceArchiveFile
= new File(path
);
690 if (!sourceArchiveFile
.exists() || sourceArchiveFile
.isDirectory()) {
694 return sourceArchiveFile
;
697 private static String
getSourceDirectoryName(String sourceName
) {
698 IPath result
= new Path(sourceName
.trim());
699 if (result
.getDevice() != null && result
.segmentCount() == 0) {
700 result
= result
.addTrailingSeparator();
702 result
= result
.removeTrailingSeparator();
704 return result
.toOSString();
707 private void updateFromSourceField() {
708 setSourcePath(getSourceField().getText());
709 updateWidgetEnablements();
712 private Combo
getSourceField() {
713 if (directoryNameField
== null) {
714 return fArchiveNameField
;
717 return directoryNameField
.isEnabled() ? directoryNameField
: fArchiveNameField
;
721 * Set the source path that was selected by the user by various input
722 * methods (Browse button, typing, etc).
724 * Clients can also call this to set the path programmatically (hard-coded
725 * initial path) and this can also be overridden to be notified when the
726 * source path changes.
731 protected void setSourcePath(String path
) {
732 Combo sourceField
= getSourceField();
733 if (sourceField
== null) {
737 if (path
.length() > 0) {
738 String
[] currentItems
= sourceField
.getItems();
739 int selectionIndex
= -1;
740 for (int i
= 0; i
< currentItems
.length
; i
++) {
741 if (currentItems
[i
].equals(path
)) {
745 if (selectionIndex
< 0) {
746 int oldLength
= currentItems
.length
;
747 String
[] newItems
= new String
[oldLength
+ 1];
748 System
.arraycopy(currentItems
, 0, newItems
, 0, oldLength
);
749 newItems
[oldLength
] = path
;
750 sourceField
.setItems(newItems
);
751 selectionIndex
= oldLength
;
753 sourceField
.select(selectionIndex
);
758 // ------------------------------------------------------------------------
759 // File Selection Group (forked WizardFileSystemResourceImportPage1)
760 // ------------------------------------------------------------------------
761 private void resetSelection() {
763 if (fSelectionGroupRoot
!= null) {
764 disposeSelectionGroupRoot();
766 fSelectionGroupRoot
= getFileSystemTree();
767 fSelectionGroup
.setRoot(fSelectionGroupRoot
);
769 if (fCreateExperimentCheckbox
!= null) {
770 File file
= getSourceFile();
772 String previousName
= fExperimentNameText
.getText().trim();
773 if (((fPreviousSource
!= null) && (previousName
.equals(fPreviousSource
))) || previousName
.isEmpty()) {
774 fExperimentNameText
.setText(file
.getName());
776 fPreviousSource
= file
.getName();
781 private void disposeSelectionGroupRoot() {
782 if (fSelectionGroupRoot
!= null && fSelectionGroupRoot
.getProvider() != null) {
783 FileSystemObjectImportStructureProvider provider
= fSelectionGroupRoot
.getProvider();
785 fSelectionGroupRoot
= null;
789 private TraceFileSystemElement
getFileSystemTree() {
790 Pair
<IFileSystemObject
, FileSystemObjectImportStructureProvider
> rootObjectAndProvider
= ArchiveUtil
.getRootObjectAndProvider(getSourceFile(), getContainer().getShell());
791 if (rootObjectAndProvider
== null) {
794 return selectFiles(rootObjectAndProvider
.getFirst(), rootObjectAndProvider
.getSecond());
797 private TraceFileSystemElement
selectFiles(final IFileSystemObject rootFileSystemObject
,
798 final FileSystemObjectImportStructureProvider structureProvider
) {
799 final TraceFileSystemElement
[] results
= new TraceFileSystemElement
[1];
800 BusyIndicator
.showWhile(getShell().getDisplay(), new Runnable() {
803 // Create the root element from the supplied file system object
804 results
[0] = TraceFileSystemElement
.createRootTraceFileElement(rootFileSystemObject
, structureProvider
);
810 // ------------------------------------------------------------------------
812 // ------------------------------------------------------------------------
813 private final void createTraceTypeGroup(Composite parent
) {
814 Composite composite
= new Composite(parent
, SWT
.NONE
);
815 GridLayout layout
= new GridLayout();
816 layout
.numColumns
= 3;
817 layout
.makeColumnsEqualWidth
= false;
818 composite
.setLayout(layout
);
819 composite
.setFont(parent
.getFont());
820 GridData buttonData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
821 composite
.setLayoutData(buttonData
);
823 // Trace type label ("Trace Type:")
824 Label typeLabel
= new Label(composite
, SWT
.NONE
);
825 typeLabel
.setText(Messages
.ImportTraceWizard_TraceType
);
826 typeLabel
.setFont(parent
.getFont());
829 fTraceTypes
= new Combo(composite
, SWT
.BORDER
| SWT
.READ_ONLY
);
830 GridData data
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 2, 1);
831 fTraceTypes
.setLayoutData(data
);
832 fTraceTypes
.setFont(parent
.getFont());
834 String
[] availableTraceTypes
= TmfTraceType
.getAvailableTraceTypes();
835 String
[] traceTypeList
= new String
[availableTraceTypes
.length
+ 1];
836 traceTypeList
[0] = TRACE_TYPE_AUTO_DETECT
;
837 for (int i
= 0; i
< availableTraceTypes
.length
; i
++) {
838 traceTypeList
[i
+ 1] = availableTraceTypes
[i
];
840 fTraceTypes
.setItems(traceTypeList
);
841 fTraceTypes
.addSelectionListener(new SelectionAdapter() {
843 public void widgetSelected(SelectionEvent e
) {
844 updateWidgetEnablements();
845 boolean enabled
= fTraceTypes
.getText().equals(TRACE_TYPE_AUTO_DETECT
);
846 fImportUnrecognizedButton
.setEnabled(enabled
);
849 fTraceTypes
.select(0);
851 // Unrecognized checkbox
852 fImportUnrecognizedButton
= new Button(composite
, SWT
.CHECK
);
853 fImportUnrecognizedButton
.setSelection(true);
854 fImportUnrecognizedButton
.setText(Messages
.ImportTraceWizard_ImportUnrecognized
);
857 // ------------------------------------------------------------------------
859 // ------------------------------------------------------------------------
862 protected void createOptionsGroupButtons(Group optionsGroup
) {
864 // Overwrite checkbox
865 fOverwriteExistingResourcesCheckbox
= new Button(optionsGroup
, SWT
.CHECK
);
866 fOverwriteExistingResourcesCheckbox
.setFont(optionsGroup
.getFont());
867 fOverwriteExistingResourcesCheckbox
.setText(Messages
.ImportTraceWizard_OverwriteExistingTrace
);
868 fOverwriteExistingResourcesCheckbox
.setSelection(false);
870 // Create links checkbox
871 fCreateLinksInWorkspaceButton
= new Button(optionsGroup
, SWT
.CHECK
);
872 fCreateLinksInWorkspaceButton
.setFont(optionsGroup
.getFont());
873 fCreateLinksInWorkspaceButton
.setText(Messages
.ImportTraceWizard_CreateLinksInWorkspace
);
874 fCreateLinksInWorkspaceButton
.setSelection(true);
876 fCreateLinksInWorkspaceButton
.addSelectionListener(new SelectionAdapter() {
878 public void widgetSelected(SelectionEvent e
) {
879 updateWidgetEnablements();
883 fPreserveFolderStructureButton
= new Button(optionsGroup
, SWT
.CHECK
);
884 fPreserveFolderStructureButton
.setFont(optionsGroup
.getFont());
885 fPreserveFolderStructureButton
.setText(Messages
.ImportTraceWizard_PreserveFolderStructure
);
886 fPreserveFolderStructureButton
.setSelection(true);
888 Composite comp
= new Composite(optionsGroup
, SWT
.NONE
);
889 GridLayout layout
= new GridLayout(2, false);
890 layout
.marginLeft
= 0;
891 layout
.marginRight
= 0;
892 layout
.marginBottom
= 0;
893 layout
.marginTop
= 0;
894 layout
.marginWidth
= 0;
895 comp
.setLayout(layout
);
896 GridData data
= new GridData(GridData
.FILL
, GridData
.CENTER
, true, false);
897 comp
.setLayoutData(data
);
899 fCreateExperimentCheckbox
= new Button(comp
, SWT
.CHECK
);
900 fCreateExperimentCheckbox
.setFont(comp
.getFont());
901 fCreateExperimentCheckbox
.setText(Messages
.ImportTraceWizard_CreateExperiment
);
902 fCreateExperimentCheckbox
.setSelection(false);
903 data
= new GridData(GridData
.BEGINNING
, GridData
.CENTER
, false, false);
904 fCreateExperimentCheckbox
.setLayoutData(data
);
906 fExperimentNameText
= new Text(comp
, SWT
.BORDER
);
907 data
= new GridData(GridData
.FILL
, GridData
.CENTER
, true, false);
908 fExperimentNameText
.setLayoutData(data
);
910 fExperimentNameText
.addModifyListener(new ModifyListener() {
912 public void modifyText(ModifyEvent e
) {
913 updateWidgetEnablements();
917 fCreateExperimentCheckbox
.addSelectionListener(new SelectionAdapter() {
919 public void widgetSelected(SelectionEvent e
) {
920 fExperimentNameText
.setEnabled(fCreateExperimentCheckbox
.getSelection());
921 updateWidgetEnablements();
925 updateWidgetEnablements();
928 // ------------------------------------------------------------------------
929 // Determine if the finish button can be enabled
930 // ------------------------------------------------------------------------
932 public boolean validateSourceGroup() {
934 File source
= getSourceFile();
935 if (source
== null) {
936 setMessage(Messages
.ImportTraceWizard_SelectTraceSourceEmpty
);
937 setErrorMessage(null);
941 if (sourceConflictsWithDestination(new Path(source
.getPath()))) {
943 setErrorMessage(getSourceConflictMessage());
947 if (!isImportFromDirectory() && !ArchiveUtil
.ensureTarSourceIsValid(source
.getAbsolutePath()) && !ArchiveUtil
.ensureZipSourceIsValid(source
.getAbsolutePath())
948 && !ArchiveUtil
.ensureGzipSourceIsValid(source
.getAbsolutePath())) {
950 setErrorMessage(Messages
.ImportTraceWizard_BadArchiveFormat
);
954 if (fSelectionGroup
.getCheckedElementCount() == 0) {
956 setErrorMessage(Messages
.ImportTraceWizard_SelectTraceNoneSelected
);
960 IContainer container
= getSpecifiedContainer();
961 if (container
!= null && container
.isVirtual()) {
962 if (Platform
.getPreferencesService().getBoolean(Activator
.PLUGIN_ID
, ResourcesPlugin
.PREF_DISABLE_LINKING
, false, null)) {
964 setErrorMessage(Messages
.ImportTraceWizard_CannotImportFilesUnderAVirtualFolder
);
967 if (fCreateLinksInWorkspaceButton
== null || !fCreateLinksInWorkspaceButton
.getSelection()) {
969 setErrorMessage(Messages
.ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder
);
973 setErrorMessage(null);
978 protected boolean validateOptionsGroup() {
979 if (fCreateExperimentCheckbox
!= null && fCreateExperimentCheckbox
.getSelection()) {
980 String name
= fExperimentNameText
.getText().trim();
981 // verify if experiment name is empty
982 if (name
.isEmpty()) {
984 setErrorMessage(Messages
.ImportTraceWizard_ErrorEmptyExperimentName
);
987 // verify that name is a valid resource name
988 IWorkspace workspace
= ResourcesPlugin
.getWorkspace();
989 if ((workspace
!= null) && (!workspace
.validateName(name
, IResource
.FILE
).isOK())) {
991 setErrorMessage(NLS
.bind(Messages
.ImportTraceWizard_ErrorExperimentNameInvalid
, name
));
994 // verify if experiment already exists
995 if (fExperimentFolderElement
!= null) {
996 TmfExperimentElement element
= fExperimentFolderElement
.getExperiment(name
);
997 if (element
!= null) {
999 setErrorMessage(NLS
.bind(Messages
.ImportTraceWizard_ErrorExperimentAlreadyExists
, name
));
1002 IFolder expResource
= fExperimentFolderElement
.getResource();
1003 IResource res
= expResource
.findMember(name
);
1006 setErrorMessage(NLS
.bind(Messages
.ImportTraceWizard_ErrorResourceAlreadyExists
, name
));
1011 setErrorMessage(null);
1015 private File
getSourceFile() {
1016 return isImportFromDirectory() ?
getSourceDirectory() : getSourceArchiveFile();
1019 private boolean isImportFromDirectory() {
1020 return fImportFromDirectoryRadio
!= null && fImportFromDirectoryRadio
.getSelection();
1024 protected void restoreWidgetValues() {
1025 super.restoreWidgetValues();
1027 IDialogSettings settings
= getDialogSettings();
1029 if (fImportUnrecognizedButton
!= null) {
1030 if (settings
.get(getPageStoreKey(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID
)) == null) {
1033 value
= settings
.getBoolean(getPageStoreKey(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID
));
1035 fImportUnrecognizedButton
.setSelection(value
);
1038 if (fPreserveFolderStructureButton
!= null) {
1039 if (settings
.get(getPageStoreKey(IMPORT_WIZARD_PRESERVE_FOLDERS_ID
)) == null) {
1042 value
= settings
.getBoolean(getPageStoreKey(IMPORT_WIZARD_PRESERVE_FOLDERS_ID
));
1044 fPreserveFolderStructureButton
.setSelection(value
);
1047 if (fCreateExperimentCheckbox
!= null) {
1048 if (settings
.get(getPageStoreKey(IMPORT_WIZARD_CREATE_EXPERIMENT_ID
)) == null) {
1051 value
= settings
.getBoolean(getPageStoreKey(IMPORT_WIZARD_CREATE_EXPERIMENT_ID
));
1053 fCreateExperimentCheckbox
.setSelection(value
);
1054 fExperimentNameText
.setEnabled(fCreateExperimentCheckbox
.getSelection());
1057 if (settings
.get(getPageStoreKey(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY_ID
)) == null) {
1060 value
= settings
.getBoolean(getPageStoreKey(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY_ID
));
1063 if (directoryNameField
!= null) {
1064 restoreComboValues(directoryNameField
, settings
, getPageStoreKey(IMPORT_WIZARD_ROOT_DIRECTORY_ID
));
1066 if (fArchiveNameField
!= null) {
1067 restoreComboValues(fArchiveNameField
, settings
, getPageStoreKey(IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID
));
1070 if (fImportFromDirectoryRadio
!= null) {
1071 fImportFromDirectoryRadio
.setSelection(value
);
1073 directoryRadioSelected();
1076 if (fImportFromArchiveRadio
!= null) {
1077 fImportFromArchiveRadio
.setSelection(!value
);
1079 archiveRadioSelected();
1085 protected void saveWidgetValues() {
1086 // Persist dialog settings
1087 IDialogSettings settings
= getDialogSettings();
1088 if (fImportUnrecognizedButton
!= null) {
1089 settings
.put(getPageStoreKey(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID
), fImportUnrecognizedButton
.getSelection());
1091 if (fPreserveFolderStructureButton
!= null) {
1092 settings
.put(getPageStoreKey(IMPORT_WIZARD_PRESERVE_FOLDERS_ID
), fPreserveFolderStructureButton
.getSelection());
1095 if (fCreateExperimentCheckbox
!= null) {
1096 settings
.put(getPageStoreKey(IMPORT_WIZARD_CREATE_EXPERIMENT_ID
), fCreateExperimentCheckbox
.getSelection());
1099 settings
.put(getPageStoreKey(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY_ID
), isImportFromDirectory());
1101 if (directoryNameField
!= null) {
1102 saveComboValues(directoryNameField
, settings
, getPageStoreKey(IMPORT_WIZARD_ROOT_DIRECTORY_ID
));
1104 if (fArchiveNameField
!= null) {
1105 saveComboValues(fArchiveNameField
, settings
, getPageStoreKey(IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID
));
1109 private String
getPageStoreKey(String key
) {
1110 return getName() + key
;
1113 private static void restoreComboValues(Combo combo
, IDialogSettings settings
, String key
) {
1114 String
[] directoryNames
= settings
.getArray(key
);
1115 if ((directoryNames
!= null) && (directoryNames
.length
!= 0)) {
1116 for (int i
= 0; i
< directoryNames
.length
; i
++) {
1117 combo
.add(directoryNames
[i
]);
1122 private void saveComboValues(Combo combo
, IDialogSettings settings
, String key
) {
1123 // update names history
1124 String
[] directoryNames
= settings
.getArray(key
);
1125 if (directoryNames
== null) {
1126 directoryNames
= new String
[0];
1129 String items
[] = combo
.getItems();
1130 for (int i
= 0; i
< items
.length
; i
++) {
1131 directoryNames
= addToHistory(directoryNames
, items
[i
]);
1133 settings
.put(key
, directoryNames
);
1136 // ------------------------------------------------------------------------
1137 // Import the trace(s)
1138 // ------------------------------------------------------------------------
1141 * Finish the import.
1143 * @return <code>true</code> if successful else <code>false</code>
1145 public boolean finish() {
1146 String traceTypeLabel
= getImportTraceTypeId();
1147 final String traceId
= !TRACE_TYPE_AUTO_DETECT
.equals(traceTypeLabel
) ? TmfTraceType
.getTraceTypeId(traceTypeLabel
) : null;
1149 // Save dialog settings
1152 final IPath baseSourceContainerPath
= new Path(getSourceContainerPath());
1153 final boolean importFromArchive
= getSourceArchiveFile() != null;
1154 final int importOptionFlags
= getImportOptionFlags();
1155 final IPath destinationContainerPath
= getContainerFullPath();
1157 final IStatus
[] operationStatus
= new IStatus
[1];
1158 operationStatus
[0] = Status
.OK_STATUS
;
1159 final List
<IResource
> traceResources
= new ArrayList
<>();
1161 getContainer().run(true, true, new IRunnableWithProgress() {
1163 public void run(IProgressMonitor monitor
) throws InvocationTargetException
, InterruptedException
{
1165 final List
<TraceFileSystemElement
> selectedFileSystemElements
= new LinkedList
<>();
1166 IElementFilter passThroughFilter
= new IElementFilter() {
1169 public void filterElements(Collection elements
, IProgressMonitor m
) {
1170 selectedFileSystemElements
.addAll(elements
);
1174 public void filterElements(Object
[] elements
, IProgressMonitor m
) {
1175 for (int i
= 0; i
< elements
.length
; i
++) {
1176 selectedFileSystemElements
.add((TraceFileSystemElement
) elements
[i
]);
1181 // List fileSystemElements will be filled using the
1182 // passThroughFilter
1183 SubMonitor subMonitor
= SubMonitor
.convert(monitor
, 1);
1184 fSelectionGroup
.getAllCheckedListItems(passThroughFilter
, subMonitor
);
1186 final TraceValidateAndImportOperation operation
= new TraceValidateAndImportOperation(getContainer().getShell(), selectedFileSystemElements
, traceId
, baseSourceContainerPath
, destinationContainerPath
, importFromArchive
,
1187 importOptionFlags
, fTraceFolderElement
);
1188 operation
.run(monitor
);
1190 operationStatus
[0] = operation
.getStatus();
1191 traceResources
.addAll(operation
.getImportedResources());
1195 // Only create experiment when option is selected and
1196 // if there has been at least one trace imported
1197 if (((importOptionFlags
& OPTION_CREATE_EXPERIMENT
) != 0) && (traceResources
.size() > 0)) {
1198 final IFolder
[] experimentFolders
= new IFolder
[1];
1199 final TmfExperimentFolder root
= fExperimentFolderElement
;
1200 final String experimentName
= fExperimentNameText
.getText().trim();
1201 // just safety guards
1202 if ((root
== null) || (experimentName
== null)) {
1205 if ((operationStatus
[0] != null) && (operationStatus
[0].isOK())) {
1206 getContainer().run(true, true, new IRunnableWithProgress() {
1208 public void run(IProgressMonitor monitor
) throws InvocationTargetException
, InterruptedException
{
1209 operationStatus
[0] = null;
1210 final NewExperimentOperation operation
= new NewExperimentOperation(root
, experimentName
);
1211 operation
.run(monitor
);
1213 operationStatus
[0] = operation
.getStatus();
1214 experimentFolders
[0] = operation
.getExperimentFolder();
1218 final IFolder expFolder
= experimentFolders
[0];
1219 final TmfTraceFolder parentTraceFolder
= fTraceFolderElement
;
1220 // just safety guards
1221 if ((expFolder
== null) || (parentTraceFolder
== null)) {
1224 if ((operationStatus
[0] != null) && (operationStatus
[0].isOK())) {
1225 getContainer().run(true, true, new IRunnableWithProgress() {
1227 public void run(IProgressMonitor monitor
) throws InvocationTargetException
, InterruptedException
{
1228 operationStatus
[0] = null;
1229 final SelectTracesOperation operation
= new SelectTracesOperation(root
, expFolder
, parentTraceFolder
, traceResources
);
1230 operation
.run(monitor
);
1232 operationStatus
[0] = operation
.getStatus();
1238 } catch (InvocationTargetException e
) {
1239 operationStatus
[0] = new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, Messages
.ImportTraceWizard_ImportProblem
, e
.getTargetException());
1240 } catch (InterruptedException e
) {
1241 operationStatus
[0] = Status
.CANCEL_STATUS
;
1243 if (!operationStatus
[0].isOK()) {
1244 if (operationStatus
[0].getSeverity() == IStatus
.CANCEL
) {
1245 setMessage(Messages
.ImportTraceWizard_ImportOperationCancelled
);
1246 setErrorMessage(null);
1248 Throwable exception
= operationStatus
[0].getException();
1249 if (exception
!= null) {
1250 Activator
.getDefault().logError(exception
.getMessage(), exception
);
1251 displayErrorDialog(operationStatus
[0].getMessage() + ": " + exception
); //$NON-NLS-1$
1254 setErrorMessage(Messages
.ImportTraceWizard_ImportProblem
);
1258 setErrorMessage(null);
1263 * Get the trace type id to import as. This can also return
1264 * {@link #TRACE_TYPE_AUTO_DETECT} to communicate that automatic trace type
1265 * detection will occur instead of setting a specific trace type when
1266 * importing the traces.
1268 * @return the trace type id or {@link #TRACE_TYPE_AUTO_DETECT}
1270 protected String
getImportTraceTypeId() {
1271 return fTraceTypes
.getText();
1275 * Get import options in the form of flags (bits).
1277 * @return the import flags.
1278 * @see #OPTION_CREATE_LINKS_IN_WORKSPACE
1279 * @see #OPTION_IMPORT_UNRECOGNIZED_TRACES
1280 * @see #OPTION_OVERWRITE_EXISTING_RESOURCES
1281 * @see #OPTION_PRESERVE_FOLDER_STRUCTURE
1282 * @see #OPTION_CREATE_EXPERIMENT
1284 protected int getImportOptionFlags() {
1286 if (fCreateLinksInWorkspaceButton
!= null && fCreateLinksInWorkspaceButton
.getSelection()) {
1287 flags
|= OPTION_CREATE_LINKS_IN_WORKSPACE
;
1289 if (fImportUnrecognizedButton
!= null && fImportUnrecognizedButton
.getSelection()) {
1290 flags
|= OPTION_IMPORT_UNRECOGNIZED_TRACES
;
1292 if (fOverwriteExistingResourcesCheckbox
!= null && fOverwriteExistingResourcesCheckbox
.getSelection()) {
1293 flags
|= OPTION_OVERWRITE_EXISTING_RESOURCES
;
1295 if (fPreserveFolderStructureButton
!= null && fPreserveFolderStructureButton
.getSelection()) {
1296 flags
|= OPTION_PRESERVE_FOLDER_STRUCTURE
;
1298 if (fCreateExperimentCheckbox
!= null && fCreateExperimentCheckbox
.getSelection()) {
1299 flags
|= OPTION_CREATE_EXPERIMENT
;
1305 public void dispose() {
1307 disposeSelectionGroupRoot();