From 3566a64c6d810807ecb4683ada275b22360aede0 Mon Sep 17 00:00:00 2001 From: "hyeran74.kim" Date: Tue, 18 Mar 2014 16:35:42 +0900 Subject: [PATCH] [Title] removed duplicate code in reArrangeTabs() [Desc.] [Issue] Change-Id: Id55d1509208a7c6c7a8247ef715bc89ec63f29e0 Signed-off-by: hyeran74.kim --- .../dynamicanalyzer/ui/widgets/DATabComposite.java | 66 ++++++++-------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DATabComposite.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DATabComposite.java index 5e57d74..8bcd82f 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DATabComposite.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DATabComposite.java @@ -199,7 +199,8 @@ public class DATabComposite extends DAView { case SWT.MouseUp: drag = false; if(curPosition.y < tabComposite.getBounds().y - || curPosition.y > tabComposite.getBounds().height) { + || curPosition.y > tabComposite.getBounds().height + || sourceButtonIndex == getButtons().size()) { return; } @@ -213,7 +214,6 @@ public class DATabComposite extends DAView { }else{ targetButtonIndex = curPosition.x / tabWidth; } - // check whether the tab button has clicked or moved if (targetButtonIndex == sourceButtonIndex) { //click @@ -288,6 +288,7 @@ public class DATabComposite extends DAView { return tabButton; } + // positioning of the tab button private void setLayoutTabs(int leftTabIndex, int tabIndex) { FormData data = new FormData(); data.top = new FormAttachment(0, 0); @@ -303,55 +304,36 @@ public class DATabComposite extends DAView { private void reArrangeTabs() { if (sourceButtonIndex < targetButtonIndex) { // move forward + // source + setLayoutTabs(targetButtonIndex, sourceButtonIndex); if (sourceButtonIndex == 0) { // source == first tab - // source - setLayoutTabs(targetButtonIndex, sourceButtonIndex); // source+1 setLayoutTabs(-1, (sourceButtonIndex + 1)); - // target+1 - if (targetButtonIndex != getButtons().size()-1) { - setLayoutTabs(sourceButtonIndex, (targetButtonIndex+1)); - } - Collections.rotate(getButtons().subList(sourceButtonIndex, targetButtonIndex + 1), -1); - Collections.rotate(getTabChildren().subList(sourceButtonIndex, targetButtonIndex + 1), -1); } else { - // source - setLayoutTabs(targetButtonIndex, sourceButtonIndex); // source+1 setLayoutTabs((sourceButtonIndex - 1), (sourceButtonIndex + 1)); - // target+1 - if (targetButtonIndex != getButtons().size()-1) { - setLayoutTabs(sourceButtonIndex, (targetButtonIndex + 1)); - } - Collections.rotate(getButtons().subList(sourceButtonIndex, targetButtonIndex + 1), -1); - Collections.rotate(getTabChildren().subList(sourceButtonIndex, targetButtonIndex + 1), -1); } + // target+1 + if (targetButtonIndex != getButtons().size()-1) { + setLayoutTabs(sourceButtonIndex, (targetButtonIndex + 1)); + } + Collections.rotate(getButtons().subList(sourceButtonIndex, targetButtonIndex + 1), -1); + Collections.rotate(getTabChildren().subList(sourceButtonIndex, targetButtonIndex + 1), -1); } else { // move backward - if (sourceButtonIndex == getButtons().size() - 1) { // source == last tab - // source - if (targetButtonIndex != 0) { - setLayoutTabs((targetButtonIndex - 1), sourceButtonIndex); - } else { - setLayoutTabs(-1, sourceButtonIndex); - } - // target - setLayoutTabs(sourceButtonIndex, targetButtonIndex); - Collections.rotate(getButtons().subList(targetButtonIndex, sourceButtonIndex + 1), 1); - Collections.rotate(getTabChildren().subList(targetButtonIndex, sourceButtonIndex + 1), 1); - } else { - // source - if (targetButtonIndex == 0) { - setLayoutTabs(-1, sourceButtonIndex); - } else { - setLayoutTabs((targetButtonIndex - 1), sourceButtonIndex); - } - // source+1 + // source + if (targetButtonIndex == 0) { // target == first tab + setLayoutTabs(-1, sourceButtonIndex); + } else { + setLayoutTabs((targetButtonIndex - 1), sourceButtonIndex); + } + if (sourceButtonIndex != getButtons().size() - 1) { + // source+1 setLayoutTabs((sourceButtonIndex - 1), (sourceButtonIndex + 1)); - // target - setLayoutTabs(sourceButtonIndex, targetButtonIndex); - Collections.rotate(getButtons().subList(targetButtonIndex, sourceButtonIndex + 1), 1); - Collections.rotate(getTabChildren().subList(targetButtonIndex, sourceButtonIndex + 1), 1); - } + } + // target + setLayoutTabs(sourceButtonIndex, targetButtonIndex); + Collections.rotate(getButtons().subList(targetButtonIndex, sourceButtonIndex + 1), 1); + Collections.rotate(getTabChildren().subList(targetButtonIndex, sourceButtonIndex + 1), 1); } } -- 2.7.4