Changeset 20724 in osm


Ignore:
Timestamp:
2010-03-28T22:07:43+02:00 (15 years ago)
Author:
guggis
Message:

Fixed drag-n-drop on empty relation member table
Few minor updates/fixes

Location:
applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions
Files:
2 added
6 edited

Legend:

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

    r20556 r20724  
    1313import org.openstreetmap.josm.tools.CheckParameterUtil;
    1414
     15/**
     16 * TurnRestrictionBuilder creates a turn restriction and initializes it with
     17 * objects from a selection of OSM primitives, i.e. the current selection
     18 * in a {@see OsmDataLayer}.
     19 *
     20 */
    1521public class TurnRestrictionBuilder {
    1622
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/dnd/PrimitiveIdListTransferHandler.java

    r20527 r20724  
    1111
    1212/**
    13  * PrimitiveIdListTransferHandler is a transfer handler for component which
     13 * PrimitiveIdListTransferHandler is a transfer handler for components which
    1414 * provide and/or accept a list of {@see PrimitiveId} via copy/paste or
    1515 * drag-and-drop.
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/RelationMemberColumnModel.java

    r20675 r20724  
    77import javax.swing.table.TableColumn;
    88
    9 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
    109import org.openstreetmap.josm.tools.CheckParameterUtil;
    1110
     
    2322                 col.setPreferredWidth(100);   
    2423                 col.setCellEditor(new MemberRoleCellEditor());
     24                 col.setCellRenderer(new RelationMemberRoleCellRenderer());
    2525                 addColumn(col);
    2626                 
     
    3030              col.setResizable(true);
    3131              col.setPreferredWidth(300);
    32               col.setCellRenderer(new OsmPrimitivRenderer());
     32              col.setCellRenderer(new RelationMemberTargetCellRenderer());
    3333              addColumn(col);         
    3434        }
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/RelationMemberEditorModel.java

    r20675 r20724  
    327327         */
    328328        protected void removedSelectedMembers() {
    329                 int j = 0;
    330                 for(int i=0; i < getRowCount();i++){
     329                for(int i=getRowCount()-1; i >= 0;i--){
    331330                        if (rowSelectionModel.isSelectedIndex(i)) {
    332                                 members.remove(i - j);
    333                                 j++;
     331                                members.remove(i);
    334332                        }
    335333                }
     
    448446
    449447        public int getRowCount() {
    450                 return members.size();
     448                if (members.size() > 0) return members.size();
     449               
     450                // we display an empty row if the model is empty because otherwise
     451                // we can't drag/drop into the empty table.
     452                // FIXME: use JTable.setFillsViewportHeight(boolean) after the migration
     453                // to Java 6.
     454                return 1;
    451455        }
    452456
    453457        public Object getValueAt(int rowIndex, int columnIndex) {
     458                if (members.size() == 0 && rowIndex == 0){
     459                        // we display an empty row if the model is empty because otherwise
     460                        // we can't drag/drop into the empty table.
     461                        // FIXME: use JTable.setFillsViewportHeight(boolean) after the migration
     462                        // to Java 6.
     463                        return null;
     464                }
    454465                switch(columnIndex){
    455466                case 0: return members.get(rowIndex).getRole();
     
    461472        @Override
    462473        public boolean isCellEditable(int rowIndex, int columnIndex) {
     474                // we display an empty row if the model is empty because otherwise
     475                // we can't drag/drop into the empty table. This row isn't editable
     476                // FIXME: use JTable.setFillsViewportHeight(boolean) after the migration
     477                // to Java 6.
     478                if (members.size() == 0 && rowIndex == 0) return false;
     479               
     480                // otherwise only the column with the member roles is editable
    463481                return columnIndex == 0;
    464482        }
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModel.java

    r20606 r20724  
    242242                                tm.setValue(value);
    243243                        } else {
    244                                 tagEditorModel.add(new TagModel("restriction", value.trim().toLowerCase()));
     244                                tagEditorModel.prepend(new TagModel("restriction", value.trim().toLowerCase()));
    245245                        }
    246246                }
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesModel.java

    r20622 r20724  
    184184                OsmPrimitive from = fromLegs.iterator().next();
    185185                OsmPrimitive to = toLegs.iterator().next();
     186               
    186187                if (! (from instanceof Way)) return;
    187188                if (! (to instanceof Way)) return;
    188                 if (from.equals(to)){
     189                if (from.equals(to) && ! "no_u_turn".equals(editorModel.getRestrictionTagValue())){
     190                        // identical from and to allowed for "no_u_turn" only
     191                        //
    189192                        issues.add(new IdenticalTurnRestrictionLegsError(this, from));
    190193                }               
Note: See TracChangeset for help on using the changeset viewer.