tmf: Switch tmf.ui to Java 7 + fix warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfTraceFolder.java
index e9154c4213e8c81fa6e33ed920debf99e2937e76..7d49ae01f587a22b8dc157040dd5095f8a3fe42f 100644 (file)
@@ -1,11 +1,11 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
- * 
+ * Copyright (c) 2011, 2013 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 - Initial API and implementation
  *******************************************************************************/
@@ -17,20 +17,24 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.eclipse.core.resources.IFolder;
+import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertySource2;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 
 /**
- * <b><u>TmfTraceFolder</u></b>
+ * Implementation of trace folder model element representing the trace folder in the project.
  * <p>
+ * @version 1.0
+ * @author Francois Chouinard
  */
 public class TmfTraceFolder extends TmfProjectModelElement implements IPropertySource2 {
 
     // ------------------------------------------------------------------------
     // Constants
     // ------------------------------------------------------------------------
-
+    /**
+     * The name of the trace folder
+     */
     public static final String TRACE_FOLDER_NAME = "Traces"; //$NON-NLS-1$
 
     // Property View stuff
@@ -39,9 +43,9 @@ public class TmfTraceFolder extends TmfProjectModelElement implements IPropertyS
     private static final String sfPath = "path"; //$NON-NLS-1$
     private static final String sfLocation = "location"; //$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,
+    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 IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor,
@@ -56,7 +60,13 @@ public class TmfTraceFolder extends TmfProjectModelElement implements IPropertyS
     // ------------------------------------------------------------------------
     // Constructor
     // ------------------------------------------------------------------------
-
+    /**
+     * Constructor.
+     * Creates trace folder model element under the project.
+     * @param name The name of trace folder.
+     * @param resource The folder resource.
+     * @param parent The parent element (project).
+     */
     public TmfTraceFolder(String name, IFolder resource, TmfProjectElement parent) {
         super(name, resource, parent);
         parent.addChild(this);
@@ -86,9 +96,13 @@ public class TmfTraceFolder extends TmfProjectModelElement implements IPropertyS
     // Operations
     // ------------------------------------------------------------------------
 
+    /**
+     * Returns a list of trace model elements under the traces folder.
+     * @return list of trace model elements
+     */
     public List<TmfTraceElement> getTraces() {
         List<ITmfProjectModelElement> children = getChildren();
-        List<TmfTraceElement> traces = new ArrayList<TmfTraceElement>();
+        List<TmfTraceElement> traces = new ArrayList<>();
         for (ITmfProjectModelElement child : children) {
             if (child instanceof TmfTraceElement) {
                 traces.add((TmfTraceElement) child);
@@ -108,20 +122,23 @@ public class TmfTraceFolder extends TmfProjectModelElement implements IPropertyS
 
     @Override
     public IPropertyDescriptor[] getPropertyDescriptors() {
-        return (sfDescriptors != null) ? Arrays.copyOf(sfDescriptors, sfDescriptors.length) : null;
+        return Arrays.copyOf(sfDescriptors, sfDescriptors.length);
     }
 
     @Override
     public Object getPropertyValue(Object id) {
 
-        if (sfName.equals(id))
+        if (sfName.equals(id)) {
             return getName();
+        }
 
-        if (sfPath.equals(id))
+        if (sfPath.equals(id)) {
             return getPath().toString();
+        }
 
-        if (sfLocation.equals(id))
+        if (sfLocation.equals(id)) {
             return getLocation().toString();
+        }
 
         return null;
     }
This page took 0.027071 seconds and 5 git commands to generate.