@Override public CustomizeData getDefaultTableCustomizeData() { CustomizeData customizeData = super.getDefaultTableCustomizeData(); for (XViewerColumn xCol : customizeData.getColumnData().getColumns()) { if (xCol.getId().equals(SprintOrderColumn.getInstance().getId())) { xCol.setSortForward(true); } } customizeData.getSortingData().setSortingNames(SprintOrderColumn.getInstance().getId()); return customizeData; }
/* * @see org.eclipse.swt.dnd.DragSourceAdapter#dragSetData(org.eclipse.swt.dnd.DragSourceEvent) */ @Override public void dragSetData(DragSourceEvent event) { if (TextTransfer.getInstance().isSupportedType(event.dataType)) { List<XViewerColumn> selCols = getVisibleTableSelection(); Collection<String> ids = new ArrayList<String>(selCols.size()); for (XViewerColumn xCol : selCols) { ids.add(xCol.getId()); } event.data = CollectionsUtil.toString(ids, null, ", ", null); } }
@SuppressWarnings("unchecked") public void performHiddenTableTextDrop(DropTargetEvent event) { String droppedIds = (String) event.data; List<XViewerColumn> droppedVisibleTableXCols = new ArrayList<XViewerColumn>(); List<XViewerColumn> orderCols = (List<XViewerColumn>) visibleColTable.getViewer().getInput(); for (XViewerColumn xCol : orderCols) { if (droppedIds.contains(xCol.getId())) { droppedVisibleTableXCols.add(xCol); } } moveFromVisibleToHidden(droppedVisibleTableXCols); }
@SuppressWarnings("unchecked") public void performVisibleTableTextDrop(DropTargetEvent event) { Tree tree = visibleColTable.getViewer().getTree(); TreeItem dragOverTreeItem = tree.getItem(visibleColTable.getViewer().getTree().toControl(event.x, event.y)); String droppedIds = (String) event.data; // Determine dragOverXCol, if any XViewerColumn dragOverXCol = null; if (dragOverTreeItem != null) { dragOverXCol = (XViewerColumn) dragOverTreeItem.getData(); // Don't allow dropping on same item as dragging if (droppedIds.contains(dragOverXCol.getId())) { return; } } List<XViewerColumn> droppedXCols = new ArrayList<XViewerColumn>(); List<XViewerColumn> orderCols = (List<XViewerColumn>) visibleColTable.getViewer().getInput(); for (XViewerColumn xCol : orderCols) { if (droppedIds.contains(xCol.getId())) { droppedXCols.add(xCol); } } for (XViewerColumn xCol : (List<XViewerColumn>) hiddenColTable.getViewer().getInput()) { if (droppedIds.contains(xCol.getId())) { droppedXCols.add(xCol); } } orderCols.removeAll(droppedXCols); int dropXColOrderColsIndex = 0; for (XViewerColumn xCol : (List<XViewerColumn>) visibleColTable.getViewer().getInput()) { if (dragOverXCol != null && xCol.getId().equals(dragOverXCol.getId())) { break; } dropXColOrderColsIndex++; } if (isFeedbackAfter) { orderCols.addAll(dropXColOrderColsIndex + 1, droppedXCols); } else { orderCols.addAll(dropXColOrderColsIndex, droppedXCols); } visibleColTable.getViewer().setInput(orderCols); List<XViewerColumn> hiddenCols = (List<XViewerColumn>) hiddenColTable.getViewer().getInput(); hiddenCols.removeAll(droppedXCols); hiddenColTable.getViewer().setInput(hiddenCols); }
@SuppressWarnings("unchecked") private void updateSortTextField() { // get visible column ids List<String> visibleColumnIds = new ArrayList<String>(); for (XViewerColumn xCol : (List<XViewerColumn>) visibleColTable.getViewer().getInput()) { visibleColumnIds.add(xCol.getId()); } // get current sortIds SortingData sortingData = new SortingData(sorterText.getText()); List<String> currentSortIds = sortingData.getSortingIds(); // get complement to determine ids that are sorted but not visible == invalid for (String invalidId : CollectionsUtil.setComplement(currentSortIds, visibleColumnIds)) { sortingData.removeSortingName(invalidId); } if (sorterText != null && !sorterText.isDisposed()) { sorterText.setText(sortingData.getXml()); } }
public SprintXViewerFactory(SprintArtifact soleSprintArtifact) { super("org.eclipse.osee.ats.SprintXViewer"); this.soleSprintArtifact = soleSprintArtifact; List<XViewerAtsAttributeValueColumn> configCols = WorldXViewerUtil.getConfigurationColumns(); List<XViewerColumn> sprintCols = new LinkedList<XViewerColumn>(); // Add default Sprint columns WorldXViewerUtil.addColumn(this, SprintOrderColumn.getInstance(), 45, sprintCols); WorldXViewerUtil.addColumn(this, TitleColumn.getInstance(), 339, sprintCols); WorldXViewerUtil.addColumn(this, StateColumn.getInstance(), 74, sprintCols); WorldXViewerUtil.addColumn(this, PriorityColumn.getInstance(), 20, sprintCols); WorldXViewerUtil.addColumn(this, ChangeTypeColumn.getInstance(), 20, sprintCols); WorldXViewerUtil.addColumn(this, AssigneeColumnUI.getInstance(), 113, sprintCols); XViewerColumn unPlannedWorkColumn = WorldXViewerUtil.getConfigColumn("ats.Unplanned Work", configCols); if (unPlannedWorkColumn != null) { WorldXViewerUtil.addColumn(this, unPlannedWorkColumn, 43, sprintCols); configCols.remove(unPlannedWorkColumn); } WorldXViewerUtil.addColumn(this, TargetedVersionColumn.getInstance(), 50, sprintCols); WorldXViewerUtil.addColumn(this, NotesColumn.getInstance(), 116, sprintCols); WorldXViewerUtil.addColumn(this, AgileFeatureGroupColumn.getInstance(), 91, sprintCols); WorldXViewerUtil.addColumn(this, CreatedDateColumn.getInstance(), 82, sprintCols); WorldXViewerUtil.addColumn(this, new AtsIdColumn(true), 50, sprintCols); // Add remaining columns from world columns for (XViewerColumn worldCol : WorldXViewerFactory.WorldViewColumns) { if (!sprintCols.contains(worldCol)) { XViewerColumn newCol = worldCol.copy(); newCol.setShow(false); registerColumns(newCol); } } WorldXViewerUtil.registerAtsAttributeColumns(this); WorldXViewerUtil.registerPluginColumns(this); WorldXViewerUtil.registerStateColumns(this); // Add remaining Configuration Columns for (XViewerAtsAttributeValueColumn col : configCols) { registerColumns(col); } }
@SuppressWarnings("unchecked") private void updateColumnFilterField() { // get visible column ids List<String> visibleColumnIds = new ArrayList<String>(); for (XViewerColumn xCol : (List<XViewerColumn>) visibleColTable.getViewer().getInput()) { visibleColumnIds.add(xCol.getId()); } // get current columnFilterIds ColumnFilterData columnFilterData = new ColumnFilterData(); columnFilterData.setFromXml(columnFilterText.getText()); Set<String> currentSortIds = columnFilterData.getColIds(); // get complement to determine ids that are sorted but not visible == invalid for (String invalidId : CollectionsUtil.setComplement(currentSortIds, visibleColumnIds)) { columnFilterData.removeFilterText(invalidId); } if (columnFilterText != null && !columnFilterText.isDisposed()) { columnFilterText.setText(columnFilterData.getXml()); } }
@Override public Image getColumnImage(Object element, XViewerColumn xCol, int columnIndex) { if (element instanceof MessageCoverageItem && xCol.equals(CoverageXViewerFactory.Name)) { return ImageManager.getImage(FrameworkImage.X_RED); } if (element instanceof MessageCoverageItem) { return null; } ICoverage coverageItem = (ICoverage) element; if (xCol.equals(CoverageXViewerFactory.Assignees_Col)) { return getCoverageItemUserImage(coverageItem); } if (xCol.equals(CoverageXViewerFactory.Name)) { return ImageManager.getImage(coverageItem.getOseeImage()); } if (xCol.equals(CoverageXViewerFactory.Work_Product_Task)) { if (Strings.isValid(coverageItem.getWorkProductTaskStr())) { return ImageManager.getImage(ServiceProvider.getOseeCmService().getImage(ImageType.Task)); } } return null; }
private void handleCustTableSelectionChanged() { if (getCustTableSelection() == null) { return; } CustomizeData custData = getCustTableSelection(); if (custData == null) { XViewerLog.logAndPopup( Activator.class, Level.SEVERE, new IllegalStateException("Can't obtain selection Xml")); return; } List<XViewerColumn> hideXCols = new ArrayList<XViewerColumn>(); List<XViewerColumn> showXCols = new ArrayList<XViewerColumn>(); for (XViewerColumn xCol : custData.getColumnData().getColumns()) { if (xCol.isShow()) { showXCols.add(xCol); } else { hideXCols.add(xCol); } } hiddenColTable.getViewer().setInput(hideXCols); visibleColTable.getViewer().setInput(showXCols); sorterText.setText(custData.getSortingData().getXml()); sorterText.setData(custData); filterText.setText(custData.getFilterData().getFilterText()); filterText.setData(custData); filterRegExCheckBox.setSelection(custData.getFilterData().isRegularExpression()); columnFilterText.setText(custData.getColumnFilterData().getXml()); columnFilterText.setData(custData); updateSortTextField(); updateColumnFilterField(); }
@Override public int getColumnGradient(Object element, XViewerColumn xCol, int columnIndex) throws Exception { if (element == null) { return 0; } if (element instanceof MessageCoverageItem) { return 0; } ICoverage coverageItem = (ICoverage) element; if (xCol.equals(CoverageXViewerFactory.Coverage_Percent)) { return coverageItem.getCoveragePercent().intValue(); } return 0; }
/** @return xColumns from hidden and visible customization lists */ private List<XViewerColumn> getConfigCustXViewerColumns() { List<XViewerColumn> xCols = new ArrayList<XViewerColumn>(); for (XViewerColumn xCol : getTableXViewerColumns(visibleColTable.getViewer())) { xCol.setShow(true); xCol.setXViewer(xViewerToCustomize); xCols.add(xCol); } for (XViewerColumn xCol : getTableXViewerColumns(hiddenColTable.getViewer())) { xCol.setShow(false); xCol.setXViewer(xViewerToCustomize); xCols.add(xCol); } return xCols; }
@Override public String getColumnText(Object element, XViewerColumn xCol, int columnIndex) throws OseeCoreException { ICoverage coverage = (ICoverage) element; if (xCol.equals(CoverageXViewerFactory.Name)) { return coverage.getName(); } if (element instanceof MessageCoverageItem) { return ""; } if (xCol.equals(CoverageXViewerFactory.Assignees_Col)) { if (element instanceof CoverageUnit) { return Artifacts.toString( "; ", OseeCoverageUnitStore.getAssignees((CoverageUnit) coverage)); } return ""; } if (xCol.equals(CoverageXViewerFactory.Notes_Col)) { return coverage.getNotes(); } if (xCol.equals(CoverageXViewerFactory.Coverage_Percent)) { return coverage.getCoveragePercentStr(); } if (xCol.equals(CoverageXViewerFactory.Location)) { return coverage.getLocation(); } if (xCol.equals(CoverageXViewerFactory.Full_Path)) { return CoverageUtil.getFullPath(coverage); } if (xCol.equals(CoverageXViewerFactory.Namespace)) { return coverage.getNamespace(); } if (xCol.equals(CoverageXViewerFactory.Work_Product_Task)) { return coverage.getWorkProductTaskStr(); } if (xCol.equals(CoverageXViewerFactory.Guid)) { return coverage.getGuid(); } if (xCol.equals(CoverageXViewerFactory.Unit)) { String unit = ""; if (element instanceof CoverageUnit) { unit = coverage.getName(); } else { unit = coverage.getParent().getName(); } return unit; } if (xCol.equals(CoverageXViewerFactory.Lines_Covered)) { if (element instanceof CoverageUnit) { return String.valueOf(((CoverageUnit) coverage).getCoverageItemsCoveredCount(true)); } } if (xCol.equals(CoverageXViewerFactory.Total_Lines)) { if (element instanceof CoverageUnit) { return String.valueOf(((CoverageUnit) coverage).getCoverageItems(true).size()); } } if (coverage instanceof CoverageItem || (coverage instanceof MergeItem && ((MergeItem) coverage).getImportItem() instanceof CoverageItem)) { CoverageItem coverageItem = null; if (coverage instanceof CoverageItem) { coverageItem = (CoverageItem) coverage; } else { coverageItem = (CoverageItem) ((MergeItem) coverage).getImportItem(); } if (xCol.equals(CoverageXViewerFactory.Coverage_Rationale)) { return coverageItem.getRationale(); } if (xCol.equals(CoverageXViewerFactory.Method_Number)) { return coverageItem.getParent().getOrderNumber(); } if (xCol.equals(CoverageXViewerFactory.Execution_Number)) { return coverageItem.getOrderNumber(); } if (xCol.equals(CoverageXViewerFactory.Line_Number)) { return coverageItem.getLineNumber(); } if (xCol.equals(CoverageXViewerFactory.Coverage_Method)) { return coverageItem.getCoverageMethod().getName(); } if (xCol.equals(CoverageXViewerFactory.Parent_Coverage_Unit)) { return coverageItem.getCoverageUnit().getName(); } if (xCol.equals(CoverageXViewerFactory.Coverage_Test_Units)) { Collection<String> testUnits = coverageItem.getTestUnits(); if (testUnits == null) { return ""; } return Collections.toString(", ", testUnits); } return ""; } if (coverage instanceof CoverageUnit || (coverage instanceof MergeItem && ((MergeItem) coverage).getImportItem() instanceof CoverageUnit)) { CoverageUnit coverageUnit = null; if (coverage instanceof CoverageUnit) { coverageUnit = (CoverageUnit) coverage; } else if (coverage instanceof MergeItem) { coverageUnit = (CoverageUnit) ((MergeItem) coverage).getImportItem(); } if (xCol.equals(CoverageXViewerFactory.Parent_Coverage_Unit)) { return coverageUnit.getParentCoverageUnit() == null ? "" : coverageUnit.getParentCoverageUnit().getName(); } if (xCol.equals(CoverageXViewerFactory.Method_Number)) { return coverageUnit.getOrderNumber(); } } if (coverage instanceof CoverageItem) { CoverageItem coverageItem = (CoverageItem) coverage; if (xCol.equals(CoverageXViewerFactory.Parent_Coverage_Unit)) { return coverageItem.getParent() == null ? "" : coverageItem.getParent().getName(); } if (xCol.equals(CoverageXViewerFactory.Method_Number)) { return coverageItem.getParent() == null ? "" : coverageItem.getParent().getOrderNumber(); } if (xCol.equals(CoverageXViewerFactory.Execution_Number)) { return coverageItem.getOrderNumber(); } if (xCol.equals(CoverageXViewerFactory.Coverage_Method)) { return coverageItem.getCoverageMethod().getName(); } } if (coverage instanceof MergeItem && (((MergeItem) coverage).getImportItem() instanceof CoverageItem || ((MergeItem) coverage).getPackageItem() instanceof CoverageItem)) { MergeItem mergeItem = (MergeItem) coverage; ICoverage importItem = mergeItem.getImportItem(); ICoverage packageItem = mergeItem.getPackageItem(); if (xCol.equals(CoverageXViewerFactory.Parent_Coverage_Unit)) { if (importItem != null && importItem.getParent() != null) { return importItem.getParent().getName(); } else if (packageItem != null && packageItem.getParent() != null) { return packageItem.getParent().getName(); } return ""; } if (xCol.equals(CoverageXViewerFactory.Method_Number)) { if (importItem != null && importItem.getParent() != null) { return importItem.getParent().getOrderNumber(); } else if (packageItem != null && packageItem.getParent() != null) { return packageItem.getParent().getOrderNumber(); } return ""; } if (xCol.equals(CoverageXViewerFactory.Execution_Number)) { if (importItem != null) { return importItem.getOrderNumber(); } else if (packageItem != null) { return packageItem.getOrderNumber(); } return ""; } if (xCol.equals(CoverageXViewerFactory.Coverage_Method)) { if (importItem != null) { return ((CoverageItem) importItem).getCoverageMethod().getName(); } else if (packageItem != null) { return ((CoverageItem) packageItem).getCoverageMethod().getName(); } return ""; } } return ""; }