tmf: support for renaming, overwriting or skipping during import
[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
BH
797 String path = file.getAbsolutePath();
798 TraceTypeHelper traceTypeHelper;
799 boolean sendValidationError = true;
800 if (fTraceType == null) {
801 traceTypeHelper = TmfTraceTypeUIUtils.selectTraceType(path, null, null);
802 } else {
803 if (!TmfTraceType.getInstance().isDirectoryTraceType(fTraceType)) {
804 return;
805 }
806 sendValidationError = false;
807 traceTypeHelper = TmfTraceType.getInstance().getTraceType(fTraceType);
808 }
16f91bd5 809 validateAndImportTrace(fileSystemElement, traceTypeHelper, sendValidationError, monitor);
252c602c
BH
810 }
811
16f91bd5 812 private void validateAndImportFileTrace(TraceFileSystemElement fileSystemElement, IProgressMonitor monitor)
252c602c 813 throws TmfTraceImportException, CoreException, InvocationTargetException, InterruptedException {
002f9f07 814
16f91bd5
BH
815
816 File file = (File) fileSystemElement.getFileSystemObject();
252c602c
BH
817 String path = file.getAbsolutePath();
818 TraceTypeHelper traceTypeHelper = null;
819 boolean sendValidationError = true;
16f91bd5 820
252c602c
BH
821 if (fTraceType == null) {
822 // TODO add automatic trace type selection for trace file
823 if (fImportUnrecognizedTraces) {
16f91bd5
BH
824 if (importResource(fileSystemElement, monitor)) {
825 fUnrecognizedResources.add(path);
826 }
252c602c
BH
827 }
828 return;
829 }
002f9f07 830
252c602c
BH
831 if (TmfTraceType.getInstance().isDirectoryTraceType(fTraceType)) {
832 return;
833 }
834 sendValidationError = false;
835 traceTypeHelper = TmfTraceType.getInstance().getTraceType(fTraceType);
16f91bd5 836 validateAndImportTrace(fileSystemElement, traceTypeHelper, sendValidationError, monitor);
252c602c 837 return;
002f9f07 838 }
252c602c 839
16f91bd5 840 private void validateAndImportTrace(TraceFileSystemElement fileSystemElement, TraceTypeHelper traceTypeHelper, boolean sendValidationError, IProgressMonitor monitor)
252c602c
BH
841 throws InvocationTargetException, InterruptedException, CoreException, TmfTraceImportException {
842
843 if (traceTypeHelper == null) {
844 throw new TmfTraceImportException(Messages.ImportTraceWizard_TraceTypeNotFound);
002f9f07 845 }
16f91bd5 846 File file = (File) fileSystemElement.getFileSystemObject();
252c602c 847 String path = file.getAbsolutePath();
002f9f07 848
252c602c 849 if (TmfTraceType.getInstance().validate(traceTypeHelper.getCanonicalName(), path)) {
16f91bd5
BH
850 if (importResource(fileSystemElement, monitor)) {
851 IResource eclipseResource = fTargetFolder.findMember(fileSystemElement.getLabel());
852 TmfTraceTypeUIUtils.setTraceType(eclipseResource.getFullPath(), traceTypeHelper);
853 }
252c602c
BH
854 return;
855 }
856 if (sendValidationError) {
16f91bd5 857 throw new TmfTraceImportException(NLS.bind(Messages.ImportTraceWizard_TraceValidationFailed, path));
002f9f07 858 }
252c602c 859 }
002f9f07 860
16f91bd5
BH
861 /**
862 * Imports a trace resource to project. In case of name collision the
863 * user will be asked to confirm overwriting the existing trace,
864 * overwriting or skipping the trace to be imported.
865 *
866 * @param fileSystemElement
867 * trace file system object to import
868 * @param monitor
869 * a progress monitor
870 * @return true if trace was imported else false
871 *
872 * @throws InvocationTargetException
873 * if problems during import operation
874 * @throws InterruptedException
875 * if cancelled
876 * @throws CoreException
877 * if problems with workspace
878 */
879 private boolean importResource(TraceFileSystemElement fileSystemElement, IProgressMonitor monitor)
880 throws InvocationTargetException, InterruptedException, CoreException {
881 ImportConfirmation mode = checkForNameClashes(fileSystemElement);
882 switch (mode) {
883 case RENAME:
884 case RENAME_ALL:
885 rename(fileSystemElement);
886 break;
887 case OVERWRITE:
888 case OVERWRITE_ALL:
889 delete(fileSystemElement, monitor);
890 break;
891 case CONTINUE:
892 break;
893 case SKIP:
894 case SKIP_ALL:
895 default:
896 return false;
897 }
898
899 List<TraceFileSystemElement> subList = new ArrayList<>();
900
901 IPath containerPath = fContainerPath;
902 FileSystemElement parentFolder = fileSystemElement.getParent();
903
904 if (fileSystemElement.isDirectory() && (!fLink)) {
905 containerPath = containerPath.addTrailingSeparator().append(fileSystemElement.getLabel());
906
907 Object[] array = fileSystemElement.getFiles().getChildren();
908 for (int i = 0; i < array.length; i++) {
909 subList.add((TraceFileSystemElement)array[i]);
910 }
911 parentFolder = fileSystemElement;
912
913 } else {
914 subList.add(fileSystemElement);
915 }
916
917
918 ImportProvider fileSystemStructureProvider = new ImportProvider();
252c602c 919
252c602c
BH
920 IOverwriteQuery myQueryImpl = new IOverwriteQuery() {
921 @Override
922 public String queryOverwrite(String file) {
16f91bd5 923 return IOverwriteQuery.NO_ALL;
252c602c
BH
924 }
925 };
926
16f91bd5
BH
927 monitor.setTaskName(Messages.ImportTraceWizard_ImportOperationTaskName + " " + ((File)fileSystemElement.getFileSystemObject()).getAbsolutePath()); //$NON-NLS-1$
928 ImportOperation operation = new ImportOperation(containerPath, parentFolder, fileSystemStructureProvider, myQueryImpl, subList);
002f9f07 929 operation.setContext(getShell());
002f9f07 930
252c602c 931 operation.setCreateContainerStructure(false);
16f91bd5 932 operation.setOverwriteResources(false);
252c602c
BH
933 operation.setCreateLinks(fLink);
934 operation.setVirtualFolders(false);
002f9f07 935
252c602c 936 operation.run(new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
16f91bd5
BH
937 return true;
938 }
002f9f07 939
16f91bd5
BH
940 private boolean isDirectoryTrace(FileSystemElement fileSystemElement) {
941 File file = (File) fileSystemElement.getFileSystemObject();
252c602c
BH
942 String path = file.getAbsolutePath();
943 if (TmfTraceType.getInstance().isDirectoryTrace(path)) {
944 return true;
945 }
002f9f07
BH
946 return false;
947 }
948
16f91bd5
BH
949 private ImportConfirmation checkForNameClashes(TraceFileSystemElement fileSystemElement) throws InterruptedException {
950
951 String traceName = ((File)fileSystemElement.getFileSystemObject()).getName();
952
953 // handle rename
954 if (getExistingTrace(traceName) != null) {
955 if ((fConfirmationMode == ImportConfirmation.RENAME_ALL) ||
956 (fConfirmationMode == ImportConfirmation.OVERWRITE_ALL) ||
957 (fConfirmationMode == ImportConfirmation.SKIP_ALL)) {
958 return fConfirmationMode;
959 }
960
961 int returnCode = promptForOverwrite(traceName);
962 if (returnCode < 0) {
963 // Cancel
964 throw new InterruptedException();
965 }
966 fConfirmationMode = ImportConfirmation.values()[returnCode];
967 return fConfirmationMode;
968 }
969 return ImportConfirmation.CONTINUE;
970 }
971
972 private int promptForOverwrite(String traceName) {
973 final MessageDialog dialog = new MessageDialog(getContainer()
974 .getShell(), null, null, NLS.bind(Messages.ImportTraceWizard_TraceAlreadyExists, traceName),
975 MessageDialog.QUESTION, new String[] {
976 ImportConfirmation.RENAME.getInName(),
977 ImportConfirmation.RENAME_ALL.getInName(),
978 ImportConfirmation.OVERWRITE.getInName(),
979 ImportConfirmation.OVERWRITE_ALL.getInName(),
980 ImportConfirmation.SKIP.getInName(),
981 ImportConfirmation.SKIP_ALL.getInName(),
982 }, 4) {
983 @Override
984 protected int getShellStyle() {
985 return super.getShellStyle() | SWT.SHEET;
986 }
987 };
988
989 final int[] returnValue = new int[1];
990 getShell().getDisplay().syncExec(new Runnable() {
991
992 @Override
993 public void run() {
994 returnValue[0] = dialog.open();
995 }
996 });
997 return returnValue[0];
998 }
999
1000 private void rename(TraceFileSystemElement fileSystemElement) {
1001 String traceName = ((File)fileSystemElement.getFileSystemObject()).getName();
1002 TmfTraceElement trace = getExistingTrace(traceName);
1003 if (trace == null) {
1004 return;
1005 }
1006
1007 IFolder folder = trace.getProject().getTracesFolder().getResource();
1008 int i = 2;
1009 while (true) {
1010 String name = trace.getName() + '(' + Integer.toString(i++) + ')';
1011 IResource resource = folder.findMember(name);
1012 if (resource == null) {
1013 fileSystemElement.setLabel(name);
1014 return;
1015 }
1016 }
1017 }
1018
1019 private void delete(TraceFileSystemElement fileSystemElement, IProgressMonitor monitor) throws CoreException {
1020 String traceName = ((File)fileSystemElement.getFileSystemObject()).getName();
1021 TmfTraceElement trace = getExistingTrace(traceName);
1022 if (trace == null) {
1023 return;
1024 }
1025
1026 trace.delete(monitor);
1027 }
1028
1029 private TmfTraceElement getExistingTrace(String traceName) {
1030 List<TmfTraceElement> traces = fTraceFolderElement.getTraces();
1031 for (TmfTraceElement t : traces) {
1032 if (t.getName().equals(traceName)) {
1033 return t;
1034 }
1035 }
1036 return null;
1037 }
1038
252c602c
BH
1039 /**
1040 * Set the status for this operation
1041 *
1042 * @param status
1043 * the status
1044 */
1045 protected void setStatus(IStatus status) {
1046 fStatus = status;
002f9f07
BH
1047 }
1048
252c602c
BH
1049 public IStatus getStatus() {
1050 return fStatus;
1051 }
002f9f07
BH
1052 }
1053
252c602c
BH
1054 /**
1055 * The <code>TraceFileSystemElement</code> is a <code>FileSystemElement</code> that knows
1056 * if it has been populated or not.
1057 */
16f91bd5 1058 private static class TraceFileSystemElement extends FileSystemElement {
252c602c 1059
16f91bd5
BH
1060 private boolean fIsPopulated = false;
1061 private String fLabel = null;
252c602c
BH
1062
1063 public TraceFileSystemElement(String name, FileSystemElement parent, boolean isDirectory) {
1064 super(name, parent, isDirectory);
1065 }
1066
1067 public void setPopulated() {
16f91bd5 1068 fIsPopulated = true;
252c602c
BH
1069 }
1070
1071 public boolean isPopulated() {
16f91bd5 1072 return fIsPopulated;
252c602c
BH
1073 }
1074
1075 @Override
1076 public AdaptableList getFiles() {
16f91bd5 1077 if(!fIsPopulated) {
252c602c
BH
1078 populateElementChildren();
1079 }
1080 return super.getFiles();
1081 }
1082
1083 @Override
1084 public AdaptableList getFolders() {
16f91bd5 1085 if(!fIsPopulated) {
252c602c
BH
1086 populateElementChildren();
1087 }
1088 return super.getFolders();
1089 }
002f9f07 1090
16f91bd5
BH
1091 /**
1092 * Sets the label for the trace to be used when importing at trace.
1093 * @param name
1094 * the label for the trace
1095 */
1096 public void setLabel(String name) {
1097 fLabel = name;
1098 }
1099
1100 /**
1101 * Returns the label for the trace to be used when importing at trace.
1102 *
1103 * @return the label of trace resource
1104 */
1105 public String getLabel() {
1106 if (fLabel == null) {
1107 //Get the name - if it is empty then return the path as it is a file root
1108 File file = (File) getFileSystemObject();
1109 String name = file.getName();
1110 if (name.length() == 0) {
1111 return file.getPath();
1112 }
1113 return name;
1114 }
1115 return fLabel;
1116 }
1117
252c602c
BH
1118 /**
1119 * Populates the children of the specified parent <code>FileSystemElement</code>
1120 */
1121 private void populateElementChildren() {
1122 FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;
1123 List<File> allchildren = provider.getChildren(this.getFileSystemObject());
1124 File child = null;
1125 TraceFileSystemElement newelement = null;
1126 Iterator<File> iter = allchildren.iterator();
1127 while(iter.hasNext()) {
1128 child = iter.next();
1129 newelement = new TraceFileSystemElement(provider.getLabel(child), this, provider.isFolder(child));
1130 newelement.setFileSystemObject(child);
1131 }
1132 setPopulated();
1133 }
1134 }
16f91bd5
BH
1135
1136 private class ImportProvider implements IImportStructureProvider {
1137
1138 private FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;
1139
1140 ImportProvider() {
1141 }
1142
1143 @Override
1144 public String getLabel(Object element) {
1145 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1146 return resource.getLabel();
1147 }
1148
1149 @Override
1150 public List getChildren(Object element) {
1151 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1152 Object[] array = resource.getFiles().getChildren();
1153 List<Object> list = new ArrayList<>();
1154 for (int i = 0; i < array.length; i++) {
1155 list.add(array[i]);
1156 }
1157 return list;
1158 }
1159
1160 @Override
1161 public InputStream getContents(Object element) {
1162 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1163 return provider.getContents(resource.getFileSystemObject());
1164 }
1165
1166 @Override
1167 public String getFullPath(Object element) {
1168 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1169 return provider.getFullPath(resource.getFileSystemObject());
1170 }
1171
1172 @Override
1173 public boolean isFolder(Object element) {
1174 TraceFileSystemElement resource = (TraceFileSystemElement)element;
1175 return resource.isDirectory();
1176 }
1177 }
1178
1179 private enum ImportConfirmation {
1180 // ------------------------------------------------------------------------
1181 // Enum definition
1182 // ------------------------------------------------------------------------
1183 RENAME(Messages.ImportTraceWizard_ImportConfigurationRename),
1184 RENAME_ALL(Messages.ImportTraceWizard_ImportConfigurationRenameAll),
1185 OVERWRITE(Messages.ImportTraceWizard_ImportConfigurationOverwrite),
1186 OVERWRITE_ALL(Messages.ImportTraceWizard_ImportConfigurationOverwriteAll),
1187 SKIP(Messages.ImportTraceWizard_ImportConfigurationSkip),
1188 SKIP_ALL(Messages.ImportTraceWizard_ImportConfigurationSkipAll),
1189 CONTINUE("CONTINUE"); //$NON-NLS-1$
1190
1191 // ------------------------------------------------------------------------
1192 // Attributes
1193 // ------------------------------------------------------------------------
1194 /**
1195 * Name of enum
1196 */
1197 private final String fInName;
1198
1199 // ------------------------------------------------------------------------
1200 // Constuctors
1201 // ------------------------------------------------------------------------
1202
1203 /**
1204 * Private constructor
1205 * @param name the name of state
1206 */
1207 private ImportConfirmation(String name) {
1208 fInName = name;
1209 }
1210
1211 // ------------------------------------------------------------------------
1212 // Accessors
1213 // ------------------------------------------------------------------------
1214 /**
1215 * @return state name
1216 */
1217 public String getInName() {
1218 return fInName;
1219 }
1220 }
002f9f07 1221}
This page took 0.078211 seconds and 5 git commands to generate.