Ignore:
Timestamp:
2014-12-10T21:25:59+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #10826 - Add note sorting options (patch by ToeBee)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/NoteDialog.java

    r7720 r7782  
    3636import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    3737import org.openstreetmap.josm.gui.NoteInputDialog;
     38import org.openstreetmap.josm.gui.NoteSortDialog;
    3839import org.openstreetmap.josm.gui.SideButton;
    3940import org.openstreetmap.josm.gui.layer.Layer;
     
    7576    private final NewAction newAction;
    7677    private final ReopenAction reopenAction;
     78    private final SortAction sortAction;
    7779    private final UploadNotesAction uploadAction;
    7880
     
    9092        newAction = new NewAction();
    9193        reopenAction = new ReopenAction();
     94        sortAction = new SortAction();
    9295        uploadAction = new UploadNotesAction();
    9396        buildDialog();
     
    121124                new SideButton(closeAction, false),
    122125                new SideButton(reopenAction, false),
     126                new SideButton(sortAction, false),
    123127                new SideButton(uploadAction, false)}));
    124128        updateButtonStates();
     
    144148            uploadAction.setEnabled(true);
    145149        }
     150        //enable sort button if any notes are loaded
     151        if (noteData == null || noteData.getNotes().isEmpty()) {
     152            sortAction.setEnabled(false);
     153        } else {
     154            sortAction.setEnabled(true);
     155        }
    146156    }
    147157
     
    161171    @Override
    162172    public void layerAdded(Layer newLayer) {
    163         if (Main.isDebugEnabled()) {
    164             Main.debug("layer added: " + newLayer);
    165         }
    166173        if (newLayer instanceof NoteLayer) {
    167             if (Main.isDebugEnabled()) {
    168                 Main.debug("note layer added");
    169             }
    170174            noteData = ((NoteLayer)newLayer).getNoteData();
    171175            model.setData(noteData.getNotes());
     176            setNoteList(noteData.getNotes());
    172177        }
    173178    }
     
    364369        }
    365370    }
     371
     372    class SortAction extends AbstractAction {
     373
     374        public SortAction() {
     375            putValue(SHORT_DESCRIPTION, tr("Sort notes"));
     376            putValue(NAME, tr("Sort"));
     377            putValue(SMALL_ICON, ImageProvider.get("dialogs", "sort"));
     378        }
     379
     380        @Override
     381        public void actionPerformed(ActionEvent e) {
     382            NoteSortDialog sortDialog = new NoteSortDialog(Main.parent, tr("Sort notes"), tr("Apply"));
     383            sortDialog.showSortDialog(noteData.getCurrentSortMethod());
     384            if (sortDialog.getValue() == 1) {
     385                noteData.setSortMethod(sortDialog.getSelectedComparator());
     386            }
     387        }
     388    }
    366389}
Note: See TracChangeset for help on using the changeset viewer.