1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 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 *******************************************************************************/
20 package org
.eclipse
.linuxtools
.internal
.tmf
.ui
.project
.wizards
.importtrace
;
23 import java
.io
.IOException
;
24 import java
.io
.InputStream
;
25 import java
.lang
.reflect
.InvocationTargetException
;
27 import java
.util
.ArrayList
;
28 import java
.util
.Collection
;
29 import java
.util
.HashMap
;
30 import java
.util
.Iterator
;
31 import java
.util
.List
;
33 import java
.util
.zip
.ZipEntry
;
34 import java
.util
.zip
.ZipException
;
35 import java
.util
.zip
.ZipFile
;
37 import org
.eclipse
.core
.resources
.IContainer
;
38 import org
.eclipse
.core
.resources
.IFolder
;
39 import org
.eclipse
.core
.resources
.IProject
;
40 import org
.eclipse
.core
.resources
.IResource
;
41 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
42 import org
.eclipse
.core
.runtime
.CoreException
;
43 import org
.eclipse
.core
.runtime
.IPath
;
44 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
45 import org
.eclipse
.core
.runtime
.IStatus
;
46 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
47 import org
.eclipse
.core
.runtime
.Path
;
48 import org
.eclipse
.core
.runtime
.Platform
;
49 import org
.eclipse
.core
.runtime
.Status
;
50 import org
.eclipse
.core
.runtime
.SubMonitor
;
51 import org
.eclipse
.core
.runtime
.SubProgressMonitor
;
52 import org
.eclipse
.core
.runtime
.URIUtil
;
53 import org
.eclipse
.jface
.dialogs
.IDialogSettings
;
54 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
55 import org
.eclipse
.jface
.layout
.PixelConverter
;
56 import org
.eclipse
.jface
.operation
.IRunnableWithProgress
;
57 import org
.eclipse
.jface
.operation
.ModalContext
;
58 import org
.eclipse
.jface
.viewers
.CheckStateChangedEvent
;
59 import org
.eclipse
.jface
.viewers
.ICheckStateListener
;
60 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
61 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
62 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
63 import org
.eclipse
.linuxtools
.tmf
.core
.TmfCommonConstants
;
64 import org
.eclipse
.linuxtools
.tmf
.core
.TmfProjectNature
;
65 import org
.eclipse
.linuxtools
.tmf
.core
.project
.model
.TmfTraceImportException
;
66 import org
.eclipse
.linuxtools
.tmf
.core
.project
.model
.TmfTraceType
;
67 import org
.eclipse
.linuxtools
.tmf
.core
.project
.model
.TraceTypeHelper
;
68 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectElement
;
69 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
70 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
71 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceFolder
;
72 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceTypeUIUtils
;
73 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTracesFolder
;
74 import org
.eclipse
.osgi
.util
.NLS
;
75 import org
.eclipse
.swt
.SWT
;
76 import org
.eclipse
.swt
.custom
.BusyIndicator
;
77 import org
.eclipse
.swt
.events
.FocusAdapter
;
78 import org
.eclipse
.swt
.events
.FocusEvent
;
79 import org
.eclipse
.swt
.events
.ModifyEvent
;
80 import org
.eclipse
.swt
.events
.ModifyListener
;
81 import org
.eclipse
.swt
.events
.SelectionAdapter
;
82 import org
.eclipse
.swt
.events
.SelectionEvent
;
83 import org
.eclipse
.swt
.events
.TraverseEvent
;
84 import org
.eclipse
.swt
.events
.TraverseListener
;
85 import org
.eclipse
.swt
.layout
.GridData
;
86 import org
.eclipse
.swt
.layout
.GridLayout
;
87 import org
.eclipse
.swt
.widgets
.Button
;
88 import org
.eclipse
.swt
.widgets
.Combo
;
89 import org
.eclipse
.swt
.widgets
.Composite
;
90 import org
.eclipse
.swt
.widgets
.DirectoryDialog
;
91 import org
.eclipse
.swt
.widgets
.Event
;
92 import org
.eclipse
.swt
.widgets
.FileDialog
;
93 import org
.eclipse
.swt
.widgets
.Group
;
94 import org
.eclipse
.swt
.widgets
.Label
;
95 import org
.eclipse
.ui
.IWorkbench
;
96 import org
.eclipse
.ui
.dialogs
.FileSystemElement
;
97 import org
.eclipse
.ui
.dialogs
.IOverwriteQuery
;
98 import org
.eclipse
.ui
.dialogs
.WizardResourceImportPage
;
99 import org
.eclipse
.ui
.internal
.ide
.DialogUtil
;
100 import org
.eclipse
.ui
.internal
.ide
.dialogs
.IElementFilter
;
101 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.ArchiveFileManipulations
;
102 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.DataTransferMessages
;
103 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.ILeveledImportStructureProvider
;
104 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.TarEntry
;
105 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.TarException
;
106 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.TarFile
;
107 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.TarLeveledStructureProvider
;
108 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.ZipLeveledStructureProvider
;
109 import org
.eclipse
.ui
.model
.AdaptableList
;
110 import org
.eclipse
.ui
.model
.WorkbenchContentProvider
;
111 import org
.eclipse
.ui
.model
.WorkbenchLabelProvider
;
112 import org
.eclipse
.ui
.model
.WorkbenchViewerComparator
;
113 import org
.eclipse
.ui
.wizards
.datatransfer
.FileSystemStructureProvider
;
114 import org
.eclipse
.ui
.wizards
.datatransfer
.IImportStructureProvider
;
115 import org
.eclipse
.ui
.wizards
.datatransfer
.ImportOperation
;
118 * A variant of the standard resource import wizard for importing traces
119 * to given tracing project. If no project or tracing project was selected
120 * the wizard imports it to the default tracing project which is created
123 * In our case traces could be files or a directory structure. This wizard
124 * supports both cases. It imports traces for a selected trace type or, if
125 * no trace type is selected, it tries to detect the trace type automatically.
126 * However, the automatic detection is a best-effort and cannot guarantee
127 * that the detection is successful. The reason for this is that there might
128 * be multiple trace types that can be assigned to a single trace.
131 * @author Francois Chouinard
134 @SuppressWarnings("restriction")
135 public class ImportTraceWizardPage
extends WizardResourceImportPage
{
137 // ------------------------------------------------------------------------
139 // ------------------------------------------------------------------------
140 private static final String IMPORT_WIZARD_PAGE
= "ImportTraceWizardPage"; //$NON-NLS-1$
141 private static final String IMPORT_WIZARD_ROOT_DIRECTORY_ID
= IMPORT_WIZARD_PAGE
+ ".import_root_directory_id"; //$NON-NLS-1$
142 private static final String IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID
= IMPORT_WIZARD_PAGE
+ ".import_archive_file_name_id"; //$NON-NLS-1$
143 private static final String IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID
= IMPORT_WIZARD_PAGE
+ ".import_unrecognized_traces_id"; //$NON-NLS-1$
144 private static final String IMPORT_WIZARD_PRESERVE_FOLDERS_ID
= IMPORT_WIZARD_PAGE
+ ".import_preserve_folders_id"; //$NON-NLS-1$
145 private static final String IMPORT_WIZARD_IMPORT_FROM_DIRECTORY
= IMPORT_WIZARD_PAGE
+ ".import_from_directory"; //$NON-NLS-1$
146 private static final String SEPARATOR
= ":"; //$NON-NLS-1$
147 private static final String AUTO_DETECT
= Messages
.ImportTraceWizard_AutoDetection
;
149 // constant from WizardArchiveFileResourceImportPage1
150 private static final String
[] FILE_IMPORT_MASK
= { "*.jar;*.zip;*.tar;*.tar.gz;*.tgz", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
151 private static final String TRACE_IMPORT_TEMP_FOLDER
= ".traceImport"; //$NON-NLS-1$
153 // ------------------------------------------------------------------------
155 // ------------------------------------------------------------------------
157 // Target import directory ('Traces' folder)
158 private IFolder fTargetFolder
;
159 // Target Trace folder element
160 private TmfTraceFolder fTraceFolderElement
;
161 // Flag to handle destination folder change event
162 private Boolean fIsDestinationChanged
= false;
163 // Combo box containing trace types
164 private Combo fTraceTypes
;
165 // Button to ignore unrecognized traces or not
166 private Button fImportUnrecognizedButton
;
167 // Button to overwrite existing resources or not
168 private Button fOverwriteExistingResourcesCheckbox
;
169 // Button to link or copy traces to workspace
170 private Button fCreateLinksInWorkspaceButton
;
171 // Button to preserve folder structure
172 private Button fPreserveFolderStructureButton
;
173 private boolean entryChanged
= false;
174 // The import from directory radio button
175 private Button fImportFromDirectoryRadio
;
176 // The import from archive radio button
177 private Button fImportFromArchiveRadio
;
178 // Flag to remember the "create links" checkbox when it gets disabled by
179 // the import from archive radio button
180 private Boolean fPreviousCreateLinksValue
= true;
181 /** The archive name field */
182 private Combo fArchiveNameField
;
183 /** The archive browse button. */
184 protected Button fArchiveBrowseButton
;
186 /** The directory name field */
187 protected Combo directoryNameField
;
188 /** The directory browse button. */
189 protected Button directoryBrowseButton
;
192 * ResourceTreeAndListGroup was internal in Kepler and we referenced it. It
193 * is now removed in Luna. To keep our builds compatible with Kepler, we
194 * need to have our own version of this class. Once we stop supporting
195 * Kepler, we can delete this class and use the public one from the
198 private ResourceTreeAndListGroup fSelectionGroup
;
200 // Keep trace of the selection root so that we can dispose its related
202 private TraceFileSystemElement fSelectionGroupRoot
;
204 // ------------------------------------------------------------------------
206 // ------------------------------------------------------------------------
209 * Constructor. Creates the trace wizard page.
212 * The name of the page.
214 * The current selection
216 protected ImportTraceWizardPage(String name
, IStructuredSelection selection
) {
217 super(name
, selection
);
221 * Create the import source selection widget. (Copied from WizardResourceImportPage
222 * but instead always uses the internal ResourceTreeAndListGroup to keep compatibility
226 protected void createFileSelectionGroup(Composite parent
) {
228 //Just create with a dummy root.
229 fSelectionGroup
= new ResourceTreeAndListGroup(parent
,
230 new FileSystemElement("Dummy", null, true),//$NON-NLS-1$
231 getFolderProvider(), new WorkbenchLabelProvider(),
232 getFileProvider(), new WorkbenchLabelProvider(), SWT
.NONE
,
233 DialogUtil
.inRegularFontMode(parent
));
235 ICheckStateListener listener
= new ICheckStateListener() {
237 public void checkStateChanged(CheckStateChangedEvent event
) {
238 updateWidgetEnablements();
242 WorkbenchViewerComparator comparator
= new WorkbenchViewerComparator();
243 fSelectionGroup
.setTreeComparator(comparator
);
244 fSelectionGroup
.setListComparator(comparator
);
245 fSelectionGroup
.addCheckStateListener(listener
);
253 * The workbench reference.
255 * The current selection
257 public ImportTraceWizardPage(IWorkbench workbench
, IStructuredSelection selection
) {
258 this(IMPORT_WIZARD_PAGE
, selection
);
259 setTitle(Messages
.ImportTraceWizard_FileSystemTitle
);
260 setDescription(Messages
.ImportTraceWizard_ImportTrace
);
262 // Locate the target trace folder
263 IFolder traceFolder
= null;
264 Object element
= selection
.getFirstElement();
266 if (element
instanceof TmfTraceFolder
) {
267 fTraceFolderElement
= (TmfTraceFolder
) element
;
268 traceFolder
= fTraceFolderElement
.getResource();
269 } else if (element
instanceof IProject
) {
270 IProject project
= (IProject
) element
;
272 if (project
.hasNature(TmfProjectNature
.ID
)) {
273 TmfProjectElement projectElement
= TmfProjectRegistry
.getProject(project
, true);
274 fTraceFolderElement
= projectElement
.getTracesFolder();
275 traceFolder
= project
.getFolder(TmfTracesFolder
.TRACES_FOLDER_NAME
);
277 } catch (CoreException e
) {
281 // If no tracing project was selected or trace folder doesn't exist use
282 // default tracing project
283 if (traceFolder
== null) {
284 IProject project
= TmfProjectRegistry
.createProject(
285 TmfCommonConstants
.DEFAULT_TRACE_PROJECT_NAME
, null, new NullProgressMonitor());
286 TmfProjectElement projectElement
= TmfProjectRegistry
.getProject(project
, true);
287 fTraceFolderElement
= projectElement
.getTracesFolder();
288 traceFolder
= project
.getFolder(TmfTracesFolder
.TRACES_FOLDER_NAME
);
291 // Set the target trace folder
292 if (traceFolder
!= null) {
293 fTargetFolder
= traceFolder
;
294 String path
= traceFolder
.getFullPath().toString();
295 setContainerFieldValue(path
);
299 // ------------------------------------------------------------------------
300 // WizardResourceImportPage
301 // ------------------------------------------------------------------------
304 protected void createSourceGroup(Composite parent
) {
305 createSourceSelectionGroup(parent
);
306 createFileSelectionGroup(parent
);
307 createTraceTypeGroup(parent
);
308 validateSourceGroup();
312 protected ITreeContentProvider
getFileProvider() {
313 return new WorkbenchContentProvider() {
315 public Object
[] getChildren(Object object
) {
316 if (object
instanceof TraceFileSystemElement
) {
317 TraceFileSystemElement element
= (TraceFileSystemElement
) object
;
318 return element
.getFiles().getChildren(element
);
320 return new Object
[0];
326 protected ITreeContentProvider
getFolderProvider() {
327 return new WorkbenchContentProvider() {
329 public Object
[] getChildren(Object o
) {
330 if (o
instanceof TraceFileSystemElement
) {
331 TraceFileSystemElement element
= (TraceFileSystemElement
) o
;
332 return element
.getFolders().getChildren();
334 return new Object
[0];
338 public boolean hasChildren(Object o
) {
339 if (o
instanceof TraceFileSystemElement
) {
340 TraceFileSystemElement element
= (TraceFileSystemElement
) o
;
341 if (element
.isPopulated()) {
342 return getChildren(element
).length
> 0;
344 //If we have not populated then wait until asked
352 // ------------------------------------------------------------------------
353 // Directory Selection Group (forked WizardFileSystemResourceImportPage1)
354 // ------------------------------------------------------------------------
357 * creates the source selection group.
360 * the parent composite
362 private void createSourceSelectionGroup(Composite workArea
) {
364 Composite sourceGroup
= new Composite(workArea
, SWT
.NONE
);
365 GridLayout layout
= new GridLayout();
366 layout
.numColumns
= 3;
367 layout
.makeColumnsEqualWidth
= false;
368 layout
.marginWidth
= 0;
369 sourceGroup
.setLayout(layout
);
370 sourceGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
372 // import from directory radio button
373 fImportFromDirectoryRadio
= new Button(sourceGroup
, SWT
.RADIO
);
374 fImportFromDirectoryRadio
375 .setText(Messages
.ImportTraceWizard_DirectoryLocation
);
377 // import location entry combo
378 directoryNameField
= new Combo(sourceGroup
, SWT
.BORDER
);
380 GridData directoryPathData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
);
381 directoryPathData
.widthHint
= new PixelConverter(directoryNameField
).convertWidthInCharsToPixels(25);
382 directoryNameField
.setLayoutData(directoryPathData
);
385 directoryBrowseButton
= new Button(sourceGroup
, SWT
.PUSH
);
386 directoryBrowseButton
387 .setText(Messages
.ImportTraceWizard_BrowseButton
);
388 setButtonLayoutData(directoryBrowseButton
);
390 // import from archive radio button
391 fImportFromArchiveRadio
= new Button(sourceGroup
, SWT
.RADIO
);
392 fImportFromArchiveRadio
393 .setText(Messages
.ImportTraceWizard_ArchiveLocation
);
395 // import location entry combo
396 fArchiveNameField
= new Combo(sourceGroup
, SWT
.BORDER
);
398 GridData archivePathData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
);
399 archivePathData
.widthHint
= new PixelConverter(fArchiveNameField
).convertWidthInCharsToPixels(25);
400 fArchiveNameField
.setLayoutData(archivePathData
); // browse button
401 fArchiveBrowseButton
= new Button(sourceGroup
, SWT
.PUSH
);
402 fArchiveBrowseButton
.setText(DataTransferMessages
.DataTransfer_browse
);
403 setButtonLayoutData(fArchiveBrowseButton
);
405 fImportFromDirectoryRadio
.setSelection(true);
406 fArchiveNameField
.setEnabled(false);
407 fArchiveBrowseButton
.setEnabled(false);
409 directoryBrowseButton
.addSelectionListener(new SelectionAdapter() {
411 public void widgetSelected(SelectionEvent e
) {
412 handleSourceDirectoryBrowseButtonPressed();
417 fArchiveBrowseButton
.addSelectionListener(new SelectionAdapter() {
419 public void widgetSelected(SelectionEvent e
) {
420 handleArchiveBrowseButtonPressed();
424 TraverseListener traverseListener
= new TraverseListener() {
426 public void keyTraversed(TraverseEvent e
) {
427 if (e
.detail
== SWT
.TRAVERSE_RETURN
) {
429 entryChanged
= false;
430 updateFromSourceField();
435 FocusAdapter focusAdapter
= new FocusAdapter() {
437 public void focusLost(FocusEvent e
) {
438 // Clear the flag to prevent constant update
440 entryChanged
= false;
441 updateFromSourceField();
446 SelectionAdapter selectionAdapter
= new SelectionAdapter() {
448 public void widgetSelected(SelectionEvent e
) {
449 entryChanged
= false;
450 updateFromSourceField();
454 ModifyListener modifyListner
= new ModifyListener() {
456 public void modifyText(ModifyEvent e
) {
461 directoryNameField
.addModifyListener(modifyListner
);
462 directoryNameField
.addTraverseListener(traverseListener
);
463 directoryNameField
.addFocusListener(focusAdapter
);
464 directoryNameField
.addSelectionListener(selectionAdapter
);
465 fArchiveNameField
.addModifyListener(modifyListner
);
466 fArchiveNameField
.addTraverseListener(traverseListener
);
467 fArchiveNameField
.addFocusListener(focusAdapter
);
468 fArchiveNameField
.addSelectionListener(selectionAdapter
);
470 fImportFromDirectoryRadio
.addSelectionListener(new SelectionAdapter() {
472 public void widgetSelected(SelectionEvent e
) {
473 directoryRadioSelected();
477 fImportFromArchiveRadio
.addSelectionListener(new SelectionAdapter() {
479 public void widgetSelected(SelectionEvent e
) {
480 archiveRadioSelected();
485 private void archiveRadioSelected() {
486 if (fImportFromArchiveRadio
.getSelection()) {
487 directoryNameField
.setEnabled(false);
488 directoryBrowseButton
.setEnabled(false);
489 fArchiveNameField
.setEnabled(true);
490 fArchiveBrowseButton
.setEnabled(true);
491 updateFromSourceField();
492 fArchiveNameField
.setFocus();
493 fPreviousCreateLinksValue
= fCreateLinksInWorkspaceButton
.getSelection();
494 fCreateLinksInWorkspaceButton
.setSelection(false);
495 fCreateLinksInWorkspaceButton
.setEnabled(false);
499 private void directoryRadioSelected() {
500 if (fImportFromDirectoryRadio
.getSelection()) {
501 directoryNameField
.setEnabled(true);
502 directoryBrowseButton
.setEnabled(true);
503 fArchiveNameField
.setEnabled(false);
504 fArchiveBrowseButton
.setEnabled(false);
505 updateFromSourceField();
506 directoryNameField
.setFocus();
507 fCreateLinksInWorkspaceButton
.setSelection(fPreviousCreateLinksValue
);
508 fCreateLinksInWorkspaceButton
.setEnabled(true);
512 // ------------------------------------------------------------------------
513 // Browse for the source directory
514 // ------------------------------------------------------------------------
517 public void handleEvent(Event event
) {
518 if (event
.widget
== directoryBrowseButton
) {
519 handleSourceDirectoryBrowseButtonPressed();
522 // Avoid overwriting destination path without repeatedly trigger
523 // call of handleEvent();
524 synchronized (fIsDestinationChanged
) {
525 if (fIsDestinationChanged
== false) {
526 event
.display
.asyncExec(new Runnable() {
529 synchronized (fIsDestinationChanged
) {
530 fIsDestinationChanged
= true;
531 String path
= fTargetFolder
.getFullPath().toString();
532 setContainerFieldValue(path
);
537 fIsDestinationChanged
= false;
540 super.handleEvent(event
);
544 protected void handleContainerBrowseButtonPressed() {
545 // Do nothing so that destination directory cannot be changed.
549 * Handle the button pressed event
551 protected void handleSourceDirectoryBrowseButtonPressed() {
552 String currentSource
= directoryNameField
.getText();
553 DirectoryDialog dialog
= new DirectoryDialog(directoryNameField
.getShell(), SWT
.SAVE
| SWT
.SHEET
);
554 dialog
.setText(Messages
.ImportTraceWizard_SelectTraceDirectoryTitle
);
555 dialog
.setMessage(Messages
.ImportTraceWizard_SelectTraceDirectoryMessage
);
556 dialog
.setFilterPath(getSourceDirectoryName(currentSource
));
558 String selectedDirectory
= dialog
.open();
559 if (selectedDirectory
!= null) {
560 // Just quit if the directory is not valid
561 if ((getSourceDirectory(selectedDirectory
) == null) || selectedDirectory
.equals(currentSource
)) {
564 // If it is valid then proceed to populate
565 setErrorMessage(null);
566 setSourceName(selectedDirectory
);
571 * Handle the button pressed event
573 private void handleArchiveBrowseButtonPressed() {
574 FileDialog dialog
= new FileDialog(fArchiveNameField
.getShell(), SWT
.SHEET
);
575 dialog
.setFilterExtensions(FILE_IMPORT_MASK
);
576 dialog
.setText(Messages
.ImportTraceWizard_SelectTraceArchiveTitle
);
577 String fileName
= fArchiveNameField
.getText().trim();
578 if (!fileName
.isEmpty()) {
579 File path
= new File(fileName
).getParentFile();
580 if (path
!= null && path
.exists()) {
581 dialog
.setFilterPath(path
.toString());
585 String selectedArchive
= dialog
.open();
586 if (selectedArchive
!= null) {
587 setErrorMessage(null);
588 setSourceName(selectedArchive
);
589 updateWidgetEnablements();
593 private File
getSourceDirectory() {
594 return getSourceDirectory(directoryNameField
.getText());
597 private File
getSourceArchiveFile() {
598 return getSourceArchiveFile(fArchiveNameField
.getText());
601 private String
getSourceContainerPath() {
602 if (fImportFromDirectoryRadio
.getSelection()) {
603 File sourceDirectory
= getSourceDirectory();
604 if (sourceDirectory
!= null) {
605 return sourceDirectory
.getAbsolutePath();
608 File sourceArchiveFile
= getSourceArchiveFile();
609 if (sourceArchiveFile
!= null) {
610 return sourceArchiveFile
.getParent();
615 private static File
getSourceDirectory(String path
) {
616 File sourceDirectory
= new File(getSourceDirectoryName(path
));
617 if (!sourceDirectory
.exists() || !sourceDirectory
.isDirectory()) {
621 return sourceDirectory
;
624 private static File
getSourceArchiveFile(String path
) {
625 File sourceArchiveFile
= new File(path
);
626 if (!sourceArchiveFile
.exists() || sourceArchiveFile
.isDirectory()) {
630 return sourceArchiveFile
;
633 private static String
getSourceDirectoryName(String sourceName
) {
634 IPath result
= new Path(sourceName
.trim());
635 if (result
.getDevice() != null && result
.segmentCount() == 0) {
636 result
= result
.addTrailingSeparator();
638 result
= result
.removeTrailingSeparator();
640 return result
.toOSString();
643 private void updateFromSourceField() {
644 setSourceName(getSourceField().getText());
645 updateWidgetEnablements();
648 private Combo
getSourceField() {
649 return directoryNameField
.isEnabled() ? directoryNameField
: fArchiveNameField
;
652 private void setSourceName(String path
) {
653 Combo sourceField
= getSourceField();
654 if (path
.length() > 0) {
655 String
[] currentItems
= sourceField
.getItems();
656 int selectionIndex
= -1;
657 for (int i
= 0; i
< currentItems
.length
; i
++) {
658 if (currentItems
[i
].equals(path
)) {
662 if (selectionIndex
< 0) {
663 int oldLength
= currentItems
.length
;
664 String
[] newItems
= new String
[oldLength
+ 1];
665 System
.arraycopy(currentItems
, 0, newItems
, 0, oldLength
);
666 newItems
[oldLength
] = path
;
667 sourceField
.setItems(newItems
);
668 selectionIndex
= oldLength
;
670 sourceField
.select(selectionIndex
);
675 // ------------------------------------------------------------------------
676 // File Selection Group (forked WizardFileSystemResourceImportPage1)
677 // ------------------------------------------------------------------------
678 private void resetSelection() {
679 if (fSelectionGroupRoot
!= null) {
680 disposeSelectionGroupRoot();
682 fSelectionGroupRoot
= getFileSystemTree();
683 fSelectionGroup
.setRoot(fSelectionGroupRoot
);
686 private void disposeSelectionGroupRoot() {
687 if (fSelectionGroupRoot
!= null && fSelectionGroupRoot
.getProvider() != null) {
688 FileSystemObjectImportStructureProvider provider
= fSelectionGroupRoot
.getProvider();
690 fSelectionGroupRoot
= null;
694 private TraceFileSystemElement
getFileSystemTree() {
695 IFileSystemObject rootElement
= null;
696 FileSystemObjectImportStructureProvider importStructureProvider
= null;
698 // Import from directory
699 if (fImportFromDirectoryRadio
.getSelection()) {
700 importStructureProvider
= new FileSystemObjectImportStructureProvider(FileSystemStructureProvider
.INSTANCE
, null);
701 File sourceDirectory
= getSourceDirectory();
702 if (sourceDirectory
== null) {
705 rootElement
= importStructureProvider
.getIFileSystemObject(sourceDirectory
);
707 // Import from archive
708 FileSystemObjectLeveledImportStructureProvider leveledImportStructureProvider
= null;
709 String archivePath
= getSourceArchiveFile() != null ?
getSourceArchiveFile().getAbsolutePath() : ""; //$NON-NLS-1$
710 if (ArchiveFileManipulations
.isTarFile(archivePath
)) {
711 if (ensureTarSourceIsValid(archivePath
)) {
712 // We close the file when we dispose the import provider, see disposeSelectionGroupRoot
713 TarFile tarFile
= getSpecifiedTarSourceFile(archivePath
);
714 leveledImportStructureProvider
= new FileSystemObjectLeveledImportStructureProvider(new TarLeveledStructureProvider(tarFile
), archivePath
);
716 } else if (ensureZipSourceIsValid(archivePath
)) {
717 // We close the file when we dispose the import provider, see disposeSelectionGroupRoot
718 @SuppressWarnings("resource")
719 ZipFile zipFile
= getSpecifiedZipSourceFile(archivePath
);
720 leveledImportStructureProvider
= new FileSystemObjectLeveledImportStructureProvider(new ZipLeveledStructureProvider(zipFile
), archivePath
);
722 if (leveledImportStructureProvider
== null) {
725 rootElement
= leveledImportStructureProvider
.getRoot();
726 importStructureProvider
= leveledImportStructureProvider
;
729 if (rootElement
== null) {
733 return selectFiles(rootElement
, importStructureProvider
);
737 * An import provider that makes use of the IFileSystemObject abstraction
738 * instead of using plain file system objects (File, TarEntry, ZipEntry)
740 private static class FileSystemObjectImportStructureProvider
implements IImportStructureProvider
{
742 private IImportStructureProvider fImportProvider
;
743 private String fArchivePath
;
744 private FileSystemObjectImportStructureProvider(IImportStructureProvider importStructureProvider
, String archivePath
) {
745 fImportProvider
= importStructureProvider
;
746 fArchivePath
= archivePath
;
750 public List
<IFileSystemObject
> getChildren(Object element
) {
751 @SuppressWarnings("rawtypes")
752 List children
= fImportProvider
.getChildren(((IFileSystemObject
)element
).getRawFileSystemObject());
753 List
<IFileSystemObject
> adapted
= new ArrayList
<>(children
.size());
754 for (Object o
: children
) {
755 adapted
.add(getIFileSystemObject(o
));
760 public IFileSystemObject
getIFileSystemObject(Object o
) {
761 if (o
instanceof File
) {
762 return new FileFileSystemObject((File
)o
);
763 } else if (o
instanceof TarEntry
) {
764 return new TarFileSystemObject((TarEntry
) o
, fArchivePath
);
765 } else if (o
instanceof ZipEntry
) {
766 return new ZipFileSystemObject((ZipEntry
) o
, fArchivePath
);
769 throw new IllegalArgumentException("Object type not handled"); //$NON-NLS-1$
773 public InputStream
getContents(Object element
) {
774 return fImportProvider
.getContents(((IFileSystemObject
)element
).getRawFileSystemObject());
778 public String
getFullPath(Object element
) {
779 return fImportProvider
.getFullPath(((IFileSystemObject
)element
).getRawFileSystemObject());
783 public String
getLabel(Object element
) {
784 return fImportProvider
.getLabel(((IFileSystemObject
)element
).getRawFileSystemObject());
788 public boolean isFolder(Object element
) {
789 return fImportProvider
.isFolder(((IFileSystemObject
)element
).getRawFileSystemObject());
793 * Disposes of the resources associated with the provider.
795 public void dispose() {
800 * An import provider that both supports using IFileSystemObject and adds
801 * "archive functionality" by delegating to a leveled import provider
802 * (TarLeveledStructureProvider, ZipLeveledStructureProvider)
804 private static class FileSystemObjectLeveledImportStructureProvider
extends FileSystemObjectImportStructureProvider
implements ILeveledImportStructureProvider
{
806 private ILeveledImportStructureProvider fLeveledImportProvider
;
808 private FileSystemObjectLeveledImportStructureProvider(ILeveledImportStructureProvider importStructureProvider
, String archivePath
) {
809 super(importStructureProvider
, archivePath
);
810 fLeveledImportProvider
= importStructureProvider
;
814 public IFileSystemObject
getRoot() {
815 return getIFileSystemObject(fLeveledImportProvider
.getRoot());
819 public void setStrip(int level
) {
820 fLeveledImportProvider
.setStrip(level
);
824 public int getStrip() {
825 return fLeveledImportProvider
.getStrip();
829 public boolean closeArchive() {
830 return fLeveledImportProvider
.closeArchive();
834 @SuppressWarnings("resource")
835 private boolean ensureZipSourceIsValid(String archivePath
) {
836 ZipFile specifiedFile
= getSpecifiedZipSourceFile(archivePath
);
837 if (specifiedFile
== null) {
840 return ArchiveFileManipulations
.closeZipFile(specifiedFile
, getShell());
843 private boolean ensureTarSourceIsValid(String archivePath
) {
844 TarFile specifiedFile
= getSpecifiedTarSourceFile(archivePath
);
845 if (specifiedFile
== null) {
848 return ArchiveFileManipulations
.closeTarFile(specifiedFile
, getShell());
851 private static ZipFile
getSpecifiedZipSourceFile(String fileName
) {
852 if (fileName
.length() == 0) {
857 return new ZipFile(fileName
);
858 } catch (ZipException e
) {
860 } catch (IOException e
) {
867 private static TarFile
getSpecifiedTarSourceFile(String fileName
) {
868 if (fileName
.length() == 0) {
873 return new TarFile(fileName
);
874 } catch (TarException e
) {
876 } catch (IOException e
) {
883 private TraceFileSystemElement
selectFiles(final IFileSystemObject rootFileSystemObject
,
884 final FileSystemObjectImportStructureProvider structureProvider
) {
885 final TraceFileSystemElement
[] results
= new TraceFileSystemElement
[1];
886 BusyIndicator
.showWhile(getShell().getDisplay(), new Runnable() {
889 // Create the root element from the supplied file system object
890 results
[0] = createRootElement(rootFileSystemObject
, structureProvider
);
896 private static TraceFileSystemElement
createRootElement(IFileSystemObject element
,
897 FileSystemObjectImportStructureProvider provider
) {
898 boolean isContainer
= provider
.isFolder(element
);
899 String elementLabel
= provider
.getLabel(element
);
901 // Use an empty label so that display of the element's full name
902 // doesn't include a confusing label
903 TraceFileSystemElement dummyParent
= new TraceFileSystemElement("", null, true, provider
);//$NON-NLS-1$
904 Object dummyParentFileSystemObject
= element
;
905 Object rawFileSystemObject
= element
.getRawFileSystemObject();
906 if (rawFileSystemObject
instanceof File
) {
907 dummyParentFileSystemObject
= provider
.getIFileSystemObject(((File
) rawFileSystemObject
).getParentFile());
909 dummyParent
.setFileSystemObject(dummyParentFileSystemObject
);
910 dummyParent
.setPopulated();
911 TraceFileSystemElement result
= new TraceFileSystemElement(
912 elementLabel
, dummyParent
, isContainer
, provider
);
913 result
.setFileSystemObject(element
);
915 //Get the files for the element so as to build the first level
921 // ------------------------------------------------------------------------
923 // ------------------------------------------------------------------------
924 private final void createTraceTypeGroup(Composite parent
) {
925 Composite composite
= new Composite(parent
, SWT
.NONE
);
926 GridLayout layout
= new GridLayout();
927 layout
.numColumns
= 3;
928 layout
.makeColumnsEqualWidth
= false;
929 composite
.setLayout(layout
);
930 composite
.setFont(parent
.getFont());
931 GridData buttonData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
932 composite
.setLayoutData(buttonData
);
934 // Trace type label ("Trace Type:")
935 Label typeLabel
= new Label(composite
, SWT
.NONE
);
936 typeLabel
.setText(Messages
.ImportTraceWizard_TraceType
);
937 typeLabel
.setFont(parent
.getFont());
940 fTraceTypes
= new Combo(composite
, SWT
.BORDER
| SWT
.READ_ONLY
);
941 GridData data
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 2, 1);
942 fTraceTypes
.setLayoutData(data
);
943 fTraceTypes
.setFont(parent
.getFont());
945 String
[] availableTraceTypes
= TmfTraceType
.getAvailableTraceTypes();
946 String
[] traceTypeList
= new String
[availableTraceTypes
.length
+ 1];
947 traceTypeList
[0] = AUTO_DETECT
;
948 for (int i
= 0; i
< availableTraceTypes
.length
; i
++) {
949 traceTypeList
[i
+ 1] = availableTraceTypes
[i
];
951 fTraceTypes
.setItems(traceTypeList
);
952 fTraceTypes
.addSelectionListener(new SelectionAdapter() {
954 public void widgetSelected(SelectionEvent e
) {
955 updateWidgetEnablements();
956 boolean enabled
= fTraceTypes
.getText().equals(AUTO_DETECT
);
957 fImportUnrecognizedButton
.setEnabled(enabled
);
960 fTraceTypes
.select(0);
962 // Unrecognized checkbox
963 fImportUnrecognizedButton
= new Button(composite
, SWT
.CHECK
);
964 fImportUnrecognizedButton
.setSelection(true);
965 fImportUnrecognizedButton
.setText(Messages
.ImportTraceWizard_ImportUnrecognized
);
968 // ------------------------------------------------------------------------
970 // ------------------------------------------------------------------------
973 protected void createOptionsGroupButtons(Group optionsGroup
) {
975 // Overwrite checkbox
976 fOverwriteExistingResourcesCheckbox
= new Button(optionsGroup
, SWT
.CHECK
);
977 fOverwriteExistingResourcesCheckbox
.setFont(optionsGroup
.getFont());
978 fOverwriteExistingResourcesCheckbox
.setText(Messages
.ImportTraceWizard_OverwriteExistingTrace
);
979 fOverwriteExistingResourcesCheckbox
.setSelection(false);
981 // Create links checkbox
982 fCreateLinksInWorkspaceButton
= new Button(optionsGroup
, SWT
.CHECK
);
983 fCreateLinksInWorkspaceButton
.setFont(optionsGroup
.getFont());
984 fCreateLinksInWorkspaceButton
.setText(Messages
.ImportTraceWizard_CreateLinksInWorkspace
);
985 fCreateLinksInWorkspaceButton
.setSelection(true);
987 fCreateLinksInWorkspaceButton
.addSelectionListener(new SelectionAdapter() {
989 public void widgetSelected(SelectionEvent e
) {
990 updateWidgetEnablements();
994 fPreserveFolderStructureButton
= new Button(optionsGroup
, SWT
.CHECK
);
995 fPreserveFolderStructureButton
.setFont(optionsGroup
.getFont());
996 fPreserveFolderStructureButton
.setText(Messages
.ImportTraceWizard_PreserveFolderStructure
);
997 fPreserveFolderStructureButton
.setSelection(true);
999 updateWidgetEnablements();
1002 // ------------------------------------------------------------------------
1003 // Determine if the finish button can be enabled
1004 // ------------------------------------------------------------------------
1006 public boolean validateSourceGroup() {
1008 File source
= fImportFromDirectoryRadio
.getSelection() ?
getSourceDirectory() : getSourceArchiveFile();
1009 if (source
== null) {
1010 setMessage(Messages
.ImportTraceWizard_SelectTraceSourceEmpty
);
1011 setErrorMessage(null);
1015 if (sourceConflictsWithDestination(new Path(source
.getPath()))) {
1017 setErrorMessage(getSourceConflictMessage());
1021 if (!fImportFromDirectoryRadio
.getSelection()) {
1022 if (!ensureTarSourceIsValid(source
.getAbsolutePath()) && !ensureZipSourceIsValid(source
.getAbsolutePath())) {
1024 setErrorMessage(Messages
.ImportTraceWizard_BadArchiveFormat
);
1029 if (fSelectionGroup
.getCheckedElementCount() == 0) {
1031 setErrorMessage(Messages
.ImportTraceWizard_SelectTraceNoneSelected
);
1035 IContainer container
= getSpecifiedContainer();
1036 if (container
!= null && container
.isVirtual()) {
1037 if (Platform
.getPreferencesService().getBoolean(Activator
.PLUGIN_ID
, ResourcesPlugin
.PREF_DISABLE_LINKING
, false, null)) {
1039 setErrorMessage(Messages
.ImportTraceWizard_CannotImportFilesUnderAVirtualFolder
);
1042 if (fCreateLinksInWorkspaceButton
== null || !fCreateLinksInWorkspaceButton
.getSelection()) {
1044 setErrorMessage(Messages
.ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder
);
1049 setErrorMessage(null);
1054 protected void restoreWidgetValues() {
1055 super.restoreWidgetValues();
1057 IDialogSettings settings
= getDialogSettings();
1059 if (settings
.get(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID
) == null) {
1062 value
= settings
.getBoolean(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID
);
1064 fImportUnrecognizedButton
.setSelection(value
);
1066 if (settings
.get(IMPORT_WIZARD_PRESERVE_FOLDERS_ID
) == null) {
1069 value
= settings
.getBoolean(IMPORT_WIZARD_PRESERVE_FOLDERS_ID
);
1071 fPreserveFolderStructureButton
.setSelection(value
);
1073 if (settings
.get(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY
) == null) {
1076 value
= settings
.getBoolean(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY
);
1078 restoreComboValues(directoryNameField
, settings
, IMPORT_WIZARD_ROOT_DIRECTORY_ID
);
1079 restoreComboValues(fArchiveNameField
, settings
, IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID
);
1081 fImportFromDirectoryRadio
.setSelection(value
);
1082 fImportFromArchiveRadio
.setSelection(!value
);
1084 directoryRadioSelected();
1086 archiveRadioSelected();
1091 protected void saveWidgetValues() {
1092 // Persist dialog settings
1093 IDialogSettings settings
= getDialogSettings();
1094 settings
.put(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID
, fImportUnrecognizedButton
.getSelection());
1095 settings
.put(IMPORT_WIZARD_PRESERVE_FOLDERS_ID
, fPreserveFolderStructureButton
.getSelection());
1096 settings
.put(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY
, fImportFromDirectoryRadio
.getSelection());
1098 saveComboValues(directoryNameField
, settings
, IMPORT_WIZARD_ROOT_DIRECTORY_ID
);
1099 saveComboValues(fArchiveNameField
, settings
, IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID
);
1102 private static void restoreComboValues(Combo combo
, IDialogSettings settings
, String key
) {
1103 String
[] directoryNames
= settings
.getArray(key
);
1104 if ((directoryNames
!= null) && (directoryNames
.length
!= 0)) {
1105 for (int i
= 0; i
< directoryNames
.length
; i
++) {
1106 combo
.add(directoryNames
[i
]);
1111 private void saveComboValues(Combo combo
, IDialogSettings settings
, String key
) {
1112 // update names history
1113 String
[] directoryNames
= settings
.getArray(key
);
1114 if (directoryNames
== null) {
1115 directoryNames
= new String
[0];
1118 String items
[] = combo
.getItems();
1119 for (int i
= 0; i
< items
.length
; i
++) {
1120 directoryNames
= addToHistory(directoryNames
, items
[i
]);
1122 settings
.put(key
, directoryNames
);
1125 // ------------------------------------------------------------------------
1126 // Import the trace(s)
1127 // ------------------------------------------------------------------------
1130 * Finish the import.
1132 * @return <code>true</code> if successful else <code>false</code>
1134 public boolean finish() {
1135 String traceTypeName
= fTraceTypes
.getText();
1136 String traceId
= null;
1137 if (!AUTO_DETECT
.equals(traceTypeName
)) {
1138 String tokens
[] = traceTypeName
.split(SEPARATOR
, 2);
1139 if (tokens
.length
< 2) {
1142 traceId
= TmfTraceType
.getTraceTypeId(tokens
[0], tokens
[1]);
1145 // Save dialog settings
1148 IPath baseSourceContainerPath
= new Path(getSourceContainerPath());
1149 boolean importFromArchive
= getSourceArchiveFile() != null;
1150 final TraceValidateAndImportOperation operation
= new TraceValidateAndImportOperation(traceId
, baseSourceContainerPath
, getContainerFullPath(), importFromArchive
,
1151 fImportUnrecognizedButton
.getSelection(), fOverwriteExistingResourcesCheckbox
.getSelection(), fCreateLinksInWorkspaceButton
.getSelection(), fPreserveFolderStructureButton
.getSelection());
1153 IStatus status
= Status
.OK_STATUS
;
1155 getContainer().run(true, true, new IRunnableWithProgress() {
1157 public void run(IProgressMonitor monitor
) throws InvocationTargetException
, InterruptedException
{
1158 operation
.run(monitor
);
1163 status
= operation
.getStatus();
1164 } catch (InvocationTargetException e
) {
1165 status
= new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, Messages
.ImportTraceWizard_ImportProblem
, e
);
1166 } catch (InterruptedException e
) {
1167 status
= Status
.CANCEL_STATUS
;
1169 if (!status
.isOK()) {
1170 if (status
.getSeverity() == IStatus
.CANCEL
) {
1171 setMessage(Messages
.ImportTraceWizard_ImportOperationCancelled
);
1172 setErrorMessage(null);
1174 if (status
.getException() != null) {
1175 displayErrorDialog(status
.getMessage() + ": " + status
.getException()); //$NON-NLS-1$
1178 setErrorMessage(Messages
.ImportTraceWizard_ImportProblem
);
1183 setErrorMessage(null);
1188 public void dispose() {
1190 disposeSelectionGroupRoot();
1193 // ------------------------------------------------------------------------
1195 // ------------------------------------------------------------------------
1197 private class TraceValidateAndImportOperation
{
1198 private IStatus fStatus
;
1199 private String fTraceType
;
1200 private IPath fDestinationContainerPath
;
1201 private IPath fBaseSourceContainerPath
;
1202 private boolean fImportFromArchive
;
1203 private boolean fImportUnrecognizedTraces
;
1204 private boolean fLink
;
1205 private boolean fPreserveFolderStructure
;
1206 private ImportConfirmation fConfirmationMode
= ImportConfirmation
.SKIP
;
1208 private TraceValidateAndImportOperation(String traceId
, IPath baseSourceContainerPath
, IPath destinationContainerPath
, boolean importFromArchive
, boolean doImport
, boolean overwrite
, boolean link
, boolean preserveFolderStructure
) {
1209 fTraceType
= traceId
;
1210 fBaseSourceContainerPath
= baseSourceContainerPath
;
1211 fDestinationContainerPath
= destinationContainerPath
;
1212 fImportFromArchive
= importFromArchive
;
1213 fImportUnrecognizedTraces
= doImport
;
1215 fConfirmationMode
= ImportConfirmation
.OVERWRITE_ALL
;
1218 fPreserveFolderStructure
= preserveFolderStructure
;
1221 public void run(IProgressMonitor progressMonitor
) {
1222 String currentPath
= null;
1223 final Map
<String
, TraceFileSystemElement
> folderElements
= new HashMap
<>();
1226 final ArrayList
<TraceFileSystemElement
> fileSystemElements
= new ArrayList
<>();
1227 IElementFilter passThroughFilter
= new IElementFilter() {
1230 public void filterElements(Collection elements
, IProgressMonitor monitor
) {
1231 fileSystemElements
.addAll(elements
);
1234 public void filterElements(Object
[] elements
, IProgressMonitor monitor
) {
1235 for (int i
= 0; i
< elements
.length
; i
++) {
1236 fileSystemElements
.add((TraceFileSystemElement
)elements
[i
]);
1241 // List fileSystemElements will be filled using the passThroughFilter
1242 SubMonitor subMonitor
= SubMonitor
.convert(progressMonitor
, 1);
1243 fSelectionGroup
.getAllCheckedListItems(passThroughFilter
, subMonitor
);
1245 // Check if operation was cancelled.
1246 ModalContext
.checkCanceled(subMonitor
);
1248 Iterator
<TraceFileSystemElement
> fileSystemElementsIter
= fileSystemElements
.iterator();
1249 IFolder destTempFolder
= null;
1250 subMonitor
= SubMonitor
.convert(progressMonitor
, fileSystemElements
.size());
1251 if (fImportFromArchive
) {
1252 // When importing from archive, we first extract the
1253 // *selected* files to a temporary folder then create a new
1254 // Iterator<TraceFileSystemElement> that points to the
1255 // extracted files. This way, the import operator can
1256 // continue as it normally would.
1258 subMonitor
= SubMonitor
.convert(progressMonitor
, fileSystemElements
.size() * 2);
1259 destTempFolder
= fTargetFolder
.getProject().getFolder(TRACE_IMPORT_TEMP_FOLDER
);
1260 if (destTempFolder
.exists()) {
1261 SubProgressMonitor monitor
= new SubProgressMonitor(subMonitor
, 1, SubProgressMonitor
.PREPEND_MAIN_LABEL_TO_SUBTASK
);
1262 destTempFolder
.delete(true, monitor
);
1264 SubProgressMonitor monitor
= new SubProgressMonitor(subMonitor
, 1, SubProgressMonitor
.PREPEND_MAIN_LABEL_TO_SUBTASK
);
1265 destTempFolder
.create(IResource
.HIDDEN
, true, monitor
);
1267 fileSystemElementsIter
= extractSelectedFiles(fileSystemElementsIter
, destTempFolder
, subMonitor
);
1268 // We need to update the source container path because the
1269 // "preserve folder structure" option would create the
1270 // wrong folders otherwise.
1271 fBaseSourceContainerPath
= destTempFolder
.getLocation();
1274 while (fileSystemElementsIter
.hasNext()) {
1275 ModalContext
.checkCanceled(progressMonitor
);
1277 TraceFileSystemElement element
= fileSystemElementsIter
.next();
1278 IFileSystemObject fileSystemObject
= element
.getFileSystemObject();
1279 String resourcePath
= element
.getFileSystemObject().getAbsolutePath(fBaseSourceContainerPath
.toOSString());
1280 element
.setDestinationContainerPath(computeDestinationContainerPath(new Path(resourcePath
)));
1282 currentPath
= resourcePath
;
1283 SubMonitor sub
= subMonitor
.newChild(1);
1284 if (element
.isDirectory()) {
1285 if (!folderElements
.containsKey(resourcePath
)) {
1286 if (isDirectoryTrace(element
)) {
1287 folderElements
.put(resourcePath
, element
);
1288 validateAndImportTrace(element
, sub
);
1292 TraceFileSystemElement parentElement
= (TraceFileSystemElement
)element
.getParent();
1293 String parentPath
= parentElement
.getFileSystemObject().getAbsolutePath(fBaseSourceContainerPath
.toOSString());
1294 parentElement
.setDestinationContainerPath(computeDestinationContainerPath(new Path(parentPath
)));
1295 currentPath
= parentPath
;
1296 if (!folderElements
.containsKey(parentPath
)) {
1297 if (isDirectoryTrace(parentElement
)) {
1298 folderElements
.put(parentPath
, parentElement
);
1299 validateAndImportTrace(parentElement
, sub
);
1301 if (fileSystemObject
.exists()) {
1302 validateAndImportTrace(element
, sub
);
1309 if (destTempFolder
!= null && destTempFolder
.exists()) {
1310 destTempFolder
.delete(true, progressMonitor
);
1313 setStatus(Status
.OK_STATUS
);
1314 } catch (InterruptedException e
) {
1315 setStatus(Status
.CANCEL_STATUS
);
1316 } catch (Exception e
) {
1317 String errorMessage
= Messages
.ImportTraceWizard_ImportProblem
+ ": " + //$NON-NLS-1$
1318 (currentPath
!= null ? currentPath
: ""); //$NON-NLS-1$
1319 Activator
.getDefault().logError(errorMessage
, e
);
1320 setStatus(new Status(IStatus
.ERROR
, Activator
.PLUGIN_ID
, errorMessage
, e
));
1324 private Iterator
<TraceFileSystemElement
> extractSelectedFiles(Iterator
<TraceFileSystemElement
> fileSystemElementsIter
, IFolder tempFolder
, IProgressMonitor progressMonitor
) throws InterruptedException
,
1325 InvocationTargetException
{
1326 List
<TraceFileSystemElement
> subList
= new ArrayList
<>();
1327 // Collect all the elements
1328 while (fileSystemElementsIter
.hasNext()) {
1329 ModalContext
.checkCanceled(progressMonitor
);
1330 TraceFileSystemElement element
= fileSystemElementsIter
.next();
1331 if (element
.isDirectory()) {
1332 Object
[] array
= element
.getFiles().getChildren();
1333 for (int i
= 0; i
< array
.length
; i
++) {
1334 subList
.add((TraceFileSystemElement
)array
[i
]);
1337 subList
.add(element
);
1340 // Find a sensible root element
1341 TraceFileSystemElement root
= subList
.get(0);
1342 while (root
.getParent() != null) {
1343 root
= (TraceFileSystemElement
) root
.getParent();
1346 ImportProvider fileSystemStructureProvider
= new ImportProvider();
1348 IOverwriteQuery myQueryImpl
= new IOverwriteQuery() {
1350 public String
queryOverwrite(String file
) {
1351 return IOverwriteQuery
.NO_ALL
;
1355 progressMonitor
.setTaskName(Messages
.ImportTraceWizard_ExtractImportOperationTaskName
);
1356 IPath containerPath
= tempFolder
.getFullPath();
1357 ImportOperation operation
= new ImportOperation(containerPath
, root
, fileSystemStructureProvider
, myQueryImpl
, subList
);
1358 operation
.setContext(getShell());
1360 operation
.setCreateContainerStructure(true);
1361 operation
.setOverwriteResources(false);
1362 operation
.setVirtualFolders(false);
1364 operation
.run(new SubProgressMonitor(progressMonitor
, subList
.size(), SubProgressMonitor
.PREPEND_MAIN_LABEL_TO_SUBTASK
));
1366 // Create the new import provider and root element based on the extracted temp folder
1367 FileSystemObjectImportStructureProvider importStructureProvider
= new FileSystemObjectImportStructureProvider(FileSystemStructureProvider
.INSTANCE
, null);
1368 IFileSystemObject rootElement
= importStructureProvider
.getIFileSystemObject(new File(tempFolder
.getLocation().toOSString()));
1369 TraceFileSystemElement createRootElement
= createRootElement(rootElement
, importStructureProvider
);
1370 List
<TraceFileSystemElement
> list
= new ArrayList
<>();
1371 getAllChildren(list
, createRootElement
);
1372 Iterator
<TraceFileSystemElement
> extractedElementsIter
= list
.iterator();
1373 return extractedElementsIter
;
1377 * Get all the TraceFileSystemElements recursively.
1380 * the list accumulating the result
1381 * @param rootElement
1382 * the root element of the file system to be imported
1384 private void getAllChildren(List
<TraceFileSystemElement
> result
, TraceFileSystemElement rootElement
) {
1385 AdaptableList files
= rootElement
.getFiles();
1386 for (Object file
: files
.getChildren()) {
1387 result
.add((TraceFileSystemElement
) file
);
1390 AdaptableList folders
= rootElement
.getFolders();
1391 for (Object folder
: folders
.getChildren()) {
1392 getAllChildren(result
, (TraceFileSystemElement
)folder
);
1396 private IPath
computeDestinationContainerPath(Path resourcePath
) {
1397 IPath destinationContainerPath
= fDestinationContainerPath
;
1399 // We need to figure out the new destination path relative to the selected "base" source directory.
1400 // Here for example, the selected source directory is /home/user
1401 if (fPreserveFolderStructure
) {
1402 // /home/user/bar/foo/trace -> /home/user/bar/foo
1403 IPath sourceContainerPath
= resourcePath
.removeLastSegments(1);
1404 if (fBaseSourceContainerPath
.equals(resourcePath
)) {
1405 // Use resourcePath directory if fBaseSourceContainerPath points to a directory trace
1406 sourceContainerPath
= resourcePath
;
1408 // /home/user/bar/foo, /home/user -> bar/foo
1409 IPath relativeContainerPath
= sourceContainerPath
.makeRelativeTo(fBaseSourceContainerPath
);
1410 // project/Traces + bar/foo -> project/Traces/bar/foo
1411 destinationContainerPath
= fDestinationContainerPath
.append(relativeContainerPath
);
1413 return destinationContainerPath
;
1416 private void validateAndImportTrace(TraceFileSystemElement fileSystemElement
, IProgressMonitor monitor
)
1417 throws TmfTraceImportException
, CoreException
, InvocationTargetException
, InterruptedException
{
1418 String parentContainerPath
= fBaseSourceContainerPath
.toOSString();
1419 String path
= fileSystemElement
.getFileSystemObject().getAbsolutePath(parentContainerPath
);
1420 TraceTypeHelper traceTypeHelper
= null;
1422 if (fTraceType
== null) {
1425 traceTypeHelper
= TmfTraceTypeUIUtils
.selectTraceType(path
, null, null);
1426 } catch (TmfTraceImportException e
) {
1427 // the trace did not match any trace type
1429 if (traceTypeHelper
== null) {
1430 if (fImportUnrecognizedTraces
) {
1431 importResource(fileSystemElement
, monitor
);
1436 boolean isDirectoryTraceType
= TmfTraceType
.isDirectoryTraceType(fTraceType
);
1437 if (fileSystemElement
.isDirectory() != isDirectoryTraceType
) {
1440 traceTypeHelper
= TmfTraceType
.getTraceType(fTraceType
);
1442 if (traceTypeHelper
== null) {
1443 // Trace type not found
1444 throw new TmfTraceImportException(Messages
.ImportTraceWizard_TraceTypeNotFound
);
1447 if (!traceTypeHelper
.validate(path
).isOK()) {
1448 // Trace type exist but doesn't validate for given trace.
1453 // Finally import trace
1454 IResource importedResource
= importResource(fileSystemElement
, monitor
);
1455 if (importedResource
!= null) {
1456 TmfTraceTypeUIUtils
.setTraceType(importedResource
, traceTypeHelper
);
1462 * Imports a trace resource to project. In case of name collision the
1463 * user will be asked to confirm overwriting the existing trace,
1464 * overwriting or skipping the trace to be imported.
1466 * @param fileSystemElement
1467 * trace file system object to import
1469 * a progress monitor
1470 * @return the imported resource or null if no resource was imported
1472 * @throws InvocationTargetException
1473 * if problems during import operation
1474 * @throws InterruptedException
1476 * @throws CoreException
1477 * if problems with workspace
1479 private IResource
importResource(TraceFileSystemElement fileSystemElement
, IProgressMonitor monitor
)
1480 throws InvocationTargetException
, InterruptedException
, CoreException
{
1482 ImportConfirmation mode
= checkForNameClashes(fileSystemElement
);
1486 rename(fileSystemElement
);
1490 delete(fileSystemElement
, monitor
);
1500 List
<TraceFileSystemElement
> subList
= new ArrayList
<>();
1502 FileSystemElement parentFolder
= fileSystemElement
.getParent();
1504 IPath containerPath
= fileSystemElement
.getDestinationContainerPath();
1505 IPath tracePath
= containerPath
.addTrailingSeparator().append(fileSystemElement
.getLabel());
1506 if (fileSystemElement
.isDirectory() && (!fLink
)) {
1507 containerPath
= tracePath
;
1509 Object
[] array
= fileSystemElement
.getFiles().getChildren();
1510 for (int i
= 0; i
< array
.length
; i
++) {
1511 subList
.add((TraceFileSystemElement
)array
[i
]);
1513 parentFolder
= fileSystemElement
;
1516 subList
.add(fileSystemElement
);
1520 ImportProvider fileSystemStructureProvider
= new ImportProvider();
1522 IOverwriteQuery myQueryImpl
= new IOverwriteQuery() {
1524 public String
queryOverwrite(String file
) {
1525 return IOverwriteQuery
.NO_ALL
;
1529 monitor
.setTaskName(Messages
.ImportTraceWizard_ImportOperationTaskName
+ " " + fileSystemElement
.getFileSystemObject().getAbsolutePath(fBaseSourceContainerPath
.toOSString())); //$NON-NLS-1$
1530 ImportOperation operation
= new ImportOperation(containerPath
, parentFolder
, fileSystemStructureProvider
, myQueryImpl
, subList
);
1531 operation
.setContext(getShell());
1533 operation
.setCreateContainerStructure(false);
1534 operation
.setOverwriteResources(false);
1535 operation
.setCreateLinks(fLink
);
1536 operation
.setVirtualFolders(false);
1538 operation
.run(new SubProgressMonitor(monitor
, 1, SubProgressMonitor
.PREPEND_MAIN_LABEL_TO_SUBTASK
));
1539 String sourceLocation
= fileSystemElement
.getFileSystemObject().getSourceLocation();
1540 IResource resource
= ResourcesPlugin
.getWorkspace().getRoot().findMember(tracePath
);
1541 if (sourceLocation
!= null) {
1542 resource
.setPersistentProperty(TmfCommonConstants
.SOURCE_LOCATION
, sourceLocation
);
1548 private boolean isDirectoryTrace(TraceFileSystemElement fileSystemElement
) {
1549 String path
= fileSystemElement
.getFileSystemObject().getAbsolutePath(fBaseSourceContainerPath
.toOSString());
1550 if (TmfTraceType
.isDirectoryTrace(path
)) {
1556 private ImportConfirmation
checkForNameClashes(TraceFileSystemElement fileSystemElement
) throws InterruptedException
{
1557 IPath tracePath
= getInitialDestinationPath(fileSystemElement
);
1560 if (getExistingTrace(tracePath
) != null) {
1561 if ((fConfirmationMode
== ImportConfirmation
.RENAME_ALL
) ||
1562 (fConfirmationMode
== ImportConfirmation
.OVERWRITE_ALL
) ||
1563 (fConfirmationMode
== ImportConfirmation
.SKIP_ALL
)) {
1564 return fConfirmationMode
;
1567 int returnCode
= promptForOverwrite(tracePath
);
1568 if (returnCode
< 0) {
1570 throw new InterruptedException();
1572 fConfirmationMode
= ImportConfirmation
.values()[returnCode
];
1573 return fConfirmationMode
;
1575 return ImportConfirmation
.CONTINUE
;
1578 private int promptForOverwrite(IPath tracePath
) {
1579 final MessageDialog dialog
= new MessageDialog(getContainer()
1580 .getShell(), null, null, NLS
.bind(Messages
.ImportTraceWizard_TraceAlreadyExists
, tracePath
.makeRelativeTo(fTraceFolderElement
.getProject().getPath())),
1581 MessageDialog
.QUESTION
, new String
[] {
1582 ImportConfirmation
.RENAME
.getInName(),
1583 ImportConfirmation
.RENAME_ALL
.getInName(),
1584 ImportConfirmation
.OVERWRITE
.getInName(),
1585 ImportConfirmation
.OVERWRITE_ALL
.getInName(),
1586 ImportConfirmation
.SKIP
.getInName(),
1587 ImportConfirmation
.SKIP_ALL
.getInName(),
1590 protected int getShellStyle() {
1591 return super.getShellStyle() | SWT
.SHEET
;
1595 final int[] returnValue
= new int[1];
1596 getShell().getDisplay().syncExec(new Runnable() {
1600 returnValue
[0] = dialog
.open();
1603 return returnValue
[0];
1607 * @return the initial destination path, before rename, if any
1609 private IPath
getInitialDestinationPath(TraceFileSystemElement fileSystemElement
) {
1610 IPath traceFolderPath
= fileSystemElement
.getDestinationContainerPath();
1611 return traceFolderPath
.append(fileSystemElement
.getFileSystemObject().getLabel());
1614 private void rename(TraceFileSystemElement fileSystemElement
) {
1615 IPath tracePath
= getInitialDestinationPath(fileSystemElement
);
1616 TmfTraceElement trace
= getExistingTrace(tracePath
);
1617 if (trace
== null) {
1621 // Not using IFolder on purpose to leave the door open to import directly into an IProject
1622 IContainer folder
= (IContainer
) trace
.getParent().getResource();
1625 String name
= trace
.getName() + '(' + Integer
.toString(i
++) + ')';
1626 IResource resource
= folder
.findMember(name
);
1627 if (resource
== null) {
1628 fileSystemElement
.setLabel(name
);
1634 private void delete(TraceFileSystemElement fileSystemElement
, IProgressMonitor monitor
) throws CoreException
{
1635 IPath tracePath
= getInitialDestinationPath(fileSystemElement
);
1636 TmfTraceElement trace
= getExistingTrace(tracePath
);
1637 if (trace
== null) {
1641 trace
.delete(monitor
);
1644 private TmfTraceElement
getExistingTrace(IPath tracePath
) {
1645 List
<TmfTraceElement
> traces
= fTraceFolderElement
.getTraces();
1646 for (TmfTraceElement t
: traces
) {
1647 if (t
.getPath().equals(tracePath
)) {
1655 * Set the status for this operation
1660 protected void setStatus(IStatus status
) {
1664 public IStatus
getStatus() {
1670 * The <code>TraceFileSystemElement</code> is a <code>FileSystemElement</code> that knows
1671 * if it has been populated or not.
1673 private static class TraceFileSystemElement
extends FileSystemElement
{
1675 private boolean fIsPopulated
= false;
1676 private String fLabel
= null;
1677 private IPath fDestinationContainerPath
;
1678 private FileSystemObjectImportStructureProvider fProvider
;
1680 public TraceFileSystemElement(String name
, FileSystemElement parent
, boolean isDirectory
, FileSystemObjectImportStructureProvider provider
) {
1681 super(name
, parent
, isDirectory
);
1682 fProvider
= provider
;
1685 public void setDestinationContainerPath(IPath destinationContainerPath
) {
1686 fDestinationContainerPath
= destinationContainerPath
;
1689 public void setPopulated() {
1690 fIsPopulated
= true;
1693 public boolean isPopulated() {
1694 return fIsPopulated
;
1698 public AdaptableList
getFiles() {
1700 populateElementChildren();
1702 return super.getFiles();
1706 public AdaptableList
getFolders() {
1708 populateElementChildren();
1710 return super.getFolders();
1714 * Sets the label for the trace to be used when importing at trace.
1716 * the label for the trace
1718 public void setLabel(String name
) {
1723 * Returns the label for the trace to be used when importing at trace.
1725 * @return the label of trace resource
1727 public String
getLabel() {
1728 if (fLabel
== null) {
1729 return getFileSystemObject().getLabel();
1735 * The full path to the container that will contain the trace
1737 * @return the destination container path
1739 public IPath
getDestinationContainerPath() {
1740 return fDestinationContainerPath
;
1744 * Populates the children of the specified parent <code>FileSystemElement</code>
1746 private void populateElementChildren() {
1747 List
<IFileSystemObject
> allchildren
= fProvider
.getChildren(this.getFileSystemObject());
1748 Object child
= null;
1749 TraceFileSystemElement newelement
= null;
1750 Iterator
<IFileSystemObject
> iter
= allchildren
.iterator();
1751 while(iter
.hasNext()) {
1752 child
= iter
.next();
1753 newelement
= new TraceFileSystemElement(fProvider
.getLabel(child
), this, fProvider
.isFolder(child
), fProvider
);
1754 newelement
.setFileSystemObject(child
);
1759 public FileSystemObjectImportStructureProvider
getProvider() {
1764 public IFileSystemObject
getFileSystemObject() {
1765 Object fileSystemObject
= super.getFileSystemObject();
1766 return (IFileSystemObject
) fileSystemObject
;
1771 * This interface abstracts the differences between different kinds of
1772 * FileSystemObjects such as File, TarEntry and ZipEntry. This allows
1773 * clients (TraceFileSystemElement, TraceValidateAndImportOperation) to
1774 * handle all the types transparently.
1776 private interface IFileSystemObject
{
1778 String
getAbsolutePath(String parentContainerPath
);
1779 String
getSourceLocation();
1780 Object
getRawFileSystemObject();
1785 * The "File" implementation of an IFileSystemObject
1787 private static class FileFileSystemObject
implements IFileSystemObject
{
1789 private File fFileSystemObject
;
1791 private FileFileSystemObject(File fileSystemObject
) {
1792 fFileSystemObject
= fileSystemObject
;
1796 public String
getLabel() {
1797 String name
= fFileSystemObject
.getName();
1798 if (name
.length() == 0) {
1799 return fFileSystemObject
.getPath();
1805 public String
getAbsolutePath(String parentContainerPath
) {
1806 return fFileSystemObject
.getAbsolutePath();
1810 public boolean exists() {
1811 return fFileSystemObject
.exists();
1815 public String
getSourceLocation() {
1816 IResource sourceResource
;
1817 String sourceLocation
= null;
1818 if (fFileSystemObject
.isDirectory()) {
1819 sourceResource
= ResourcesPlugin
.getWorkspace().getRoot().getContainerForLocation(Path
.fromOSString(fFileSystemObject
.getAbsolutePath()));
1821 sourceResource
= ResourcesPlugin
.getWorkspace().getRoot().getFileForLocation(Path
.fromOSString(fFileSystemObject
.getAbsolutePath()));
1823 if (sourceResource
!= null && sourceResource
.exists()) {
1825 sourceLocation
= sourceResource
.getPersistentProperty(TmfCommonConstants
.SOURCE_LOCATION
);
1826 } catch (CoreException e
) {
1827 // Something went wrong with the already existing resource.
1828 // This is not a problem, we'll assign a new location below.
1831 if (sourceLocation
== null) {
1832 sourceLocation
= URIUtil
.toUnencodedString(fFileSystemObject
.toURI());
1834 return sourceLocation
;
1838 public Object
getRawFileSystemObject() {
1839 return fFileSystemObject
;
1844 * The "Tar" implementation of an IFileSystemObject
1846 private static class TarFileSystemObject
implements IFileSystemObject
{
1848 private TarEntry fFileSystemObject
;
1849 private String fArchivePath
;
1851 private TarFileSystemObject(TarEntry fileSystemObject
, String archivePath
) {
1852 fFileSystemObject
= fileSystemObject
;
1853 fArchivePath
= archivePath
;
1857 public String
getLabel() {
1858 return new Path(fFileSystemObject
.getName()).lastSegment();
1862 public String
getAbsolutePath(String parentContainerPath
) {
1863 return new Path(parentContainerPath
).append(fFileSystemObject
.getName()).toOSString();
1867 public boolean exists() {
1872 public String
getSourceLocation() {
1873 URI uri
= new File(fArchivePath
).toURI();
1874 IPath entryPath
= new Path(fFileSystemObject
.getName());
1875 return URIUtil
.toUnencodedString(URIUtil
.toJarURI(uri
, entryPath
));
1879 public Object
getRawFileSystemObject() {
1880 return fFileSystemObject
;
1885 * The "Zip" implementation of an IFileSystemObject
1887 private static class ZipFileSystemObject
implements IFileSystemObject
{
1889 private ZipEntry fFileSystemObject
;
1890 private String fArchivePath
;
1892 private ZipFileSystemObject(ZipEntry fileSystemObject
, String archivePath
) {
1893 fFileSystemObject
= fileSystemObject
;
1894 fArchivePath
= archivePath
;
1898 public String
getLabel() {
1899 return new Path(fFileSystemObject
.getName()).lastSegment();
1903 public String
getAbsolutePath(String parentContainerPath
) {
1904 return new Path(parentContainerPath
).append(fFileSystemObject
.getName()).toOSString();
1908 public boolean exists() {
1913 public String
getSourceLocation() {
1914 URI uri
= new File(fArchivePath
).toURI();
1915 IPath entryPath
= new Path(fFileSystemObject
.getName());
1916 return URIUtil
.toUnencodedString(URIUtil
.toJarURI(uri
, entryPath
));
1920 public Object
getRawFileSystemObject() {
1921 return fFileSystemObject
;
1925 private class ImportProvider
implements IImportStructureProvider
{
1931 public String
getLabel(Object element
) {
1932 TraceFileSystemElement resource
= (TraceFileSystemElement
)element
;
1933 return resource
.getLabel();
1937 public List
getChildren(Object element
) {
1938 TraceFileSystemElement resource
= (TraceFileSystemElement
)element
;
1939 Object
[] array
= resource
.getFiles().getChildren();
1940 List
<Object
> list
= new ArrayList
<>();
1941 for (int i
= 0; i
< array
.length
; i
++) {
1948 public InputStream
getContents(Object element
) {
1949 TraceFileSystemElement resource
= (TraceFileSystemElement
)element
;
1950 return resource
.getProvider().getContents(resource
.getFileSystemObject());
1954 public String
getFullPath(Object element
) {
1955 TraceFileSystemElement resource
= (TraceFileSystemElement
)element
;
1956 return resource
.getProvider().getFullPath(resource
.getFileSystemObject());
1960 public boolean isFolder(Object element
) {
1961 TraceFileSystemElement resource
= (TraceFileSystemElement
)element
;
1962 return resource
.isDirectory();
1966 private enum ImportConfirmation
{
1967 // ------------------------------------------------------------------------
1969 // ------------------------------------------------------------------------
1970 RENAME(Messages
.ImportTraceWizard_ImportConfigurationRename
),
1971 RENAME_ALL(Messages
.ImportTraceWizard_ImportConfigurationRenameAll
),
1972 OVERWRITE(Messages
.ImportTraceWizard_ImportConfigurationOverwrite
),
1973 OVERWRITE_ALL(Messages
.ImportTraceWizard_ImportConfigurationOverwriteAll
),
1974 SKIP(Messages
.ImportTraceWizard_ImportConfigurationSkip
),
1975 SKIP_ALL(Messages
.ImportTraceWizard_ImportConfigurationSkipAll
),
1976 CONTINUE("CONTINUE"); //$NON-NLS-1$
1978 // ------------------------------------------------------------------------
1980 // ------------------------------------------------------------------------
1984 private final String fInName
;
1986 // ------------------------------------------------------------------------
1988 // ------------------------------------------------------------------------
1991 * Private constructor
1992 * @param name the name of state
1994 private ImportConfirmation(String name
) {
1998 // ------------------------------------------------------------------------
2000 // ------------------------------------------------------------------------
2002 * @return state name
2004 public String
getInName() {