Skip to content

#24098 done. Auto zoom mode added in SelectionListDialog. #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public class SelectionListDialog extends ToggleDialog {
private final ShowHistoryAction actShowHistory = new ShowHistoryAction();
private final ZoomToJOSMSelectionAction actZoomToJOSMSelection = new ZoomToJOSMSelectionAction();
private final ZoomToListSelection actZoomToListSelection = new ZoomToListSelection();
private boolean autoZoomMode = false;

/** the popup menu and its handler */
private final ListPopupMenu popupMenu;
Expand Down Expand Up @@ -164,6 +165,7 @@ public SelectionListDialog() {
popupMenuHandler = setupPopupMenuHandler();

lstPrimitives.addListSelectionListener(e -> {
if (autoZoomMode) { actZoomToListSelection.actionPerformed(null); }
actZoomToListSelection.valueChanged(e);
popupMenuHandler.setPrimitives(model.getSelected());
});
Expand Down Expand Up @@ -234,6 +236,7 @@ public void mouseExited(MouseEvent me) {

private PopupMenuHandler setupPopupMenuHandler() {
PopupMenuHandler handler = new PopupMenuHandler(popupMenu);
handler.addAction(new AutoZoomSwitchAction());
handler.addAction(actZoomToJOSMSelection);
handler.addAction(actZoomToListSelection);
handler.addSeparator();
Expand Down Expand Up @@ -464,6 +467,21 @@ public void valueChanged(ListSelectionEvent e) {
}
}

/** Turns on/off auto zoom mode */
class AutoZoomSwitchAction extends AbstractAction {
AutoZoomSwitchAction() {
putValue(NAME, tr("Autozoom on/off"));
putValue(SHORT_DESCRIPTION, tr("Autozoom on/off!"));
new ImageProvider("dialogs", "search").getResource().attachImageIcon(this, true);
setEnabled(true);
}

@Override
public void actionPerformed(ActionEvent e) {
autoZoomMode = !autoZoomMode;
}
}

/**
* The list model for the list of OSM primitives in the current JOSM selection.
* <p>
Expand Down