/*******************************************************************************
- * Copyright (c) 2009, 2010, 2011, 2012 Ericsson and others.
+ * Copyright (c) 2009, 2013 Ericsson and others.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* A variant of the standard resource import wizard with the following changes:
* <ul>
* <li>A folder/file combined checkbox tree viewer to select traces
- * <li>Cherry-picking of traces in the file structure without re-creating the file hierarchy
+ * <li>Cherry-picking of traces in the file structure without re-creating the
+ * file hierarchy
* <li>A trace types dropbox for optional characterization
* </ul>
- * For our purpose, a trace can either be a single file or a whole directory sub-tree, whichever is reached first from
- * the root directory.
+ * For our purpose, a trace can either be a single file or a whole directory
+ * sub-tree, whichever is reached first from the root directory.
* <p>
*
* @version 1.0
// ------------------------------------------------------------------------
/**
- * Constructor.
- * Creates the trace wizard page.
+ * Constructor. Creates the trace wizard page.
*
- * @param name The name of the page.
- * @param selection The current selection
+ * @param name
+ * The name of the page.
+ * @param selection
+ * The current selection
*/
protected ImportTraceWizardPage(String name, IStructuredSelection selection) {
super(name, selection);
/**
* Constructor
- * @param workbench The workbench reference.
- * @param selection The current selection
+ *
+ * @param workbench
+ * The workbench reference.
+ * @param selection
+ * The current selection
*/
public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) {
this(IMPORT_WIZARD_PAGE, selection);
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.WizardResourceImportPage#createControl(org.eclipse.swt.widgets.Composite)
+ *
+ * @see
+ * org.eclipse.ui.dialogs.WizardResourceImportPage#createControl(org.eclipse
+ * .swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
/*
* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.WizardResourceImportPage#createSourceGroup(org.eclipse.swt.widgets.Composite)
+ *
+ * @see
+ * org.eclipse.ui.dialogs.WizardResourceImportPage#createSourceGroup(org
+ * .eclipse.swt.widgets.Composite)
*/
@Override
protected void createSourceGroup(Composite parent) {
/*
* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.WizardResourceImportPage#createFileSelectionGroup(org.eclipse.swt.widgets.Composite)
+ *
+ * @see
+ * org.eclipse.ui.dialogs.WizardResourceImportPage#createFileSelectionGroup
+ * (org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createFileSelectionGroup(Composite parent) {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.dialogs.WizardResourceImportPage#getFolderProvider()
*/
@Override
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.dialogs.WizardResourceImportPage#getFileProvider()
*/
@Override
/*
* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.WizardResourceImportPage#getSelectedResources()
+ *
+ * @see
+ * org.eclipse.ui.dialogs.WizardResourceImportPage#getSelectedResources()
*/
@Override
protected List<FileSystemElement> getSelectedResources() {
/**
* creates the directory selection group.
- * @param parent the parent composite
+ *
+ * @param parent
+ * the parent composite
*/
protected void createDirectorySelectionGroup(Composite parent) {
/*
* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.WizardResourceImportPage#handleEvent(org.eclipse.swt.widgets.Event)
+ *
+ * @see
+ * org.eclipse.ui.dialogs.WizardResourceImportPage#handleEvent(org.eclipse
+ * .swt.widgets.Event)
*/
@Override
public void handleEvent(Event event) {
});
}
- // The mapping of available trace type IDs to their corresponding configuration element
+ // The mapping of available trace type IDs to their corresponding
+ // configuration element
private final Map<String, IConfigurationElement> fTraceTypeAttributes = new HashMap<String, IConfigurationElement>();
private final Map<String, IConfigurationElement> fTraceCategories = new HashMap<String, IConfigurationElement>();
private final Map<String, IConfigurationElement> fTraceAttributes = new HashMap<String, IConfigurationElement>();
/*
* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.WizardDataTransferPage#createOptionsGroupButtons(org.eclipse.swt.widgets.Group)
+ *
+ * @see
+ * org.eclipse.ui.dialogs.WizardDataTransferPage#createOptionsGroupButtons
+ * (org.eclipse.swt.widgets.Group)
*/
@Override
protected void createOptionsGroupButtons(Group optionsGroup) {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.ui.dialogs.WizardDataTransferPage#validateSourceGroup()
*/
@Override
// Perform trace validation
String traceTypeName = fTraceTypes.getText();
if (traceTypeName != null && !"".equals(traceTypeName) && //$NON-NLS-1$
- !traceTypeName.startsWith(CUSTOM_TXT_CATEGORY) && !traceTypeName.startsWith(CUSTOM_XML_CATEGORY)) {
+ !traceTypeName.startsWith(CUSTOM_TXT_CATEGORY) && !traceTypeName.startsWith(CUSTOM_XML_CATEGORY)) {
List<File> traces = isolateTraces();
for (File trace : traces) {
- ITmfTrace<?> tmfTrace = null;
+ ITmfTrace tmfTrace = null;
+
try {
IConfigurationElement ce = fTraceAttributes.get(traceTypeName);
- tmfTrace = (ITmfTrace<?>) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);
- if (tmfTrace != null && !tmfTrace.validate(fProject, trace.getAbsolutePath())) {
- setMessage(null);
- setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
- tmfTrace.dispose();
- return false;
+ tmfTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);
+ if (tmfTrace != null) {
+ IStatus status = tmfTrace.validate(fProject, trace.getAbsolutePath());
+ if (!status.isOK()) {
+ setMessage(null);
+ setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
+ tmfTrace.dispose();
+ return false;
+ }
}
} catch (CoreException e) {
} finally {
/**
* Finish the import.
+ *
* @return <code>true</code> if successful else false
*/
public boolean finish() {
return false;
}
- String sourceDirPath;
try {
- sourceDirPath = sourceDir.getCanonicalPath();
+ sourceDir.getCanonicalPath();
} catch (IOException e) {
MessageDialog.openInformation(getContainer().getShell(), Messages.ImportTraceWizard_Information,
Messages.ImportTraceWizard_InvalidTraceDirectory);
List<FileSystemElement> selectedResources = getSelectedResources();
Iterator<FileSystemElement> resources = selectedResources.iterator();
- // Use a map to end up with unique resources (getSelectedResources() can return duplicates)
+ // Use a map to end up with unique resources (getSelectedResources() can
+ // return duplicates)
Map<String, File> fileSystemObjects = new HashMap<String, File>();
while (resources.hasNext()) {
File file = (File) resources.next().getFileSystemObject();
}
if (fileSystemObjects.size() > 0) {
- boolean ok = importResources(sourceDirPath, fileSystemObjects);
+ boolean ok = importResources(fileSystemObjects);
String traceBundle = null;
String traceTypeId = null;
String traceIcon = null;
return false;
}
- private boolean importResources(String rootDirectory, Map<String, File> fileSystemObjects) {
+ private boolean importResources(Map<String, File> fileSystemObjects) {
// Determine the sorted canonical list of items to import
List<File> fileList = new ArrayList<File>();
}
});
- // Perform a distinct import operation for everything that has the same prefix
- // (distinct prefixes correspond to traces - we don't want to re-create parent structures)
+ // Perform a distinct import operation for everything that has the same
+ // prefix
+ // (distinct prefixes correspond to traces - we don't want to re-create
+ // parent structures)
boolean ok = true;
boolean isLinked = createLinksInWorkspaceButton.getSelection();
for (int i = 0; i < fileList.size(); i++) {