Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2012-03-23 14:00:44 -0400
committerRoberto E. Escobar2012-03-23 14:00:44 -0400
commitf77467ac5a12823dc31eb7c0f4ff872b82e6c73d (patch)
tree983f578aa3ac2c9b10165ea810f1b0650882f2b6
parent1094954cb6184d55c2817e028064d5a36ca8bb6a (diff)
downloadorg.eclipse.osee-f77467ac5a12823dc31eb7c0f4ff872b82e6c73d.tar.gz
org.eclipse.osee-f77467ac5a12823dc31eb7c0f4ff872b82e6c73d.tar.xz
org.eclipse.osee-f77467ac5a12823dc31eb7c0f4ff872b82e6c73d.zip
feature[ats_H6RWE]: Improve VersionListDialog to filter released versions unless selected to show
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/VersionListDialog.java91
1 files changed, 78 insertions, 13 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/VersionListDialog.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/VersionListDialog.java
index 020d9725a9..2e32e10004 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/VersionListDialog.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/VersionListDialog.java
@@ -11,11 +11,23 @@
package org.eclipse.osee.ats.util.widgets.dialog;
import java.util.Collection;
+import java.util.LinkedList;
+import java.util.logging.Level;
import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.ats.core.version.VersionArtifact;
+import org.eclipse.osee.ats.internal.Activator;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.skynet.util.ArtifactNameReverseSorter;
+import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBox;
import org.eclipse.osee.framework.ui.swt.Displays;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -24,30 +36,83 @@ import org.eclipse.swt.widgets.Control;
*/
public class VersionListDialog extends org.eclipse.ui.dialogs.ListDialog {
+ XCheckBox showReleased = new XCheckBox("Show Released Versions");
+ VersionContentProvider versionContentProvider;
+ private final Collection<VersionArtifact> verArts;
+
public VersionListDialog(String title, String message, Collection<VersionArtifact> verArts) {
super(Displays.getActiveShell());
+ this.verArts = verArts;
this.setTitle(title);
this.setMessage(message);
- this.setContentProvider(new ArrayContentProvider() {
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof Collection) {
- Collection list = (Collection) inputElement;
- return list.toArray(new Artifact[list.size()]);
- }
- return super.getElements(inputElement);
- }
- });
+ versionContentProvider = new VersionContentProvider(false);
+ this.setContentProvider(versionContentProvider);
setLabelProvider(new VersionArtifactLabelProvider());
setInput(verArts);
}
@Override
protected Control createDialogArea(Composite container) {
- Control c = super.createDialogArea(container);
+ Control control = super.createDialogArea(container);
getTableViewer().setSorter(new ArtifactNameReverseSorter());
- return c;
+
+ if (AtsUtilCore.isAtsAdmin()) {
+ Composite comp = new Composite(control.getParent(), SWT.NONE);
+ comp.setLayout(new GridLayout(2, false));
+ comp.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ showReleased.createWidgets(comp, 2);
+ showReleased.set(false);
+ showReleased.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ versionContentProvider.setShowReleased(!versionContentProvider.getShowReleased());
+ setInput(verArts);
+ getTableViewer().refresh();
+ };
+ });
+ }
+
+ return control;
}
+ public class VersionContentProvider extends ArrayContentProvider {
+
+ boolean showReleased = false;
+
+ public VersionContentProvider(boolean showReleased) {
+ this.showReleased = showReleased;
+ }
+
+ public boolean getShowReleased() {
+ return showReleased;
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ @Override
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof Collection) {
+ Collection list = (Collection) inputElement;
+ Collection<Object> verArts = new LinkedList<Object>();
+ for (Object obj : list.toArray(new Artifact[list.size()])) {
+ if (obj instanceof VersionArtifact) {
+ VersionArtifact verArt = (VersionArtifact) obj;
+ try {
+ if (showReleased || (!showReleased && !verArt.isReleased())) {
+ verArts.add(verArt);
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ }
+ return verArts.toArray(new Artifact[verArts.size()]);
+ }
+ return super.getElements(inputElement);
+ }
+
+ public void setShowReleased(boolean showReleased) {
+ this.showReleased = showReleased;
+ }
+ }
}

Back to the top