diff options
author | rbrooks | 2007-12-08 08:27:23 +0000 |
---|---|---|
committer | rbrooks | 2007-12-08 08:27:23 +0000 |
commit | b9ebde7ed4628188c7a390826dc4e05c2315b3e1 (patch) | |
tree | 754cecea0bbc60f366816c5729fc64559cce86c4 /org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/AttributeContentProvider.java | |
parent | 508ebd486ac6b455da319993de8a6cf26fe0c19e (diff) | |
download | org.eclipse.osee-b9ebde7ed4628188c7a390826dc4e05c2315b3e1.tar.gz org.eclipse.osee-b9ebde7ed4628188c7a390826dc4e05c2315b3e1.tar.xz org.eclipse.osee-b9ebde7ed4628188c7a390826dc4e05c2315b3e1.zip |
Diffstat (limited to 'org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/AttributeContentProvider.java')
-rw-r--r-- | org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/AttributeContentProvider.java | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/AttributeContentProvider.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/AttributeContentProvider.java new file mode 100644 index 00000000000..521ced7bce0 --- /dev/null +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/AttributeContentProvider.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 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; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.attribute.Attribute; +import org.eclipse.osee.framework.skynet.core.attribute.DynamicAttributeManager; +import org.eclipse.osee.framework.ui.skynet.util.OSEELog; + +/** + * @author Ryan D. Brooks + */ +public class AttributeContentProvider implements IStructuredContentProvider { + + private Collection<String> ignoreAttributes; + private Collection<DynamicAttributeManager> attributeTypes; + private Object[] dummyArray = new Object[0]; + + /** + * + */ + public AttributeContentProvider(Collection<String> ignoreAttributes) { + super(); + this.ignoreAttributes = ignoreAttributes; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object inputElement) { + + if (inputElement instanceof Artifact) { + + Artifact artifact = (Artifact) inputElement; + + ArrayList<Attribute> elements = new ArrayList<Attribute>(); + try { + Collection<DynamicAttributeManager> types = populateAttributeTypes(artifact); + for (DynamicAttributeManager type : types) { + for (Attribute attribute : type.getAttributes()) { + elements.add(attribute); + } + } + return elements.toArray(); + } catch (SQLException ex) { + OSEELog.logException(SkynetGuiPlugin.class, ex, true); + } + } + return dummyArray; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + } + + public Collection<DynamicAttributeManager> populateAttributeTypes(Artifact artifact) throws SQLException { + Collection<DynamicAttributeManager> attrTypes = null; + if (ignoreAttributes == null) + attrTypes = artifact.getAttributes(); + else { + attrTypes = new ArrayList<DynamicAttributeManager>(); + for (DynamicAttributeManager udat : artifact.getAttributes()) + if (!ignoreAttributes.contains(udat.getDescriptor().getName())) attrTypes.add(udat); + } + return attrTypes; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + + } + + /** + * @return Returns the attributeTypes. + */ + public Collection<DynamicAttributeManager> getAttributeTypes() { + return attributeTypes; + } +} |