1 package org.simantics.scl.ui.modulebrowser;
3 import org.eclipse.jface.viewers.ITreeContentProvider;
4 import org.eclipse.jface.viewers.Viewer;
5 import org.simantics.scl.compiler.module.repository.ModuleRepository;
7 public class SCLModuleTreeContentProvider implements ITreeContentProvider {
8 private ModuleRepository repository;
9 private final ModuleNameTreeEntry rootEntry = new ModuleNameTreeEntry(null, "", "");
11 public void update() {
12 rootEntry.clearModuleFlags();
13 if(repository != null) {
14 for(String moduleName : repository.getSourceRepository().getModuleNames()) {
15 rootEntry.addModule(moduleName);
22 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
23 this.repository = (ModuleRepository)newInput;
28 public Object[] getElements(Object inputElement) {
29 return rootEntry.children();
33 public Object[] getChildren(Object parentElement) {
34 ModuleNameTreeEntry entry = (ModuleNameTreeEntry)parentElement;
35 return entry.children();
39 public Object getParent(Object element) {
40 ModuleNameTreeEntry entry = (ModuleNameTreeEntry)element;
45 public boolean hasChildren(Object element) {
46 ModuleNameTreeEntry entry = (ModuleNameTreeEntry)element;
47 return !entry.childMap.isEmpty();
51 public void dispose() {