Ignore:
Timestamp:
2010-03-22T13:10:48+01:00 (15 years ago)
Author:
guggis
Message:

Added test cases and documentation

Location:
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/RelationMemberEditorModel.java

    r20586 r20606  
    181181         * in whose context this editor is working
    182182         */
    183         public void setVias(List<OsmPrimitive> vias){
     183        public void setVias(List<OsmPrimitive> vias) throws IllegalArgumentException{
    184184                boolean viasDeleted = removeMembersWithRole("via");
    185185                if (vias == null || vias.isEmpty()){
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionComboBoxModel.java

    r20489 r20606  
    4040               
    4141                String tagValue = model.getRestrictionTagValue();
    42                 if (tagValue == null) {
     42                if (tagValue.trim().equals("")) {
    4343                        selectedTagValue = null;
    4444                } else {
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModel.java

    r20586 r20606  
    6868        private  RelationMemberEditorModel memberModel;
    6969        private  IssuesModel issuesModel;
     70        private NavigationControler navigationControler;
    7071       
    7172        /**
     
    7374         *
    7475         * @param layer the layer. Must not be null.
     76         * @param navigationControler control to direct the user to specific UI components. Must not be null
    7577         * @throws IllegalArgumentException thrown if {@code layer} is null
    7678         */
    7779        public TurnRestrictionEditorModel(OsmDataLayer layer, NavigationControler navigationControler) throws IllegalArgumentException{
    7880                CheckParameterUtil.ensureParameterNotNull(layer, "layer");
     81                CheckParameterUtil.ensureParameterNotNull(navigationControler, "navigationControler");
    7982                this.layer = layer;
     83                this.navigationControler = navigationControler;
    8084                memberModel = new RelationMemberEditorModel(layer);
    8185                memberModel.addTableModelListener(new RelationMemberModelListener());
    82                 issuesModel = new IssuesModel(this,navigationControler);
     86                issuesModel = new IssuesModel(this);
    8387                addObserver(issuesModel);
    8488                tagEditorModel.addTableModelListener(new TagEditorModelObserver());
     
    214218        /**
    215219         * Replies the current tag value for the tag <tt>restriction</tt>.
    216          * null, if there isn't a tag <tt>restriction</tt>. 
     220         * The empty tag, if there isn't a tag <tt>restriction</tt>. 
    217221         *
    218222         * @return the tag value
     
    220224        public String getRestrictionTagValue() {
    221225                TagCollection tags = tagEditorModel.getTagCollection();
    222                 if (!tags.hasTagsFor("restriction")) return null;
     226                if (!tags.hasTagsFor("restriction")) return "";
    223227                return tags.getJoinedValues("restriction");
    224228        }
     
    238242                                tm.setValue(value);
    239243                        } else {
    240                                 tagEditorModel.add(new TagModel("restriction", value));
     244                                tagEditorModel.add(new TagModel("restriction", value.trim().toLowerCase()));
    241245                        }
    242246                }
     
    262266         * must be equal to the dataset of this editor model, see {@see #getDataSet()}
    263267         *
     268         * null values in {@see vias} are skipped.
     269         *
    264270         * @param vias the list of vias
    265          * @throws IllegalArgumentException thrown if one of the via objects is null or
    266          * if it belongs to the wrong dataset
    267          */
    268         public void setVias(List<OsmPrimitive> vias) {
     271         * @throws IllegalArgumentException thrown if one of the via objects belongs to the wrong dataset
     272         */
     273        public void setVias(List<OsmPrimitive> vias) throws IllegalArgumentException{
    269274                memberModel.setVias(vias);
    270275        }
     
    320325        public IssuesModel getIssuesModel() {
    321326                return issuesModel;
     327        }
     328       
     329        public NavigationControler getNavigationControler() {
     330                return navigationControler;
    322331        }
    323332       
     
    422431                }               
    423432        }
    424        
     433
     434        /* ----------------------------------------------------------------------------------------- */
     435        /* inner classes                                                                             */
     436        /* ----------------------------------------------------------------------------------------- */
    425437        class TagEditorModelObserver implements TableModelListener {
    426438                public void tableChanged(TableModelEvent e) {
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionSelectionPopupPanel.java

    r20556 r20606  
    354354                public void focusLost(FocusEvent e) {
    355355                        // if we loose the focus to a component outside of the popup panel
    356                         // we hide the popup
    357                         if (!SwingUtilities.isDescendingFrom(e.getOppositeComponent(), TurnRestrictionSelectionPopupPanel.this)) {
     356                        // we hide the popup                   
     357                        if (e.getOppositeComponent() == null ||!SwingUtilities.isDescendingFrom(e.getOppositeComponent(), TurnRestrictionSelectionPopupPanel.this)) {
    358358                                if (parentPopup != null){
    359359                                        parentPopup.hide();
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesModel.java

    r20586 r20606  
    3030public class IssuesModel extends Observable implements Observer{
    3131        private final ArrayList<Issue> issues = new ArrayList<Issue>();
    32         private NavigationControler navigationContoler;
    3332        private TurnRestrictionEditorModel editorModel;
    3433       
     
    4140         *
    4241         * @param editorModel the editor model. Must not be null.
    43          * @param controler the navigation controler. Must not be null.
    4442         * @throws IllegalArgumentException thrown if controler is null
    4543         */
    46         public IssuesModel(TurnRestrictionEditorModel editorModel, NavigationControler controler) throws IllegalArgumentException{
     44        public IssuesModel(TurnRestrictionEditorModel editorModel) throws IllegalArgumentException{
    4745                CheckParameterUtil.ensureParameterNotNull(editorModel, "editorModel");
    48                 CheckParameterUtil.ensureParameterNotNull(controler, "controler");
    49                 this.navigationContoler = controler;
    5046                this.editorModel = editorModel;
    5147                this.editorModel.addObserver(this);
     
    193189       
    194190        public NavigationControler getNavigationControler() {
    195                 return navigationContoler;
     191                return editorModel.getNavigationControler();
    196192        }
    197193       
Note: See TracChangeset for help on using the changeset viewer.