Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2013-11-14 18:42:44 -0500
committerMarc-Andre Laperle2013-12-09 15:09:43 -0500
commit1bf44920f3697717aabb76b9ae85971ef7da4404 (patch)
tree8200b282f39b9940611bbdf4924c84f0dabed5b4
parent9760b1372065624c01bc403c6adfb4cfc9633ec1 (diff)
downloadorg.eclipse.linuxtools-1bf44920f3697717aabb76b9ae85971ef7da4404.tar.gz
org.eclipse.linuxtools-1bf44920f3697717aabb76b9ae85971ef7da4404.tar.xz
org.eclipse.linuxtools-1bf44920f3697717aabb76b9ae85971ef7da4404.zip
tmf: Import and export multiple traces in a package
Change-Id: I935a1fcf76518bcad02940f8cc687389dae89673 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/18533 Reviewed-on: https://git.eclipse.org/r/19532
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml45
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/schema/export-manifest.xsd2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/Messages.java4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/messages.properties4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageOperation.java19
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageWizardPage.java29
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageHandler.java55
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java67
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizard.java21
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizardPage.java25
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ImportTracePackageWizardPage.java86
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java13
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java18
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java141
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties6
16 files changed, 381 insertions, 158 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml b/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
index 9876d7291e..f40ff7bb99 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
@@ -612,18 +612,26 @@
checkEnabled="false">
<with
variable="selection">
- <and>
- <count
- value="1">
- </count>
- <iterate
- ifEmpty="false"
- operator="and">
- <instanceof
- value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
- </instanceof>
- </iterate>
- </and>
+ <or>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
+ </instanceof>
+ </iterate>
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">
+ </instanceof>
+ </iterate>
+ </and>
+ </or>
</with>
</visibleWhen>
</command>
@@ -1091,19 +1099,6 @@
<handler
class="org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.ExportTracePackageHandler"
commandId="org.eclipse.linuxtools.tmf.ui.command.exporttracepkg">
- <activeWhen>
- <and>
- <count
- value="1">
- </count>
- <iterate
- operator="and">
- <instanceof
- value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement">
- </instanceof>
- </iterate>
- </and>
- </activeWhen>
</handler>
<handler
class="org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.ImportTracePackageHandler"
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/schema/export-manifest.xsd b/lttng/org.eclipse.linuxtools.tmf.ui/schema/export-manifest.xsd
index 4f19998ae7..21480bd8d7 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/schema/export-manifest.xsd
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/schema/export-manifest.xsd
@@ -15,7 +15,7 @@
<xs:element name="tmf-export">
<xs:complexType>
<xs:sequence>
- <xs:element name="trace">
+ <xs:element name="trace" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/Messages.java
index 9b1996bea9..ab451ab7b3 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/Messages.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/Messages.java
@@ -25,8 +25,8 @@ public class Messages extends NLS {
public static String SelectSpplementaryResources_DialogTitle;
public static String SelectSpplementaryResources_ResourcesGroupTitle;
- public static String SelectSpplementaryResources_SelectAll;
- public static String SelectSpplementaryResources_DeselectAll;
+ public static String Dialog_SelectAll;
+ public static String Dialog_DeselectAll;
static {
// initialize resource bundle
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java
index 4357da8dd8..7a91bcc51e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/SelectSupplementaryResourcesDialog.java
@@ -178,7 +178,7 @@ public class SelectSupplementaryResourcesDialog extends Dialog {
btComp.setLayoutData(gd);
final Button selectAll = new Button(btComp, SWT.PUSH);
- selectAll.setText(Messages.SelectSpplementaryResources_SelectAll);
+ selectAll.setText(Messages.Dialog_SelectAll);
selectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -192,7 +192,7 @@ public class SelectSupplementaryResourcesDialog extends Dialog {
});
final Button deselectAll = new Button(btComp, SWT.PUSH);
- deselectAll.setText(Messages.SelectSpplementaryResources_DeselectAll);
+ deselectAll.setText(Messages.Dialog_DeselectAll);
deselectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/messages.properties
index ab6840b537..476306e1fd 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/dialogs/messages.properties
@@ -12,5 +12,5 @@
###############################################################################
SelectSpplementaryResources_DialogTitle=Delete Resources
SelectSpplementaryResources_ResourcesGroupTitle=Select resources to delete
-SelectSpplementaryResources_SelectAll=Select All
-SelectSpplementaryResources_DeselectAll=Deselect All \ No newline at end of file
+Dialog_SelectAll=Select All
+Dialog_DeselectAll=Deselect All \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageOperation.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageOperation.java
index 03376610de..ee13ca5167 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageOperation.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageOperation.java
@@ -139,6 +139,25 @@ abstract public class AbstractTracePackageOperation {
}
/**
+ * Returns whether or not the Files element is checked under the given trace
+ * package element
+ *
+ * @param tracePackageElement
+ * the trace package element
+ * @return whether or not the Files element is checked under the given trace
+ * package element
+ */
+ public static boolean isFilesChecked(TracePackageElement tracePackageElement) {
+ for (TracePackageElement element : tracePackageElement.getChildren()) {
+ if (element instanceof TracePackageFilesElement) {
+ return element.isChecked();
+ }
+ }
+
+ return false;
+ }
+
+ /**
* Common interface between ZipEntry and TarEntry
*/
protected interface ArchiveEntry {
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageWizardPage.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageWizardPage.java
index 655a06b6ad..e8d3d08369 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageWizardPage.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/AbstractTracePackageWizardPage.java
@@ -89,11 +89,11 @@ abstract public class AbstractTracePackageWizardPage extends WizardPage {
/**
* Create the element viewer
*
- * @param parent
+ * @param compositeParent
* the parent composite
*/
- protected void createElementViewer(Composite parent) {
- fElementViewer = new CheckboxTreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.CHECK);
+ protected void createElementViewer(Composite compositeParent) {
+ fElementViewer = new CheckboxTreeViewer(compositeParent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.CHECK);
fElementViewer.addCheckStateListener(new ICheckStateListener() {
@Override
@@ -105,6 +105,29 @@ abstract public class AbstractTracePackageWizardPage extends WizardPage {
setSubtreeChecked(fElementViewer, element, true, event.getChecked());
}
maintainCheckIntegrity(element);
+
+ if (element.getParent() != null) {
+ // Uncheck everything in this trace if Trace files are unchecked
+ if (element instanceof TracePackageFilesElement) {
+ if (!element.isChecked()) {
+ setSubtreeChecked(fElementViewer, element.getParent(), false, false);
+ }
+ // Check Trace files if anything else is selected
+ } else if (element.isChecked()) {
+ TracePackageElement parent = element.getParent();
+ while (parent != null) {
+ for (TracePackageElement e : parent.getChildren()) {
+ if (e instanceof TracePackageFilesElement) {
+ setSubtreeChecked(fElementViewer, e, false, true);
+ break;
+ }
+ }
+ parent = parent.getParent();
+ }
+ }
+ }
+
+
updateApproximateSelectedSize();
updatePageCompletion();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageHandler.java
index 525af468d2..e6674d8bc1 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageHandler.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageHandler.java
@@ -12,6 +12,9 @@
package org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@@ -19,6 +22,10 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
+import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -30,25 +37,69 @@ import org.eclipse.ui.handlers.HandlerUtil;
*/
public class ExportTracePackageHandler extends AbstractHandler {
+ private boolean fEnabled = false;
+
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- ExportTracePackageWizard w = new ExportTracePackageWizard();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-
if (window == null) {
return false;
}
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
IStructuredSelection sec = StructuredSelection.EMPTY;
+ List<TmfTraceElement> selectedTraces = new ArrayList<TmfTraceElement>();
if (currentSelection instanceof IStructuredSelection) {
sec = (IStructuredSelection) currentSelection;
+ Object[] selectedElements = sec.toArray();
+ for (Object selectedElement : selectedElements) {
+ if (selectedElement instanceof TmfTraceElement) {
+ TmfTraceElement tmfTraceElement = (TmfTraceElement) selectedElement;
+ selectedTraces.add(tmfTraceElement.getElementUnderTraceFolder());
+ } else if (selectedElement instanceof TmfTraceFolder) {
+ TmfTraceFolder tmfTraceFolder = (TmfTraceFolder) selectedElement;
+ selectedTraces = tmfTraceFolder.getTraces();
+ }
+ }
}
+ ExportTracePackageWizard w = new ExportTracePackageWizard(selectedTraces);
+
w.init(PlatformUI.getWorkbench(), sec);
WizardDialog dialog = new WizardDialog(window.getShell(), w);
dialog.open();
return null;
}
+ @Override
+ public boolean isEnabled() {
+ return super.isEnabled() && fEnabled;
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ super.setEnabled(evaluationContext);
+
+ fEnabled = true;
+
+ Object s = HandlerUtil.getVariable(evaluationContext, ISources.ACTIVE_MENU_SELECTION_NAME);
+ if (s instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) s;
+ // If we have traces selected, make sure they are all from the same
+ // project, disable handler otherwise
+ Object[] selectedElements = selection.toArray();
+ TmfProjectElement firstProject = null;
+ for (Object selectedElement : selectedElements) {
+ if (selectedElement instanceof TmfTraceElement) {
+ TmfTraceElement tmfTraceElement = (TmfTraceElement) selectedElement;
+ TmfProjectElement project = tmfTraceElement.getProject();
+ if (firstProject != null && !project.equals(firstProject)) {
+ fEnabled = false;
+ }
+
+ firstProject = project;
+ }
+ }
+ }
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java
index eaf11bc6e4..ead9438820 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageSelectTraceWizardPage.java
@@ -32,6 +32,7 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
@@ -88,7 +89,7 @@ public class ExportTracePackageSelectTraceWizardPage extends WizardPage {
projectViewer.setLabelProvider(new WorkbenchLabelProvider());
projectViewer.setInput(TraceUtils.getOpenedTmfProjects().toArray(new IProject[] {}));
- fTraceTable = new Table(projectSelectionGroup, SWT.SINGLE | SWT.BORDER);
+ fTraceTable = new Table(projectSelectionGroup, SWT.BORDER | SWT.CHECK);
fTraceTable.setLayoutData(new GridData(GridData.FILL_BOTH));
final TableViewer traceViewer = new TableViewer(fTraceTable);
@@ -113,12 +114,8 @@ public class ExportTracePackageSelectTraceWizardPage extends WizardPage {
fTraceTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- TableItem[] items = fTraceTable.getSelection();
- TmfTraceElement trace = (TmfTraceElement) items[0].getData();
- ExportTracePackageWizardPage page = (ExportTracePackageWizardPage) getWizard().getPage(ExportTracePackageWizardPage.PAGE_NAME);
- ArrayList<TmfTraceElement> traces = new ArrayList<TmfTraceElement>();
- traces.add(trace);
- page.setSelectedTraces(traces);
+ getWizard().getContainer().updateButtons();
+ updateNextPageData();
}
});
@@ -143,13 +140,67 @@ public class ExportTracePackageSelectTraceWizardPage extends WizardPage {
}
});
+ Composite btComp = new Composite(projectSelectionGroup, SWT.NONE);
+ btComp.setLayout(new GridLayout(2, true));
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.horizontalAlignment = SWT.RIGHT;
+ btComp.setLayoutData(gd);
+
+ final Button selectAll = new Button(btComp, SWT.PUSH);
+ selectAll.setText(org.eclipse.linuxtools.internal.tmf.ui.project.dialogs.Messages.Dialog_SelectAll);
+ selectAll.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = fTraceTable.getItems();
+ for (TableItem item : items) {
+ item.setChecked(true);
+ }
+
+ getWizard().getContainer().updateButtons();
+ updateNextPageData();
+ }
+ });
+
+ final Button deselectAll = new Button(btComp, SWT.PUSH);
+ deselectAll.setText(org.eclipse.linuxtools.internal.tmf.ui.project.dialogs.Messages.Dialog_DeselectAll);
+ deselectAll.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = fTraceTable.getItems();
+ for (TableItem item : items) {
+ item.setChecked(false);
+ }
+
+ getWizard().getContainer().updateButtons();
+ updateNextPageData();
+ }
+ });
+
setControl(projectSelectionGroup);
setTitle(Messages.ExportTracePackageWizardPage_Title);
setMessage(Messages.ExportTracePackageSelectTraceWizardPage_ChooseTrace);
}
+ private ArrayList<TmfTraceElement> getCheckedTraces() {
+ TableItem[] items = fTraceTable.getItems();
+ ArrayList<TmfTraceElement> traces = new ArrayList<TmfTraceElement>();
+ for (TableItem item : items) {
+ if (item.getChecked()) {
+ TmfTraceElement trace = (TmfTraceElement) item.getData();
+ traces.add(trace);
+ }
+ }
+ return traces;
+ }
+
+ private void updateNextPageData() {
+ ExportTracePackageWizardPage page = (ExportTracePackageWizardPage) getWizard().getPage(ExportTracePackageWizardPage.PAGE_NAME);
+ page.setSelectedTraces(getCheckedTraces());
+ }
+
@Override
public boolean canFlipToNextPage() {
- return fTraceTable.getSelectionCount() > 0;
+ return getCheckedTraces().size() > 0;
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizard.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizard.java
index 2eb2c2ad0d..21889161d4 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizard.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizard.java
@@ -12,6 +12,9 @@
package org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
@@ -29,6 +32,7 @@ public class ExportTracePackageWizard extends Wizard implements IExportWizard {
private static final String STORE_EXPORT_TRACE_WIZARD = "ExportTraceWizard"; //$NON-NLS-1$
private IStructuredSelection fSelection;
+ private List<TmfTraceElement> fSelectedTraces;
private ExportTracePackageWizardPage fPage;
/**
@@ -42,11 +46,24 @@ public class ExportTracePackageWizard extends Wizard implements IExportWizard {
section = workbenchSettings.addNewSection(STORE_EXPORT_TRACE_WIZARD);
}
setDialogSettings(section);
+ fSelectedTraces = new ArrayList<TmfTraceElement>();
+ }
+
+ /**
+ * Constructor for the export trace wizard with known selected traces
+ *
+ * @param selectedTraces
+ * the selected traces
+ */
+ public ExportTracePackageWizard(List<TmfTraceElement> selectedTraces) {
+ this();
+ fSelectedTraces = selectedTraces;
}
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
fSelection = selection;
+
setNeedsProgressMonitor(true);
}
@@ -58,8 +75,8 @@ public class ExportTracePackageWizard extends Wizard implements IExportWizard {
@Override
public void addPages() {
super.addPages();
- fPage = new ExportTracePackageWizardPage(fSelection);
- if (!(fSelection.getFirstElement() instanceof TmfTraceElement)) {
+ fPage = new ExportTracePackageWizardPage(fSelection, fSelectedTraces);
+ if (fSelectedTraces.isEmpty()) {
addPage(new ExportTracePackageSelectTraceWizardPage());
}
addPage(fPage);
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizardPage.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizardPage.java
index 575ddd4251..b7e1734108 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizardPage.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ExportTracePackageWizardPage.java
@@ -90,17 +90,12 @@ public class ExportTracePackageWizardPage extends AbstractTracePackageWizardPage
*
* @param selection
* the current object selection
+ * @param selectedTraces
+ * the selected traces from the selection
*/
- public ExportTracePackageWizardPage(IStructuredSelection selection) {
+ public ExportTracePackageWizardPage(IStructuredSelection selection, List<TmfTraceElement> selectedTraces) {
super(PAGE_NAME, Messages.ExportTracePackageWizardPage_Title, Activator.getDefault().getImageDescripterFromPath(ICON_PATH), selection);
-
- Object[] selectedElements = getSelection().toArray();
- fSelectedTraces = new ArrayList<TmfTraceElement>();
- for (Object selectedElement : selectedElements) {
- if (selectedElement instanceof TmfTraceElement) {
- fSelectedTraces.add(((TmfTraceElement) selectedElement).getElementUnderTraceFolder());
- }
- }
+ fSelectedTraces = selectedTraces;
}
/**
@@ -144,6 +139,16 @@ public class ExportTracePackageWizardPage extends AbstractTracePackageWizardPage
setControl(composite);
}
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ updatePageCompletion();
+ } else {
+ setPageComplete(false);
+ }
+ }
+
/**
* Restore widget values to the values that they held last time this wizard
* was used to completion.
@@ -299,8 +304,6 @@ public class ExportTracePackageWizardPage extends AbstractTracePackageWizardPage
List<TracePackageElement> children = new ArrayList<TracePackageElement>();
TracePackageFilesElement filesElement = new TracePackageFilesElement(traceElement, tmfTraceElement.getResource());
filesElement.setChecked(true);
- // Always export the files
- filesElement.setEnabled(false);
children.add(filesElement);
// Supplementary files
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ImportTracePackageWizardPage.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ImportTracePackageWizardPage.java
index e57e5e4fcb..51613905aa 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ImportTracePackageWizardPage.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ImportTracePackageWizardPage.java
@@ -14,12 +14,15 @@ package org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importex
import java.io.File;
import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -27,6 +30,7 @@ import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.internal.tmf.ui.project.model.TmfImportHelper;
+import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.AbstractTracePackageOperation;
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.AbstractTracePackageWizardPage;
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement;
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement;
@@ -233,18 +237,12 @@ public class ImportTracePackageWizardPage extends AbstractTracePackageWizardPage
// Canceled
}
- TracePackageElement resultElement = op.getResultElement();
- if (resultElement == null) {
+ TracePackageElement[] resultElements = op.getResultElement();
+ if (resultElements == null || resultElements.length == 0) {
return null;
}
- for (TracePackageElement e : resultElement.getChildren()) {
- if (e instanceof TracePackageFilesElement) {
- e.setEnabled(false);
- }
- }
-
- return new TracePackageElement[] { resultElement };
+ return resultElements;
}
@Override
@@ -313,9 +311,9 @@ public class ImportTracePackageWizardPage extends AbstractTracePackageWizardPage
saveWidgetValues();
- TracePackageElement[] input = (TracePackageElement[]) getElementViewer().getInput();
- TracePackageTraceElement traceElement = (TracePackageTraceElement) input[0];
- final TracePackageImportOperation importOperation = new TracePackageImportOperation(fValidatedFilePath, traceElement, fTmfTraceFolder);
+ Object input = getElementViewer().getInput();
+ TracePackageElement[] traceElements = (TracePackageElement[]) input;
+ final TracePackageImportOperation importOperation = new TracePackageImportOperation(fValidatedFilePath, traceElements, fTmfTraceFolder);
try {
getContainer().run(true, true, new IRunnableWithProgress() {
@@ -339,16 +337,72 @@ public class ImportTracePackageWizardPage extends AbstractTracePackageWizardPage
}
private boolean checkForOverwrite() {
- TracePackageTraceElement traceElement = (TracePackageTraceElement) ((TracePackageElement[]) getElementViewer().getInput())[0];
- String traceName = traceElement.getText();
+ TracePackageElement[] traceElements = (TracePackageElement[]) getElementViewer().getInput();
+ List<TracePackageTraceElement> noImportTraces = new ArrayList<TracePackageTraceElement>();
+ boolean noToAll = false;
+ for (TracePackageElement packageElement : traceElements) {
+ TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement;
+ if (!AbstractTracePackageOperation.isFilesChecked(traceElement)) {
+ continue;
+ }
+
+ if (noToAll) {
+ noImportTraces.add(traceElement);
+ continue;
+ }
+
+ String traceName = traceElement.getText();
+ if (traceExists(traceName)) {
+ int returnCode = promptForOverwrite(traceName);
+ final String[] response = new String[] { IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.YES_LABEL };
+ if (response[returnCode].equals(IDialogConstants.YES_TO_ALL_LABEL)) {
+ break;
+ } else if (response[returnCode].equals(IDialogConstants.NO_TO_ALL_LABEL)) {
+ noToAll = true;
+ noImportTraces.add(traceElement);
+ } else if (response[returnCode].equals(IDialogConstants.NO_LABEL)) {
+ noImportTraces.add(traceElement);
+ }
+ }
+ }
+
+ // Unselect the traces that the user decided not to import
+ for (TracePackageTraceElement t : noImportTraces) {
+ for (TracePackageElement e : t.getChildren()) {
+ if (e instanceof TracePackageFilesElement) {
+ ((TracePackageFilesElement) e).setChecked(false);
+ }
+ }
+ }
+
+ return true;
+ }
+ private boolean traceExists(String traceName) {
List<TmfTraceElement> traces = fTmfTraceFolder.getTraces();
for (TmfTraceElement t : traces) {
if (t.getName().equals(traceName)) {
- return MessageDialog.openQuestion(getContainer().getShell(), null, Messages.ImportTracePackageWizardPage_AlreadyExists);
+ return true;
}
}
- return true;
+ return false;
+ }
+
+ private int promptForOverwrite(String traceName) {
+ final MessageDialog dialog = new MessageDialog(getContainer()
+ .getShell(), null, null, MessageFormat.format(Messages.ImportTracePackageWizardPage_AlreadyExists, traceName),
+ MessageDialog.QUESTION, new String[] {
+ IDialogConstants.NO_TO_ALL_LABEL,
+ IDialogConstants.NO_LABEL,
+ IDialogConstants.YES_TO_ALL_LABEL,
+ IDialogConstants.YES_LABEL,
+ }, 3) {
+ @Override
+ protected int getShellStyle() {
+ return super.getShellStyle() | SWT.SHEET;
+ }
+ };
+ return dialog.open();
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java
index c53b56dd50..f9168ae212 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java
@@ -16,7 +16,8 @@ import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
@@ -65,7 +66,7 @@ public class TracePackageExportOperation extends AbstractTracePackageOperation {
private final TracePackageTraceElement[] fTraceExportElements;
private final boolean fUseCompression;
private final boolean fUseTar;
- private final List<IResource> fResources;
+ private final Set<IResource> fResources;
private IFolder fExportFolder;
/**
@@ -85,7 +86,7 @@ public class TracePackageExportOperation extends AbstractTracePackageOperation {
fTraceExportElements = traceExportElements;
fUseCompression = useCompression;
fUseTar = useTar;
- fResources = new ArrayList<IResource>();
+ fResources = new HashSet<IResource>();
}
/**
@@ -110,6 +111,10 @@ public class TracePackageExportOperation extends AbstractTracePackageOperation {
Node tmfNode = doc.appendChild(createElement);
for (TracePackageTraceElement tracePackageElement : fTraceExportElements) {
+ if (!isFilesChecked(tracePackageElement)) {
+ continue;
+ }
+
exportTrace(progressMonitor, tmfNode, tracePackageElement);
}
@@ -268,7 +273,7 @@ public class TracePackageExportOperation extends AbstractTracePackageOperation {
}
private IStatus exportToArchive(IProgressMonitor monitor, int totalWork) throws InvocationTargetException, InterruptedException {
- ArchiveFileExportOperation op = new ArchiveFileExportOperation(fResources, getFileName());
+ ArchiveFileExportOperation op = new ArchiveFileExportOperation(new ArrayList<IResource>(fResources), getFileName());
op.setCreateLeadupStructure(false);
op.setUseCompression(fUseCompression);
op.setUseTarFormat(fUseTar);
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java
index 7cff208d55..1d67e1dc0e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExtractManifestOperation.java
@@ -65,7 +65,7 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
private static final String EXPORT_MANIFEST_SCHEMA_FILE_NAME = "export-manifest.xsd"; //$NON-NLS-1$
// Result of reading the manifest
- private TracePackageElement fResultElement;
+ private TracePackageElement[] fResultElements;
/**
* Constructs a new import operation for reading the manifest
@@ -87,7 +87,7 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
*/
@Override
public void run(IProgressMonitor progressMonitor) {
- TracePackageElement element = null;
+ TracePackageElement[] elements = null;
try {
progressMonitor.worked(1);
ArchiveFile archiveFile = getSpecifiedArchiveFile();
@@ -114,7 +114,7 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
validateManifest(inputStream);
inputStream = archiveFile.getInputStream(entry);
- element = loadElementsFromManifest(inputStream);
+ elements = loadElementsFromManifest(inputStream);
break;
}
@@ -128,7 +128,7 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.TracePackageExtractManifestOperation_ErrorManifestNotFound, ITracePackageConstants.MANIFEST_FILENAME)));
}
- fResultElement = element;
+ fResultElements = elements;
} catch (InterruptedException e) {
setStatus(Status.CANCEL_STATUS);
@@ -142,8 +142,8 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
*
* @return the resulting element
*/
- public TracePackageElement getResultElement() {
- return fResultElement;
+ public TracePackageElement[] getResultElement() {
+ return fResultElements;
}
private static void validateManifest(InputStream xml) throws IOException
@@ -165,7 +165,8 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
}
}
- private static TracePackageElement loadElementsFromManifest(InputStream inputStream) throws IOException, SAXException, ParserConfigurationException {
+ private static TracePackageElement[] loadElementsFromManifest(InputStream inputStream) throws IOException, SAXException, ParserConfigurationException {
+ List<TracePackageElement> packageElements = new ArrayList<TracePackageElement>();
TracePackageElement element = null;
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
@@ -236,8 +237,9 @@ public class TracePackageExtractManifestOperation extends AbstractTracePackageOp
}
element.setChildren(children.toArray(new TracePackageElement[] {}));
+ packageElements.add(element);
}
}
- return element;
+ return packageElements.toArray(new TracePackageElement[] {});
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java
index 2717e70a49..871b7a3cc9 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageImportOperation.java
@@ -61,25 +61,22 @@ import org.eclipse.ui.wizards.datatransfer.ImportOperation;
@SuppressWarnings("restriction")
public class TracePackageImportOperation extends AbstractTracePackageOperation implements IOverwriteQuery {
- private final TracePackageTraceElement fImportTraceElement;
+ private final TracePackageElement[] fImportTraceElements;
private final TmfTraceFolder fTmfTraceFolder;
- // Result of reading the manifest
- private TracePackageElement fResultElement;
-
/**
* Constructs a new import operation
*
- * @param importTraceElement
+ * @param importTraceElements
* the trace element to be imported
* @param fileName
* the output file name
* @param tmfTraceFolder
* the destination folder
*/
- public TracePackageImportOperation(String fileName, TracePackageTraceElement importTraceElement, TmfTraceFolder tmfTraceFolder) {
+ public TracePackageImportOperation(String fileName, TracePackageElement[] importTraceElements, TmfTraceFolder tmfTraceFolder) {
super(fileName);
- fImportTraceElement = importTraceElement;
+ fImportTraceElements = importTraceElements;
fTmfTraceFolder = tmfTraceFolder;
}
@@ -168,7 +165,7 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
*/
@Override
public void run(IProgressMonitor progressMonitor) {
- int totalWork = getNbCheckedElements(new TracePackageElement[] { fImportTraceElement }) * 2;
+ int totalWork = getNbCheckedElements(fImportTraceElements) * 2;
progressMonitor.beginTask(Messages.TracePackageImportOperation_ImportingPackage, totalWork);
doRun(progressMonitor);
progressMonitor.done();
@@ -176,79 +173,95 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
private void doRun(IProgressMonitor progressMonitor) {
try {
- setStatus(deleteExistingTrace(progressMonitor));
+ setStatus(deleteExistingTraces(progressMonitor));
if (getStatus().getSeverity() != IStatus.OK) {
return;
}
- TracePackageElement[] children = fImportTraceElement.getChildren();
- for (TracePackageElement element : children) {
- ModalContext.checkCanceled(progressMonitor);
+ for (TracePackageElement packageElement : fImportTraceElements) {
+ TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement;
+ if (!isFilesChecked(packageElement)) {
+ continue;
+ }
+
+ TracePackageElement[] children = traceElement.getChildren();
+ for (TracePackageElement element : children) {
+ ModalContext.checkCanceled(progressMonitor);
+
+ if (element instanceof TracePackageFilesElement) {
+ TracePackageFilesElement traceFilesElement = (TracePackageFilesElement) element;
+ setStatus(importTraceFiles(traceFilesElement, progressMonitor));
- if (element instanceof TracePackageFilesElement) {
- TracePackageFilesElement traceFilesElement = (TracePackageFilesElement) element;
- setStatus(importTraceFiles(progressMonitor, traceFilesElement));
+ } else if (element instanceof TracePackageSupplFilesElement) {
+ TracePackageSupplFilesElement suppFilesElement = (TracePackageSupplFilesElement) element;
+ setStatus(importSupplFiles(suppFilesElement, traceElement, progressMonitor));
+ }
- } else if (element instanceof TracePackageSupplFilesElement) {
- TracePackageSupplFilesElement suppFilesElement = (TracePackageSupplFilesElement) element;
- setStatus(importSupplFiles(progressMonitor, suppFilesElement));
+ if (getStatus().getSeverity() != IStatus.OK) {
+ return;
+ }
}
- if (getStatus().getSeverity() != IStatus.OK) {
+ String traceName = traceElement.getText();
+ IResource traceRes = fTmfTraceFolder.getResource().findMember(traceName);
+ if (traceRes == null || !traceRes.exists()) {
+ setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorFindingImportedTrace, traceName)));
return;
}
- }
- String traceName = fImportTraceElement.getText();
- IResource traceRes = fTmfTraceFolder.getResource().findMember(traceName);
- if (traceRes == null || !traceRes.exists()) {
- setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorFindingImportedTrace, traceName)));
- return;
- }
+ TraceTypeHelper traceType = TmfTraceType.getInstance().getTraceType(traceElement.getTraceType());
+ if (traceType == null) {
+ setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorSettingTraceType, traceElement.getTraceType(), traceName)));
+ return;
+ }
- TraceTypeHelper traceType = TmfTraceType.getInstance().getTraceType(fImportTraceElement.getTraceType());
- if (traceType == null) {
- setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorSettingTraceType, fImportTraceElement.getTraceType(), traceName)));
- return;
- }
+ try {
+ TmfTraceType.setTraceType(traceRes.getFullPath(), traceType);
+ } catch (CoreException e) {
+ setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorSettingTraceType, traceElement.getTraceType(), traceName), e));
+ }
- try {
- TmfTraceType.setTraceType(traceRes.getFullPath(), traceType);
- } catch (CoreException e) {
- setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.ImportTracePackageWizardPage_ErrorSettingTraceType, fImportTraceElement.getTraceType(), traceName), e));
+ importBookmarks(traceRes, traceElement, progressMonitor);
}
- importBookmarks(traceRes, progressMonitor);
+
} catch (InterruptedException e) {
setStatus(Status.CANCEL_STATUS);
}
}
- private IStatus deleteExistingTrace(IProgressMonitor progressMonitor) {
+ private IStatus deleteExistingTraces(IProgressMonitor progressMonitor) {
List<TmfTraceElement> traces = fTmfTraceFolder.getTraces();
- TmfTraceElement existingTrace = null;
- for (TmfTraceElement t : traces) {
- if (t.getName().equals(fImportTraceElement.getText())) {
- existingTrace = t;
- break;
+ for (TracePackageElement packageElement : fImportTraceElements) {
+ TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement;
+ if (!isFilesChecked(traceElement)) {
+ continue;
}
- }
- if (existingTrace != null) {
- try {
- existingTrace.delete(new SubProgressMonitor(progressMonitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
- } catch (CoreException e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.Messages.TracePackage_ErrorOperation, e);
+ TmfTraceElement existingTrace = null;
+ for (TmfTraceElement t : traces) {
+ if (t.getName().equals(traceElement.getText())) {
+ existingTrace = t;
+ break;
+ }
+ }
+
+ if (existingTrace != null) {
+ try {
+ existingTrace.delete(new SubProgressMonitor(progressMonitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+ } catch (CoreException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.Messages.TracePackage_ErrorOperation, e);
+ }
}
}
return Status.OK_STATUS;
}
- private void importBookmarks(IResource traceRes, IProgressMonitor monitor) {
- for (TracePackageElement o : fImportTraceElement.getChildren()) {
+ private void importBookmarks(IResource traceRes, TracePackageTraceElement traceElement, IProgressMonitor monitor) {
+ for (TracePackageElement o : traceElement.getChildren()) {
if (o instanceof TracePackageBookmarkElement && o.isChecked()) {
// Get element
@@ -315,7 +328,7 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
return fileMatch || folderMatch;
}
- private IStatus importTraceFiles(IProgressMonitor monitor, TracePackageFilesElement traceFilesElement) {
+ private IStatus importTraceFiles(TracePackageFilesElement traceFilesElement, IProgressMonitor monitor) {
List<String> fileNames = new ArrayList<String>();
IPath prefix = new Path(TmfTraceFolder.TRACE_FOLDER_NAME);
fileNames.add(traceFilesElement.getFileName());
@@ -327,7 +340,7 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
return status;
}
- private IStatus importSupplFiles(IProgressMonitor monitor, TracePackageSupplFilesElement suppFilesElement) {
+ private IStatus importSupplFiles(TracePackageSupplFilesElement suppFilesElement, TracePackageTraceElement traceElement, IProgressMonitor monitor) {
List<String> fileNames = new ArrayList<String>();
for (TracePackageElement child : suppFilesElement.getChildren()) {
TracePackageSupplFileElement supplFile = (TracePackageSupplFileElement) child;
@@ -336,20 +349,20 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
if (!fileNames.isEmpty()) {
List<TmfTraceElement> traces = fTmfTraceFolder.getTraces();
- TmfTraceElement traceElement = null;
+ TmfTraceElement tmfTraceElement = null;
for (TmfTraceElement t : traces) {
- if (t.getName().equals(fImportTraceElement.getText())) {
- traceElement = t;
+ if (t.getName().equals(traceElement.getText())) {
+ tmfTraceElement = t;
break;
}
}
- if (traceElement != null) {
+ if (tmfTraceElement != null) {
ArchiveFile archiveFile = getSpecifiedArchiveFile();
- traceElement.refreshSupplementaryFolder();
- String traceName = traceElement.getResource().getName();
+ tmfTraceElement.refreshSupplementaryFolder();
+ String traceName = tmfTraceElement.getResource().getName();
// Project/.tracing/tracename
- IPath destinationContainerPath = traceElement.getTraceSupplementaryFolder(traceName).getFullPath();
+ IPath destinationContainerPath = tmfTraceElement.getTraceSupplementaryFolder(traceName).getFullPath();
// .tracing/tracename
IPath pathInArchive = new Path(TmfCommonConstants.TRACE_SUPPLEMENATARY_FOLDER_NAME).append(traceName);
return importFiles(archiveFile, fileNames, pathInArchive, destinationContainerPath, monitor);
@@ -419,14 +432,4 @@ public class TracePackageImportOperation extends AbstractTracePackageOperation i
// We always overwrite once we reach this point
return null;
}
-
- /**
- * Get the resulting element from extracting the manifest from the archive
- *
- * @return the resulting element
- */
- public TracePackageElement getResultElement() {
- return fResultElement;
- }
-
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties
index 055afc0167..09d6b18e72 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/messages.properties
@@ -10,9 +10,9 @@
# Marc-Andre Laperle - Initial API and implementation
###############################################################################
-ExportTracePackageSelectTraceWizardPage_ChooseTrace=Choose a trace to export
+ExportTracePackageSelectTraceWizardPage_ChooseTrace=Choose traces to export
ExportTracePackageSelectTraceWizardPage_ProjectSelection=Project
-ExportTracePackageSelectTraceWizardPage_TraceSelection=Trace
+ExportTracePackageSelectTraceWizardPage_TraceSelection=Traces
ExportTracePackageWizardPage_AlreadyExitst = Target file already exists. Would you like to overwrite it?
ExportTracePackageWizardPage_ApproximateSizeLbl=Approximate uncompressed size: {0}
ExportTracePackageWizardPage_ChooseContent=Choose the content to export
@@ -29,7 +29,7 @@ ExportTracePackageWizardPage_SizeMegabyte=MB
ExportTracePackageWizardPage_SizeTerabyte=TB
ExportTracePackageWizardPage_Title=Export trace package
ExportTracePackageWizardPage_ToArchive=To &archive file:
-ImportTracePackageWizardPage_AlreadyExists=A trace with the same name already exists. Would you like to overwrite it?
+ImportTracePackageWizardPage_AlreadyExists=A trace with the name ''{0}'' already exists. Would you like to overwrite it?
ImportTracePackageWizardPage_ErrorFileNotFound=File does not exist
ImportTracePackageWizardPage_ErrorOperation=Error occurred during import trace operation
ImportTracePackageWizardPage_ErrorSettingTraceType=Error setting the type {0} for the trace {1}

Back to the top