diff options
author | ddunne | 2008-08-01 23:40:56 +0000 |
---|---|---|
committer | ddunne | 2008-08-01 23:40:56 +0000 |
commit | ac9e9377801fbb28b0324736824968d1739816e4 (patch) | |
tree | 8a50ac3ccea1c93e964b7ac101fee442e9dcbd72 | |
parent | b12031d3772d055018827e45639f52ef561a735e (diff) | |
download | org.eclipse.osee-ac9e9377801fbb28b0324736824968d1739816e4.tar.gz org.eclipse.osee-ac9e9377801fbb28b0324736824968d1739816e4.tar.xz org.eclipse.osee-ac9e9377801fbb28b0324736824968d1739816e4.zip |
5 files changed, 108 insertions, 88 deletions
diff --git a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/GenerateReviewParticipationReport.java b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/GenerateReviewParticipationReport.java index 4519a175564..33a67add696 100644 --- a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/GenerateReviewParticipationReport.java +++ b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/GenerateReviewParticipationReport.java @@ -27,8 +27,6 @@ import org.eclipse.osee.ats.world.search.MyReviewWorkflowItem; import org.eclipse.osee.ats.world.search.MyReviewWorkflowItem.ReviewState; import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.skynet.core.attribute.AttributeType; -import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.eclipse.osee.framework.skynet.core.exception.OseeCoreException; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassArtifactEditor; @@ -39,13 +37,11 @@ import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateItem; import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateItemAction; import org.eclipse.osee.framework.ui.skynet.widgets.xnavigate.XNavigateComposite.TableLoadOption; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewerColumn; -import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.XViewerAttributeSortDataType; +import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.SkynetXViewerFactory; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerArtifactNameColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerArtifactTypeColumn; -import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerAttributeColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerGuidColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerHridColumn; -import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; /** @@ -66,7 +62,7 @@ public class GenerateReviewParticipationReport extends XNavigateItemAction { AWorkbench.popup("ERROR", "Must select user"); return; } - User selectedUser = (User) ld.getSelection(); + User selectedUser = ld.getSelection(); ParticipationReportJob job = new ParticipationReportJob("Review Participation Report - " + selectedUser, selectedUser); job.setUser(true); @@ -84,6 +80,7 @@ public class GenerateReviewParticipationReport extends XNavigateItemAction { this.user = user; } + @Override public IStatus run(IProgressMonitor monitor) { try { MyReviewWorkflowItem srch = new MyReviewWorkflowItem("", user, ReviewState.All); @@ -111,11 +108,7 @@ public class GenerateReviewParticipationReport extends XNavigateItemAction { columns.add(WorldXViewerFactory.Related_To_State_Col); columns.add(new XViewerArtifactNameColumn("Name")); columns.add(new XViewerGuidColumn("Guid")); - for (AttributeType attributeType : AttributeTypeManager.getTypes(AtsPlugin.getAtsBranch())) { - columns.add(new XViewerAttributeColumn("attr." + attributeType.getName(), attributeType.getName(), - attributeType.getName(), 75, SWT.LEFT, false, XViewerAttributeSortDataType.get(attributeType), false, - null)); - } + columns.addAll(SkynetXViewerFactory.getAllAttributeColumns()); return columns; } diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java index 62a9bd6db75..e242f96d745 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java @@ -141,6 +141,7 @@ public class MassArtifactEditor extends AbstractArtifactEditor implements IDirti item.setImage(SkynetGuiPlugin.getInstance().getImage("refresh.gif")); item.setToolTipText("Refresh"); item.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { xViewer.refresh(); } @@ -150,6 +151,7 @@ public class MassArtifactEditor extends AbstractArtifactEditor implements IDirti item.setImage(SkynetGuiPlugin.getInstance().getImage("customize.gif")); item.setToolTipText("Customize Table"); item.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { xViewer.getCustomizeMgr().handleTableCustomization(); } @@ -176,6 +178,7 @@ public class MassArtifactEditor extends AbstractArtifactEditor implements IDirti } + @Override public boolean isSaveOnCloseNeeded() { return isDirty(); } @@ -214,6 +217,7 @@ public class MassArtifactEditor extends AbstractArtifactEditor implements IDirti return false; } + @Override public String toString() { return "MassArtifactEditor"; } @@ -229,7 +233,7 @@ public class MassArtifactEditor extends AbstractArtifactEditor implements IDirti IEditorInput editorInput = getEditorInput(); if (editorInput instanceof MassArtifactEditorInput) { MassArtifactEditorInput aei = (MassArtifactEditorInput) editorInput; - artifacts = ((MassArtifactEditorInput) aei).getArtifacts(); + artifacts = (aei).getArtifacts(); } else throw new IllegalArgumentException("Editor Input not TaskEditorInput"); @@ -263,7 +267,11 @@ public class MassArtifactEditor extends AbstractArtifactEditor implements IDirti SkynetEventManager.getInstance().register(DefaultBranchChangedEvent.class, this); setActivePage(artifactsPageIndex); - xViewer.set(((MassArtifactEditorInput) editorInput).getArtifacts()); + try { + xViewer.set(((MassArtifactEditorInput) editorInput).getArtifacts()); + } catch (Exception ex) { + OSEELog.logException(SkynetGuiPlugin.class, ex, true); + } } public Branch getBranch() { diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java index 393612fd9cf..67d60775264 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java @@ -24,7 +24,6 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactData; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTransfer; import org.eclipse.osee.framework.skynet.core.artifact.BranchPersistenceManager; import org.eclipse.osee.framework.skynet.core.artifact.IATSArtifact; -import org.eclipse.osee.framework.skynet.core.attribute.AttributeType; import org.eclipse.osee.framework.skynet.core.event.LocalTransactionEvent; import org.eclipse.osee.framework.skynet.core.event.RemoteTransactionEvent; import org.eclipse.osee.framework.skynet.core.event.SkynetEventManager; @@ -40,12 +39,11 @@ import org.eclipse.osee.framework.ui.skynet.util.OSEELog; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewer; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewerColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.customize.CustomizeData; -import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.XViewerAttributeSortDataType; +import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.SkynetXViewerFactory; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerArtifactNameColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerGuidColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerHridColumn; import org.eclipse.osee.framework.ui.swt.IDirtiableEditor; -import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DragSource; import org.eclipse.swt.dnd.DragSourceEvent; @@ -68,7 +66,7 @@ public class MassXViewer extends XViewer implements IEventReceiver { private String title; private Collection<? extends Artifact> artifacts; private final IDirtiableEditor editor; - private List<String> EXTRA_COLUMNS = Arrays.asList(new String[] {"GUID", "HRID", "Artifact Type"}); + private final List<String> EXTRA_COLUMNS = Arrays.asList(new String[] {"GUID", "HRID", "Artifact Type"}); /** * @param parent @@ -187,31 +185,38 @@ public class MassXViewer extends XViewer implements IEventReceiver { ArtifactTransfer.getInstance()}); target.addDropListener(new DropTargetAdapter() { + @Override public void drop(DropTargetEvent event) { performDrop(event); } + @Override public void dragOver(DropTargetEvent event) { // if ((event.data instanceof ArtifactData) && ((ArtifactData) // event.data).getArtifacts().length > 0) event.detail = DND.DROP_COPY; } + @Override public void dropAccept(DropTargetEvent event) { } }); } private void performDrop(DropTargetEvent e) { - if (e.data instanceof ArtifactData) { - Artifact[] artsToAdd = ((ArtifactData) e.data).getArtifacts(); - Set<Artifact> arts = new HashSet<Artifact>(); - arts.addAll(artifacts); - for (Artifact art : artsToAdd) - arts.add(art); - set(arts); + try { + if (e.data instanceof ArtifactData) { + Artifact[] artsToAdd = ((ArtifactData) e.data).getArtifacts(); + Set<Artifact> arts = new HashSet<Artifact>(); + arts.addAll(artifacts); + for (Artifact art : artsToAdd) + arts.add(art); + set(arts); + } + refresh(); + } catch (Exception ex) { + OSEELog.logException(SkynetGuiPlugin.class, ex, true); } - refresh(); } public void handleDoubleClick() { @@ -231,6 +236,7 @@ public class MassXViewer extends XViewer implements IEventReceiver { /** * Release resources */ + @Override public void dispose() { SkynetEventManager.getInstance().unRegisterAll(this); SkynetEventManager.getInstance().unRegisterAll(this); @@ -253,18 +259,18 @@ public class MassXViewer extends XViewer implements IEventReceiver { return title; } - public void add(Collection<Artifact> artifacts) { + public void add(Collection<Artifact> artifacts) throws SQLException { resetColumns(artifacts); ((MassContentProvider) getContentProvider()).add(artifacts); } - public void set(Collection<? extends Artifact> artifacts) { + public void set(Collection<? extends Artifact> artifacts) throws SQLException { resetColumns(artifacts); this.artifacts = artifacts; ((MassContentProvider) getContentProvider()).set(artifacts); } - public void resetColumns(Collection<? extends Artifact> artifacts) { + public void resetColumns(Collection<? extends Artifact> artifacts) throws SQLException { CustomizeData custData = new CustomizeData(); List<XViewerColumn> columns = @@ -273,47 +279,18 @@ public class MassXViewer extends XViewer implements IEventReceiver { columns = getDefaultArtifactColumns(this, artifacts); custData.getSortingData().setSortingNames(Arrays.asList(nameCol.getId())); } - for (XViewerColumn col : columns) { - col.setXViewer(this); - } - custData.getColumnData().setColumns(columns); ((MassXViewerFactory) getXViewerFactory()).setDefaultCustData(custData); + ((MassXViewerFactory) getXViewerFactory()).setColumns(columns); getCustomizeMgr().loadCustomization(custData); } private static final XViewerArtifactNameColumn nameCol = new XViewerArtifactNameColumn("Name"); - public static List<XViewerColumn> getDefaultArtifactColumns(XViewer xViewer, Collection<? extends Artifact> artifacts) { - Set<AttributeType> attributeTypes = new HashSet<AttributeType>(); - - try { - for (Artifact art : artifacts) { - attributeTypes.addAll(art.getAttributeTypes()); - } - } catch (SQLException ex) { - OSEELog.logException(SkynetGuiPlugin.class, ex, true); - } - - List<XViewerColumn> columns = new ArrayList<XViewerColumn>(); - Set<String> attrNames = new HashSet<String>(); - // Add Name first - columns.add(nameCol); - attrNames.add("Name"); - - // Add other attributes - for (AttributeType attributeType : attributeTypes) { - if (!attrNames.contains(attributeType.getName())) { - XViewerColumn newCol = - new XViewerColumn("attribute." + attributeType.getName(), attributeType.getName(), 75, SWT.CENTER, - true, XViewerAttributeSortDataType.get(attributeType), true, null); - columns.add(newCol); - attrNames.add(attributeType.getName()); - } - } - + public static List<XViewerColumn> getDefaultArtifactColumns(XViewer xViewer, Collection<? extends Artifact> artifacts) throws SQLException { + List<XViewerColumn> columns = SkynetXViewerFactory.getAllAttributeColumnsForArtifacts(artifacts); columns.add(new XViewerHridColumn("ID")); - columns.add(new XViewerGuidColumn("Guid")); + columns.add(new XViewerGuidColumn("GUID")); return columns; } diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewerFactory.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewerFactory.java index b8828512719..b2708398cb4 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewerFactory.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewerFactory.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.framework.ui.skynet.artifact.massEditor; -import java.util.ArrayList; +import java.util.List; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewer; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewerColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewerSorter; @@ -22,44 +22,38 @@ import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.SkynetXViewer */ public class MassXViewerFactory extends SkynetXViewerFactory { - private CustomizeData custData; private static String NAMESPACE = "org.eclipse.osee.framework.ui.skynet.massEditor.ArtifactXViewer"; + private CustomizeData custData; public MassXViewerFactory() { super(NAMESPACE); } + @Override public XViewerSorter createNewXSorter(XViewer xViewer) { return new XViewerSorter(xViewer); } - public CustomizeData getDefaultTableCustomizeData() { - CustomizeData custData = new CustomizeData(); - ArrayList<XViewerColumn> cols = new ArrayList<XViewerColumn>(); - custData.getColumnData().setColumns(cols); - return custData; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.osee.framework.ui.skynet.widgets.xviewer.IXViewerFactory#getDefaultXViewerColumn() + /* (non-Javadoc) + * @see org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewerFactory#getDefaultTableCustomizeData() */ - public XViewerColumn getDefaultXViewerColumn(String id) { - if (custData != null) for (XViewerColumn xCol : custData.getColumnData().getColumns()) - if (xCol.getName().equals(id)) return xCol; - return null; + @Override + public CustomizeData getDefaultTableCustomizeData() { + if (custData != null) return custData; + return super.getDefaultTableCustomizeData(); } /** * @param custData the custData to set */ - public void setDefaultCustData(CustomizeData custData) { - this.custData = custData; + public void setColumns(List<XViewerColumn> columns) { clearColumnRegistration(); - for (XViewerColumn xCol : custData.getColumnData().getColumns()) { + for (XViewerColumn xCol : columns) { registerColumn(xCol); } } + public void setDefaultCustData(CustomizeData custData) { + this.custData = custData; + } } diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/SkynetXViewerFactory.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/SkynetXViewerFactory.java index 3fd11579635..f806ff47890 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/SkynetXViewerFactory.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/SkynetXViewerFactory.java @@ -10,14 +10,23 @@ *******************************************************************************/ package org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import org.eclipse.osee.framework.db.connection.ConnectionHandler; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.attribute.AttributeType; import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.util.OSEELog; +import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewerColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.XViewerFactory; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.customize.IXViewerCustomizations; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.customize.XViewerCustomizations; +import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerArtifactNameColumn; import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerAttributeColumn; import org.eclipse.swt.SWT; @@ -58,15 +67,54 @@ public class SkynetXViewerFactory extends XViewerFactory { public void registerAllAttributeColumns() { try { - for (AttributeType attributeType : AttributeTypeManager.getTypes()) { - XViewerAttributeColumn newCol = - new XViewerAttributeColumn("attribute." + attributeType.getName(), attributeType.getName(), - attributeType.getName(), 75, SWT.LEFT, false, XViewerAttributeSortDataType.get(attributeType), - false, null); - registerColumn(newCol); - } + registerColumn(getAllAttributeColumns().toArray(new XViewerColumn[AttributeTypeManager.getTypes().size()])); } catch (Exception ex) { OSEELog.logException(SkynetGuiPlugin.class, ex, false); } } + + public static List<XViewerColumn> getAllAttributeColumns() throws SQLException { + List<XViewerColumn> columns = new ArrayList<XViewerColumn>(); + for (AttributeType attributeType : AttributeTypeManager.getTypes()) { + columns.add(getAttributeColumn(attributeType)); + } + return columns; + } + + public static XViewerColumn getAttributeColumn(AttributeType attributeType) { + return new XViewerAttributeColumn("attribute." + attributeType.getName(), attributeType.getName(), + attributeType.getName(), 75, SWT.LEFT, false, XViewerAttributeSortDataType.get(attributeType), false, null); + } + + /** + * Return columns for attributes valid for at least on of the given artifacts + * + * @param artifacts + * @return + * @throws SQLException + */ + public static List<XViewerColumn> getAllAttributeColumnsForArtifacts(Collection<? extends Artifact> artifacts) throws SQLException { + List<XViewerColumn> columns = new ArrayList<XViewerColumn>(); + Set<AttributeType> attributeTypes = new HashSet<AttributeType>(); + try { + for (Artifact art : artifacts) { + attributeTypes.addAll(art.getAttributeTypes()); + } + } catch (SQLException ex) { + OSEELog.logException(SkynetGuiPlugin.class, ex, true); + } + Set<String> attrNames = new HashSet<String>(); + // Add Name first + columns.add(new XViewerArtifactNameColumn("Name")); + attrNames.add("Name"); + // Add all other attributes that are valid for the given artifacts + columns.addAll(SkynetXViewerFactory.getAllAttributeColumns()); + for (AttributeType attributeType : attributeTypes) { + if (!attrNames.contains(attributeType.getName())) { + columns.add(getAttributeColumn(attributeType)); + attrNames.add(attributeType.getName()); + } + } + return columns; + } } |