tmf: Add automatic trace type detection to import trace wizard
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / wizards / importtrace / ImportTraceWizardPage.java
CommitLineData
002f9f07 1/*******************************************************************************
252c602c 2 * Copyright (c) 2009, 2014 Ericsson and others.
002f9f07
BH
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * 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
252c602c 16 * Bernd Hufmann - Re-design of trace selection and trace validation
002f9f07
BH
17 *******************************************************************************/
18
19package org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace;
20
21import java.io.File;
16f91bd5 22import java.io.InputStream;
002f9f07
BH
23import java.lang.reflect.InvocationTargetException;
24import java.util.ArrayList;
002f9f07
BH
25import java.util.HashMap;
26import java.util.Iterator;
002f9f07
BH
27import java.util.List;
28import java.util.Map;
002f9f07
BH
29
30import org.eclipse.core.resources.IContainer;
31import org.eclipse.core.resources.IFolder;
32import org.eclipse.core.resources.IProject;
33import org.eclipse.core.resources.IResource;
34import org.eclipse.core.resources.ResourcesPlugin;
35import org.eclipse.core.runtime.CoreException;
36import org.eclipse.core.runtime.IPath;
252c602c 37import org.eclipse.core.runtime.IProgressMonitor;
002f9f07 38import org.eclipse.core.runtime.IStatus;
252c602c 39import org.eclipse.core.runtime.NullProgressMonitor;
002f9f07
BH
40import org.eclipse.core.runtime.Path;
41import org.eclipse.core.runtime.Platform;
252c602c
BH
42import org.eclipse.core.runtime.Status;
43import org.eclipse.core.runtime.SubMonitor;
44import org.eclipse.core.runtime.SubProgressMonitor;
45import org.eclipse.jface.dialogs.IDialogSettings;
16f91bd5 46import org.eclipse.jface.dialogs.MessageDialog;
252c602c
BH
47import org.eclipse.jface.operation.IRunnableWithProgress;
48import org.eclipse.jface.operation.ModalContext;
002f9f07
BH
49import org.eclipse.jface.viewers.IStructuredSelection;
50import org.eclipse.jface.viewers.ITreeContentProvider;
51import org.eclipse.linuxtools.internal.tmf.ui.Activator;
252c602c 52import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
002f9f07 53import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
252c602c 54import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceImportException;
002f9f07
BH
55import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType;
56import org.eclipse.linuxtools.tmf.core.project.model.TraceTypeHelper;
002f9f07 57import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectRegistry;
16f91bd5 58import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
002f9f07
BH
59import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
60import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceTypeUIUtils;
61import org.eclipse.linuxtools.tmf.ui.project.wizards.Messages;
16f91bd5 62import org.eclipse.osgi.util.NLS;
002f9f07
BH
63import org.eclipse.swt.SWT;
64import org.eclipse.swt.custom.BusyIndicator;
65import org.eclipse.swt.events.FocusEvent;
66import org.eclipse.swt.events.FocusListener;
67import org.eclipse.swt.events.KeyEvent;
68import org.eclipse.swt.events.KeyListener;
69import org.eclipse.swt.events.SelectionAdapter;
70import org.eclipse.swt.events.SelectionEvent;
71import org.eclipse.swt.events.SelectionListener;
72import org.eclipse.swt.layout.GridData;
73import org.eclipse.swt.layout.GridLayout;
74import org.eclipse.swt.widgets.Button;
75import org.eclipse.swt.widgets.Combo;
76import org.eclipse.swt.widgets.Composite;
77import org.eclipse.swt.widgets.DirectoryDialog;
78import org.eclipse.swt.widgets.Event;
79import org.eclipse.swt.widgets.Group;
80import org.eclipse.swt.widgets.Label;
81import org.eclipse.ui.IWorkbench;
82import org.eclipse.ui.dialogs.FileSystemElement;
252c602c 83import org.eclipse.ui.dialogs.IOverwriteQuery;
002f9f07 84import org.eclipse.ui.dialogs.WizardResourceImportPage;
252c602c 85import org.eclipse.ui.model.AdaptableList;
002f9f07 86import org.eclipse.ui.model.WorkbenchContentProvider;
002f9f07
BH
87import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
88import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
89import org.eclipse.ui.wizards.datatransfer.ImportOperation;
90
91/**
252c602c
BH
92 * A variant of the standard resource import wizard for importing traces
93 * to given tracing project. If no project or tracing project was selected
94 * the wizard imports it to the default tracing project which is created
95 * if necessary.
96 *
97 * In our case traces could be files or a directory structure. This wizard
98 * supports both cases. It imports traces for a selected trace type or, if
99 * no trace type is selected, it tries to detect the trace type automatically.
100 * However, the automatic detection is a best-effort and cannot guarantee
101 * that the detection is successful. The reason for this is that there might
102 * be multiple trace types that can be assigned to a single trace.
103 *
002f9f07 104 *
002f9f07
BH
105 * @author Francois Chouinard
106 * @since 2.0
107 */
108public class ImportTraceWizardPage extends WizardResourceImportPage {
109
002f9f07
BH
110 // ------------------------------------------------------------------------
111 // Constants
112 // ------------------------------------------------------------------------
002f9f07 113 private static final String IMPORT_WIZARD_PAGE = "ImportTraceWizardPage"; //$NON-NLS-1$
252c602c
BH
114 private static final String IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID = IMPORT_WIZARD_PAGE + ".import_unrecognized_traces_id"; //$NON-NLS-1$
115 private static final String SEPARATOR = ":"; //$NON-NLS-1$
116 private static final String AUTO_DETECT = Messages.ImportTraceWizard_AutoDetection;
002f9f07
BH
117
118 // ------------------------------------------------------------------------
119 // Attributes
120 // ------------------------------------------------------------------------
121
122 // Folder navigation start point (saved between invocations)
123 private static String fRootDirectory = null;
002f9f07
BH
124 // Target import directory ('Traces' folder)
125 private IFolder fTargetFolder;
16f91bd5
BH
126 // Target Trace folder element
127 private TmfTraceFolder fTraceFolderElement;
252c602c
BH
128 // Flag to handle destination folder change event
129 private Boolean fIsDestinationChanged = false;
130 // Combo box containing trace types
131 private Combo fTraceTypes;
132 // Button to ignore unrecognized traces or not
133 private Button fImportUnrecognizedButton;
134 // Button to overwrite existing resources or not
135 private Button fOverwriteExistingResourcesCheckbox;
136 // Button to link or copy traces to workspace
137 private Button fCreateLinksInWorkspaceButton;
138 private boolean entryChanged = false;
139 /** The directory name field */
140 protected Combo directoryNameField;
141 /** The directory browse button. */
142 protected Button directoryBrowseButton;
002f9f07
BH
143
144 // ------------------------------------------------------------------------
145 // Constructors
146 // ------------------------------------------------------------------------
147
148 /**
149 * Constructor. Creates the trace wizard page.
150 *
151 * @param name
152 * The name of the page.
153 * @param selection
154 * The current selection
155 */
156 protected ImportTraceWizardPage(String name, IStructuredSelection selection) {
157 super(name, selection);
158 }
159
160 /**
161 * Constructor
162 *
163 * @param workbench
164 * The workbench reference.
165 * @param selection
166 * The current selection
167 */
168 public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) {
169 this(IMPORT_WIZARD_PAGE, selection);
170 setTitle(Messages.ImportTraceWizard_FileSystemTitle);
171 setDescription(Messages.ImportTraceWizard_ImportTrace);
172
173 // Locate the target trace folder
174 IFolder traceFolder = null;
175 Object element = selection.getFirstElement();
176
177 if (element instanceof TmfTraceFolder) {
16f91bd5
BH
178 fTraceFolderElement = (TmfTraceFolder) element;
179 fTraceFolderElement.getProject().getResource();
180 traceFolder = fTraceFolderElement.getResource();
002f9f07
BH
181 } else if (element instanceof IProject) {
182 IProject project = (IProject) element;
183 try {
184 if (project.hasNature(TmfProjectNature.ID)) {
252c602c 185 traceFolder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
16f91bd5 186 fTraceFolderElement = TmfProjectRegistry.getProject(project).getTracesFolder();
002f9f07
BH
187 }
188 } catch (CoreException e) {
189 }
190 }
191
252c602c
BH
192 /*
193 * If no tracing project was selected or trace folder doesn't exist use
194 */
195 if (traceFolder == null) {
196 IProject project = TmfProjectRegistry.createProject(
197 TmfCommonConstants.DEFAULT_TRACE_PROJECT_NAME, null, new NullProgressMonitor());
198 traceFolder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
16f91bd5 199 fTraceFolderElement = TmfProjectRegistry.getProject(project).getTracesFolder();
252c602c
BH
200 }
201
002f9f07
BH
202 // Set the target trace folder
203 if (traceFolder != null) {
204 fTargetFolder = traceFolder;
205 String path = traceFolder.getFullPath().toOSString();
206 setContainerFieldValue(path);
207 }
208 }
209
210 // ------------------------------------------------------------------------
211 // WizardResourceImportPage
212 // ------------------------------------------------------------------------
213
214 @Override
215 public void createControl(Composite parent) {
216 super.createControl(parent);
217 // Restore last directory if applicable
218 if (fRootDirectory != null) {
219 directoryNameField.setText(fRootDirectory);
220 updateFromSourceField();
221 }
222 }
223
224 @Override
225 protected void createSourceGroup(Composite parent) {
226 createDirectorySelectionGroup(parent);
227 createFileSelectionGroup(parent);
228 createTraceTypeGroup(parent);
229 validateSourceGroup();
230 }
231
232 @Override
252c602c
BH
233 protected ITreeContentProvider getFileProvider() {
234 return new WorkbenchContentProvider() {
002f9f07 235 @Override
252c602c
BH
236 public Object[] getChildren(Object object) {
237 if (object instanceof TraceFileSystemElement) {
238 TraceFileSystemElement element = (TraceFileSystemElement) object;
239 return element.getFiles().getChildren(element);
002f9f07 240 }
252c602c 241 return new Object[0];
002f9f07 242 }
252c602c 243 };
002f9f07
BH
244 }
245
246 @Override
247 protected ITreeContentProvider getFolderProvider() {
002f9f07
BH
248 return new WorkbenchContentProvider() {
249 @Override
250 public Object[] getChildren(Object o) {
252c602c
BH
251 if (o instanceof TraceFileSystemElement) {
252 TraceFileSystemElement element = (TraceFileSystemElement) o;
253 return element.getFolders().getChildren();
002f9f07
BH
254 }
255 return new Object[0];
256 }
002f9f07 257
252c602c
BH
258 @Override
259 public boolean hasChildren(Object o) {
260 if (o instanceof TraceFileSystemElement) {
261 TraceFileSystemElement element = (TraceFileSystemElement) o;
262 if (element.isPopulated()) {
263 return getChildren(element).length > 0;
264 }
265 //If we have not populated then wait until asked
266 return true;
002f9f07 267 }
252c602c 268 return false;
002f9f07 269 }
252c602c 270 };
002f9f07
BH
271 }
272
273 // ------------------------------------------------------------------------
274 // Directory Selection Group (forked WizardFileSystemResourceImportPage1)
275 // ------------------------------------------------------------------------
276
002f9f07
BH
277 /**
278 * creates the directory selection group.
279 *
280 * @param parent
281 * the parent composite
282 */
283 protected void createDirectorySelectionGroup(Composite parent) {
284
285 Composite directoryContainerGroup = new Composite(parent, SWT.NONE);
286 GridLayout layout = new GridLayout();
287 layout.numColumns = 3;
288 directoryContainerGroup.setLayout(layout);
289 directoryContainerGroup.setFont(parent.getFont());
290 directoryContainerGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
291
292 // Label ("Trace directory:")
293 Label groupLabel = new Label(directoryContainerGroup, SWT.NONE);
294 groupLabel.setText(Messages.ImportTraceWizard_DirectoryLocation);
295 groupLabel.setFont(parent.getFont());
296
297 // Directory name entry field
298 directoryNameField = new Combo(directoryContainerGroup, SWT.BORDER);
299 GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
300 data.widthHint = SIZING_TEXT_FIELD_WIDTH;
301 directoryNameField.setLayoutData(data);
302 directoryNameField.setFont(parent.getFont());
303
304 directoryNameField.addSelectionListener(new SelectionAdapter() {
305 @Override
306 public void widgetSelected(SelectionEvent e) {
307 updateFromSourceField();
308 }
309 });
310
311 directoryNameField.addKeyListener(new KeyListener() {
312 @Override
313 public void keyPressed(KeyEvent e) {
314 // If there has been a key pressed then mark as dirty
315 entryChanged = true;
316 if (e.character == SWT.CR) { // Windows...
317 entryChanged = false;
318 updateFromSourceField();
319 }
320 }
321
322 @Override
323 public void keyReleased(KeyEvent e) {
324 }
325 });
326
327 directoryNameField.addFocusListener(new FocusListener() {
328 @Override
329 public void focusGained(FocusEvent e) {
330 // Do nothing when getting focus
331 }
002f9f07
BH
332 @Override
333 public void focusLost(FocusEvent e) {
334 // Clear the flag to prevent constant update
335 if (entryChanged) {
336 entryChanged = false;
337 updateFromSourceField();
338 }
339 }
340 });
341
342 // Browse button
343 directoryBrowseButton = new Button(directoryContainerGroup, SWT.PUSH);
344 directoryBrowseButton.setText(Messages.ImportTraceWizard_BrowseButton);
345 directoryBrowseButton.addListener(SWT.Selection, this);
346 directoryBrowseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
347 directoryBrowseButton.setFont(parent.getFont());
348 setButtonLayoutData(directoryBrowseButton);
349 }
350
351 // ------------------------------------------------------------------------
352 // Browse for the source directory
353 // ------------------------------------------------------------------------
354
355 @Override
356 public void handleEvent(Event event) {
357 if (event.widget == directoryBrowseButton) {
358 handleSourceDirectoryBrowseButtonPressed();
359 }
252c602c
BH
360
361 // Avoid overwriting destination path without repeatedly trigger
362 // call of handleEvent();
363 synchronized (fIsDestinationChanged) {
364 if (fIsDestinationChanged == false) {
365 event.display.asyncExec(new Runnable() {
366 @Override
367 public void run() {
368 synchronized (fIsDestinationChanged) {
369 fIsDestinationChanged = true;
370 String path = fTargetFolder.getFullPath().toOSString();
371 setContainerFieldValue(path);
372 }
373 }
374 });
375 } else {
376 fIsDestinationChanged = false;
377 }
378 }
002f9f07
BH
379 super.handleEvent(event);
380 }
381
252c602c
BH
382 @Override
383 protected void handleContainerBrowseButtonPressed() {
384 // Do nothing so that destination directory cannot be changed.
385 }
386
002f9f07
BH
387 /**
388 * Handle the button pressed event
389 */
390 protected void handleSourceDirectoryBrowseButtonPressed() {
391 String currentSource = directoryNameField.getText();
392 DirectoryDialog dialog = new DirectoryDialog(directoryNameField.getShell(), SWT.SAVE | SWT.SHEET);
393 dialog.setText(Messages.ImportTraceWizard_SelectTraceDirectoryTitle);
394 dialog.setMessage(Messages.ImportTraceWizard_SelectTraceDirectoryMessage);
395 dialog.setFilterPath(getSourceDirectoryName(currentSource));
396
397 String selectedDirectory = dialog.open();
398 if (selectedDirectory != null) {
399 // Just quit if the directory is not valid
400 if ((getSourceDirectory(selectedDirectory) == null) || selectedDirectory.equals(currentSource)) {
401 return;
402 }
403 // If it is valid then proceed to populate
404 setErrorMessage(null);
405 setSourceName(selectedDirectory);
406 }
407 }
408
409 private File getSourceDirectory() {
410 return getSourceDirectory(directoryNameField.getText());
411 }
412
413 private static File getSourceDirectory(String path) {
414 File sourceDirectory = new File(getSourceDirectoryName(path));
415 if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) {
416 return null;
417 }
418
419 return sourceDirectory;
420 }
421
422 private static String getSourceDirectoryName(String sourceName) {
423 IPath result = new Path(sourceName.trim());
424 if (result.getDevice() != null && result.segmentCount() == 0) {
425 result = result.addTrailingSeparator();
426 } else {
427 result = result.removeTrailingSeparator();
428 }
429 return result.toOSString();
430 }
431
432 private String getSourceDirectoryName() {
433 return getSourceDirectoryName(directoryNameField.getText());
434 }
435
436 private void updateFromSourceField() {
437 setSourceName(directoryNameField.getText());
438 updateWidgetEnablements();
439 }
440
441 private void setSourceName(String path) {
442 if (path.length() > 0) {
443 String[] currentItems = directoryNameField.getItems();
444 int selectionIndex = -1;
445 for (int i = 0; i < currentItems.length; i++) {
446 if (currentItems[i].equals(path)) {
447 selectionIndex = i;
448 }
449 }
450 if (selectionIndex < 0) {
451 int oldLength = currentItems.length;
452 String[] newItems = new String[oldLength + 1];
453 System.arraycopy(currentItems, 0, newItems, 0, oldLength);
454 newItems[oldLength] = path;
455 directoryNameField.setItems(newItems);
456 selectionIndex = oldLength;
457 }
458 directoryNameField.select(selectionIndex);
459 }
460 resetSelection();
461 }
462
463 // ------------------------------------------------------------------------
464 // File Selection Group (forked WizardFileSystemResourceImportPage1)
465 // ------------------------------------------------------------------------
002f9f07 466 private void resetSelection() {
252c602c
BH
467 TraceFileSystemElement root = getFileSystemTree();
468 selectionGroup.setRoot(root);
002f9f07
BH
469 }
470
252c602c 471 private TraceFileSystemElement getFileSystemTree() {
002f9f07
BH
472 File sourceDirectory = getSourceDirectory();
473 if (sourceDirectory == null) {
474 return null;
475 }
476 return selectFiles(sourceDirectory, FileSystemStructureProvider.INSTANCE);
477 }
478
252c602c
BH
479 private TraceFileSystemElement selectFiles(final Object rootFileSystemObject,
480 final IImportStructureProvider structureProvider) {
481 final TraceFileSystemElement[] results = new TraceFileSystemElement[1];
002f9f07
BH
482 BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
483 @Override
484 public void run() {
485 // Create the root element from the supplied file system object
486 results[0] = createRootElement(rootFileSystemObject, structureProvider);
487 }
488 });
489 return results[0];
490 }
491
252c602c 492 private static TraceFileSystemElement createRootElement(Object fileSystemObject,
002f9f07
BH
493 IImportStructureProvider provider) {
494
495 boolean isContainer = provider.isFolder(fileSystemObject);
496 String elementLabel = provider.getLabel(fileSystemObject);
497
252c602c
BH
498 // Use an empty label so that display of the element's full name
499 // doesn't include a confusing label
500 TraceFileSystemElement dummyParent = new TraceFileSystemElement("", null, true);//$NON-NLS-1$
16f91bd5 501 dummyParent.setFileSystemObject(((File)fileSystemObject).getParentFile());
252c602c
BH
502 dummyParent.setPopulated();
503 TraceFileSystemElement result = new TraceFileSystemElement(
504 elementLabel, dummyParent, isContainer);
505 result.setFileSystemObject(fileSystemObject);
002f9f07 506
252c602c
BH
507 //Get the files for the element so as to build the first level
508 result.getFiles();
002f9f07
BH
509
510 return dummyParent;
511 }
512
513 // ------------------------------------------------------------------------
514 // Trace Type Group
515 // ------------------------------------------------------------------------
002f9f07
BH
516 private final void createTraceTypeGroup(Composite parent) {
517 Composite composite = new Composite(parent, SWT.NONE);
518 GridLayout layout = new GridLayout();
519 layout.numColumns = 3;
520 layout.makeColumnsEqualWidth = false;
521 composite.setLayout(layout);
522 composite.setFont(parent.getFont());
523 GridData buttonData = new GridData(SWT.FILL, SWT.FILL, true, false);
524 composite.setLayoutData(buttonData);
525
526 // Trace type label ("Trace Type:")
527 Label typeLabel = new Label(composite, SWT.NONE);
528 typeLabel.setText(Messages.ImportTraceWizard_TraceType);
529 typeLabel.setFont(parent.getFont());
530
531 // Trace type combo
252c602c 532 fTraceTypes = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
002f9f07
BH
533 GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
534 fTraceTypes.setLayoutData(data);
535 fTraceTypes.setFont(parent.getFont());
536
537 String[] availableTraceTypes = TmfTraceType.getInstance().getAvailableTraceTypes();
252c602c
BH
538 String[] traceTypeList = new String[availableTraceTypes.length + 1];
539 traceTypeList[0] = AUTO_DETECT;
540 for (int i = 0; i < availableTraceTypes.length; i++) {
541 traceTypeList[i + 1] = availableTraceTypes[i];
542 }
543 fTraceTypes.setItems(traceTypeList);
002f9f07
BH
544 fTraceTypes.addSelectionListener(new SelectionListener() {
545 @Override
546 public void widgetSelected(SelectionEvent e) {
547 updateWidgetEnablements();
548 }
549
550 @Override
551 public void widgetDefaultSelected(SelectionEvent e) {
552 }
553 });
252c602c
BH
554 fTraceTypes.select(0);
555
16f91bd5 556 // Unrecognized checkbox
252c602c
BH
557 fImportUnrecognizedButton = new Button(composite, SWT.CHECK);
558 fImportUnrecognizedButton.setSelection(true);
559 fImportUnrecognizedButton.setText(Messages.ImportTraceWizard_ImportUnrecognized);
560
561 IDialogSettings settings = getDialogSettings();
562 boolean value;
563 if (settings.get(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID) == null) {
564 value = true;
565 } else {
566 value = settings.getBoolean(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID);
567 }
568 fImportUnrecognizedButton.setSelection(value);
002f9f07
BH
569 }
570
571 // ------------------------------------------------------------------------
572 // Options
573 // ------------------------------------------------------------------------
574
002f9f07
BH
575 @Override
576 protected void createOptionsGroupButtons(Group optionsGroup) {
577
578 // Overwrite checkbox
252c602c
BH
579 fOverwriteExistingResourcesCheckbox = new Button(optionsGroup, SWT.CHECK);
580 fOverwriteExistingResourcesCheckbox.setFont(optionsGroup.getFont());
581 fOverwriteExistingResourcesCheckbox.setText(Messages.ImportTraceWizard_OverwriteExistingTrace);
582 fOverwriteExistingResourcesCheckbox.setSelection(false);
002f9f07
BH
583
584 // Create links checkbox
252c602c
BH
585 fCreateLinksInWorkspaceButton = new Button(optionsGroup, SWT.CHECK);
586 fCreateLinksInWorkspaceButton.setFont(optionsGroup.getFont());
587 fCreateLinksInWorkspaceButton.setText(Messages.ImportTraceWizard_CreateLinksInWorkspace);
588 fCreateLinksInWorkspaceButton.setSelection(true);
002f9f07 589
252c602c 590 fCreateLinksInWorkspaceButton.addSelectionListener(new SelectionAdapter() {
002f9f07
BH
591 @Override
592 public void widgetSelected(SelectionEvent e) {
593 updateWidgetEnablements();
594 }
595 });
596
597 updateWidgetEnablements();
598 }
599
600 // ------------------------------------------------------------------------
601 // Determine if the finish button can be enabled
602 // ------------------------------------------------------------------------
603
604 @Override
605 public boolean validateSourceGroup() {
606
607 File sourceDirectory = getSourceDirectory();
608 if (sourceDirectory == null) {
609 setMessage(Messages.ImportTraceWizard_SelectTraceSourceEmpty);
610 return false;
611 }
612
613 if (sourceConflictsWithDestination(new Path(sourceDirectory.getPath()))) {
614 setMessage(null);
615 setErrorMessage(getSourceConflictMessage());
616 return false;
617 }
618
619 List<FileSystemElement> resourcesToImport = getSelectedResources();
620 if (resourcesToImport.size() == 0) {
621 setMessage(null);
622 setErrorMessage(Messages.ImportTraceWizard_SelectTraceNoneSelected);
623 return false;
624 }
625
626 IContainer container = getSpecifiedContainer();
627 if (container != null && container.isVirtual()) {
628 if (Platform.getPreferencesService().getBoolean(Activator.PLUGIN_ID, ResourcesPlugin.PREF_DISABLE_LINKING, false, null)) {
629 setMessage(null);
630 setErrorMessage(Messages.ImportTraceWizard_CannotImportFilesUnderAVirtualFolder);
631 return false;
632 }
252c602c 633 if (fCreateLinksInWorkspaceButton == null || !fCreateLinksInWorkspaceButton.getSelection()) {
002f9f07
BH
634 setMessage(null);
635 setErrorMessage(Messages.ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder);
636 return false;
637 }
638 }
639
002f9f07
BH
640 setErrorMessage(null);
641 return true;
642 }
643
644 // ------------------------------------------------------------------------
645 // Import the trace(s)
646 // ------------------------------------------------------------------------
647
648 /**
649 * Finish the import.
650 *
252c602c 651 * @return <code>true</code> if successful else <code>false</code>
002f9f07
BH
652 */
653 public boolean finish() {
252c602c
BH
654 IDialogSettings settings = getDialogSettings();
655 settings.put(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID, fImportUnrecognizedButton.getSelection());
002f9f07 656
252c602c
BH
657 String traceTypeName = fTraceTypes.getText();
658 String traceId = null;
659 if (!AUTO_DETECT.equals(traceTypeName)) {
660 String tokens[] = traceTypeName.split(SEPARATOR, 2);
661 if (tokens.length < 2) {
662 return false;
663 }
664 traceId = TmfTraceType.getInstance().getTraceTypeId(tokens[0], tokens[1]);
002f9f07
BH
665 }
666
667 // Save directory for next import operation
668 fRootDirectory = getSourceDirectoryName();
669
252c602c
BH
670 final TraceValidateAndImportOperation operation = new TraceValidateAndImportOperation(traceId, getContainerFullPath(),
671 fImportUnrecognizedButton.getSelection(), fOverwriteExistingResourcesCheckbox.getSelection(), fCreateLinksInWorkspaceButton.getSelection());
002f9f07 672
252c602c
BH
673 IStatus status = Status.OK_STATUS;
674 try {
675 getContainer().run(true, true, new IRunnableWithProgress() {
676 @Override
677 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
678 operation.run(monitor);
679 monitor.done();
002f9f07 680 }
252c602c 681 });
002f9f07 682
252c602c
BH
683 status = operation.getStatus();
684 } catch (InvocationTargetException e) {
685 status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportTraceWizard_ImportProblem, e);
686 } catch (InterruptedException e) {
687 status = Status.CANCEL_STATUS;
688 } finally {
689 if (!status.isOK()) {
690 if (status.getSeverity() == IStatus.CANCEL) {
691 setMessage(Messages.ImportTraceWizard_ImportOperationCancelled);
692 setErrorMessage(null);
002f9f07 693 } else {
252c602c
BH
694 if (status.getException() != null) {
695 displayErrorDialog(status.getMessage() + ": " + status.getException()); //$NON-NLS-1$
696 }
002f9f07 697 setMessage(null);
252c602c 698 setErrorMessage(Messages.ImportTraceWizard_ImportProblem);
002f9f07 699 }
252c602c
BH
700 return false;
701 }
702 }
703 if (operation.getUnrecognizedTraces().size() > 0) {
704 StringBuilder unrecognizedTraces = new StringBuilder();
705 for(String trace: operation.getUnrecognizedTraces()) {
706 unrecognizedTraces.append(System.getProperty("line.separator")).append(trace); //$NON-NLS-1$
002f9f07 707 }
252c602c
BH
708 displayErrorDialog(Messages.ImportTraceWizard_NoValidTraceTypeFound + ":" + unrecognizedTraces.toString()); //$NON-NLS-1$
709 }
710 setErrorMessage(null);
711 return true;
712 }
002f9f07 713
252c602c
BH
714
715 // ------------------------------------------------------------------------
716 // Classes
717 // ------------------------------------------------------------------------
718
16f91bd5 719 private class TraceValidateAndImportOperation {
252c602c 720 private IStatus fStatus;
16f91bd5 721 private final List<String> fUnrecognizedResources = new ArrayList<>();
252c602c
BH
722 private String fTraceType;
723 private IPath fContainerPath;
724 private boolean fImportUnrecognizedTraces;
252c602c 725 private boolean fLink;
16f91bd5 726 private ImportConfirmation fConfirmationMode = ImportConfirmation.SKIP;
252c602c 727
16f91bd5 728 private TraceValidateAndImportOperation(String traceId, IPath containerPath, boolean doImport, boolean overwrite, boolean link) {
252c602c
BH
729 fTraceType = traceId;
730 fContainerPath = containerPath;
731 fImportUnrecognizedTraces = doImport;
16f91bd5
BH
732 if (overwrite) {
733 fConfirmationMode = ImportConfirmation.OVERWRITE_ALL;
734 }
252c602c
BH
735 fLink = link;
736 }
737
738 public void run(IProgressMonitor progressMonitor) {
739 String currentPath = null;
16f91bd5 740 final Map<String, TraceFileSystemElement> folderElements = new HashMap<>();
252c602c 741 try {
16f91bd5
BH
742 List<TraceFileSystemElement> fileSystemElements = getSelectedResources();
743 Iterator<TraceFileSystemElement> fileSystemElementsIter = fileSystemElements.iterator();
744 SubMonitor subMonitor = SubMonitor.convert(progressMonitor, fileSystemElements.size());
252c602c 745
16f91bd5 746 while (fileSystemElementsIter.hasNext()) {
252c602c
BH
747 ModalContext.checkCanceled(progressMonitor);
748 currentPath = null;
16f91bd5
BH
749 TraceFileSystemElement element = fileSystemElementsIter.next();
750 File fileResource = (File) element.getFileSystemObject();
751 String resourcePath = fileResource.getAbsolutePath();
252c602c
BH
752 currentPath = resourcePath;
753 SubMonitor sub = subMonitor.newChild(1);
16f91bd5
BH
754 if (element.isDirectory()) {
755 if (!folderElements.containsKey(resourcePath)) {
756 if (isDirectoryTrace(element)) {
757 folderElements.put(resourcePath, element);
758 validateAndImportDirectoryTrace(element, sub);
252c602c
BH
759 }
760 }
761 } else {
16f91bd5
BH
762 TraceFileSystemElement parentElement = (TraceFileSystemElement)element.getParent();
763 File parentFile = (File) parentElement.getFileSystemObject();
764 String parentPath = parentFile.getAbsolutePath();
252c602c 765 currentPath = parentPath;
16f91bd5
BH
766 if (!folderElements.containsKey(parentPath)) {
767 if (isDirectoryTrace(parentElement)) {
768 folderElements.put(parentPath, parentElement);
769 validateAndImportDirectoryTrace(parentElement, sub);
252c602c 770 } else {
16f91bd5
BH
771 if (fileResource.exists()) {
772 validateAndImportFileTrace(element, sub);
002f9f07 773 }
002f9f07
BH
774 }
775 }
776 }
777 }
252c602c
BH
778 setStatus(Status.OK_STATUS);
779 } catch (InterruptedException e) {
780 setStatus(Status.CANCEL_STATUS);
781 } catch (Exception e) {
782 setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportTraceWizard_ImportProblem + ": " + //$NON-NLS-1$
783 (currentPath != null ? currentPath : "") , e)); //$NON-NLS-1$
002f9f07 784 }
002f9f07
BH
785 }
786
252c602c
BH
787 /**
788 * @return a list of trace file names for that no trace type could be detected.
789 */
790 public List<String> getUnrecognizedTraces() {
791 return new ArrayList<>(fUnrecognizedResources);
792 }
793
16f91bd5 794 private void validateAndImportDirectoryTrace(TraceFileSystemElement fileSystemElement, IProgressMonitor monitor)
252c602c 795 throws TmfTraceImportException, CoreException, InvocationTargetException, InterruptedException {
16f91bd5 796 File file = (File) fileSystemElement.getFileSystemObject();
252c602c 797 String path = file.getAbsolutePath();
350cae41 798 TraceTypeHelper traceTypeHelper = null;
252c602c
BH
799 boolean sendValidationError = true;
800 if (fTraceType == null) {
350cae41
PT
801 try {
802 traceTypeHelper = TmfTraceTypeUIUtils.selectTraceType(path, null, null);
803 } catch (TmfTraceImportException e) {
804 // the trace did not match any trace type
805 }
806 if (traceTypeHelper == null) {
807 if (fImportUnrecognizedTraces) {
808 if (importResource(fileSystemElement, monitor)) {
809 fUnrecognizedResources.add(path);
810 }
811 }
812 return;
813 }
252c602c
BH
814 } else {
815 if (!TmfTraceType.getInstance().isDirectoryTraceType(fTraceType)) {
816 return;
817 }
818 sendValidationError = false;
819 traceTypeHelper = TmfTraceType.getInstance().getTraceType(fTraceType);
820 }
16f91bd5 821 validateAndImportTrace(fileSystemElement, traceTypeHelper, sendValidationError, monitor);
252c602c
BH
822 }
823
16f91bd5 824 private void validateAndImportFileTrace(TraceFileSystemElement fileSystemElement, IProgressMonitor monitor)
252c602c 825 throws TmfTraceImportException, CoreException, InvocationTargetException, InterruptedException {
002f9f07 826
16f91bd5 827 File file = (File) fileSystemElement.getFileSystemObject();
252c602c
BH
828 String path = file.getAbsolutePath();
829 TraceTypeHelper traceTypeHelper = null;
830 boolean sendValidationError = true;
16f91bd5 831
252c602c 832 if (fTraceType == null) {
350cae41
PT
833 try {
834 traceTypeHelper = TmfTraceTypeUIUtils.selectTraceType(path, null, null);
835 } catch (TmfTraceImportException e) {
836 // the trace did not match any trace type
837 }
838 if (traceTypeHelper == null) {
839 if (fImportUnrecognizedTraces) {
840 if (importResource(fileSystemElement, monitor)) {
841 fUnrecognizedResources.add(path);
842 }
16f91bd5 843 }
350cae41 844 return;
252c602c 845 }
350cae41
PT
846 } else {
847 if (TmfTraceType.getInstance().isDirectoryTraceType(fTraceType)) {
848 return;
849 }
850 sendValidationError = false;
851 traceTypeHelper = TmfTraceType.getInstance().getTraceType(fTraceType);
252c602c 852 }
002f9f07 853
16f91bd5 854 validateAndImportTrace(fileSystemElement, traceTypeHelper, sendValidationError, monitor);
252c602c 855 return;
002f9f07 856 }
252c602c 857
16f91bd5 858 private void validateAndImportTrace(TraceFileSystemElement fileSystemElement, TraceTypeHelper traceTypeHelper, boolean sendValidationError, IProgressMonitor monitor)
252c602c
BH
859 throws InvocationTargetException, InterruptedException, CoreException, TmfTraceImportException {
860
861 if (traceTypeHelper == null) {
862 throw new TmfTraceImportException(Messages.ImportTraceWizard_TraceTypeNotFound);
002f9f07 863 }
16f91bd5 864 File file = (File) fileSystemElement.getFileSystemObject();
252c602c 865 String path = file.getAbsolutePath();
002f9f07 866
252c602c 867 if (TmfTraceType.getInstance().validate(traceTypeHelper.getCanonicalName(), path)) {
16f91bd5
BH
868 if (importResource(fileSystemElement, monitor)) {
869 IResource eclipseResource = fTargetFolder.findMember(fileSystemElement.getLabel());
870 TmfTraceTypeUIUtils.setTraceType(eclipseResource.getFullPath(), traceTypeHelper);
871 }
252c602c
BH
872 return;
873 }
874 if (sendValidationError) {
16f91bd5 875 throw new TmfTraceImportException(NLS.bind(Messages.ImportTraceWizard_TraceValidationFailed, path));
002f9f07 876 }
252c602c 877 }
002f9f07 878
16f91bd5
BH
879 /**
880 * Imports a trace resource to project. In case of name collision the
881 * user will be asked to confirm overwriting the existing trace,
882 * overwriting or skipping the trace to be imported.
883 *
884 * @param fileSystemElement
885 * trace file system object to import
886 * @param monitor
887 * a progress monitor
888 * @return true if trace was imported else false
889 *
890 * @throws InvocationTargetException
891 * if problems during import operation
892 * @throws InterruptedException
893 * if cancelled
894 * @throws CoreException
895 * if problems with workspace
896 */
897 private boolean importResource(TraceFileSystemElement fileSystemElement, IProgressMonitor monitor)
898 throws InvocationTargetException, InterruptedException, CoreException {
899 ImportConfirmation mode = checkForNameClashes(fileSystemElement);
900 switch (mode) {
901 case RENAME:
902 case RENAME_ALL:
903 rename(fileSystemElement);
904 break;
905 case OVERWRITE:
906 case OVERWRITE_ALL:
907 delete(fileSystemElement, monitor);
908 break;
909 case CONTINUE:
910 break;
911 case SKIP:
912 case SKIP_ALL:
913 default:
914 return false;
915 }
916
917 List<TraceFileSystemElement> subList = new ArrayList<>();
918
919 IPath containerPath = fContainerPath;
920 FileSystemElement parentFolder = fileSystemElement.getParent();
921
922 if (fileSystemElement.isDirectory() && (!fLink)) {
923 containerPath = containerPath.addTrailingSeparator().append(fileSystemElement.getLabel());
924
925 Object[] array = fileSystemElement.getFiles().getChildren();
926 for (int i = 0; i < array.length; i++) {
927 subList.add((TraceFileSystemElement)array[i]);
928 }
929 parentFolder = fileSystemElement;
930
931 } else {
932 subList.add(fileSystemElement);
933 }
934
935
936 ImportProvider fileSystemStructureProvider = new ImportProvider();
252c602c 937
252c602c
BH
938 IOverwriteQuery myQueryImpl = new IOverwriteQuery() {
939 @Override
940 public String queryOverwrite(String file) {
16f91bd5 941 return IOverwriteQuery.NO_ALL;
252c602c
BH
942 }
943 };
944
16f91bd5
BH
945 monitor.setTaskName(Messages.ImportTraceWizard_ImportOperationTaskName + " " + ((File)fileSystemElement.getFileSystemObject()).getAbsolutePath()); //$NON-NLS-1$
946 ImportOperation operation = new ImportOperation(containerPath, parentFolder, fileSystemStructureProvider, myQueryImpl, subList);
002f9f07 947 operation.setContext(getShell());
002f9f07 948
252c602c 949 operation.setCreateContainerStructure(false);
16f91bd5 950 operation.setOverwriteResources(false);
252c602c
BH
951 operation.setCreateLinks(fLink);
952 operation.setVirtualFolders(false);
002f9f07 953
252c602c 954 operation.run(new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
16f91bd5
BH
955 return true;
956 }
002f9f07 957
16f91bd5
BH
958 private boolean isDirectoryTrace(FileSystemElement fileSystemElement) {
959 File file = (File) fileSystemElement.getFileSystemObject();
252c602c
BH
960 String path = file.getAbsolutePath();
961 if (TmfTraceType.getInstance().isDirectoryTrace(path)) {
962 return true;
963 }
002f9f07
BH
964 return false;
965 }
966
16f91bd5
BH
967 private ImportConfirmation checkForNameClashes(TraceFileSystemElement fileSystemElement) throws InterruptedException {
968
969 String traceName = ((File)fileSystemElement.getFileSystemObject()).getName();
970
971 // handle rename
972 if (getExistingTrace(traceName) != null) {
973 if ((fConfirmationMode == ImportConfirmation.RENAME_ALL) ||
974 (fConfirmationMode == ImportConfirmation.OVERWRITE_ALL) ||
975 (fConfirmationMode == ImportConfirmation.SKIP_ALL)) {
976 return fConfirmationMode;
977 }
978
979 int returnCode = promptForOverwrite(traceName);
980 if (returnCode < 0) {
981 // Cancel
982 throw new InterruptedException();
983 }
984 fConfirmationMode = ImportConfirmation.values()[returnCode];
985 return fConfirmationMode;
986 }
987 return ImportConfirmation.CONTINUE;
988 }
989
990 private int promptForOverwrite(String traceName) {
991 final MessageDialog dialog = new MessageDialog(getContainer()
992 .getShell(), null, null, NLS.bind(Messages.ImportTraceWizard_TraceAlreadyExists, traceName),
993 MessageDialog.QUESTION, new String[] {
994 ImportConfirmation.RENAME.getInName(),
995 ImportConfirmation.RENAME_ALL.getInName(),
996 ImportConfirmation.OVERWRITE.getInName(),
997 ImportConfirmation.OVERWRITE_ALL.getInName(),
998 ImportConfirmation.SKIP.getInName(),
999 ImportConfirmation.SKIP_ALL.getInName(),
1000 }, 4) {
1001 @Override
1002 protected int getShellStyle() {
1003 return super.getShellStyle() | SWT.SHEET;
1004 }
1005 };
1006
1007 final int[] returnValue = new int[1];
1008 getShell().getDisplay().syncExec(new Runnable() {
1009
1010 @Override
1011 public void run() {
1012 returnValue[0] = dialog.open();
1013 }
1014 });
1015 return returnValue[0];
1016 }
1017
1018 private void rename(TraceFileSystemElement fileSystemElement) {
1019 String traceName = ((File)fileSystemElement.getFileSystemObject()).getName();
1020 TmfTraceElement trace = getExistingTrace(traceName);
1021 if (trace == null) {
1022 return;
1023 }
1024
1025 IFolder folder = trace.getProject().getTracesFolder().getResource();
1026 int i = 2;
1027 while (true) {
1028 String name = trace.getName() + '(' + Integer.toString(i++) + ')';
1029 IResource resource = folder.findMember(name);
1030 if (resource == null) {
1031 fileSystemElement.setLabel(name);
1032 return;
1033 }
1034 }
1035 }
1036
1037 private void delete(TraceFileSystemElement fileSystemElement, IProgressMonitor monitor) throws CoreException {
1038 String traceName = ((File)fileSystemElement.getFileSystemObject()).getName();
1039 TmfTraceElement trace = getExistingTrace(traceName);
1040 if (trace == null) {
1041 return;
1042 }
1043
1044 trace.delete(monitor);
1045 }
1046
1047 private TmfTraceElement getExistingTrace(String traceName) {
1048 List<TmfTraceElement> traces = fTraceFolderElement.getTraces();
1049 for (TmfTraceElement t : traces) {
1050 if (t.getName().equals(traceName)) {
1051 return t;
1052 }
1053 }
1054 return null;
1055 }
1056
252c602c
BH
1057 /**
1058 * Set the status for this operation
1059 *
1060 * @param status
1061 * the status
1062 */
1063 protected void setStatus(IStatus status) {
1064 fStatus = status;
002f9f07
BH
1065 }
1066
252c602c
BH
1067 public IStatus getStatus() {
1068 return fStatus;
1069 }
002f9f07
BH
1070 }
1071
252c602c
BH
1072 /**
1073 * The <code>TraceFileSystemElement</code> is a <code>FileSystemElement</code> that knows
1074 * if it has been populated or not.
1075 */
16f91bd5 1076 private static class TraceFileSystemElement extends FileSystemElement {
252c602c 1077
16f91bd5
BH
1078 private boolean fIsPopulated = false;
1079 private String fLabel = null;
252c602c
BH
1080
1081 public TraceFileSystemElement(String name, FileSystemElement parent, boolean isDirectory) {
1082 super(name, parent, isDirectory);
1083 }
1084
1085 public void setPopulated() {
16f91bd5 1086 fIsPopulated = true;
252c602c
BH
1087 }
1088
1089 public boolean isPopulated() {
16f91bd5 1090 return fIsPopulated;
252c602c
BH
1091 }
1092
1093 @Override
1094 public AdaptableList getFiles() {
16f91bd5 1095 if(!fIsPopulated) {
252c602c
BH
1096 populateElementChildren();
1097 }
1098 return super.getFiles();
1099 }
1100
1101 @Override
1102 public AdaptableList getFolders() {
16f91bd5 1103 if(!fIsPopulated) {
252c602c
BH
1104 populateElementChildren();
1105 }
1106 return super.getFolders();
1107 }
002f9f07 1108
16f91bd5
BH
1109 /**
1110 * Sets the label for the trace to be used when importing at trace.
1111 * @param name
1112 * the label for the trace
1113 */
1114 public void setLabel(String name) {
1115 fLabel = name;
1116 }
1117
1118 /**
1119 * Returns the label for the trace to be used when importing at trace.
1120 *
1121 * @return the label of trace resource
1122 */
1123 public String getLabel() {
1124 if (fLabel == null) {
1125 //Get the name - if it is empty then return the path as it is a file root
1126 File file = (File) getFileSystemObject();
1127 String name = file.getName();
1128 if (name.length() == 0) {
1129 return file.getPath();
1130 }
1131 return name;
1132 }
1133 return fLabel;
1134 }
1135
252c602c
BH
1136 /**
1137 * Populates the children of the specified parent <code>FileSystemElement</code>
1138 */
1139 private void populateElementChildren() {
1140 FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;
1141 List<File> allchildren = provider.getChildren(this.getFileSystemObject());
1142 File child = null;
1143 TraceFileSystemElement newelement = null;
1144 Iterator<File> iter = allchildren.iterator();
1145 while(iter.hasNext()) {
1146 child = iter.next();
1147 newelement = new TraceFileSystemElement(provider.getLabel(child), this, provider.isFolder(child));
1148 newelement.setFileSystemObject(child);
1149 }
1150 setPopulated();
1151 }
1152 }
16f91bd5
BH
1153
1154 private class ImportProvider implements IImportStructureProvider {
1155
1156 private FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;
1157
1158 ImportProvider() {
1159 }
1160
1161 @Override
1162 public String getLabel(Object element) {
1163 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1164 return resource.getLabel();
1165 }
1166
1167 @Override
1168 public List getChildren(Object element) {
1169 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1170 Object[] array = resource.getFiles().getChildren();
1171 List<Object> list = new ArrayList<>();
1172 for (int i = 0; i < array.length; i++) {
1173 list.add(array[i]);
1174 }
1175 return list;
1176 }
1177
1178 @Override
1179 public InputStream getContents(Object element) {
1180 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1181 return provider.getContents(resource.getFileSystemObject());
1182 }
1183
1184 @Override
1185 public String getFullPath(Object element) {
1186 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1187 return provider.getFullPath(resource.getFileSystemObject());
1188 }
1189
1190 @Override
1191 public boolean isFolder(Object element) {
1192 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1193 return resource.isDirectory();
1194 }
1195 }
1196
1197 private enum ImportConfirmation {
1198 // ------------------------------------------------------------------------
1199 // Enum definition
1200 // ------------------------------------------------------------------------
1201 RENAME(Messages.ImportTraceWizard_ImportConfigurationRename),
1202 RENAME_ALL(Messages.ImportTraceWizard_ImportConfigurationRenameAll),
1203 OVERWRITE(Messages.ImportTraceWizard_ImportConfigurationOverwrite),
1204 OVERWRITE_ALL(Messages.ImportTraceWizard_ImportConfigurationOverwriteAll),
1205 SKIP(Messages.ImportTraceWizard_ImportConfigurationSkip),
1206 SKIP_ALL(Messages.ImportTraceWizard_ImportConfigurationSkipAll),
1207 CONTINUE("CONTINUE"); //$NON-NLS-1$
1208
1209 // ------------------------------------------------------------------------
1210 // Attributes
1211 // ------------------------------------------------------------------------
1212 /**
1213 * Name of enum
1214 */
1215 private final String fInName;
1216
1217 // ------------------------------------------------------------------------
1218 // Constuctors
1219 // ------------------------------------------------------------------------
1220
1221 /**
1222 * Private constructor
1223 * @param name the name of state
1224 */
1225 private ImportConfirmation(String name) {
1226 fInName = name;
1227 }
1228
1229 // ------------------------------------------------------------------------
1230 // Accessors
1231 // ------------------------------------------------------------------------
1232 /**
1233 * @return state name
1234 */
1235 public String getInName() {
1236 return fInName;
1237 }
1238 }
002f9f07 1239}
This page took 0.084187 seconds and 5 git commands to generate.