Skip to content

Commit

Permalink
Merge remote-tracking branch 'don-vip/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnonthgol committed Jan 31, 2014
2 parents 167eb51 + 50b440c commit 20e107e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
29 changes: 19 additions & 10 deletions src/org/openstreetmap/josm/plugins/todo/TodoDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public class TodoDialog extends ToggleDialog implements PropertyChangeListener {
private JList lstPrimitives;
private final TodoPopup popupMenu;
private AddAction actAdd;
private PassAction actPass;
private MarkAction actMark;
private MarkSelectedAction actMarkSelected;
private Shortcut sctPass;
private Shortcut sctMark;

/**
* Builds the content panel for this dialog
Expand All @@ -61,20 +65,18 @@ protected void buildContentPanel() {

// the add button
final SideButton addButton = new SideButton(actAdd = new AddAction(model));
actAdd.updateEnabledState();
actAdd.updateEnabledState();

// the pass button
PassAction actPass;
final SideButton passButton = new SideButton(actPass = new PassAction(model));
lstPrimitives.getSelectionModel().addListSelectionListener(actPass);
Main.registerActionShortcut(actPass, Shortcut.registerShortcut("subwindow:todo:pass",
Main.registerActionShortcut(actPass, sctPass = Shortcut.registerShortcut("subwindow:todo:pass",
tr("Pass over element without marking it"), KeyEvent.VK_OPEN_BRACKET, Shortcut.DIRECT));

// the mark button
MarkAction actMark;
final SideButton markButton = new SideButton(actMark = new MarkAction(model));
lstPrimitives.getSelectionModel().addListSelectionListener(actMark);
Main.registerActionShortcut(actMark, Shortcut.registerShortcut("subwindow:todo:mark",
Main.registerActionShortcut(actMark, sctMark = Shortcut.registerShortcut("subwindow:todo:mark",
tr("Mark element done"), KeyEvent.VK_CLOSE_BRACKET, Shortcut.DIRECT));

createLayout(lstPrimitives, true, Arrays.asList(new SideButton[] {
Expand All @@ -91,22 +93,22 @@ public TodoDialog() {

lstPrimitives.addMouseListener(new DblClickHandler());
lstPrimitives.addMouseListener(new TodoPopupLauncher());
this.toggleAction.addPropertyChangeListener(this);
toggleAction.addPropertyChangeListener(this);

popupMenu = new TodoPopup(lstPrimitives);
}

protected static void selectAndZoom(OsmPrimitive object) {
if (object == null) return;
if (Main.map == null || Main.map.mapView == null || Main.map.mapView.getEditLayer() == null) return;
Main.map.mapView.getEditLayer().data.setSelected(object);
if (Main.main.getEditLayer() == null) return;
Main.main.getEditLayer().data.setSelected(object);
AutoScaleAction.autoScale("selection");
}

protected static void selectAndZoom(Collection<OsmPrimitive> object) {
if (object == null) return;
if (Main.map == null || Main.map.mapView == null || Main.map.mapView.getEditLayer() == null) return;
Main.map.mapView.getEditLayer().data.setSelected(object);
if (Main.main.getEditLayer() == null) return;
Main.main.getEditLayer().data.setSelected(object);
AutoScaleAction.autoScale("selection");
}

Expand Down Expand Up @@ -401,4 +403,11 @@ public TodoPopup(JList list) {
public void propertyChange(PropertyChangeEvent arg0) {
actAdd.updateEnabledState();
}

@Override
public void destroy() {
super.destroy();
Main.unregisterActionShortcut(actPass, sctPass);
Main.unregisterActionShortcut(actMark, sctMark);
}
}
7 changes: 4 additions & 3 deletions src/org/openstreetmap/josm/plugins/todo/TodoPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ public TodoPlugin(PluginInformation info) {

@Override
public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
if(newFrame != null && newFrame.mapView != null) {
if (todoDialog == null)
todoDialog = new TodoDialog();
if (newFrame != null && newFrame.mapView != null) {
todoDialog = new TodoDialog();
newFrame.addToggleDialog(todoDialog);
} else if (newFrame == null) {
todoDialog = null;
}
}
}

0 comments on commit 20e107e

Please sign in to comment.