diff options
author | donald.g.dunne | 2016-09-13 21:26:28 +0000 |
---|---|---|
committer | Donald Dunne | 2016-09-14 18:37:05 +0000 |
commit | 0fae680b42cd178af4f790a0d5f5d73dda30af5f (patch) | |
tree | 4c178e832f84216eebc9ded688195c4d3791b2dd | |
parent | 72b61d75865e156c2cd3dca44135b810ab93c817 (diff) | |
download | org.eclipse.osee-0fae680b42cd178af4f790a0d5f5d73dda30af5f.tar.gz org.eclipse.osee-0fae680b42cd178af4f790a0d5f5d73dda30af5f.tar.xz org.eclipse.osee-0fae680b42cd178af4f790a0d5f5d73dda30af5f.zip |
bug[ats_ATS314406]: Resource History on certain artifacts locks UI
Change-Id: I92924aaedf54436961fd3744d739c0a1a205004d
13 files changed, 495 insertions, 55 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java index bba7303f3ac..fcd8acc84f3 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java @@ -16,7 +16,9 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; +import java.util.Set; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TokenFactory; @@ -48,6 +50,9 @@ public final class TransactionManager { private static final String SELECT_TRANSACTIONS = "SELECT * FROM osee_tx_details WHERE branch_id = ? ORDER BY transaction_id DESC"; + private static final String SELECT_TRANSACTIONS_BY_IDS = + "SELECT * FROM osee_tx_details WHERE transaction_id in (%s)"; + private static final String SELECT_COMMIT_TRANSACTIONS = "SELECT * FROM osee_tx_details WHERE commit_art_id = ?"; private static final String UPDATE_TRANSACTION_COMMENTS = @@ -204,4 +209,20 @@ public final class TransactionManager { () -> new TransactionDoesNotExist("A transaction with id %d was not found.", txId), stmt -> loadTransaction(stmt), TX_GET_TRANSACTION_BY_ID, txId); } + + public static Collection<TransactionRecord> getTransactions(Set<Long> ids) { + List<TransactionRecord> transactions = new LinkedList<TransactionRecord>(); + JdbcStatement chStmt = ConnectionHandler.getStatement(); + try { + String query = String.format(SELECT_TRANSACTIONS_BY_IDS, + org.eclipse.osee.framework.jdk.core.util.Collections.toString(",", ids)); + chStmt.runPreparedQuery(query); + while (chStmt.next()) { + transactions.add(loadTransaction(chStmt)); + } + } finally { + chStmt.close(); + } + return transactions; + } }
\ 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/HistoryTransactionCache.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryTransactionCache.java new file mode 100644 index 00000000000..3db42f25c82 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryTransactionCache.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.ui.skynet.widgets.xHistory; + +import java.util.HashMap; +import java.util.Map; +import org.eclipse.osee.framework.core.model.TransactionRecord; + +/** + * @author Donald G. Dunne + */ +public class HistoryTransactionCache implements IHistoryTransactionProvider { + + private final Map<Long, TransactionRecord> txIdToTransRecord = new HashMap<Long, TransactionRecord>(500); + + public Map<Long, TransactionRecord> getTxIdToTransRecord() { + return txIdToTransRecord; + } + + @Override + public TransactionRecord getTransactionRecord(Long id) { + return txIdToTransRecord.get(id); + } + + @Override + public void put(Long id, TransactionRecord transaction) { + txIdToTransRecord.put(transaction.getId(), transaction); + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java index 0fe1f7bc617..ce542e70f46 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java @@ -241,6 +241,7 @@ public class HistoryView extends GenericViewPart implements IBranchEventListener replaceWithMenu.addSelectionListener(new SelectionAdapter() { + @SuppressWarnings("deprecation") @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) xHistoryWidget.getXViewer().getSelection(); 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 0e814924e92..fe2e36efa57 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 @@ -11,16 +11,19 @@ package org.eclipse.osee.framework.ui.skynet.widgets.xHistory; import java.util.ArrayList; +import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.action.IMenuListener; 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.core.model.CustomizeData; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; +import org.eclipse.osee.framework.core.model.TransactionRecord; 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; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.column.HistoryTransactionIdColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.OseeTreeReportAdapter; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TreeItem; @@ -28,12 +31,15 @@ import org.eclipse.swt.widgets.TreeItem; /** * @author Jeff C. Phillips */ -public class HistoryXViewer extends XViewer { +public class HistoryXViewer extends XViewer implements IHistoryTransactionProvider { private final XHistoryWidget xHistoryViewer; + private final IHistoryTransactionProvider txCache; public HistoryXViewer(Composite parent, int style, XHistoryWidget xRoleViewer) { - super(parent, style, new HistoryXViewerFactory(new OseeTreeReportAdapter("Table Report - History View"))); + super(parent, style, new HistoryXViewerFactory(new OseeTreeReportAdapter("Table Report - History View"), + new HistoryTransactionCache())); this.xHistoryViewer = xRoleViewer; + txCache = ((HistoryXViewerFactory) getXViewerFactory()).getTxCache(); } @Override @@ -91,9 +97,6 @@ public class HistoryXViewer extends XViewer { mm.insertBefore(MENU_GROUP_PRE, new Separator()); } - /** - * Release resources - */ @Override public void dispose() { if (getLabelProvider() != null) { @@ -101,17 +104,44 @@ public class HistoryXViewer extends XViewer { } } - /** - * @return the xHistoryViewer - */ - public XHistoryWidget getXHisotryViewer() { + public XHistoryWidget getXHistoryViewer() { return xHistoryViewer; } public boolean isSortByTransaction() { - CustomizeData generateCustDataFromTable = - xHistoryViewer.getXViewer().getCustomizeMgr().generateCustDataFromTable(); - return generateCustDataFromTable.getSortingData().getSortingIds().contains( - HistoryXViewerFactory.transaction.getId()); + List<XViewerColumn> sortXCols = xHistoryViewer.getXViewer().getCustomizeMgr().getSortXCols(); + for (XViewerColumn col : sortXCols) { + if (col.getId().equals(HistoryTransactionIdColumn.ID)) { + return true; + } + } + return false; + } + + public boolean isDisposed() { + return getTree() == null || getTree().isDisposed(); + } + + @Override + public void refresh() { + if (isDisposed()) { + return; + } + super.refreshColumnsWithPreCompute(getInput()); } + + @Override + public TransactionRecord getTransactionRecord(Long id) { + return txCache.getTransactionRecord(id); + } + + public IHistoryTransactionProvider getTxCache() { + return txCache; + } + + @Override + public void put(Long id, TransactionRecord transaction) { + txCache.put(id, transaction); + } + } 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 cd9b2e898d7..52084416fb5 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 @@ -16,6 +16,10 @@ import org.eclipse.nebula.widgets.xviewer.core.model.CustomizeData; import org.eclipse.nebula.widgets.xviewer.core.model.SortDataType; import org.eclipse.nebula.widgets.xviewer.core.model.XViewerAlign; import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.column.HistoryTransactionAuthorColumn; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.column.HistoryTransactionCommentColumn; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.column.HistoryTransactionDateColumn; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.column.HistoryTransactionIdColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.IOseeTreeReportProvider; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.SkynetXViewerFactory; @@ -23,8 +27,7 @@ import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.SkynetXViewer * @author Jeff C. Phillips */ public class HistoryXViewerFactory extends SkynetXViewerFactory { - public final static XViewerColumn transaction = new XViewerColumn("framework.history.transaction", "Transaction", 90, - XViewerAlign.Left, true, SortDataType.Integer, false, null); + private final HistoryTransactionDateColumn historyTransactionDateColumn; public final static XViewerColumn gamma = new XViewerColumn("framework.history.gamma", "Gamma", 60, XViewerAlign.Left, false, SortDataType.Integer, false, null); public final static XViewerColumn itemType = new XViewerColumn("framework.history.itemType", "Item Type", 150, @@ -39,18 +42,17 @@ public class HistoryXViewerFactory extends SkynetXViewerFactory { new XViewerColumn("framework.history.was", "Was", 150, XViewerAlign.Left, true, SortDataType.String, false, null); public final static XViewerColumn is = new XViewerColumn("framework.history.is", "Is", 150, XViewerAlign.Left, true, SortDataType.String, false, null); - public final static XViewerColumn timeStamp = new XViewerColumn("framework.history.timeStamp", "Time Stamp", 110, - XViewerAlign.Left, true, SortDataType.Date, false, null); - public final static XViewerColumn author = new XViewerColumn("framework.history.author", "Author", 100, - XViewerAlign.Left, true, SortDataType.String, false, null); - public final static XViewerColumn comment = new XViewerColumn("framework.history.comment", "Comment", 300, - XViewerAlign.Left, true, SortDataType.String, false, null); public final static String NAMESPACE = "osee.skynet.gui.HisotryXViewer"; + private final IHistoryTransactionProvider txCache; - public HistoryXViewerFactory(IOseeTreeReportProvider reportProvider) { + public HistoryXViewerFactory(IOseeTreeReportProvider reportProvider, IHistoryTransactionProvider txCache) { super(NAMESPACE, reportProvider); - registerColumns(transaction, gamma, itemType, itemChange, modType, itemId, was, is, timeStamp, author, comment); + this.txCache = txCache; + historyTransactionDateColumn = new HistoryTransactionDateColumn(txCache); + registerColumns(new HistoryTransactionIdColumn(txCache), gamma, itemType, itemChange, modType, itemId, was, is, + historyTransactionDateColumn, new HistoryTransactionAuthorColumn(txCache), + new HistoryTransactionCommentColumn(txCache)); registerAllAttributeColumns(); } @@ -63,12 +65,20 @@ public class HistoryXViewerFactory extends SkynetXViewerFactory { public CustomizeData getDefaultTableCustomizeData() { CustomizeData customizeData = super.getDefaultTableCustomizeData(); for (XViewerColumn xCol : customizeData.getColumnData().getColumns()) { - if (xCol.getId() == transaction.getId()) { + if (xCol.getId().equals(HistoryTransactionIdColumn.ID)) { xCol.setSortForward(false); } } - customizeData.getSortingData().setSortingNames(transaction.getId()); + customizeData.getSortingData().setSortingNames(HistoryTransactionIdColumn.ID); return customizeData; } + public HistoryTransactionDateColumn getHistoryTransactionDateColumn() { + return historyTransactionDateColumn; + } + + public IHistoryTransactionProvider getTxCache() { + return txCache; + } + } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/IHistoryTransactionProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/IHistoryTransactionProvider.java new file mode 100644 index 00000000000..41df1361cfe --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/IHistoryTransactionProvider.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * 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.ui.skynet.widgets.xHistory; + +import org.eclipse.osee.framework.core.model.TransactionRecord; + +/** + * @author Donald G. Dunne + */ +public interface IHistoryTransactionProvider { + + public TransactionRecord getTransactionRecord(Long id); + + public void put(Long id, TransactionRecord transaction); + +} 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 47327d31be0..8cd148cfa2b 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 @@ -10,19 +10,21 @@ *******************************************************************************/ package org.eclipse.osee.framework.ui.skynet.widgets.xHistory; -import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.nebula.widgets.xviewer.XViewerCells; import org.eclipse.nebula.widgets.xviewer.XViewerLabelProvider; import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; -import org.eclipse.osee.framework.core.model.TransactionRecord; -import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.change.ArtifactChange; import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.skynet.core.change.RelationChange; -import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.column.HistoryTransactionDateColumn; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.column.HistoryTransactionIdColumn; import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.swt.graphics.Color; @@ -35,6 +37,9 @@ public class XHistoryLabelProvider extends XViewerLabelProvider { private final HistoryXViewer historyXViewer; private static Color lightGreyColor; + private final Map<XViewerColumn, Long> colToTime = new HashMap<XViewerColumn, Long>(); + private final Map<Object, Image> objectToImage = new HashMap<Object, Image>(500); + private static Image transactionImage = null; public XHistoryLabelProvider(HistoryXViewer historyXViewer) { super(historyXViewer); @@ -47,11 +52,7 @@ public class XHistoryLabelProvider extends XViewerLabelProvider { try { if (element instanceof Change) { Change data = (Change) element; - TransactionRecord endTx = TransactionManager.getTransaction(data.getTxDelta().getEndTx()); - - if (cCol.equals(HistoryXViewerFactory.transaction)) { - toReturn = String.valueOf(endTx.getId()); - } else if (cCol.equals(HistoryXViewerFactory.gamma)) { + if (cCol.equals(HistoryXViewerFactory.gamma)) { toReturn = String.valueOf(data.getGamma()); } else if (cCol.equals(HistoryXViewerFactory.itemType)) { if (data instanceof ArtifactChange && data.getChangeArtifact() == null) { @@ -69,12 +70,6 @@ public class XHistoryLabelProvider extends XViewerLabelProvider { toReturn = data.getWasValue(); } else if (cCol.equals(HistoryXViewerFactory.is)) { toReturn = data.getIsValue(); - } else if (cCol.equals(HistoryXViewerFactory.timeStamp)) { - toReturn = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a").format(endTx.getTimeStamp()); - } else if (cCol.equals(HistoryXViewerFactory.author)) { - toReturn = UserManager.getSafeUserNameById(endTx.getAuthor()); - } else if (cCol.equals(HistoryXViewerFactory.comment)) { - toReturn = endTx.getComment(); } else { toReturn = "unhandled column"; } @@ -95,8 +90,11 @@ public class XHistoryLabelProvider extends XViewerLabelProvider { return ""; } Change data = (Change) element; - if (xCol.equals(HistoryXViewerFactory.timeStamp)) { - return TransactionManager.getTransaction(data.getTxDelta().getEndTx()).getTimeStamp(); + if (xCol.getId().equals(HistoryTransactionDateColumn.ID)) { + Date date = + ((HistoryXViewerFactory) ((HistoryXViewer) xCol.getXViewer()).getXViewerFactory()).getHistoryTransactionDateColumn().getTransactionDate( + data.getTxDelta().getEndTx().getId()); + return date; } return super.getBackingData(element, xCol, columnIndex); } @@ -127,21 +125,23 @@ public class XHistoryLabelProvider extends XViewerLabelProvider { @Override public Image getColumnImage(Object element, XViewerColumn xCol, int columnIndex) { + Image result = null; try { - if (!(element instanceof Change)) { - return null; - } - Change change = (Change) element; - if (xCol.equals(HistoryXViewerFactory.transaction)) { - return ImageManager.getImage(FrameworkImage.DB_ICON_BLUE); - } else if (xCol.equals(HistoryXViewerFactory.itemType)) { - return ArtifactImageManager.getChangeTypeImage(change); + if (element instanceof Change) { + if (xCol.getId().equals(HistoryTransactionIdColumn.ID)) { + if (transactionImage == null) { + transactionImage = ImageManager.getImage(FrameworkImage.DB_ICON_BLUE); + } + result = transactionImage; + } else if (xCol.equals(HistoryXViewerFactory.itemType)) { + result = objectToImage.get(element); + objectToImage.put(element, result); + } } - } catch (Exception ex) { // do nothing } - return null; + return result; } @Override @@ -149,7 +149,7 @@ public class XHistoryLabelProvider extends XViewerLabelProvider { if (historyXViewer.isSortByTransaction()) { Change change = (Change) element; long transactionId = change.getTxDelta().getEndTx().getId(); - if (historyXViewer.getXHisotryViewer().isShaded(transactionId)) { + if (historyXViewer.getXHistoryViewer().isShaded(transactionId)) { return getLightGreyColor(); } } @@ -163,4 +163,11 @@ public class XHistoryLabelProvider extends XViewerLabelProvider { return lightGreyColor; } + public void calculateImages(Collection<Change> changes) { + for (Change change : changes) { + Image result = ArtifactImageManager.getChangeTypeImage(change); + objectToImage.put(change, result); + } + } + } 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 d8caf9fe3ba..9e813598cbd 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 @@ -28,6 +28,7 @@ import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.model.Branch; +import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.AHTML; import org.eclipse.osee.framework.jdk.core.util.Conditions; @@ -39,6 +40,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.skynet.core.revision.ChangeManager; +import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.plugin.PluginUiImage; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.internal.Activator; @@ -289,7 +291,9 @@ public class XHistoryWidget extends GenericXWidget { } if (Widgets.isAccessible(xHistoryViewer.getControl())) { calculateShading(changes); - xHistoryViewer.setInput(changes); + calculateTransactions(changes); + ((XHistoryLabelProvider) getXViewer().getLabelProvider()).calculateImages(changes); + xHistoryViewer.setInputXViewer(changes); } } else { if (Widgets.isAccessible(extraInfoLabel)) { @@ -308,6 +312,16 @@ public class XHistoryWidget extends GenericXWidget { Jobs.startJob(job); } + public void calculateTransactions(Collection<Change> changes) { + Set<Long> ids = new HashSet<>(); + for (Change change : changes) { + ids.add(change.getTxDelta().getEndTx().getId()); + } + for (TransactionRecord transaction : TransactionManager.getTransactions(ids)) { + xHistoryViewer.put(transaction.getId(), transaction); + } + } + private void calculateShading(Collection<Change> changes) { shadedTransactions.clear(); try { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/AbstractTransactionColumn.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/AbstractTransactionColumn.java new file mode 100644 index 00000000000..40ad451803b --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/AbstractTransactionColumn.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.ui.skynet.widgets.xHistory.column; + +import org.eclipse.nebula.widgets.xviewer.IXViewerPreComputedColumn; +import org.eclipse.nebula.widgets.xviewer.core.model.SortDataType; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerAlign; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerColumn; +import org.eclipse.osee.framework.core.model.TransactionRecord; +import org.eclipse.osee.framework.skynet.core.change.Change; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.IHistoryTransactionProvider; + +/** + * @author Donald G. Dunne + */ +public abstract class AbstractTransactionColumn extends XViewerColumn implements IXViewerPreComputedColumn { + + protected final IHistoryTransactionProvider txCache; + + public AbstractTransactionColumn(IHistoryTransactionProvider txCache, String id, String name, int width, XViewerAlign align, boolean show, SortDataType sortDataType, boolean multiColumnEditable, String description) { + super(id, name, width, align, show, sortDataType, multiColumnEditable, description); + this.txCache = txCache; + } + + protected TransactionRecord getTransactionRecord(Change data) { + return txCache.getTransactionRecord(data.getTxDelta().getEndTx().getId()); + } + + @Override + public Long getKey(Object obj) { + if (obj instanceof Change) { + Change data = (Change) obj; + return data.getTxDelta().getEndTx().getId(); + } + return 0L; + } + + @Override + public String getText(Object obj, Long key, String cachedValue) { + return cachedValue; + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionAuthorColumn.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionAuthorColumn.java new file mode 100644 index 00000000000..4e23ef4903a --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionAuthorColumn.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * 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.ui.skynet.widgets.xHistory.column; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.nebula.widgets.xviewer.core.model.SortDataType; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerAlign; +import org.eclipse.osee.framework.core.model.TransactionRecord; +import org.eclipse.osee.framework.skynet.core.UserManager; +import org.eclipse.osee.framework.skynet.core.change.Change; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.IHistoryTransactionProvider; + +/** + * @author Donald G. Dunne + */ +public class HistoryTransactionAuthorColumn extends AbstractTransactionColumn { + + // Cache to quickly get author so don't need to load from UserManager + private final Map<Long, String> transIdToAuthor = new HashMap<Long, String>(); + + public HistoryTransactionAuthorColumn(IHistoryTransactionProvider txCache) { + super(txCache, "framework.history.author", "Author", 100, XViewerAlign.Left, true, SortDataType.String, false, + null); + } + + /** + * XViewer uses copies of column definitions so originals that are registered are not corrupted. Classes extending + * XViewerValueColumn MUST extend this constructor so the correct sub-class is created + */ + @Override + public HistoryTransactionAuthorColumn copy() { + HistoryTransactionAuthorColumn newXCol = new HistoryTransactionAuthorColumn(txCache); + super.copy(this, newXCol); + return newXCol; + } + + @Override + public void populateCachedValues(Collection<?> objects, Map<Long, String> preComputedValueMap) { + for (Object obj : objects) { + if (obj instanceof Change) { + Change data = (Change) obj; + TransactionRecord endTx = getTransactionRecord(data); + String value = transIdToAuthor.get(endTx.getId()); + if (value == null) { + value = UserManager.getSafeUserNameById(endTx.getAuthor()); + transIdToAuthor.put(endTx.getId(), value); + } + preComputedValueMap.put(data.getTxDelta().getEndTx().getId(), value); + } + } + // don't need anymore + transIdToAuthor.clear(); + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionCommentColumn.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionCommentColumn.java new file mode 100644 index 00000000000..30b6d234c78 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionCommentColumn.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.ui.skynet.widgets.xHistory.column; + +import java.util.Collection; +import java.util.Map; +import org.eclipse.nebula.widgets.xviewer.core.model.SortDataType; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerAlign; +import org.eclipse.osee.framework.core.model.TransactionRecord; +import org.eclipse.osee.framework.skynet.core.change.Change; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.IHistoryTransactionProvider; + +/** + * @author Donald G. Dunne + */ +public class HistoryTransactionCommentColumn extends AbstractTransactionColumn { + + public HistoryTransactionCommentColumn(IHistoryTransactionProvider txCache) { + super(txCache, "framework.history.comment", "Comment", 300, XViewerAlign.Left, true, SortDataType.String, false, + null); + } + + /** + * XViewer uses copies of column definitions so originals that are registered are not corrupted. Classes extending + * XViewerValueColumn MUST extend this constructor so the correct sub-class is created + */ + @Override + public HistoryTransactionCommentColumn copy() { + HistoryTransactionCommentColumn newXCol = new HistoryTransactionCommentColumn(txCache); + super.copy(this, newXCol); + return newXCol; + } + + @Override + public void populateCachedValues(Collection<?> objects, Map<Long, String> preComputedValueMap) { + for (Object obj : objects) { + if (obj instanceof Change) { + Change data = (Change) obj; + TransactionRecord endTx = getTransactionRecord(data); + String value = endTx.getComment(); + preComputedValueMap.put(data.getTxDelta().getEndTx().getId(), value); + } + } + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionDateColumn.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionDateColumn.java new file mode 100644 index 00000000000..efbdfdbda74 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionDateColumn.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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.ui.skynet.widgets.xHistory.column; + +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.nebula.widgets.xviewer.core.model.SortDataType; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerAlign; +import org.eclipse.osee.framework.core.model.TransactionRecord; +import org.eclipse.osee.framework.skynet.core.change.Change; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.IHistoryTransactionProvider; + +/** + * @author Donald G. Dunne + */ +public class HistoryTransactionDateColumn extends AbstractTransactionColumn { + + public static final String ID = "framework.history.timeStamp"; + // Cache to quickly get author so don't need to load from UserManager + private final Map<Long, String> transIdToDateStr = new HashMap<Long, String>(); + private final Map<Long, Date> transIdToDate = new HashMap<Long, Date>(); + + public HistoryTransactionDateColumn(IHistoryTransactionProvider txCache) { + super(txCache, ID, "Time Stamp", 110, XViewerAlign.Left, true, SortDataType.Date, false, null); + } + + /** + * XViewer uses copies of column definitions so originals that are registered are not corrupted. Classes extending + * XViewerValueColumn MUST extend this constructor so the correct sub-class is created + */ + @Override + public HistoryTransactionDateColumn copy() { + HistoryTransactionDateColumn newXCol = new HistoryTransactionDateColumn(txCache); + super.copy(this, newXCol); + return newXCol; + } + + @Override + public void populateCachedValues(Collection<?> objects, Map<Long, String> preComputedValueMap) { + for (Object obj : objects) { + if (obj instanceof Change) { + Change data = (Change) obj; + TransactionRecord endTx = getTransactionRecord(data); + String value = transIdToDateStr.get(endTx.getId()); + if (value == null) { + Date timeStamp = endTx.getTimeStamp(); + value = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a").format(timeStamp); + transIdToDateStr.put(endTx.getId(), value); + transIdToDate.put(endTx.getId(), timeStamp); + } + preComputedValueMap.put(data.getTxDelta().getEndTx().getId(), value); + } + } + } + + public Date getTransactionDate(Long id) { + return transIdToDate.get(id); + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionIdColumn.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionIdColumn.java new file mode 100644 index 00000000000..74591eb10fd --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/column/HistoryTransactionIdColumn.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.ui.skynet.widgets.xHistory.column; + +import java.util.Collection; +import java.util.Map; +import org.eclipse.nebula.widgets.xviewer.core.model.SortDataType; +import org.eclipse.nebula.widgets.xviewer.core.model.XViewerAlign; +import org.eclipse.osee.framework.core.model.TransactionRecord; +import org.eclipse.osee.framework.skynet.core.change.Change; +import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.IHistoryTransactionProvider; + +/** + * @author Donald G. Dunne + */ +public class HistoryTransactionIdColumn extends AbstractTransactionColumn { + + public static final String ID = "framework.history.transaction"; + + public HistoryTransactionIdColumn(IHistoryTransactionProvider txCache) { + super(txCache, ID, "Transaction", 90, XViewerAlign.Left, true, SortDataType.Integer, false, null); + } + + /** + * XViewer uses copies of column definitions so originals that are registered are not corrupted. Classes extending + * XViewerValueColumn MUST extend this constructor so the correct sub-class is created + */ + @Override + public HistoryTransactionIdColumn copy() { + HistoryTransactionIdColumn newXCol = new HistoryTransactionIdColumn(txCache); + super.copy(this, newXCol); + return newXCol; + } + + @Override + public void populateCachedValues(Collection<?> objects, Map<Long, String> preComputedValueMap) { + for (Object obj : objects) { + if (obj instanceof Change) { + Change data = (Change) obj; + TransactionRecord endTx = getTransactionRecord(data); + preComputedValueMap.put(data.getTxDelta().getEndTx().getId(), String.valueOf(endTx.getId())); + } + } + } + +} |