ANIMATOR : Remove null point exception 11/18211/1
authorjinwooim.bae <jinwooim.bae@samsung.com>
Tue, 18 Mar 2014 11:20:30 +0000 (20:20 +0900)
committerjinwooim.bae <jinwooim.bae@samsung.com>
Tue, 18 Mar 2014 11:20:30 +0000 (20:20 +0900)
The Animator code has null point eception bug code. so It is removed.

Change-Id: I5c751c316d7a7bba5d872244af555c558e1b461b
Signed-off-by: jinwooim.bae <jinwooim.bae@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/TimelinePage.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/command/TimelineFrameDeleteCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/editpart/TimelineEditPart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/header/TimelineContentHeaderContainer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/widget/TimelineWidgetContextMenu.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/utils/AnimatorUtils.java

index 24ace23..f103cab 100644 (file)
@@ -300,7 +300,10 @@ public class TimelinePage extends ContentOutlinePage {
      *            {@link AnimatorPagePart}
      */
     public void refreshPage(Part pagePart) {
-
+        if(!(pagePart instanceof AnimatorPagePart)) {
+               return;
+        }
+        
         List<AnimatorAnimation> animations = ((AnimatorPagePart)pagePart).getAnimations();
 
         String animationId = null;
index d15bed8..28e22e9 100644 (file)
@@ -117,14 +117,23 @@ public class TimelineFrameDeleteCommand extends Command {
         keyframe.updateTimeForFrameAdd(currentTime);
         keyframe.addChild(originalFrameIndex, frame);
         frame.setFrameTime(originalFrameTime);
-        if (curveFrames != null)
-            ((AnimatorFrame) keyframe.getPrevChild(frame)).setCurveFrames(curveFrames);
-
-        AnimatorModelManager animatorModelManager =
-                AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
-        animatorModelManager.fireEvent(true, frame.getParent().getParent(),
-                                       AnimatorModelEvent.EventType.FRAME_ADD,
-                                       AnimatorModelEvent.Origin.TIMELINE, frame);
+        if (curveFrames != null) {
+               AnimatorModel childFrame = keyframe.getPrevChild(frame);
+               if(childFrame != null) {
+                       ((AnimatorFrame) childFrame).setCurveFrames(curveFrames);
+                
+                AnimatorModelManager animatorModelManager =
+                        AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
+                animatorModelManager.fireEvent(true, frame.getParent().getParent(),
+                                               AnimatorModelEvent.EventType.FRAME_ADD,
+                                               AnimatorModelEvent.Origin.TIMELINE, frame);     
+               } else {
+                       return;
+               }
+        } else {
+               return;
+        }
+        
     }
 
     /**
index 6efc4c3..2905d68 100644 (file)
@@ -1163,18 +1163,21 @@ public class TimelineEditPart extends AbstractTreeEditPart {
                     for (KeyFrameWidget currentKeyframe : keyframes) {
                         if (currentKeyframe.getKeyframe().getId().equals(keyframe.getId())) {
                             LifeWidget lifeWidget = currentKeyframe.getLifeWidget();
-                            FrameWidget frameWidget = lifeWidget.findFrame((AnimatorFrame) model);
-
-                            lifeWidget.removeChild(frameWidget);
-                            frameWidget.dispose();
-
-                            if (frameWidget.getFrameType() != FrameWidget.COMMON_FRAME) {
-
-                                currentKeyframe.setKeyframeWidgetStartTime(keyframe.getDelay());
-                                currentKeyframe.setKeyframeWidgetDurationTime(keyframe
-                                        .getDuration());
-
-                                lifeWidget.setFrameType();
+                            if(lifeWidget != null) {
+                                FrameWidget frameWidget = lifeWidget.findFrame((AnimatorFrame) model);
+                                if(frameWidget != null) {
+                                       
+                                       lifeWidget.removeChild(frameWidget);
+                                       frameWidget.dispose();
+                                       
+                                       if (frameWidget.getFrameType() != FrameWidget.COMMON_FRAME) {   
+                                           currentKeyframe.setKeyframeWidgetStartTime(keyframe.getDelay());
+                                           currentKeyframe.setKeyframeWidgetDurationTime(keyframe
+                                                   .getDuration());
+       
+                                           lifeWidget.setFrameType();
+                                       }
+                                }
                             }
                             currentKeyframe.redraw();
                         }
index 411b088..6cf52f5 100644 (file)
@@ -96,51 +96,54 @@ public class TimelineContentHeaderContainer extends Composite {
             public void paintControl(PaintEvent e) {
                 if (contentHeadersashFormSash == null) {
                     Sash[] sashes = getSashes(contentHeadersashForm);
-
-                    contentHeadersashFormSash = sashes[0];
-                    contentHeadersashFormSash.addSelectionListener(new SelectionAdapter() {
-                        @Override
-                        public void widgetSelected(SelectionEvent event) {
-                            int headerContainerWidth =
-                                    TimelineContentHeaderContainer.this.getBounds().width;
-                            if (event.x < OUTLINE_HEADER_MIN_WIDTH) {
-                                contentHeadersashForm.setWeights(new int[] {
-                                        OUTLINE_HEADER_MIN_WIDTH,
-                                        headerContainerWidth - OUTLINE_HEADER_MIN_WIDTH });
-
-                                if (!isMinWidth) {
-                                    // AnimatorNotifierDialog.notify("Minimum Width",
-                                    // "The minimum width is 225px.", NotificationType.INFO,
-                                    // TimelineContentHeaderContainer.this,
-                                    // outlineHeader.getBounds().width - 175,
-                                    // outlineHeader.getBounds().height + 30);
-
-                                    isMinWidth = true;
-                                }
-                            } else if (event.x > OUTLINE_HEADER_MAX_WIDTH - 5) {
-                                contentHeadersashForm.setWeights(new int[] {
-                                        OUTLINE_HEADER_MAX_WIDTH,
-                                        headerContainerWidth - OUTLINE_HEADER_MAX_WIDTH });
-
-                                if (!isMaxWidth) {
-                                    // AnimatorNotifierDialog.notify("Maximum Width",
-                                    // "The maximum width is 450px.", NotificationType.INFO,
-                                    // TimelineContentHeaderContainer.this,
-                                    // outlineHeader.getBounds().width - 175,
-                                    // outlineHeader.getBounds().height + 30);
-
-                                    isMaxWidth = true;
+                    if(sashes == null) {
+                        return;
+                    } else {
+                       contentHeadersashFormSash = sashes[0];
+                        contentHeadersashFormSash.addSelectionListener(new SelectionAdapter() {
+                            @Override
+                            public void widgetSelected(SelectionEvent event) {
+                                int headerContainerWidth =
+                                        TimelineContentHeaderContainer.this.getBounds().width;
+                                if (event.x < OUTLINE_HEADER_MIN_WIDTH) {
+                                    contentHeadersashForm.setWeights(new int[] {
+                                            OUTLINE_HEADER_MIN_WIDTH,
+                                            headerContainerWidth - OUTLINE_HEADER_MIN_WIDTH });
+
+                                    if (!isMinWidth) {
+                                        // AnimatorNotifierDialog.notify("Minimum Width",
+                                        // "The minimum width is 225px.", NotificationType.INFO,
+                                        // TimelineContentHeaderContainer.this,
+                                        // outlineHeader.getBounds().width - 175,
+                                        // outlineHeader.getBounds().height + 30);
+
+                                        isMinWidth = true;
+                                    }
+                                } else if (event.x > OUTLINE_HEADER_MAX_WIDTH - 5) {
+                                    contentHeadersashForm.setWeights(new int[] {
+                                            OUTLINE_HEADER_MAX_WIDTH,
+                                            headerContainerWidth - OUTLINE_HEADER_MAX_WIDTH });
+
+                                    if (!isMaxWidth) {
+                                        // AnimatorNotifierDialog.notify("Maximum Width",
+                                        // "The maximum width is 450px.", NotificationType.INFO,
+                                        // TimelineContentHeaderContainer.this,
+                                        // outlineHeader.getBounds().width - 175,
+                                        // outlineHeader.getBounds().height + 30);
+
+                                        isMaxWidth = true;
+                                    }
+                                } else {
+                                    isMinWidth = false;
+                                    isMaxWidth = false;
                                 }
-                            } else {
-                                isMinWidth = false;
-                                isMaxWidth = false;
-                            }
 
-                            if (event.detail != SWT.DRAG) {
-                                contentHeadersashForm.layout();
+                                if (event.detail != SWT.DRAG) {
+                                    contentHeadersashForm.layout();
+                                }
                             }
-                        }
-                    });
+                        });
+                    }
                 }
             }
         });
index 7aeb409..c4ae082 100644 (file)
@@ -179,8 +179,13 @@ public class TimelineWidgetContextMenu {
 
         KeyFrameWidget keyframeWidget = (KeyFrameWidget) frameWidget.getParent().getParent();
         TimelineViewer viewer = AnimatorUtils.getViewer(keyframeWidget);
-        viewer.getEditDomain().getCommandStack().execute(frameDeleteCommand);
-        viewer.setLastSelectedKeyframeWidget(null);
+        if(viewer == null) {
+            return;
+        } else {
+            viewer.getEditDomain().getCommandStack().execute(frameDeleteCommand);
+            viewer.setLastSelectedKeyframeWidget(null);
+        }
+        
     }
 
     /**
@@ -195,8 +200,12 @@ public class TimelineWidgetContextMenu {
         Command keyframeDeleteCommand = new TimelineKeyframeDeleteCommand(keyframe);
 
         TimelineViewer viewer = AnimatorUtils.getViewer(keyframeWidget);
-        viewer.getEditDomain().getCommandStack().execute(keyframeDeleteCommand);
-        viewer.setLastSelectedKeyframeWidget(null);
+        if(viewer == null) {
+            return;
+        } else {
+            viewer.getEditDomain().getCommandStack().execute(keyframeDeleteCommand);
+            viewer.setLastSelectedKeyframeWidget(null);
+        }
     }
 
     /**
index cb4096e..00477ec 100644 (file)
@@ -464,9 +464,13 @@ public class AnimatorUtils {
      * @return
      */
     public static int convertPixToInt(String pix) {
-        if (pix != null && pix.equals(Constants.auto)) {
+        if(pix == null) {
             return 0;
-        }
+        } else {
+               if (pix.equals(Constants.auto)) {
+                return 0;
+            }
+        }      
         return Integer.parseInt(pix.replace("px", ""));
     }
 
@@ -552,10 +556,7 @@ public class AnimatorUtils {
      * @return
      */
     public static TimelineViewer getViewer(KeyFrameWidget keyframeWidget) {
-        if (!(keyframeWidget instanceof KeyFrameWidget)) {
-            return null;
-        }
-
+        
         TimeTreeElement timeTreeElement = (TimeTreeElement) keyframeWidget.getParent();
         TreeItem treeItem = (TreeItem) timeTreeElement.getData("RefrenceTreeItem");