| /******************************************************************************* |
| * 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.widgets; |
| |
| import java.util.ArrayList; |
| import java.util.logging.Level; |
| import org.eclipse.jface.viewers.ITreeContentProvider; |
| import org.eclipse.jface.viewers.Viewer; |
| import org.eclipse.osee.framework.logging.OseeLog; |
| import org.eclipse.osee.framework.skynet.core.artifact.Branch; |
| import org.eclipse.osee.framework.skynet.core.attribute.AttributeType; |
| import org.eclipse.osee.framework.skynet.core.attribute.TypeValidityManager; |
| import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; |
| |
| /** |
| * @author Jeff C. Phillips |
| */ |
| public class AttributeContentProvider implements ITreeContentProvider { |
| public Object[] getElements(Object inputElement) { |
| return getChildren(inputElement); |
| } |
| |
| public Object[] getChildren(Object parentElement) { |
| if (parentElement instanceof Branch) { |
| ArrayList<Object> descriptors = new ArrayList<Object>(); |
| |
| try { |
| for (AttributeType descriptor : TypeValidityManager.getValidAttributeTypes((Branch) parentElement)) { |
| descriptors.add((Object) descriptor); |
| } |
| } catch (Exception ex) { |
| OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex); |
| } |
| return descriptors.toArray(); |
| |
| } |
| return null; |
| } |
| |
| public Object getParent(Object element) { |
| return null; |
| } |
| |
| public boolean hasChildren(Object element) { |
| return false; |
| } |
| |
| public void dispose() { |
| } |
| |
| public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| } |
| } |