diff options
author | Eike Stepper | 2012-10-14 06:44:50 +0000 |
---|---|---|
committer | Eike Stepper | 2012-10-14 06:44:50 +0000 |
commit | ad48ab030c7ff7a331cfe68885550f2cb15d1572 (patch) | |
tree | 96f46aaacc3ee1220a88d817a8fce4fc383f19f6 | |
parent | 8baeeeafeb541f21190e7cfa9899904fc0422277 (diff) | |
download | cdo-ad48ab030c7ff7a331cfe68885550f2cb15d1572.tar.gz cdo-ad48ab030c7ff7a331cfe68885550f2cb15d1572.tar.xz cdo-ad48ab030c7ff7a331cfe68885550f2cb15d1572.zip |
[391503] [UI] Render a CDOCommitInfo graph into the history page
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391503
9 files changed, 113 insertions, 43 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfo.java index f3c16c7d38..fdf8603d92 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfo.java @@ -10,6 +10,7 @@ */ package org.eclipse.emf.cdo.common.commit; +import org.eclipse.emf.cdo.common.CDOCommonRepository; import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; /** @@ -34,4 +35,11 @@ public interface CDOCommitInfo extends CDOBranchPoint, CDOCommitData public String getUserID(); public String getComment(); + + /** + * Returns <code>true</code> if this commit info describes the first initializing commit in the {@link CDOCommonRepository repository}, <code>false</code> otherwise. + * + * @since 4.2 + */ + public boolean isInitialCommit(); } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java index c7d5b7a94b..f42c4ecf29 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java @@ -34,7 +34,7 @@ import java.util.Date; /** * Various static methods that may help with I/O and time stamps. - * + * * @author Eike Stepper * @since 3.0 */ @@ -45,6 +45,11 @@ public final class CDOCommonUtil */ public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'.'SSS"); + /** + * @since 4.2 + */ + public static final String SYSTEM_USER_ID = "CDO_SYSTEM"; //$NON-NLS-1$ + private CDOCommonUtil() { } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitHistoryImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitHistoryImpl.java index f4440988b2..b66abbfd4d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitHistoryImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitHistoryImpl.java @@ -439,6 +439,11 @@ public class CDOCommitHistoryImpl extends Container<CDOCommitInfo> implements CD return true; } + public boolean isInitialCommit() + { + return false; + } + public List<CDOPackageUnit> getNewPackageUnits() { return null; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java index 7ba657a1e6..7cd2979ebe 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java @@ -34,7 +34,7 @@ import java.util.Map; */ public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitInfo { -// private static final CDOCommitInfo[] NO_PARENTS = {}; + // private static final CDOCommitInfo[] NO_PARENTS = {}; private InternalCDOCommitInfoManager commitInfoManager; @@ -46,7 +46,7 @@ public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitIn private CDOCommitData commitData; -// private transient CDOCommitInfo[] parents; + // private transient CDOCommitInfo[] parents; public CDOCommitInfoImpl(InternalCDOCommitInfoManager commitInfoManager, CDOBranch branch, long timeStamp, long previousTimeStamp, String userID, String comment, CDOCommitData commitData) @@ -65,23 +65,23 @@ public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitIn return commitInfoManager; } -// public synchronized CDOCommitInfo[] getParents() -// { -// if (parents == null) -// { -// CDOCommitInfo previousCommitInfo = commitInfoManager.getCommitInfo(previousTimeStamp); -// if (previousCommitInfo != null) -// { -// parents = new CDOCommitInfo[] { previousCommitInfo }; -// } -// else -// { -// parents = NO_PARENTS; -// } -// } -// -// return parents; -// } + // public synchronized CDOCommitInfo[] getParents() + // { + // if (parents == null) + // { + // CDOCommitInfo previousCommitInfo = commitInfoManager.getCommitInfo(previousTimeStamp); + // if (previousCommitInfo != null) + // { + // parents = new CDOCommitInfo[] { previousCommitInfo }; + // } + // else + // { + // parents = NO_PARENTS; + // } + // } + // + // return parents; + // } public long getPreviousTimeStamp() { @@ -98,6 +98,11 @@ public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitIn return comment; } + public boolean isInitialCommit() + { + return CDOCommonUtil.SYSTEM_USER_ID.equals(userID); + } + public boolean isEmpty() { loadCommitDataIfNeeded(); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java index d0e0e604b9..1f79eaa574 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java @@ -69,6 +69,11 @@ public abstract class DelegatingCommitInfo implements CDOCommitInfo return getDelegate().isEmpty(); } + public boolean isInitialCommit() + { + return getDelegate().isInitialCommit(); + } + public List<CDOPackageUnit> getNewPackageUnits() { return getDelegate().getNewPackageUnits(); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java index 1517828476..b387a5520b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java @@ -74,6 +74,11 @@ public class FailureCommitInfo implements CDOCommitInfo return true; } + public boolean isInitialCommit() + { + return false; + } + public List<CDOPackageUnit> getNewPackageUnits() { return Collections.emptyList(); diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java index 1d5bb1a543..f26b0af5fe 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java @@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.common.lock.IDurableLockingManager; import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionManager; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; import org.eclipse.net4j.util.container.IContainer; import org.eclipse.net4j.util.om.monitor.OMMonitor; @@ -52,7 +53,7 @@ public interface IRepository extends CDOCommonRepository, IQueryHandlerProvider, /** * @since 3.0 */ - public static final String SYSTEM_USER_ID = "CDO_SYSTEM"; //$NON-NLS-1$ + public static final String SYSTEM_USER_ID = CDOCommonUtil.SYSTEM_USER_ID; public IStore getStore(); diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/history/NetRenderer.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/history/NetRenderer.java index 344d4797ad..a287c9d729 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/history/NetRenderer.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/history/NetRenderer.java @@ -39,6 +39,8 @@ import org.eclipse.swt.widgets.TableItem; */ public class NetRenderer implements Listener { + private static final int ROUND_EDGE = 3; + private static final int TRACK_OFFSET = 4; private static final int TRACK_WIDTH = 14; @@ -225,7 +227,7 @@ public class NetRenderer implements Listener { int y = cellHeightHalf + 1; int x2 = gc.getClipping().width; - drawLine(colorDotOutline, width, y, x2, y, LINE_WIDTH); + drawLine(colorDotOutline, width, y, x2, y); } } @@ -260,30 +262,21 @@ public class NetRenderer implements Listener int commitTrackCenter = getTrackCenter(commitTrackPosition); int positionDelta = Math.abs(i - commitTrackPosition); - int x2 = commitTrackCenter; + int horizontal = (positionDelta - 1) * TRACK_WIDTH + 6 + ROUND_EDGE; if (i < commitTrackPosition) { - // Horizontal line to left - x2 -= (positionDelta - 1) * TRACK_WIDTH + 7; - drawLine(color, commitTrackCenter, cellHeightHalf, x2, cellHeightHalf, LINE_WIDTH); - - // Diagonal line to upper left - drawLine(color, x2, cellHeightHalf, getTrackCenter(i), 0, LINE_WIDTH); + horizontal = -horizontal; } - else - { - // Horizontal line to right - x2 += (positionDelta - 1) * TRACK_WIDTH + 7; - drawLine(color, commitTrackCenter, cellHeightHalf, x2, cellHeightHalf, LINE_WIDTH); - // Diagonal line to upper right - drawLine(color, x2, cellHeightHalf, getTrackCenter(i), 0, LINE_WIDTH); - } + LinePlotter plotter = new LinePlotter(color, commitTrackCenter, cellHeightHalf); + plotter.relative(horizontal, 0); + plotter.absolute(getTrackCenter(i), ROUND_EDGE); + plotter.relative(0, -ROUND_EDGE); } else { // Full vertical line - drawLine(color, trackCenter, 0, trackCenter, cellHeight, LINE_WIDTH); + drawLine(color, trackCenter, 0, trackCenter, cellHeight); } } } @@ -295,13 +288,16 @@ public class NetRenderer implements Listener if (commitTime < commitSegment.getLastCommitTime()) { // Half vertical line to top - drawLine(color, trackCenter, 0, trackCenter, cellHeightHalf, LINE_WIDTH); + drawLine(color, trackCenter, 0, trackCenter, cellHeightHalf); } if (commitTime > commitSegment.getFirstVisualTime() || !commitSegment.isComplete()) { - // Half vertical line to bottom - drawLine(color, trackCenter, cellHeightHalf, trackCenter, cellHeight, LINE_WIDTH); + if (!commitInfo.isInitialCommit()) + { + // Half vertical line to bottom + drawLine(color, trackCenter, cellHeightHalf, trackCenter, cellHeight); + } } int dotX = trackCenter - dotSizeHalf - 1; @@ -313,10 +309,10 @@ public class NetRenderer implements Listener return getTrackX(segments.length) + TRACK_WIDTH; } - private void drawLine(final Color color, final int x1, final int y1, final int x2, final int y2, final int width) + private void drawLine(Color color, int x1, int y1, int x2, int y2) { gc.setForeground(color); - gc.setLineWidth(width); + gc.setLineWidth(LINE_WIDTH); gc.drawLine(cellX + x1, cellY + y1, cellX + x2, cellY + y2); } @@ -357,4 +353,39 @@ public class NetRenderer implements Listener { return getTrackX(position) + TRACK_WIDTH / 2; } + + /** + * @author Eike Stepper + */ + private final class LinePlotter + { + private final Color color; + + private int x; + + private int y; + + public LinePlotter(Color color, int x, int y) + { + this.color = color; + this.x = x; + this.y = y; + } + + public void relative(int width, int height) + { + int fromX = x; + int fromY = y; + x += width; + y += height; + drawLine(color, fromX, fromY, x, y); + } + + public void absolute(int x, int y) + { + drawLine(color, this.x, this.y, x, y); + this.x = x; + this.y = y; + } + } } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java index 6be2ac5a09..1f99a5f8e2 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java @@ -1894,6 +1894,11 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme return false; } + public boolean isInitialCommit() + { + return commitInfo.isInitialCommit(); + } + public CDOChangeSetData copy() { return commitInfo.copy(); |