Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2016-01-20 11:35:11 -0500
committerdonald.g.dunne2016-01-22 11:26:48 -0500
commit3738818bbb7713456f6e4d30ba9e8009aad04d21 (patch)
treefd0f216cd68589622fa90764d8679e6f7b3749a0
parent7700f068a437d9637d465a19ebb613d3323ebef6 (diff)
downloadorg.eclipse.osee-3738818bbb7713456f6e4d30ba9e8009aad04d21.tar.gz
org.eclipse.osee-3738818bbb7713456f6e4d30ba9e8009aad04d21.tar.xz
org.eclipse.osee-3738818bbb7713456f6e4d30ba9e8009aad04d21.zip
feature: Add shading to Resource History0.23.1.v201601221708_NRB
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewer.java11
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewerFactory.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryLabelProvider.java33
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java43
4 files changed, 80 insertions, 9 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewer.java
index c3d8935254..8181e56499 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewer.java
@@ -17,6 +17,7 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.nebula.widgets.xviewer.XViewer;
+import org.eclipse.nebula.widgets.xviewer.customize.CustomizeData;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
@@ -55,7 +56,7 @@ public class HistoryXViewer extends XViewer {
for (TreeItem item : items) {
Artifact artifact = null;
if (item.getData() instanceof IAdaptable) {
- artifact = (Artifact) ((IAdaptable) item.getData()).getAdapter(Artifact.class);
+ artifact = ((IAdaptable) item.getData()).getAdapter(Artifact.class);
if (artifact != null) {
arts.add(artifact);
@@ -106,4 +107,12 @@ public class HistoryXViewer extends XViewer {
return xHistoryViewer;
}
+ public boolean isSortByTransaction() {
+ CustomizeData generateCustDataFromTable =
+ xHistoryViewer.getXViewer().getCustomizeMgr().generateCustDataFromTable();
+ return generateCustDataFromTable.getSortingData().getSortingIds().contains(
+ HistoryXViewerFactory.transaction.getId());
+
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewerFactory.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewerFactory.java
index 4dc33aac87..9a0e963a87 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewerFactory.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryXViewerFactory.java
@@ -23,7 +23,7 @@ import org.eclipse.swt.SWT;
*/
public class HistoryXViewerFactory extends SkynetXViewerFactory {
public final static XViewerColumn transaction = new XViewerColumn("framework.history.transaction", "Transaction",
- 70, SWT.LEFT, true, SortDataType.Integer, false, null);
+ 90, SWT.LEFT, true, SortDataType.Integer, false, null);
public final static XViewerColumn gamma = new XViewerColumn("framework.history.gamma", "Gamma", 60, SWT.LEFT, false,
SortDataType.Integer, false, null);
public final static XViewerColumn itemType = new XViewerColumn("framework.history.itemType", "Item Type", 150,
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryLabelProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryLabelProvider.java
index 7cb19753c8..1faf5e1465 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryLabelProvider.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryLabelProvider.java
@@ -21,18 +21,22 @@ import org.eclipse.osee.framework.skynet.core.change.Change;
import org.eclipse.osee.framework.skynet.core.change.RelationChange;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
/**
* @author Jeff C. Phillips
*/
public class XHistoryLabelProvider extends XViewerLabelProvider {
- private final HistoryXViewer changeXViewer;
- public XHistoryLabelProvider(HistoryXViewer changeXViewer) {
- super(changeXViewer);
- this.changeXViewer = changeXViewer;
+ private final HistoryXViewer historyXViewer;
+ private static Color lightGreyColor;
+
+ public XHistoryLabelProvider(HistoryXViewer historyXViewer) {
+ super(historyXViewer);
+ this.historyXViewer = historyXViewer;
}
@Override
@@ -116,7 +120,7 @@ public class XHistoryLabelProvider extends XViewerLabelProvider {
}
public HistoryXViewer getTreeViewer() {
- return changeXViewer;
+ return historyXViewer;
}
@Override
@@ -138,4 +142,23 @@ public class XHistoryLabelProvider extends XViewerLabelProvider {
return null;
}
+ @Override
+ public Color getBackground(Object element, int columnIndex) {
+ if (historyXViewer.isSortByTransaction()) {
+ Change change = (Change) element;
+ long transactionId = change.getTxDelta().getEndTx().getId();
+ if (historyXViewer.getXHisotryViewer().isShaded(transactionId)) {
+ return getLightGreyColor();
+ }
+ }
+ return super.getBackground(element, columnIndex);
+ }
+
+ private Color getLightGreyColor() {
+ if (lightGreyColor == null) {
+ lightGreyColor = Displays.getColor(234, 234, 234);
+ }
+ return lightGreyColor;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java
index f6874b5484..0bc0bec724 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java
@@ -13,7 +13,10 @@ package org.eclipse.osee.framework.ui.skynet.widgets.xHistory;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -73,6 +76,7 @@ public class XHistoryWidget extends GenericXWidget {
private Artifact artifact;
private ToolBar toolBar;
private Composite rightComp;
+ private final Set<Long> shadedTransactions = new HashSet<>();
public XHistoryWidget() {
super("History");
@@ -186,7 +190,7 @@ public class XHistoryWidget extends GenericXWidget {
}
protected void onRefresh() {
- // Can be overridden by clients
+ // Can be overridden by clients
}
public void loadTable() {
@@ -284,6 +288,7 @@ public class XHistoryWidget extends GenericXWidget {
extraInfoLabel.setText(infoLabel);
}
if (Widgets.isAccessible(xHistoryViewer.getControl())) {
+ calculateShading(changes);
xHistoryViewer.setInput(changes);
}
} else {
@@ -292,6 +297,7 @@ public class XHistoryWidget extends GenericXWidget {
}
}
}
+
});
} catch (OseeCoreException ex) {
OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
@@ -301,6 +307,39 @@ public class XHistoryWidget extends GenericXWidget {
};
Jobs.startJob(job);
}
+
+ private void calculateShading(Collection<Change> changes) {
+ shadedTransactions.clear();
+ try {
+ Set<Long> transactionIds = new TreeSet<>();
+ for (Change change : changes) {
+ long transId = change.getTxDelta().getEndTx().getId();
+ transactionIds.add(transId);
+ }
+
+ /**
+ * Loop through sorted transactionIds and store every other one in shadedTransactions collection. This allows
+ * isShaded method to quickly return true or false for transactionId.
+ */
+ boolean shade = false;
+ for (Long transId : transactionIds) {
+ if (shade) {
+ shadedTransactions.add(transId);
+ }
+ shade = !shade;
+ }
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
+
+ /**
+ * @return true if transactionId line should be shaded, false otherwise
+ */
+ public boolean isShaded(Long transactionId) {
+ return shadedTransactions.contains(transactionId);
+ }
+
public class HistoryDragAndDrop extends SkynetDragAndDrop {
public HistoryDragAndDrop(Tree tree, String viewId) {
@@ -321,7 +360,7 @@ public class XHistoryWidget extends GenericXWidget {
for (Object object : selection.toArray()) {
if (object instanceof IAdaptable) {
- Artifact artifact = (Artifact) ((IAdaptable) object).getAdapter(Artifact.class);
+ Artifact artifact = ((IAdaptable) object).getAdapter(Artifact.class);
if (artifact != null) {
artifacts.add(artifact);

Back to the top