diff options
author | Andre Dietisheim | 2010-03-18 20:10:22 +0000 |
---|---|---|
committer | Andre Dietisheim | 2010-03-18 20:10:22 +0000 |
commit | 899ced6a1b10dfcc1101dd770a4f82565fcd6766 (patch) | |
tree | b3408916c13d099138e89327f3960229ebab56ad | |
parent | 8d3aa92f915ca060b15878998a0753b9d68b2cfc (diff) | |
download | cdo-899ced6a1b10dfcc1101dd770a4f82565fcd6766.tar.gz cdo-899ced6a1b10dfcc1101dd770a4f82565fcd6766.tar.xz cdo-899ced6a1b10dfcc1101dd770a4f82565fcd6766.zip |
[256624] [UI] Create a Commit History ViewPart
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256624
implemented left hand layouted sub branches
-rw-r--r-- | plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractBranchViewLayoutStrategy.java | 18 | ||||
-rw-r--r-- | plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractVerticalLayoutStrategy.java (renamed from plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/VerticallyDistributedSubBranches.java) | 53 | ||||
-rw-r--r-- | plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchTreeLayoutAlgorithm.java | 3 | ||||
-rw-r--r-- | plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/BranchView.java | 2 | ||||
-rw-r--r-- | plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/HorizontallyAlternatingSubBranches.java | 80 | ||||
-rw-r--r-- | plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/RightHandSubBranches.java | 58 |
6 files changed, 162 insertions, 52 deletions
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 3bf4e993df..c49622e903 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 @@ -181,8 +181,8 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo public void scale(BranchView branchView, DisplayIndependentRectangle targetBounds) { DisplayIndependentRectangle branchViewBounds = branchView.getBounds(); - DisplayIndependentDimension scaling = new DisplayIndependentDimension(branchViewBounds.width / targetBounds.width, - branchViewBounds.height / targetBounds.height); + DisplayIndependentDimension scaling = new DisplayIndependentDimension(targetBounds.width / branchViewBounds.width, + targetBounds.height / branchViewBounds.height); scale(branchView, scaling); translateBy(branchView, GeometryUtils.getTranslation(branchView.getBounds(), targetBounds.x, targetBounds.y)); } @@ -208,8 +208,8 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo for (AbstractBranchPointNode node : branchView.getNodes()) { InternalNode internalNode = BranchPointNodeUtils.getInternalNode(node); - double newX = centerX / scaling.width - internalNode.getInternalWidth() / 2; - double newY = internalNode.getInternalY() / scaling.height; + double newX = centerX * scaling.width - internalNode.getInternalWidth() / 2; + double newY = internalNode.getInternalY() * scaling.height; internalNode.setInternalLocation(newX, newY); if (!branchView.areBoundsSet()) { @@ -238,4 +238,14 @@ public abstract class AbstractBranchViewLayoutStrategy implements BranchViewLayo branchView.setBounds(GeometryUtils.union(branchView.getBounds(), subBranch.getBounds())); } } + + /** + * Returns the horizontal padding between branch views. + * + * @return the branch padding + */ + protected double getBranchPadding() + { + return 60; + } } diff --git a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/VerticallyDistributedSubBranches.java b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractVerticalLayoutStrategy.java index 85f5fb0091..a642ecefc6 100644 --- a/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/VerticallyDistributedSubBranches.java +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/AbstractVerticalLayoutStrategy.java @@ -27,9 +27,9 @@ import org.eclipse.zest.layouts.dataStructures.InternalNode; * * @author Andre Dietisheim */ -public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutStrategy +public abstract class AbstractVerticalLayoutStrategy extends AbstractBranchViewLayoutStrategy { - private static final VerticallyDistributedSubBranches RIGHT = new VerticallyDistributedSubBranches() + public static final HorizontallyAlternatingSubBranches RIGHT = new HorizontallyAlternatingSubBranches() { @Override protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranchView, @@ -51,7 +51,7 @@ public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutSt } }; - private static final VerticallyDistributedSubBranches LEFT = new VerticallyDistributedSubBranches() + protected static final HorizontallyAlternatingSubBranches LEFT = new HorizontallyAlternatingSubBranches() { @Override protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranch, @@ -74,30 +74,6 @@ public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutSt } }; - protected VerticallyDistributedSubBranches currentSubBranchStrategy = null; - - @Override - protected void setSubBranchViewLocation(BranchView branchView, BranchView subBranchView, BranchPointNode branchPointNode) - { - currentSubBranchStrategy = getSubBranchStrategy(currentSubBranchStrategy); - currentSubBranchStrategy.setSubBranchLocation(branchView, subBranchView, branchPointNode); - } - - /** - * Returns the strategy that layouts the next branch view. Starts with right, second call returns left, etc. - * - * @return the current sub branch strategy - */ - private VerticallyDistributedSubBranches getSubBranchStrategy(VerticallyDistributedSubBranches currentStrategy) - { - if (currentStrategy == null || currentStrategy == LEFT) - { - return RIGHT; - } - - return LEFT; - } - /** * 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 @@ -134,11 +110,8 @@ public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutSt * the sub branch * @return the branch point translation */ - protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranch, - BranchPointNode branchPointNode) - { - return currentSubBranchStrategy.getTranslationToBranchPoint(subBranch, branchPointNode); - } + protected abstract DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranch, + BranchPointNode branchPointNode); /** * Returns the offset that's needed to translate the given branch so that it does not collide with the latter branch. @@ -149,18 +122,6 @@ public class VerticallyDistributedSubBranches extends AbstractBranchViewLayoutSt * the latter branch * @return the latter branch translation */ - protected DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranch) - { - return currentSubBranchStrategy.getTranslationToLatterBranch(subBranch, latterBranch); - } - - /** - * Returns the horizontal padding between branch views. - * - * @return the branch padding - */ - protected double getBranchPadding() - { - return 60; - } + protected abstract DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, + BranchView latterBranch); } 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 a8d557d572..85edb47a29 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 @@ -131,7 +131,8 @@ public class BranchTreeLayoutAlgorithm extends AbstractLayoutAlgorithm private BranchView buildBranch(AbstractBranchPointNode branchRootNode) { - return new BranchView(branchRootNode, new VerticallyDistributedSubBranches()); + // return new BranchView(branchRootNode, new VerticallyDistributedSubBranches()); + return new BranchView(branchRootNode, new RightHandSubBranches()); } @Override 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 4c47f86e8d..673cad28ff 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 @@ -27,7 +27,7 @@ import java.util.Collection; * terms of time stamp). * * @author Andre Dietisheim - * @see VerticallyDistributedSubBranches + * @see HorizontallyAlternatingSubBranches */ public class BranchView { 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 new file mode 100644 index 0000000000..4256a1c949 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/HorizontallyAlternatingSubBranches.java @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * 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: + * Andre Dietisheim - initial API and implementation + */ +package org.eclipse.emf.cdo.ui.internal.branch.layout; + +import org.eclipse.emf.cdo.ui.internal.branch.item.BranchPointNode; + +import org.eclipse.zest.layouts.dataStructures.DisplayIndependentDimension; + +/** + * 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 + */ +public class HorizontallyAlternatingSubBranches extends AbstractVerticalLayoutStrategy +{ + protected HorizontallyAlternatingSubBranches currentSubBranchStrategy = null; + + /** + * Sets either a location to the left or to the right of the current branch. Delegates for this to appropriate + * strategies + * + * @param subBranchView + * the sub branch to layout in the current branch + * @param branchPointNode + * the branch point node the given sub branch is attached to + * @param branchView + * the branch view + * @see #LEFT + * @see #RIGHT + */ + @Override + protected void setSubBranchViewLocation(BranchView branchView, BranchView subBranchView, + BranchPointNode branchPointNode) + { + currentSubBranchStrategy = getSubBranchStrategy(currentSubBranchStrategy); + currentSubBranchStrategy.setSubBranchLocation(branchView, subBranchView, branchPointNode); + } + + /** + * Returns the strategy that layouts the next branch view. Starts with right, second call returns left, etc. + * + * @return the current sub branch strategy + * @see #LEFT + * @see #RIGHT + */ + private HorizontallyAlternatingSubBranches getSubBranchStrategy(HorizontallyAlternatingSubBranches currentStrategy) + { + if (currentStrategy == null || currentStrategy == LEFT) + { + return RIGHT; + } + + return LEFT; + } + + @Override + protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranch, + BranchPointNode branchPointNode) + { + return currentSubBranchStrategy.getTranslationToBranchPoint(subBranch, branchPointNode); + } + + @Override + protected DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranch) + { + return currentSubBranchStrategy.getTranslationToLatterBranch(subBranch, latterBranch); + } +} 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 new file mode 100644 index 0000000000..45688d1265 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.ui.branch/src/org/eclipse/emf/cdo/ui/internal/branch/layout/RightHandSubBranches.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * 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: + * Andre Dietisheim - initial API and implementation + */ +package org.eclipse.emf.cdo.ui.internal.branch.layout; + +import org.eclipse.emf.cdo.ui.internal.branch.item.BranchPointNode; + +import org.eclipse.zest.layouts.dataStructures.DisplayIndependentDimension; + +/** + * 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 + */ +public class RightHandSubBranches extends AbstractVerticalLayoutStrategy +{ + /** + * Sets the location to the right of the current branch. Delegates for this to appropriate strategy + * + * @param subBranchView + * the sub branch to layout in the current branch + * @param branchPointNode + * the branch point node the given sub branch is attached to + * @param branchView + * the branch view + * @see #RIGHT + */ + @Override + protected void setSubBranchViewLocation(BranchView branchView, BranchView subBranchView, + BranchPointNode branchPointNode) + { + RIGHT.setSubBranchLocation(branchView, subBranchView, branchPointNode); + } + + @Override + protected DisplayIndependentDimension getTranslationToBranchPoint(BranchView subBranch, + BranchPointNode branchPointNode) + { + return RIGHT.getTranslationToBranchPoint(subBranch, branchPointNode); + } + + @Override + protected DisplayIndependentDimension getTranslationToLatterBranch(BranchView subBranch, BranchView latterBranch) + { + return RIGHT.getTranslationToLatterBranch(subBranch, latterBranch); + } +} |