New Jide License
[indepmod/experimental.git] / IndependentModeler / src / cz / cvut / promod / gui / dialogs / pluginsOverview / notations / NotationOverviewTabModel.java
blobd1c46666d11847988ed06538e90ece062daa0626
1 package cz.cvut.promod.gui.dialogs.pluginsOverview.notations;
3 import cz.cvut.promod.services.ModelerSession;
4 import cz.cvut.promod.services.pluginLoaderService.utils.NotationSpecificPlugins;
5 import cz.cvut.promod.plugin.notationSpecificPlugIn.module.Module;
7 import javax.swing.event.ListDataListener;
8 import javax.swing.*;
9 import java.util.List;
10 import java.util.LinkedList;
12 /**
13 * ProMod, master thesis project
14 * User: Petr Zverina, petr.zverina@gmail.com
15 * Date: 18:00:07, 11.2.2010
17 * A Module component of NotationOverviewTab.
19 public class NotationOverviewTabModel implements ListModel {
21 private final List<NotationLabelWrapper> notationsList;
24 public NotationOverviewTabModel() {
25 notationsList = new LinkedList<NotationLabelWrapper>();
27 initList();
30 private void initList(){
31 for(final String identifier : ModelerSession.getNotationService().getNotationsIdentifiers()){
32 final NotationSpecificPlugins specificPlugins = ModelerSession.getNotationService().getNotationSpecificPlugins(identifier);
33 final List<ModuleListModel.ModuleLabelWrapper> modulesList = new LinkedList<ModuleListModel.ModuleLabelWrapper>();
34 for(final Module module : specificPlugins.getModules()){
35 modulesList.add(new ModuleListModel.ModuleLabelWrapper(module.getIdentifier(), module.getName()));
38 notationsList.add(new NotationLabelWrapper(
39 specificPlugins.getNotation().getIdentifier(), specificPlugins.getNotation().getFullName(), new ModuleListModel(modulesList)
40 ));
44 public int getSize() {
45 return notationsList.size();
48 public Object getElementAt(int index) {
49 return notationsList.get(index);
52 public void addListDataListener(ListDataListener l) {
56 public void removeListDataListener(ListDataListener l) {
60 /**
61 * Represents a list in list of notations.
63 protected static class NotationLabelWrapper {
65 private final String identifier;
66 private final String displayName;
68 private final ModuleListModel moduleListModel;
70 private NotationLabelWrapper(final String identifier,
71 final String displayName,
72 final ModuleListModel moduleListModel) {
74 this.identifier = identifier;
75 this.displayName = displayName;
76 this.moduleListModel = moduleListModel;
79 public String getIdentifier() {
80 return identifier;
83 @Override
84 public String toString() {
85 return displayName;
88 public ModuleListModel getModuleListModel() {
89 return moduleListModel;