private void initPointPresentation() { OverviewCategory overview = view.addOverview(resources.getString("Linguistics.Overview.Border")); final IValueView<Integer> familyView = overview.addIntegerValueView(resources.getString("Linguistics.Overview.Families"), 1); final IValueView<Integer> barbarianView = overview.addIntegerValueView(resources.getString("Linguistics.Overview.Barbarian"), 2); final LabelledAllotmentView totalView = overview.addAlotmentView(resources.getString("Linguistics.Overview.Total"), 2); model.addModelChangeListener( new RemovableEntryListener<Identifier>() { @Override public void entryAdded(Identifier entry) { updateOverview(familyView, totalView, barbarianView); } @Override public void entryAllowed(boolean complete) { // nothing to do; } @Override public void entryRemoved(Identifier entry) { updateOverview(familyView, totalView, barbarianView); } }); model.addCharacterChangedListener( new ChangeListener() { @Override public void changeOccurred() { updateOverview(familyView, totalView, barbarianView); } }); updateOverview(familyView, totalView, barbarianView); }
private void addEntry(final Identifier language) { RelativePath removeIcon = new BasicUi().getRemoveIconPath(); RemovableEntryView entryView = view.addEntryView(removeIcon, getDisplayString(language)); viewsByEntry.put(language, entryView); entryView.addButtonListener( new Command() { @Override public void execute() { model.removeEntry(language); } }); }
@SuppressWarnings("serial") private void initEntryPresentation() { String labelText = resources.getString("Linguistics.SelectionView.Label"); AgnosticUIConfiguration<Object> uiConfiguration = new LanguageUiConfiguration(); final ObjectSelectionViewWithTool<Object> selectionView = view.addSelectionView(labelText, uiConfiguration); selectionView.setObjects(model.getPredefinedLanguages()); selectionView.addObjectSelectionChangedListener( new ObjectValueListener<Object>() { @Override public void valueChanged(Object newValue) { if (newValue == null) { return; } Identifier definedLanguage = getLanguage(newValue); if (definedLanguage == null) { model.selectBarbarianLanguage(newValue.toString()); } else { model.selectLanguage(definedLanguage); } } }); final Tool addButton = selectionView.addTool(); addButton.setIcon(new BasicUi().getAddIconPath()); addButton.setCommand( new Command() { @Override public void execute() { if (!model.isEntryAllowed()) { return; } model.commitSelection(); } }); model.addModelChangeListener( new RemovableEntryListener<Identifier>() { @Override public void entryAdded(Identifier entry) { addEntry(entry); selectionView.setSelectedObject(null); } @Override public void entryAllowed(boolean complete) { selectionView.setSelectedObject(model.getSelectedEntry()); if (complete) { addButton.enable(); } else { addButton.disable(); } } @Override public void entryRemoved(Identifier entry) { RemovableEntryView entryView = viewsByEntry.remove(entry); entryView.delete(); } }); for (Identifier language : model.getPredefinedLanguages()) { languagesByDisplayName.put(getDisplayString(language), language); } for (Identifier language : model.getEntries()) { addEntry(language); } }