Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-03-11 16:04:27 +0000
committerRyan D. Brooks2014-03-11 16:04:27 +0000
commitd0ac0728e2c9e0aa6a8292d6881c2f24668727bd (patch)
tree24a5233d19e56dae9694fd272761a7d0125576d4
parent67c31ec85ed63db7c1589c30fffbfaca3e8ee475 (diff)
downloadorg.eclipse.osee-d0ac0728e2c9e0aa6a8292d6881c2f24668727bd.tar.gz
org.eclipse.osee-d0ac0728e2c9e0aa6a8292d6881c2f24668727bd.tar.xz
org.eclipse.osee-d0ac0728e2c9e0aa6a8292d6881c2f24668727bd.zip
feature[ats_ATS25926]: Add attribute exists to advanced search
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeExistsSearch.java48
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java38
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AttributeExistsFilter.java52
3 files changed, 135 insertions, 3 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeExistsSearch.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeExistsSearch.java
new file mode 100644
index 00000000000..28c9d106d92
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/AttributeExistsSearch.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.skynet.core.artifact.search;
+
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
+
+/**
+ * @author John Misinco
+ */
+public class AttributeExistsSearch implements ISearchPrimitive {
+ private final IAttributeType attributeType;
+
+ public AttributeExistsSearch(IAttributeType attributeType) {
+ Conditions.checkNotNull(attributeType, "attributeType");
+ this.attributeType = attributeType;
+ }
+
+ @Override
+ public String toString() {
+ return "Attribute type: \"" + attributeType + "\"";
+ }
+
+ @Override
+ public String getStorageString() {
+ return attributeType.getGuid().toString();
+ }
+
+ public static AttributeExistsSearch getPrimitive(String storageString) {
+ IAttributeType type = TokenFactory.createAttributeType(Long.valueOf(storageString), "SearchAttrType");
+ return new AttributeExistsSearch(type);
+ }
+
+ @Override
+ public void addToQuery(QueryBuilderArtifact builder) {
+ builder.andExists(attributeType);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java
index 2af6622c6e8..1bcdebbc43f 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/ArtifactSearchPage.java
@@ -273,13 +273,44 @@ public class ArtifactSearchPage extends DialogPage implements ISearchPage, IRepl
new Label(attributeControls, SWT.NONE); // spacerLabelSoTheNextOneWillBeInColumnTwo
- Label wildLabel = new Label(attributeControls, SWT.NONE);
- wildLabel.setText("(* = any string, \\* = literal *)");
-
ATTRIBUTE_VALUE_FILTER = new AttributeValueFilter(attributeControls, attributeTypeList, attributeValue);
addToSearchTypeList(ATTRIBUTE_VALUE_FILTER);
}
+ private void createAttributeExistsControls(Composite optionsComposite) {
+ Composite attributeControls = new Composite(optionsComposite, SWT.NONE);
+ attributeControls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ attributeControls.setLayout(new GridLayout(2, false));
+
+ Label typeLabel = new Label(attributeControls, SWT.HORIZONTAL);
+ typeLabel.setText("Attribute Type:");
+
+ final ComboViewer attributeTypeList = new ComboViewer(attributeControls, SWT.DROP_DOWN | SWT.READ_ONLY);
+ attributeTypeList.setContentProvider(new SearchContentProvider());
+ attributeTypeList.setLabelProvider(new SearchLabelProvider());
+ attributeTypeList.setSorter(new SearchSorter());
+
+ try {
+ for (IAttributeType type : AttributeTypeManager.getValidAttributeTypes(getSelectedBranch())) {
+ attributeTypeList.add(type);
+ attributeTypeList.setData(type.getName(), type);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP,
+ "Error encountered while getting list of attribute types", ex);
+ }
+ attributeTypeList.getCombo().setVisibleItemCount(Math.min(attributeTypeList.getCombo().getItemCount(), 15));
+ attributeTypeList.getCombo().select(lastAttributeTypeListSelected);
+ attributeTypeList.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ lastAttributeTypeListSelected = attributeTypeList.getCombo().getSelectionIndex();
+ }
+ });
+
+ addToSearchTypeList(new AttributeExistsFilter(attributeControls, attributeTypeList));
+ }
+
private void addFilterControls(Composite mainComposite) {
Group filterGroup = new Group(mainComposite, SWT.NONE);
filterGroup.setText("Create a Filter");
@@ -303,6 +334,7 @@ public class ArtifactSearchPage extends DialogPage implements ISearchPage, IRepl
optionsComposite.setLayout(selectionLayout);
createAttributeSearchControls(optionsComposite);
+ createAttributeExistsControls(optionsComposite);
createArtifactTypeSearchControls(optionsComposite);
createRelationSearchControls(optionsComposite);
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AttributeExistsFilter.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AttributeExistsFilter.java
new file mode 100644
index 00000000000..bc472031dcf
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AttributeExistsFilter.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.search;
+
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeExistsSearch;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ISearchPrimitive;
+import org.eclipse.osee.framework.ui.skynet.search.filter.FilterTableViewer;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author John Misinco
+ */
+public class AttributeExistsFilter extends SearchFilter {
+ private final ComboViewer attributeTypeList;
+
+ public AttributeExistsFilter(Control optionsControl, ComboViewer attributeTypeList) {
+ super("Attribute Exists", optionsControl);
+ this.attributeTypeList = attributeTypeList;
+ }
+
+ @Override
+ public void addFilterTo(FilterTableViewer filterViewer) {
+ String typeName = attributeTypeList.getCombo().getText();
+
+ IAttributeType attributeType = (IAttributeType) attributeTypeList.getData(typeName);
+ ISearchPrimitive primitive = new AttributeExistsSearch(attributeType);
+ filterViewer.addItem(primitive, getFilterName(), typeName, Strings.EMPTY_STRING);
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ @Override
+ public void loadFromStorageString(FilterTableViewer filterViewer, String type, String value, String storageString, boolean isNotEnabled) {
+ ISearchPrimitive primitive = AttributeExistsSearch.getPrimitive(storageString);
+ filterViewer.addItem(primitive, getFilterName(), type, value);
+ }
+
+}

Back to the top