Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2016-11-21 13:51:08 -0500
committerdonald.g.dunne2016-11-21 13:51:08 -0500
commitea7b408e3b9ef18aef0130a393b96773c7815f18 (patch)
tree560631bca7198ee528b69946a8acf04ca0f8049b
parent21febfb417710798f9b6c609748cdfe1f6ff978b (diff)
downloadorg.eclipse.osee-ea7b408e3b9ef18aef0130a393b96773c7815f18.tar.gz
org.eclipse.osee-ea7b408e3b9ef18aef0130a393b96773c7815f18.tar.xz
org.eclipse.osee-ea7b408e3b9ef18aef0130a393b96773c7815f18.zip
bug[ats_ATS325709]: Add load selection to Resource History
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java5
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java28
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionIdComparator.java32
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java67
4 files changed, 129 insertions, 3 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
index 9d4d39ee93..dd108ba3ea 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
@@ -69,6 +69,10 @@ public final class ChangeManager {
return revsionChangeLoader.getChangesPerArtifact(artifact, monitor, loadChangeTypes);
}
+ public static Collection<? extends Change> getChangesPerArtifact(Artifact artifact, int numberTransactionsToShow, IProgressMonitor monitor) {
+ return revsionChangeLoader.getChangesPerArtifact(artifact, numberTransactionsToShow, monitor);
+ }
+
/**
* Acquires artifact, relation and attribute changes from a source branch since its creation.
*/
@@ -184,4 +188,5 @@ public final class ChangeManager {
}
return branchMap;
}
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
index 9096fb2a18..4f9bab6110 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.framework.skynet.core.revision;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
@@ -48,6 +49,7 @@ import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
import org.eclipse.osee.framework.skynet.core.revision.acquirer.ArtifactChangeAcquirer;
import org.eclipse.osee.framework.skynet.core.revision.acquirer.AttributeChangeAcquirer;
import org.eclipse.osee.framework.skynet.core.revision.acquirer.RelationChangeAcquirer;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionIdComparator;
import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler;
import org.eclipse.osee.jdbc.JdbcStatement;
@@ -89,6 +91,31 @@ public final class RevisionChangeLoader {
return changes;
}
+ public Collection<? extends Change> getChangesPerArtifact(Artifact artifact, int numberTransactionsToShow, IProgressMonitor monitor) {
+ BranchId branch = artifact.getBranch();
+ Set<TransactionToken> transactionIds = new LinkedHashSet<>();
+ boolean recurseThroughBranchHierarchy = true;
+ loadBranchTransactions(branch, artifact, transactionIds, TransactionManager.getHeadTransaction(branch),
+ recurseThroughBranchHierarchy);
+
+ Collection<Change> changes = new ArrayList<>();
+ List<TransactionToken> sortedTransIds = new ArrayList<>();
+ sortedTransIds.addAll(transactionIds);
+ Collections.sort(sortedTransIds, new TransactionIdComparator());
+ Collections.reverse(sortedTransIds);
+
+ int count = 0;
+ for (TransactionToken transactionId : sortedTransIds) {
+ loadChanges(null, transactionId, monitor, artifact, changes, LoadChangeType.artifact, LoadChangeType.attribute,
+ LoadChangeType.relation);
+ count++;
+ if (count >= numberTransactionsToShow) {
+ break;
+ }
+ }
+ return changes;
+ }
+
private void loadBranchTransactions(BranchId branch, Artifact artifact, Set<TransactionToken> transactionIds, TransactionId transactionId, boolean recurseThroughBranchHierarchy) throws OseeCoreException {
loadTransactions(branch, artifact, transactionId, transactionIds);
@@ -237,4 +264,5 @@ public final class RevisionChangeLoader {
}
return changes;
}
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionIdComparator.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionIdComparator.java
new file mode 100644
index 0000000000..e0cfcf7aff
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionIdComparator.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.skynet.core.transaction;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import org.eclipse.osee.framework.core.data.TransactionId;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class TransactionIdComparator implements Comparator<TransactionId>, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public TransactionIdComparator() {
+ super();
+ }
+
+ @Override
+ public int compare(TransactionId trans1, TransactionId trans2) {
+ return trans1.getId().compareTo(trans2.getId());
+ }
+} \ No newline at end of file
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 d927f777cb..9a5ffafc53 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
@@ -71,13 +71,14 @@ public class XHistoryWidget extends GenericXWidget {
private HistoryXViewer xHistoryViewer;
public final static String normalColor = "#EEEEEE";
- private static final String LOADING = "Loading ...";
private static final String NO_HISTORY = "No History changes were found";
protected Label extraInfoLabel;
private Artifact artifact;
private ToolBar toolBar;
private Composite rightComp;
private final Set<Long> shadedTransactions = new HashSet<>();
+ private int numberTransactionsToShow = 25;
+ private ToolItem show25Item, show75Item, showAllItem, show50Item;
public XHistoryWidget() {
super("History");
@@ -184,6 +185,63 @@ public class XHistoryWidget extends GenericXWidget {
}
});
+ show25Item = new ToolItem(toolBar, SWT.RADIO | SWT.BORDER);
+ show25Item.setText(" 25");
+ show25Item.setToolTipText("Show last 25 transactions.");
+ show25Item.setSelection(true);
+ show25Item.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ numberTransactionsToShow = 25;
+ show25Item.setSelection(true);
+ show50Item.setSelection(false);
+ show75Item.setSelection(false);
+ showAllItem.setSelection(false);
+ }
+ });
+
+ show50Item = new ToolItem(toolBar, SWT.RADIO | SWT.BORDER);
+ show50Item.setText(" 50");
+ show50Item.setToolTipText("Show last 50 transactions.");
+ show50Item.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ numberTransactionsToShow = 50;
+ show25Item.setSelection(false);
+ show50Item.setSelection(true);
+ show75Item.setSelection(false);
+ showAllItem.setSelection(false);
+ }
+ });
+
+ show75Item = new ToolItem(toolBar, SWT.RADIO | SWT.BORDER);
+ show75Item.setText(" 75");
+ show75Item.setToolTipText("Show last 75 transactions.");
+ show75Item.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ numberTransactionsToShow = 75;
+ show25Item.setSelection(false);
+ show50Item.setSelection(false);
+ show75Item.setSelection(true);
+ showAllItem.setSelection(false);
+ }
+ });
+
+ showAllItem = new ToolItem(toolBar, SWT.RADIO | SWT.BORDER);
+ showAllItem.setText(" All");
+ showAllItem.setToolTipText("Show All transactions.");
+ showAllItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ numberTransactionsToShow = Integer.MAX_VALUE;
+ show25Item.setSelection(false);
+ show50Item.setSelection(false);
+ show75Item.setSelection(false);
+ showAllItem.setSelection(true);
+ }
+ });
+
new ActionContributionItem(xHistoryViewer.getCustomizeAction()).fill(toolBar, -1);
rightComp.layout();
@@ -257,7 +315,10 @@ public class XHistoryWidget extends GenericXWidget {
public void setInputData(final Artifact artifact, final boolean loadHistory) {
this.artifact = artifact;
- extraInfoLabel.setText(LOADING);
+ extraInfoLabel.setText(String.format("Loading %d Transactions...",
+ (numberTransactionsToShow == Integer.MAX_VALUE ? "All" : numberTransactionsToShow)));
+
+ final int fNumnberTransactionsToShow = numberTransactionsToShow;
Job job = new Job("History: " + artifact.getName()) {
@@ -267,7 +328,7 @@ public class XHistoryWidget extends GenericXWidget {
try {
if (loadHistory) {
- changes.addAll(ChangeManager.getChangesPerArtifact(artifact, monitor));
+ changes.addAll(ChangeManager.getChangesPerArtifact(artifact, fNumnberTransactionsToShow, monitor));
}
Displays.ensureInDisplayThread(new Runnable() {

Back to the top