diff options
author | Andre Dietisheim | 2010-03-20 00:11:45 +0000 |
---|---|---|
committer | Andre Dietisheim | 2010-03-20 00:11:45 +0000 |
commit | 29e7d7f52abc93a28097eccf5a24f69391379d07 (patch) | |
tree | 9f152f5df8a1783e5eaf2069de46b33a1587b5e0 /plugins | |
parent | 35e07b53276038f2849d2cac366e44f06f32d5be (diff) | |
download | cdo-29e7d7f52abc93a28097eccf5a24f69391379d07.tar.gz cdo-29e7d7f52abc93a28097eccf5a24f69391379d07.tar.xz cdo-29e7d7f52abc93a28097eccf5a24f69391379d07.zip |
[256624] [UI] Create a Commit History ViewPart
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256624
commented, refactored and fixed sub branch view related bugs
Diffstat (limited to 'plugins')
9 files changed, 115 insertions, 38 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/BranchViewPart.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/BranchViewPart.java index 130d798ef1..84eac88f2b 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/BranchViewPart.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/BranchViewPart.java @@ -21,7 +21,7 @@ import org.eclipse.emf.cdo.ui.internal.branch.item.NewBranchConnection; import org.eclipse.emf.cdo.ui.internal.branch.item.RootNode; import org.eclipse.emf.cdo.ui.internal.branch.item.SameBranchConnection; import org.eclipse.emf.cdo.ui.internal.branch.layout.BranchTreeLayoutAlgorithm; -import org.eclipse.emf.cdo.ui.internal.branch.layout.HorizontallyAlternatingSubBranches; +import org.eclipse.emf.cdo.ui.internal.branch.layout.RightHandSubBranches; import org.eclipse.net4j.Net4jUtil; import org.eclipse.net4j.connector.IConnector; @@ -68,7 +68,7 @@ public class BranchViewPart extends ViewPart createTestTree(graph); LayoutAlgorithm layout = new BranchTreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING, - new HorizontallyAlternatingSubBranches()); + new RightHandSubBranches()); graph.setLayoutAlgorithm(layout, true); } diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/geometry/GeometryUtils.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/geometry/GeometryUtils.java index 7623465d3e..53f2909a77 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/geometry/GeometryUtils.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/geometry/GeometryUtils.java @@ -20,18 +20,17 @@ public class GeometryUtils { /** - * Unifies both given dimensions. + * Adds the width and height of the given second (source) dimension to the given first (target) dimension . * - * @param thisDimension + * @param targetDimension * the this dimension - * @param thatDimension + * @param sourceDimension * the that dimension */ - public static void union(DisplayIndependentDimension thisDimension, DisplayIndependentDimension thatDimension) + public static void union(DisplayIndependentDimension targetDimension, DisplayIndependentDimension sourceDimension) { - DisplayIndependentDimension union = new DisplayIndependentDimension(thisDimension); - union.width += thatDimension.width; - union.height += thatDimension.height; + targetDimension.width += sourceDimension.width; + targetDimension.height += sourceDimension.height; } /** diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/item/AbstractBranchPointNode.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/item/AbstractBranchPointNode.java index 32eb35336e..d8092d8294 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/item/AbstractBranchPointNode.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/item/AbstractBranchPointNode.java @@ -101,7 +101,7 @@ public abstract class AbstractBranchPointNode extends CGraphNode implements CDOB return connectionList; } - public AbstractBranchPointNode getLatter(AbstractBranchPointNode node) + public AbstractBranchPointNode getLater(AbstractBranchPointNode node) { if (node != null && node.getTimeStamp() > getTimeStamp()) { diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java index 0839815540..1a2419f9c6 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java @@ -234,6 +234,6 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo */ protected double getBranchPadding() { - return 60; + return 30; } } diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractVerticalLayoutStrategy.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractVerticalLayoutStrategy.java index b1199234f2..aee41e23b4 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractVerticalLayoutStrategy.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractVerticalLayoutStrategy.java @@ -45,12 +45,14 @@ public abstract class AbstractVerticalLayoutStrategy extends AbstractBranchViewL + branchPadding, 0); } - public DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranch, + public DisplayIndependentDimension getTranslationToLaterBranch(BranchView subBranchView, BranchView laterBranch, double branchPadding) { - DisplayIndependentRectangle latterBranchBounds = latterBranch.getBounds(); + DisplayIndependentRectangle laterBranchBounds = laterBranch.getBounds(); return new DisplayIndependentDimension(// - latterBranchBounds.x + latterBranchBounds.width + branchPadding, 0); + GeometryUtils.getTranslation(subBranchView.getBounds().x, laterBranchBounds.x) // + + laterBranchBounds.width // + + branchPadding, 0); } }; @@ -67,12 +69,12 @@ public abstract class AbstractVerticalLayoutStrategy extends AbstractBranchViewL - branchPadding, 0); } - public DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranchView, - double branchPadding) + public DisplayIndependentDimension getTranslationToLaterBranch(BranchView subBranchView, + BranchView laterBranchView, double branchPadding) { - DisplayIndependentRectangle latterBranchBounds = latterBranchView.getBounds(); return new DisplayIndependentDimension( // - latterBranchBounds.x - branchPadding, 0); + GeometryUtils.getTranslation(subBranchView.getBounds().x, laterBranchView.getBounds().x) // + - branchPadding, 0); } }; @@ -105,37 +107,43 @@ public abstract class AbstractVerticalLayoutStrategy extends AbstractBranchViewL * the padding between branches * @return the latter branch translation */ - public DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranchView, + public DisplayIndependentDimension getTranslationToLaterBranch(BranchView subBranch, BranchView latterBranchView, double branchPadding); } /** - * Sets the location of the given sub branch in the current branch. Branches are created and located with their - * baseline node at x == 0, y == 0. The bounds of the sub branch (and its sub sub-branches) are from negative + * Sets the location of the given sub branch in the current branch. Branches are created and located with the center + * of the baseline node at x == 0, y == 0. The bounds of the sub branch (and its sub sub-branches) are from negative * x-coordinates up to positive x-coordinates. The purpose of this method is to translate the whole sub branch to the - * correct location to the right or to the left of its branch point. + * correct location to the right or to the left of its branch point. A first translation has to occur so that the + * branch view does not collide with its branch point. A second translation has to occur so that it does not overlap + * with latter branches. * * @param subBranchView - * the sub branch to layout in the current branch + * the sub branch view to layout in the current branch * @param branchPointNode - * the branch point node the given sub branch is attached to + * the branch point node the sub branch is attached to * @param branchView - * the branch view + * the branch view the sub branch shall be attached to */ @Override public void setSubBranchViewLocation(BranchView branchView, BranchView subBranchView, BranchPointNode branchPointNode) { currentTranslationStrategy = getSubBranchTranslationStrategy(branchView, currentTranslationStrategy); - // translate branch off the branchPointNode (to the right or to the left) - DisplayIndependentDimension translation = currentTranslationStrategy.getTranslationToBranchPoint(subBranchView, - branchPointNode, getBranchPadding()); - BranchView latterBranch = branchView.getSecondToLastSubBranchView(); - if (latterBranch != null && !GeometryUtils.bottomEndsBefore(subBranchView.getBounds(), latterBranch.getBounds())) + BranchView laterBranch = getLaterOverlapingBranch(branchView, subBranchView); + DisplayIndependentDimension translation = new DisplayIndependentDimension(0, 0); + if (laterBranch != null) { - // collides vertically with latter sub-branch -> additionally translate off latter branch (to the right or to + // overlaps with later sub-branch -> translate from later branch (to the right or to // the left) - GeometryUtils.union(translation, currentTranslationStrategy.getTranslationToLatterBranch(subBranchView, - latterBranch, getBranchPadding())); + translation = currentTranslationStrategy.getTranslationToLaterBranch(subBranchView, laterBranch, + getBranchPadding()); + } + else + { + // translate branch away from branchPointNode (to the right or to the left) + translation = currentTranslationStrategy.getTranslationToBranchPoint(subBranchView, branchPointNode, + getBranchPadding()); } translateBy(subBranchView, translation); } @@ -153,4 +161,16 @@ public abstract class AbstractVerticalLayoutStrategy extends AbstractBranchViewL */ protected abstract SubBranchViewTranslation getSubBranchTranslationStrategy(BranchView branchView, SubBranchViewTranslation currentTranslationStrategy); + + /** + * Gets the later sub branch view, that possibly overlaps with the given sub branch view. Returns <tt>null</tt> if + * there's none that overlaps. + * + * @param subBranchView + * the sub branch view that shall be checked for collisions + * @param branchView + * the branch view the sub branch view is attached to + * @return the colliding later branch or <tt>null</tt> if there's none + */ + public abstract BranchView getLaterOverlapingBranch(BranchView branchView, BranchView subBranchView); } diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java index f39875bd94..3f54470f77 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java @@ -106,7 +106,7 @@ public class BranchTreeLayoutAlgorithm extends AbstractLayoutAlgorithm { if (node instanceof RootNode) { - rootNode = (RootNode)node.getLatter(rootNode); + rootNode = (RootNode)node.getLater(rootNode); } } } diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java index 673cad28ff..f577bf2bdb 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java @@ -145,8 +145,19 @@ public class BranchView /** * Returns not the last, but the one before the last sub branch view. If none is present, <tt>null<tt> is returned. + * <p> + * The sub branch views are collected bottom up (from the latest one to the earliest one in terms of time stamp). + * This method return the sub branch view that was layouted in the second but last step. Layout strategies need + * to check overlapping. Layout strategies that put sub branch views to one side of the main branch only (left/right + * or top/bottom) a sub branch overlaps the sub branch that's next in terms of time stamp. Distributing layout strategies + * need to check the one that was layouted 2 steps ago. * * @return the second to last sub branch view or <tt>null<tt> + * @see #getSubBranchViews() + * @see #getLastSubBranchView() + * @see AbstractVerticalLayoutStrategy#setSubBranchViewLocation + * @see HorizontallyAlternatingSubBranches#getLaterOverlapingBranch(BranchView, BranchView) + * @see RightHandSubBranches#getLaterOverlapingBranch(BranchView, BranchView) */ public BranchView getSecondToLastSubBranchView() { @@ -159,11 +170,32 @@ public class BranchView } /** - * Returns all sub branch views present in this branch view. + * Returns not the last sub branch view. If none is present, <tt>null<tt> is returned. + * <p> + * The sub branch views are collected bottom up (from the latest one to the earliest one in terms of time stamp). + * This method return the sub branch view that was layouted in the second but last step. Layout strategies need + * to check overlapping. Layout strategies that put sub branch views to one side of the main branch only (left/right + * or top/bottom) a sub branch overlaps the sub branch that's next in terms of time stamp. Distributing layout strategies + * need to check the one that was layouted 2 steps ago. + * + * @return the second to last sub branch view or <tt>null<tt> + * @see #getSubBranchViews() + * @see #getLastSubBranchView() + * @see AbstractVerticalLayoutStrategy#LEFT + * @see AbstractVerticalLayoutStrategy#RIGHT + */ + public BranchView getLastSubBranchView() + { + return subBranchViews.peekLast(); + } + + /** + * Returns all sub branch views present in this branch view. The sub branch views are collected bottom up (from the + * latest one to the earliest one in terms of time stamp). * * @return all sub branch views in this branch view */ - public Collection<BranchView> getSubBranchViews() + public Deque<BranchView> getSubBranchViews() { return subBranchViews; } diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/HorizontallyAlternatingSubBranches.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/HorizontallyAlternatingSubBranches.java index 41b045e8e1..af3f15b8c5 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/HorizontallyAlternatingSubBranches.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/HorizontallyAlternatingSubBranches.java @@ -10,6 +10,8 @@ */ package org.eclipse.emf.cdo.ui.internal.branch.layout; +import org.eclipse.emf.cdo.ui.internal.branch.geometry.GeometryUtils; + /** * A strategy that layouts a branch vertically and displaces sub branch view to the right or to the left. Left and right * sub branches alternate equally, they're distributed equally. @@ -41,4 +43,16 @@ public class HorizontallyAlternatingSubBranches extends AbstractVerticalLayoutSt return LEFT; } + + @Override + public BranchView getLaterOverlapingBranch(BranchView branchView, BranchView subBranchView) + { + BranchView overlapingBranch = branchView.getSecondToLastSubBranchView(); + if (overlapingBranch != null + && GeometryUtils.bottomEndsBefore(subBranchView.getBounds(), overlapingBranch.getBounds())) + { + return null; + } + return overlapingBranch; + } } diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/RightHandSubBranches.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/RightHandSubBranches.java index d97db74e82..4c6f5ede33 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/RightHandSubBranches.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/RightHandSubBranches.java @@ -10,12 +10,12 @@ */ package org.eclipse.emf.cdo.ui.internal.branch.layout; +import org.eclipse.emf.cdo.ui.internal.branch.geometry.GeometryUtils; + /** * A strategy that layouts a branch. A branch centers its (sibling) nodes below each other while using their time stamp * to set the y coordinate. Sub-Branches are displaced to the right or to the left (left and right sub branches are * distributed equally). - * <p> - * The current implementation may only layout vertically. * * @author Andre Dietisheim */ @@ -27,4 +27,16 @@ public class RightHandSubBranches extends AbstractVerticalLayoutStrategy { return RIGHT; } + + @Override + public BranchView getLaterOverlapingBranch(BranchView branchView, BranchView subBranchView) + { + BranchView overlapingBranch = branchView.getLastSubBranchView(); + if (overlapingBranch != null + && GeometryUtils.bottomEndsBefore(subBranchView.getBounds(), overlapingBranch.getBounds())) + { + return null; + } + return overlapingBranch; + } } |