From 0cbb3a9c2591d7916ab4272bffa3c25daf68adbf Mon Sep 17 00:00:00 2001 From: Geneviève Bastien Date: Mon, 18 Feb 2013 10:20:00 -0500 Subject: TMF: Add supplementary folder to experiments Just like traces, experiments can save information in supplementary files on disk (see bug 400949). * Added class TmfWithFolderElement that TmfTraceElement and TmfExperimentElement extends * TmfExperiment constructors are modified/added to receive a IResource as parameter * Call to constructors are modified in the .ui code to add the resources * Added calls to delete/copy/rename supplementary folder Change-Id: Ic6996ca2c39bd3ea499521349f04bfc7c237b419 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/10435 Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Tested-by: Alexandre Montplaisir --- .../linuxtools/tmf/core/trace/TmfExperiment.java | 40 +++- .../project/handlers/DeleteExperimentHandler.java | 7 + .../DeleteExperimentSupplementaryFilesHandler.java | 5 +- .../ui/project/handlers/OpenExperimentHandler.java | 8 +- .../linuxtools/tmf/ui/editors/TmfEventsEditor.java | 2 +- .../tmf/ui/project/model/TmfExperimentElement.java | 12 +- .../tmf/ui/project/model/TmfTraceElement.java | 144 +------------- .../tmf/ui/project/model/TmfWithFolderElement.java | 206 +++++++++++++++++++++ .../ui/project/wizards/CopyExperimentDialog.java | 14 +- .../ui/project/wizards/RenameExperimentDialog.java | 2 + 10 files changed, 286 insertions(+), 154 deletions(-) create mode 100644 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfWithFolderElement.java diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java index 674b3dc909..296a77f97e 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java @@ -80,9 +80,26 @@ public class TmfExperiment extends TmfTrace implements ITmfEventParser { * @param traces the experiment set of traces */ public TmfExperiment(final Class type, final String id, final ITmfTrace[] traces) { - this(type, id, traces, DEFAULT_INDEX_PAGE_SIZE); + this(type, id, traces, DEFAULT_INDEX_PAGE_SIZE, null); } + /** + * Constructor of experiment taking type, path, traces and resource + * + * @param type + * the event type + * @param id + * the experiment id + * @param traces + * the experiment set of traces + * @param resource + * the resource associated to the experiment + */ + public TmfExperiment(final Class type, final String id, final ITmfTrace[] traces, IResource resource) { + this(type, id, traces, DEFAULT_INDEX_PAGE_SIZE, resource); + } + + /** * @param type the event type * @param path the experiment path @@ -90,12 +107,31 @@ public class TmfExperiment extends TmfTrace implements ITmfEventParser { * @param indexPageSize the experiment index page size */ public TmfExperiment(final Class type, final String path, final ITmfTrace[] traces, final int indexPageSize) { + this(type, path, traces, indexPageSize, null); + } + + /** + * Full constructor of an experiment, taking the type, path, traces, + * indexPageSize and resource + * + * @param type + * the event type + * @param path + * the experiment path + * @param traces + * the experiment set of traces + * @param indexPageSize + * the experiment index page size + * @param resource + * the resource associated to the experiment + */ + public TmfExperiment(final Class type, final String path, final ITmfTrace[] traces, final int indexPageSize, IResource resource) { setCacheSize(indexPageSize); setStreamingInterval(0); setIndexer(new TmfCheckpointIndexer(this, indexPageSize)); setParser(this); try { - super.initialize(null, path, type); + super.initialize(resource, path, type); } catch (TmfTraceException e) { e.printStackTrace(); } diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentHandler.java index 959d00ca07..f86ea8e143 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentHandler.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentHandler.java @@ -20,6 +20,7 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.TreeSelection; import org.eclipse.linuxtools.internal.tmf.ui.Activator; @@ -96,6 +97,12 @@ public class DeleteExperimentHandler extends AbstractHandler { } } + IPath path = resource.getLocation(); + if (path != null) { + // Delete supplementary files + experiment.deleteSupplementaryFolder(); + } + // Finally, delete the experiment resource.delete(true, null); diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentSupplementaryFilesHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentSupplementaryFilesHandler.java index e11fb31466..7d8a7c375e 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentSupplementaryFilesHandler.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DeleteExperimentSupplementaryFilesHandler.java @@ -79,13 +79,16 @@ public class DeleteExperimentSupplementaryFilesHandler extends AbstractHandler { TmfExperimentElement trace = (TmfExperimentElement) element; + IResource[] resources = trace.getSupplementaryResources(); + resourcesList.addAll(Arrays.asList(resources)); + for (TmfTraceElement aTrace : trace.getTraces()) { // If trace is under an experiment, use the original trace from the traces folder aTrace = aTrace.getElementUnderTraceFolder(); // Delete the selected resources - IResource[] resources = aTrace.getSupplementaryResources(); + resources = aTrace.getSupplementaryResources(); resourcesList.addAll(Arrays.asList(resources)); } diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java index 6bc0d4d88d..5d367958c6 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java @@ -120,6 +120,12 @@ public class OpenExperimentHandler extends AbstractHandler { return; } + /* Unlike traces, there is no instanceExperiment, so we call this function + * here alone. Maybe it would be better to do this on experiment's element + * constructor? + */ + experimentElement.refreshSupplementaryFolder(); + // Instantiate the experiment's traces final List traceEntries = experimentElement.getTraces(); final int nbTraces = traceEntries.size(); @@ -167,7 +173,7 @@ public class OpenExperimentHandler extends AbstractHandler { } // Create the experiment - final TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, experimentElement.getName(), traces, cacheSize); + final TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, experimentElement.getName(), traces, cacheSize, experimentElement.getResource()); experiment.setBookmarksFile(file); final String editorId = commonEditorId; diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java index 7357d1bba6..68c689effd 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/editors/TmfEventsEditor.java @@ -158,7 +158,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus cacheSize = Math.min(cacheSize, trace.getCacheSize()); traces[i] = trace; } - final TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, experimentElement.getName(), traces, cacheSize); + final TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, experimentElement.getName(), traces, cacheSize, experimentElement.getResource()); experiment.setBookmarksFile(fFile); fTrace = experiment; break; diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java index 33448a383d..3ad213d45a 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfExperimentElement.java @@ -35,7 +35,7 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; * @author Francois Chouinard * */ -public class TmfExperimentElement extends TmfProjectModelElement implements IPropertySource2 { +public class TmfExperimentElement extends TmfWithFolderElement implements IPropertySource2 { // ------------------------------------------------------------------------ // Constants @@ -46,6 +46,7 @@ public class TmfExperimentElement extends TmfProjectModelElement implements IPro private static final String sfName = "name"; //$NON-NLS-1$ private static final String sfPath = "path"; //$NON-NLS-1$ private static final String sfLocation = "location"; //$NON-NLS-1$ + private static final String sfFolderSuffix = "_exp"; //$NON-NLS-1$ private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName); private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath); @@ -230,4 +231,13 @@ public class TmfExperimentElement extends TmfProjectModelElement implements IPro return false; } + /** + * Return the suffix for resource names + * @return The folder suffix + */ + @Override + public String getSuffix() { + return sfFolderSuffix; + } + } diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java index 2b3ca409d7..20d9852036 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java @@ -9,6 +9,7 @@ * Contributors: * Francois Chouinard - Initial API and implementation * Bernd Hufmann - Added supplementary files handling + * Geneviève Bastien - Moved supplementary files handling to parent class *******************************************************************************/ package org.eclipse.linuxtools.tmf.ui.project.model; @@ -24,7 +25,6 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; import org.eclipse.linuxtools.internal.tmf.ui.Activator; import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtEvent; @@ -51,7 +51,7 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; * @version 1.0 * @author Francois Chouinard */ -public class TmfTraceElement extends TmfProjectModelElement implements IActionFilter, IPropertySource2 { +public class TmfTraceElement extends TmfWithFolderElement implements IActionFilter, IPropertySource2 { // ------------------------------------------------------------------------ // Constants @@ -332,146 +332,6 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi return this; } - /** - * Deletes the trace specific supplementary folder. - */ - public void deleteSupplementaryFolder() { - IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); - if (supplFolder.exists()) { - try { - supplFolder.delete(true, new NullProgressMonitor()); - } catch (CoreException e) { - Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ - } - } - } - - /** - * Renames the trace specific supplementary folder according to the new trace name. - * - * @param newTraceName The new trace name - */ - public void renameSupplementaryFolder(String newTraceName) { - IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); - IFolder newSupplFolder = getTraceSupplementaryFolder(newTraceName); - - // Rename supplementary folder - if (oldSupplFolder.exists()) { - try { - oldSupplFolder.move(newSupplFolder.getFullPath(), true, new NullProgressMonitor()); - } catch (CoreException e) { - Activator.getDefault().logError("Error renaming supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ - } - } - } - - /** - * Copies the trace specific supplementary folder to the new trace name. - * - * @param newTraceName The new trace name - */ - public void copySupplementaryFolder(String newTraceName) { - IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); - IFolder newSupplFolder = getTraceSupplementaryFolder(newTraceName); - - // copy supplementary folder - if (oldSupplFolder.exists()) { - try { - oldSupplFolder.copy(newSupplFolder.getFullPath(), true, new NullProgressMonitor()); - } catch (CoreException e) { - Activator.getDefault().logError("Error renaming supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ - } - } - } - - /** - * Copies the trace specific supplementary folder a new folder. - * - * @param destination The destination folder to copy to. - */ - public void copySupplementaryFolder(IFolder destination) { - IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); - - // copy supplementary folder - if (oldSupplFolder.exists()) { - try { - oldSupplFolder.copy(destination.getFullPath(), true, new NullProgressMonitor()); - } catch (CoreException e) { - Activator.getDefault().logError("Error copying supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ - } - } - } - - - /** - * Refreshes the trace specific supplementary folder information. It creates the folder if not exists. - * It sets the persistence property of the trace resource - */ - public void refreshSupplementaryFolder() { - createSupplementaryDirectory(); - } - - /** - * Checks if supplementary resource exist or not. - * - * @return true if one or more files are under the trace supplementary folder - */ - public boolean hasSupplementaryResources() { - IResource[] resources = getSupplementaryResources(); - return (resources.length > 0); - } - - /** - * Returns the supplementary resources under the trace supplementary folder. - * - * @return array of resources under the trace supplementary folder. - */ - public IResource[] getSupplementaryResources() { - IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); - if (supplFolder.exists()) { - try { - return supplFolder.members(); - } catch (CoreException e) { - Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ - } - } - return new IResource[0]; - } - - /** - * Deletes the given resources. - * - * @param resources array of resources to delete. - */ - public void deleteSupplementaryResources(IResource[] resources) { - - for (int i = 0; i < resources.length; i++) { - try { - resources[i].delete(true, new NullProgressMonitor()); - } catch (CoreException e) { - Activator.getDefault().logError("Error deleting supplementary resource " + resources[i], e); //$NON-NLS-1$ - } - } - } - - private void createSupplementaryDirectory() { - IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); - if (!supplFolder.exists()) { - try { - supplFolder.create(true, true, new NullProgressMonitor()); - } catch (CoreException e) { - Activator.getDefault().logError("Error creating resource supplementary file " + supplFolder, e); //$NON-NLS-1$ - } - } - - try { - fResource.setPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, supplFolder.getLocationURI().getPath()); - } catch (CoreException e) { - Activator.getDefault().logError("Error setting persistant property " + TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, e); //$NON-NLS-1$ - } - - } - // ------------------------------------------------------------------------ // IActionFilter // ------------------------------------------------------------------------ diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfWithFolderElement.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfWithFolderElement.java new file mode 100644 index 0000000000..02e5b33d52 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfWithFolderElement.java @@ -0,0 +1,206 @@ +/******************************************************************************* + * Copyright (c) 2010-2013 Ericsson, École Polytechnique de Montréal + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bernd Hufmann - Added supplementary files handling (in class TmfTraceElement) + * Geneviève Bastien - Copied supplementary files handling from TmfTracElement + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.project.model; + + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.linuxtools.internal.tmf.ui.Activator; +import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; + + +/** + * Base class for project elements who will have folder elements + * under them to store supplementary files. + * + * @author gbastien + * @since 2.0 + */ +public abstract class TmfWithFolderElement extends TmfProjectModelElement { + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + + /** + * Constructor. + * Creates model element. + * @param name The name of the element + * @param resource The resource. + * @param parent The parent element + */ + public TmfWithFolderElement(String name, IResource resource, TmfProjectModelElement parent) { + super(name, resource, parent); + } + + /** + * Return the resource name for this element + * + * @return The name of the resource for this element + */ + protected String getResourceName() { + return fResource.getName() + getSuffix(); + } + + /** + * @return The suffix for resource names + */ + protected String getSuffix() { + return ""; //$NON-NLS-1$ + } + + /** + * Deletes this element specific supplementary folder. + */ + public void deleteSupplementaryFolder() { + IFolder supplFolder = getTraceSupplementaryFolder(getResourceName()); + if (supplFolder.exists()) { + try { + supplFolder.delete(true, new NullProgressMonitor()); + } catch (CoreException e) { + Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ + } + } + } + + /** + * Renames the element specific supplementary folder according to the new element name. + * + * @param newName The new element name + */ + public void renameSupplementaryFolder(String newName) { + IFolder oldSupplFolder = getTraceSupplementaryFolder(getResourceName()); + IFolder newSupplFolder = getTraceSupplementaryFolder(newName + getSuffix()); + + // Rename supplementary folder + if (oldSupplFolder.exists()) { + try { + oldSupplFolder.move(newSupplFolder.getFullPath(), true, new NullProgressMonitor()); + } catch (CoreException e) { + Activator.getDefault().logError("Error renaming supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ + } + } + } + + /** + * Copies the element specific supplementary folder to the new element name. + * + * @param newName The new element name + */ + public void copySupplementaryFolder(String newName) { + IFolder oldSupplFolder = getTraceSupplementaryFolder(getResourceName()); + IFolder newSupplFolder = getTraceSupplementaryFolder(newName + getSuffix()); + + // copy supplementary folder + if (oldSupplFolder.exists()) { + try { + oldSupplFolder.copy(newSupplFolder.getFullPath(), true, new NullProgressMonitor()); + } catch (CoreException e) { + Activator.getDefault().logError("Error renaming supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ + } + } + } + + /** + * Copies the element specific supplementary folder a new folder. + * + * @param destination The destination folder to copy to. + */ + public void copySupplementaryFolder(IFolder destination) { + IFolder oldSupplFolder = getTraceSupplementaryFolder(getResourceName()); + + // copy supplementary folder + if (oldSupplFolder.exists()) { + try { + oldSupplFolder.copy(destination.getFullPath(), true, new NullProgressMonitor()); + } catch (CoreException e) { + Activator.getDefault().logError("Error copying supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ + } + } + } + + + /** + * Refreshes the element specific supplementary folder information. It creates the folder if not exists. + * It sets the persistence property of the trace resource + */ + public void refreshSupplementaryFolder() { + createSupplementaryDirectory(); + } + + /** + * Checks if supplementary resource exist or not. + * + * @return true if one or more files are under the element supplementary folder + */ + public boolean hasSupplementaryResources() { + IResource[] resources = getSupplementaryResources(); + return (resources.length > 0); + } + + /** + * Returns the supplementary resources under the trace supplementary folder. + * + * @return array of resources under the trace supplementary folder. + */ + public IResource[] getSupplementaryResources() { + IFolder supplFolder = getTraceSupplementaryFolder(getResourceName()); + if (supplFolder.exists()) { + try { + return supplFolder.members(); + } catch (CoreException e) { + Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ + } + } + return new IResource[0]; + } + + /** + * Deletes the given resources. + * + * @param resources array of resources to delete. + */ + public void deleteSupplementaryResources(IResource[] resources) { + + for (int i = 0; i < resources.length; i++) { + try { + resources[i].delete(true, new NullProgressMonitor()); + } catch (CoreException e) { + Activator.getDefault().logError("Error deleting supplementary resource " + resources[i], e); //$NON-NLS-1$ + } + } + } + + private void createSupplementaryDirectory() { + IFolder supplFolder = getTraceSupplementaryFolder(getResourceName()); + if (!supplFolder.exists()) { + try { + supplFolder.create(true, true, new NullProgressMonitor()); + } catch (CoreException e) { + Activator.getDefault().logError("Error creating resource supplementary file " + supplFolder, e); //$NON-NLS-1$ + } + } + + try { + fResource.setPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, supplFolder.getLocationURI().getPath()); + } catch (CoreException e) { + Activator.getDefault().logError("Error setting persistant property " + TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, e); //$NON-NLS-1$ + } + + } + +} diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyExperimentDialog.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyExperimentDialog.java index 1dd6aee84a..a31a3487dc 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyExperimentDialog.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/CopyExperimentDialog.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2011, 2012 Ericsson - * + * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Francois Chouinard - Copied and adapted from NewFolderDialog *******************************************************************************/ @@ -87,7 +87,7 @@ public class CopyExperimentDialog extends SelectionStatusDialog { // ------------------------------------------------------------------------ // Dialog // ------------------------------------------------------------------------ - + /* * (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) @@ -144,7 +144,7 @@ public class CopyExperimentDialog extends SelectionStatusDialog { } private void validateNewExperimentName() { - + String name = fNewExperimentName.getText(); IWorkspace workspace = fExperimentFolder.getWorkspace(); IStatus nameStatus = workspace.validateName(name, IResource.FOLDER); @@ -153,12 +153,12 @@ public class CopyExperimentDialog extends SelectionStatusDialog { updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_EmptyNameError, null)); return; } - + if (!nameStatus.isOK()) { updateStatus(nameStatus); return; } - + IPath path = new Path(name); if (fExperimentFolder.getFolder(path).exists() || fExperimentFolder.getFile(path).exists()) { updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_ExistingNameError, null)); @@ -220,6 +220,8 @@ public class CopyExperimentDialog extends SelectionStatusDialog { if (monitor.isCanceled()) { throw new OperationCanceledException(); } + // Copy supplementary files first + fExperiment.copySupplementaryFolder(newName); fExperiment.getResource().copy(newPath, IResource.FORCE | IResource.SHALLOW, null); // Delete any bookmarks file found in copied experiment folder IFolder folder = fExperimentFolder.getFolder(newName); diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java index 657691e90a..ad9438bed8 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/RenameExperimentDialog.java @@ -246,6 +246,8 @@ public class RenameExperimentDialog extends SelectionStatusDialog { bookmarksFile.move(newBookmarksPath, IResource.FORCE | IResource.SHALLOW, null); } } + + fExperiment.renameSupplementaryFolder(newName); fExperiment.getResource().move(newPath, IResource.FORCE | IResource.SHALLOW, null); if (monitor.isCanceled()) { throw new OperationCanceledException(); -- cgit v1.2.3