tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfTraceElement.java
index 2b3ca409d7f5c1f3cf04eeb09554c74ef4362a0a..e3c0dbacae6381239df4077701b13524a209a9e3 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2011, 2012 Ericsson
+ * 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
@@ -9,6 +9,8 @@
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *   Bernd Hufmann - Added supplementary files handling
+ *   Geneviève Bastien - Moved supplementary files handling to parent class, added
+ *                      code to copy trace
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.project.model;
@@ -24,7 +26,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;
@@ -37,11 +38,11 @@ import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
 import org.eclipse.ui.IActionFilter;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertySource2;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 
 /**
  * Implementation of trace model element representing a trace. It provides methods to instantiate
@@ -51,7 +52,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
@@ -75,11 +76,11 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi
     private static final String sfEventType = "type"; //$NON-NLS-1$
     private static final String sfIsLinked = "linked"; //$NON-NLS-1$
 
-    private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName);
-    private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath);
-    private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, sfLocation);
-    private static final TextPropertyDescriptor sfTypeDescriptor = new TextPropertyDescriptor(sfEventType, sfEventType);
-    private static final TextPropertyDescriptor sfIsLinkedDescriptor = new TextPropertyDescriptor(sfIsLinked, sfIsLinked);
+    private static final ReadOnlyTextPropertyDescriptor sfNameDescriptor = new ReadOnlyTextPropertyDescriptor(sfName, sfName);
+    private static final ReadOnlyTextPropertyDescriptor sfPathDescriptor = new ReadOnlyTextPropertyDescriptor(sfPath, sfPath);
+    private static final ReadOnlyTextPropertyDescriptor sfLocationDescriptor = new ReadOnlyTextPropertyDescriptor(sfLocation, sfLocation);
+    private static final ReadOnlyTextPropertyDescriptor sfTypeDescriptor = new ReadOnlyTextPropertyDescriptor(sfEventType, sfEventType);
+    private static final ReadOnlyTextPropertyDescriptor sfIsLinkedDescriptor = new ReadOnlyTextPropertyDescriptor(sfIsLinked, sfIsLinked);
 
     private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, sfLocationDescriptor,
             sfTypeDescriptor, sfIsLinkedDescriptor };
@@ -332,146 +333,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 <code>true</code> 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
     // ------------------------------------------------------------------------
@@ -488,10 +349,7 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi
     // ------------------------------------------------------------------------
     // TmfTraceElement
     // ------------------------------------------------------------------------
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject()
-     */
+
     @Override
     public TmfProjectElement getProject() {
         if (getParent() instanceof TmfTraceFolder) {
@@ -512,28 +370,16 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi
     // IPropertySource2
     // ------------------------------------------------------------------------
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
-     */
     @Override
     public Object getEditableValue() {
         return null;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
-     */
     @Override
     public IPropertyDescriptor[] getPropertyDescriptors() {
         return Arrays.copyOf(sfDescriptors, sfDescriptors.length);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
-     */
     @Override
     public Object getPropertyValue(Object id) {
 
@@ -574,38 +420,37 @@ public class TmfTraceElement extends TmfProjectModelElement implements IActionFi
         return "[no category]"; //$NON-NLS-1$
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
-     */
     @Override
     public void resetPropertyValue(Object id) {
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
-     */
     @Override
     public void setPropertyValue(Object id, Object value) {
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object)
-     */
     @Override
     public boolean isPropertyResettable(Object id) {
         return false;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object)
-     */
     @Override
     public boolean isPropertySet(Object id) {
         return false;
     }
 
+    /**
+     * Copy this trace in the trace folder. No other parameters are mentioned so
+     * the trace is copied in this element's project trace folder
+     *
+     * @param string
+     *            The new trace name
+     * @return the new Resource object
+     * @since 2.0
+     */
+    public TmfTraceElement copy(String string) {
+        TmfTraceFolder folder = this.getProject().getTracesFolder();
+        IResource res = super.copy(string, false);
+        return new TmfTraceElement(string, res, folder);
+    }
+
 }
This page took 0.02699 seconds and 5 git commands to generate.