summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2012-06-28 16:56:12 (EDT)
committer Roberto E. Escobar2012-06-28 16:56:12 (EDT)
commit4ae001566ddb6e00cb66851c495012db7ed807d1 (patch)
tree5ae28a5fe643a37122e994278b594a24fd6c4c97
parent25073e175a543429ce734ecd85a7cc52d18d0506 (diff)
downloadorg.eclipse.osee-4ae001566ddb6e00cb66851c495012db7ed807d1.zip
org.eclipse.osee-4ae001566ddb6e00cb66851c495012db7ed807d1.tar.gz
org.eclipse.osee-4ae001566ddb6e00cb66851c495012db7ed807d1.tar.bz2
feature[ats_7JQVG]: Widget changes for cross branch reference editing
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/CollectionsTest.java17
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java23
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/AttributeTypeToXWidgetName.java6
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java1
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java6
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidgetWithSave.java90
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewWithSave.java102
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewer.java57
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java44
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java6
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/FrameworkXWidgetProvider.java25
11 files changed, 333 insertions, 44 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/CollectionsTest.java b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/CollectionsTest.java
index d569d3f..78c9791 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/CollectionsTest.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core.test/src/org/eclipse/osee/framework/jdk/core/util/CollectionsTest.java
@@ -15,7 +15,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.Assert;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.junit.Test;
/**
@@ -105,6 +104,22 @@ public class CollectionsTest {
Assert.assertTrue(complementSet.contains(20));
}
+ @Test
+ public void test_flatten() {
+ Collection<Object> deepList = new ArrayList<Object>();
+ deepList.add("A");
+ deepList.add(Arrays.asList("B", "C"));
+ deepList.add(Arrays.asList("D"));
+ deepList.add(Arrays.asList("E"));
+
+ List<Object> flattened = new ArrayList<Object>();
+ Collections.flatten(deepList, flattened);
+
+ List<Object> expected = Collections.castAll(Object.class, getTestList());
+
+ Assert.assertTrue(expected.equals(flattened));
+ }
+
private List<String> getTestList() {
List<String> newList = new ArrayList<String>();
newList.addAll(Arrays.asList("A", "B", "C", "D", "E"));
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
index 6ccb686..9fa343d 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/Collections.java
@@ -317,4 +317,27 @@ public class Collections {
}
return true;
}
+
+ /**
+ * Iterates over a collectionInput, pulls out individual elements or instances of Collection, and puts them into a
+ * flattenedOutput list.
+ * <p>
+ * Example: <br/>
+ * Collection<String> input = [[A], B, C, [D , E, [F]]]; <br/>
+ * List<String> output = [A, B, C, D, E, F];
+ * </p>
+ *
+ * @param collectionInput
+ * @param modList
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> void flatten(Collection<T> input, List<T> flattenedOutput) {
+ for (T item : input) {
+ if (item instanceof Collection<?>) {
+ flatten((Collection<T>) item, flattenedOutput);
+ } else {
+ flattenedOutput.add(item);
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/AttributeTypeToXWidgetName.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/AttributeTypeToXWidgetName.java
index 79f3d27..1a3136c 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/AttributeTypeToXWidgetName.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/AttributeTypeToXWidgetName.java
@@ -14,9 +14,11 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.skynet.core.attribute.ArtifactReferenceAttribute;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
import org.eclipse.osee.framework.skynet.core.attribute.BinaryAttribute;
import org.eclipse.osee.framework.skynet.core.attribute.BooleanAttribute;
+import org.eclipse.osee.framework.skynet.core.attribute.BranchReferenceAttribute;
import org.eclipse.osee.framework.skynet.core.attribute.DateAttribute;
import org.eclipse.osee.framework.skynet.core.attribute.EnumeratedAttribute;
import org.eclipse.osee.framework.skynet.core.attribute.FloatingPointAttribute;
@@ -60,6 +62,10 @@ public class AttributeTypeToXWidgetName {
xWidgetName = "XFloatDam";
} else if (AttributeTypeManager.isBaseTypeCompatible(BinaryAttribute.class, attributeType)) {
xWidgetName = "XLabelDam";
+ } else if (AttributeTypeManager.isBaseTypeCompatible(BranchReferenceAttribute.class, attributeType)) {
+ xWidgetName = "XBranchSelectWidget";
+ } else if (AttributeTypeManager.isBaseTypeCompatible(ArtifactReferenceAttribute.class, attributeType)) {
+ xWidgetName = "XListDropViewWithSave";
} else if (AttributeTypeManager.isBaseTypeCompatible(StringAttribute.class, attributeType)) {
if (maxOccurrence == 1) {
xWidgetName = "XTextDam";
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java
index a18a7e4..6b53ef0 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java
@@ -87,7 +87,6 @@ public class ArtifactEditor extends AbstractEventArtifactEditor {
@Override
public void showBusy(boolean busy) {
- super.showBusy(busy);
ArtifactFormPage page = getFormPage();
if (page != null) {
page.showBusy(busy);
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java
index 173d73b..99b1adb 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java
@@ -36,7 +36,7 @@ import org.eclipse.swt.widgets.Listener;
public class XBranchSelectWidget extends GenericXWidget implements Listener {
public static final String WIDGET_ID = XBranchSelectWidget.class.getSimpleName();
- private BranchSelectComposite selectComposite;
+ protected BranchSelectComposite selectComposite;
private Composite composite;
private IOseeBranch defaultBranch;
@@ -141,7 +141,7 @@ public class XBranchSelectWidget extends GenericXWidget implements Listener {
Displays.ensureInDisplayThread(new Runnable() {
@Override
public void run() {
- if (Strings.isValid(toolTip) != false) {
+ if (Strings.isValid(toolTip)) {
XBranchSelectWidget.super.setToolTip(toolTip);
if (selectComposite != null && selectComposite.isDisposed() != true) {
selectComposite.setToolTipText(toolTip);
@@ -158,6 +158,7 @@ public class XBranchSelectWidget extends GenericXWidget implements Listener {
public void handleEvent(Event event) {
super.validate();
notifyListeners(event);
+ notifyXModifiedListeners();
}
public void addListener(Listener listener) {
@@ -184,5 +185,4 @@ public class XBranchSelectWidget extends GenericXWidget implements Listener {
public BranchSelectComposite getSelectComposite() {
return selectComposite;
}
-
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidgetWithSave.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidgetWithSave.java
new file mode 100644
index 0000000..eafc970
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidgetWithSave.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Result;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+
+public class XBranchSelectWidgetWithSave extends XBranchSelectWidget implements IAttributeWidget {
+
+ private Artifact artifact;
+ private IAttributeType attributeType;
+
+ public XBranchSelectWidgetWithSave(String label) {
+ super(label);
+ addXModifiedListener(new DirtyListener());
+ }
+
+ public List<IOseeBranch> getStored() throws OseeCoreException {
+ return artifact.getAttributeValues(attributeType);
+ }
+
+ @Override
+ public Artifact getArtifact() {
+ return artifact;
+ }
+
+ @Override
+ public void saveToArtifact() throws OseeCoreException {
+ artifact.setAttributeFromValues(attributeType, Arrays.asList(getSelection()));
+ }
+
+ @Override
+ public void revert() throws OseeCoreException {
+ setAttributeType(getArtifact(), getAttributeType());
+ }
+
+ @Override
+ public Result isDirty() {
+ if (isEditable()) {
+ try {
+ Collection<IOseeBranch> storedValues = getStored();
+ Collection<IOseeBranch> widgetInput = Arrays.asList(getSelection());
+ if (!Collections.isEqual(widgetInput, storedValues)) {
+ return new Result(true, getAttributeType() + " is dirty");
+ }
+ } catch (OseeCoreException ex) {
+ // Do nothing
+ }
+ }
+ return Result.FalseResult;
+ }
+
+ @Override
+ public void setAttributeType(Artifact artifact, IAttributeType attributeTypeName) throws OseeCoreException {
+ this.artifact = artifact;
+ this.attributeType = attributeTypeName;
+ List<IOseeBranch> storedBranchReference = getStored();
+ if (!storedBranchReference.isEmpty()) {
+ setSelection(storedBranchReference.get(0));
+ }
+ }
+
+ @Override
+ public IAttributeType getAttributeType() {
+ return attributeType;
+ }
+
+ private class DirtyListener implements XModifiedListener {
+ @Override
+ public void widgetModified(XWidget widget) {
+ isDirty();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewWithSave.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewWithSave.java
new file mode 100644
index 0000000..d31d753
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewWithSave.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Result;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+
+/**
+ * XListDropViewer with save artifacts/state
+ */
+public class XListDropViewWithSave extends XListDropViewer implements IAttributeWidget {
+
+ private Artifact artifact;
+ private IAttributeType attributeType;
+
+ public XListDropViewWithSave(String displayLabel) {
+ super(displayLabel);
+ addXModifiedListener(dirtyListener);
+ singleItemMode = true;
+ }
+
+ public List<Artifact> getStored() throws OseeCoreException {
+ return artifact.getAttributeValues(attributeType);
+ }
+
+ @Override
+ public Artifact getArtifact() {
+ return artifact;
+ }
+
+ @Override
+ public void setAttributeType(Artifact artifact, IAttributeType attributeTypeName) throws OseeCoreException {
+ this.artifact = artifact;
+ this.attributeType = attributeTypeName;
+ List<Artifact> storedArtifacts = getStored();
+ if (!storedArtifacts.isEmpty()) {
+ setSelected(storedArtifacts);
+ setInput(storedArtifacts);
+ }
+ }
+
+ @Override
+ public void saveToArtifact() throws OseeCoreException {
+ List<Artifact> artifacts = getArtifacts();
+ Collection<Artifact> saveItems = null;
+ if (!artifacts.isEmpty()) {
+ saveItems = Arrays.asList(artifacts.get(0));
+ } else {
+ saveItems = java.util.Collections.emptyList();
+ }
+ artifact.setAttributeFromValues(CoreAttributeTypes.ArtifactReference, saveItems);
+ }
+
+ @Override
+ public void revert() throws OseeCoreException {
+ setAttributeType(getArtifact(), getAttributeType());
+ }
+
+ @Override
+ public IAttributeType getAttributeType() {
+ return attributeType;
+ }
+
+ @Override
+ public Result isDirty() {
+ if (isEditable()) {
+ try {
+ List<Artifact> enteredValues = new ArrayList<Artifact>();
+ Collections.flatten(getArtifacts(), enteredValues);
+ Collection<Artifact> storedValues = getStored();
+ if (!Collections.isEqual(enteredValues, storedValues)) {
+ return new Result(true, getAttributeType() + " is dirty");
+ }
+ } catch (OseeCoreException ex) {
+ // Do nothing
+ }
+ }
+ return Result.FalseResult;
+ }
+ private final XModifiedListener dirtyListener = new XModifiedListener() {
+ @Override
+ public void widgetModified(XWidget widget) {
+ isDirty();
+ }
+ };
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewer.java
index e87f8a6..ac819c2 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListDropViewer.java
@@ -13,12 +13,15 @@ package org.eclipse.osee.framework.ui.skynet.widgets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.operation.ClientLogger;
import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.skynet.ArtifactLabelProvider;
import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer;
@@ -49,6 +52,8 @@ public class XListDropViewer extends XListViewer implements IXWidgetInputAddable
private Menu popupMenu;
+ protected boolean singleItemMode;
+
public XListDropViewer(String displayLabel) {
super(displayLabel);
this.myArrayContentProvider = new ArrayContentProvider();
@@ -71,7 +76,7 @@ public class XListDropViewer extends XListViewer implements IXWidgetInputAddable
private void createRemoveFromMenuItem(final Menu popupMenu) {
removeFromMenuItem = new MenuItem(popupMenu, SWT.PUSH);
- removeFromMenuItem.setText("Remove From This Blam's Parameters ");
+ removeFromMenuItem.setText("Remove");
removeFromMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
@@ -79,15 +84,20 @@ public class XListDropViewer extends XListViewer implements IXWidgetInputAddable
IStructuredSelection structuredSelection = (IStructuredSelection) myTableViewer.getSelection();
Iterator<?> iterator = structuredSelection.iterator();
- Object orginalInput = getInput();
- Collection<Object> modList = getCollectionInput();
+ Collection<Object> items = getCollectionInput();
+ if (items != null && !items.isEmpty()) {
+ List<Object> modList = new ArrayList<Object>();
- while (iterator.hasNext()) {
- modList.remove(iterator.next());
- }
+ while (iterator.hasNext()) {
+ modList.remove(iterator.next());
+ }
- myArrayContentProvider.inputChanged(myTableViewer, orginalInput, modList);
- refresh();
+ Object orginalInput = getInput();
+ myArrayContentProvider.inputChanged(myTableViewer, orginalInput, modList);
+ setInput(modList);
+ notifyXModifiedListeners();
+ refresh();
+ }
}
});
@@ -107,8 +117,8 @@ public class XListDropViewer extends XListViewer implements IXWidgetInputAddable
TextTransfer transfer = TextTransfer.getInstance();
String data = (String) cb.getContents(transfer);
Branch branch = BranchSelectionDialog.getBranchFromUser();
- Operations.executeAsJob(new StringGuidsToArtifactListOperation(new ClientLogger(
- Activator.class), data, branch, XListDropViewer.this), true);
+ Operations.executeAsJob(new StringGuidsToArtifactListOperation(new ClientLogger(Activator.class),
+ data, branch, XListDropViewer.this), true);
} finally {
cb.dispose();
}
@@ -119,16 +129,24 @@ public class XListDropViewer extends XListViewer implements IXWidgetInputAddable
});
}
+ public List<Artifact> getArtifacts() {
+ return Collections.castAll(getData());
+ }
+
+ public List<Artifact> getSelectedArtifacts() {
+ List<Object> selectedArtifacts = new ArrayList<Object>();
+ Collections.flatten(getSelected(), selectedArtifacts);
+ return Collections.castAll(Artifact.class, selectedArtifacts);
+ }
+
/**
* Adds artifacts to the viewer's input.
*/
public void addToInput(Artifact... artifacts) {
- ArrayList<Object> objects = new ArrayList<Object>();
-
+ List<Object> objects = new ArrayList<Object>();
for (Artifact artifact : artifacts) {
objects.add(artifact);
}
-
addToInput(objects);
}
@@ -150,12 +168,14 @@ public class XListDropViewer extends XListViewer implements IXWidgetInputAddable
}
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getData() {
- return getInput();
+ public Collection<Object> getData() {
+ return (Collection<Object>) getInput();
}
private class XDragAndDrop extends SkynetDragAndDrop {
+
public XDragAndDrop() {
super(null, getControl(), "viewId");
}
@@ -175,6 +195,13 @@ public class XListDropViewer extends XListViewer implements IXWidgetInputAddable
@Override
public void performArtifactDrop(Artifact[] dropArtifacts) {
addToInput(dropArtifacts);
+ if (XListDropViewer.this.singleItemMode && dropArtifacts.length > 1) {
+ setMessage(XListDropViewer.class.getSimpleName(), String.format("Only 1 [%s] can be present", getLabel()),
+ IMessageProvider.ERROR);
+ }
+ setSelected(dropArtifacts);
+ notifyXModifiedListeners();
+ refresh();
}
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java
index 42f0c53..c952069 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.ui.skynet.widgets;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import org.eclipse.core.runtime.IStatus;
@@ -72,6 +73,8 @@ public class XListViewer extends GenericXWidget {
private int widthHint;
private int heightHint;
+ private StructuredSelection preselected;
+
public XListViewer(String displayLabel) {
super(displayLabel);
}
@@ -103,14 +106,16 @@ public class XListViewer extends GenericXWidget {
this.sorter = sorter;
}
- public void setInput(Collection<Object> input) {
- this.input = input;
- if (listViewer != null) {
- listViewer.setInput(input);
- }
+ public void setInputArtifacts(Collection<? extends Artifact> arts) {
+ setInput(arts);
}
public void setInput(Object input) {
+ setInput(Arrays.asList(input));
+ }
+
+ public void setInput(Collection<Object> input) {
+ this.input = input;
if (listViewer != null) {
listViewer.setInput(input);
}
@@ -124,12 +129,6 @@ public class XListViewer extends GenericXWidget {
return input;
}
- public void setInputArtifacts(Collection<? extends Artifact> arts) {
- ArrayList<Object> objs = new ArrayList<Object>();
- objs.addAll(arts);
- setInput(objs);
- }
-
public void addSelectionChangedListener(ISelectionChangedListener listener) {
listViewer.addSelectionChangedListener(listener);
}
@@ -192,6 +191,7 @@ public class XListViewer extends GenericXWidget {
handleSelection();
}
});
+
GridData gd = new GridData(GridData.FILL_BOTH);
gd.verticalSpan = 10;
if (grabHorizontal) {
@@ -210,6 +210,10 @@ public class XListViewer extends GenericXWidget {
if (defaultSelectedObject != null) {
setSelected(defaultSelectedObject);
}
+ if (preselected != null) {
+ setSelected(preselected);
+ }
+
updateListWidget();
}
@@ -258,8 +262,10 @@ public class XListViewer extends GenericXWidget {
}
protected void updateListWidget() {
- listViewer.refresh();
- validate();
+ if (listViewer != null) {
+ listViewer.refresh();
+ validate();
+ }
}
public void add(Object object) {
@@ -280,16 +286,20 @@ public class XListViewer extends GenericXWidget {
}
public void setSelected(ArrayList<Object> selected) {
- setSelected(new StructuredSelection(selected.toArray(new Object[selected.size()])));
+ preselected = new StructuredSelection(selected.toArray(new Object[selected.size()]));
+ setSelected(preselected);
}
public void setSelected(Object selected) {
- setSelected(new StructuredSelection(selected));
+ preselected = new StructuredSelection(selected);
+ setSelected(preselected);
}
private void setSelected(StructuredSelection selection) {
- listViewer.setSelection(selection);
- updateListWidget();
+ if (listViewer != null) {
+ listViewer.setSelection(selection);
+ updateListWidget();
+ }
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java
index bdd205e..53e08dd 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/DefaultAttributeXWidgetProvider.java
@@ -17,7 +17,9 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.skynet.core.attribute.ArtifactReferenceAttribute;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
+import org.eclipse.osee.framework.skynet.core.attribute.BranchReferenceAttribute;
import org.eclipse.osee.framework.skynet.core.attribute.WordAttribute;
import org.eclipse.osee.framework.skynet.core.utility.AttributeTypeToXWidgetName;
import org.eclipse.osee.framework.ui.skynet.widgets.XOption;
@@ -57,6 +59,10 @@ public class DefaultAttributeXWidgetProvider implements IAttributeXWidgetProvide
if (useMultiLineWidget(attributeType)) {
xWidgetName = "XStackedDam";
defaultData.getXOptionHandler().add(XOption.NOT_EDITABLE);
+ } else if (AttributeTypeManager.isBaseTypeCompatible(BranchReferenceAttribute.class, attributeType)) {
+ xWidgetName = "XBranchSelectWidgetWithSave";
+ } else if (AttributeTypeManager.isBaseTypeCompatible(ArtifactReferenceAttribute.class, attributeType)) {
+ xWidgetName = "XListDropViewerWithSave";
}
} catch (OseeCoreException ex) {
xWidgetName = "XTextDam";
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/FrameworkXWidgetProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/FrameworkXWidgetProvider.java
index 9449b4b..b651926 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/FrameworkXWidgetProvider.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/util/FrameworkXWidgetProvider.java
@@ -42,6 +42,7 @@ import org.eclipse.osee.framework.ui.skynet.widgets.XArtifactTypeMultiChoiceSele
import org.eclipse.osee.framework.ui.skynet.widgets.XAttributeTypeComboViewer;
import org.eclipse.osee.framework.ui.skynet.widgets.XAttributeTypeMultiChoiceSelect;
import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget;
+import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidgetWithSave;
import org.eclipse.osee.framework.ui.skynet.widgets.XButton;
import org.eclipse.osee.framework.ui.skynet.widgets.XButtonPush;
import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBox;
@@ -64,6 +65,7 @@ import org.eclipse.osee.framework.ui.skynet.widgets.XLabel;
import org.eclipse.osee.framework.ui.skynet.widgets.XLabelDam;
import org.eclipse.osee.framework.ui.skynet.widgets.XList;
import org.eclipse.osee.framework.ui.skynet.widgets.XListDam;
+import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewWithSave;
import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewer;
import org.eclipse.osee.framework.ui.skynet.widgets.XMembersCombo;
import org.eclipse.osee.framework.ui.skynet.widgets.XMembersList;
@@ -251,11 +253,9 @@ public final class FrameworkXWidgetProvider {
xWidget = combo;
if (Strings.isValid(xWidgetLayoutData.getDefaultValue())) {
String value = xWidgetLayoutData.getDefaultValue();
- if (value == null) {
- combo.set("");
- } else if (value.equals("true") || value.equals("yes")) {
+ if ("true".equals(value) || "yes".equals(value)) {
combo.set("yes");
- } else if (value.equals("false") || value.equals("no")) {
+ } else if ("false".equals(value) || "no".equals(value)) {
combo.set("no");
} else {
combo.set("");
@@ -307,7 +307,11 @@ public final class FrameworkXWidgetProvider {
} else if (xWidgetName.equals("XHyperlabelMemberSelection")) {
xWidget = new XHyperlabelMemberSelection(name);
} else if (xWidgetName.startsWith("XListDropViewer")) {
- xWidget = new XListDropViewer(name);
+ if ("XListDropViewerWithSave".equals(xWidgetName)) {
+ xWidget = new XListDropViewWithSave(name);
+ } else {
+ xWidget = new XListDropViewer(name);
+ }
} else if (xWidgetName.startsWith("XList")) {
String values[] =
xWidgetLayoutData.getDynamicXWidgetLayout().getOptionResolver().getWidgetOptions(xWidgetLayoutData);
@@ -326,8 +330,15 @@ public final class FrameworkXWidgetProvider {
XArtifactList artifactList = new XArtifactList(name);
artifactList.setMultiSelect(xWidgetLayoutData.getXOptionHandler().contains(XOption.MULTI_SELECT));
xWidget = artifactList;
- } else if (xWidgetName.equals(XBranchSelectWidget.WIDGET_ID)) {
- XBranchSelectWidget widget = new XBranchSelectWidget(name);
+ } else if (xWidgetName.startsWith(XBranchSelectWidget.WIDGET_ID)) {
+ XBranchSelectWidget widget = null;
+
+ if (xWidgetName.endsWith("WithSave")) {
+ widget = new XBranchSelectWidgetWithSave(name);
+ } else {
+ widget = new XBranchSelectWidget(name);
+ }
+
widget.setToolTip(xWidgetLayoutData.getToolTip());
try {
String branchGuid = xWidgetLayoutData.getDefaultValue();