| /******************************************************************************* |
| * Copyright (c) 2004-2008 Istvan Rath and Daniel Varro |
| * 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: |
| * Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.frameworkgui.dialogs; |
| |
| import org.eclipse.jface.viewers.ITreeContentProvider; |
| import org.eclipse.jface.viewers.Viewer; |
| import org.eclipse.viatra2.core.IModelElement; |
| import org.eclipse.viatra2.framework.IFramework; |
| |
| /** |
| * Content provider used in dialogs for displaying a tree of a model space. |
| * @author Istvan Rath |
| * |
| */ |
| public class ModelspaceContentProvider implements ITreeContentProvider { |
| |
| public Object[] getChildren(Object parentElement) { |
| if (parentElement instanceof IModelElement) { |
| return ((IModelElement) parentElement).getElementsInNamespace() |
| .toArray(); |
| } else |
| return null; |
| } |
| |
| public Object getParent(Object element) { |
| if (element instanceof IModelElement) { |
| return ((IModelElement) element).getNamespace(); |
| } |
| return null; |
| } |
| |
| public boolean hasChildren(Object element) { |
| if (element instanceof IModelElement) { |
| return !((IModelElement) element).getElementsInNamespace() |
| .isEmpty(); |
| } |
| return false; |
| } |
| |
| public Object[] getElements(Object inputElement) { |
| if (inputElement instanceof IFramework) { |
| return ((IFramework) inputElement).getTopmodel() |
| .getModelManager().getRoot().getContents().toArray(); |
| } else |
| return null; |
| } |
| |
| public void dispose() { |
| } |
| |
| public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| } |
| |
| } |