tmf: Add check for ineffective setters in AbstractTimeGraphView
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 20 Nov 2015 16:06:52 +0000 (11:06 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Fri, 20 Nov 2015 21:13:53 +0000 (16:13 -0500)
If these setters are called after the part control has been created,
they have no effect.

Change-Id: I34bab27624a98df122efd08546d1740d5d672fd8
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/60940
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java

index ceb09de044612e24a09a1f378c6218218017c26a..c22734ab4367c30b6bad4319779eac719dc61359 100644 (file)
@@ -763,62 +763,73 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
 
     /**
      * Sets the tree column labels.
+     * <p>
      * This should be called from the constructor.
      *
      * @param columns
      *            The array of tree column labels
      */
     protected void setTreeColumns(final String[] columns) {
+        checkPartNotCreated();
         fColumns = columns;
     }
 
     /**
      * Sets the tree label provider.
+     * <p>
      * This should be called from the constructor.
      *
      * @param tlp
      *            The tree label provider
      */
     protected void setTreeLabelProvider(final TreeLabelProvider tlp) {
+        checkPartNotCreated();
         fLabelProvider = tlp;
     }
 
     /**
-     * Sets the time graph content provider. This should be called from the
-     * constructor.
+     * Sets the time graph content provider.
+     * <p>
+     * This should be called from the constructor.
      *
      * @param tgcp
      *            The time graph content provider
      * @since 1.0
      */
     protected void setTimeGraphContentProvider(final @NonNull ITimeGraphContentProvider tgcp) {
+        checkPartNotCreated();
         fTimeGraphContentProvider = tgcp;
     }
 
     /**
      * Sets the relative weight of each part of the time graph combo.
+     * <p>
      * This should be called from the constructor.
      *
      * @param weights
      *            The array (length 2) of relative weights of each part of the combo
      */
     protected void setWeight(final int[] weights) {
+        checkPartNotCreated();
         fWeight = weights;
     }
 
     /**
      * Sets the filter column labels.
+     * <p>
      * This should be called from the constructor.
      *
      * @param filterColumns
      *            The array of filter column labels
      */
     protected void setFilterColumns(final String[] filterColumns) {
+        checkPartNotCreated();
         fFilterColumns = filterColumns;
     }
 
     /**
      * Sets the filter content provider.
+     * <p>
      * This should be called from the constructor.
      *
      * @param contentProvider
@@ -826,20 +837,29 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      * @since 2.0
      */
     protected void setFilterContentProvider(final ITreeContentProvider contentProvider) {
+        checkPartNotCreated();
         fFilterContentProvider = contentProvider;
     }
 
     /**
      * Sets the filter label provider.
+     * <p>
      * This should be called from the constructor.
      *
      * @param labelProvider
      *            The filter label provider
      */
     protected void setFilterLabelProvider(final TreeLabelProvider labelProvider) {
+        checkPartNotCreated();
         fFilterLabelProvider = labelProvider;
     }
 
+    private void checkPartNotCreated() {
+        if (getParentComposite() != null) {
+            throw new IllegalStateException("This method must be called before createPartControl."); //$NON-NLS-1$
+        }
+    }
+
     /**
      * Gets the display width
      *
This page took 0.029541 seconds and 5 git commands to generate.