Ignore:
Timestamp:
2010-09-01T13:27:48+02:00 (14 years ago)
Author:
rcernoch
Message:

CzechAddress: No more plugin crash when used without a map. THX to Libor Pechacek!

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/CzechAddressPlugin.java

    r19621 r22915  
    5050 *
    5151 * @author Radomír Černoch, radomir.cernoch@gmail.com
     52 * @author Libor Pechacek, lpechacek@gmx.com
    5253 */
    5354public class CzechAddressPlugin extends Plugin implements StatusListener {
     
    150151                reasoner.update(street);
    151152
    152             for (OsmPrimitive prim : Main.main.getCurrentDataSet().allPrimitives()) {
    153                 if (House.isMatchable(prim) || Street.isMatchable(prim))
    154                     reasoner.update(prim);
     153            org.openstreetmap.josm.data.osm.DataSet dataSet = Main.main.getCurrentDataSet();
     154            if (dataSet != null) {
     155                for (OsmPrimitive prim : dataSet.allPrimitives()) {
     156                    if (House.isMatchable(prim) || Street.isMatchable(prim))
     157                        reasoner.update(prim);
     158                }
    155159            }
    156160            reasoner.closeTransaction();
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/PointManipulatorAction.java

    r16750 r22915  
    4343     */
    4444    public void actionPerformed(ActionEvent e) {
    45         Collection<OsmPrimitive> data = Main.main.getCurrentDataSet().getSelected();
     45        org.openstreetmap.josm.data.osm.DataSet dataSet = Main.main.getCurrentDataSet();
     46        if (dataSet == null) return;
     47        Collection<OsmPrimitive> data = dataSet.getSelected();
    4648
    4749        if (data.size() != 1) return;
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.java

    r22813 r22915  
    8787
    8888        BoundingXYVisitor visitor = new BoundingXYVisitor();
    89         for (OsmPrimitive op : Main.main.getCurrentDataSet().allPrimitives()) {
     89        org.openstreetmap.josm.data.osm.DataSet dataSet = Main.main.getCurrentDataSet();
     90        if (dataSet == null) return;
     91
     92        for (OsmPrimitive op : dataSet.allPrimitives()) {
    9093            if (op instanceof Node) {
    9194                ((Node) op).visit(visitor);
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ManagerDialog.form

    r16744 r22915  
    5050                  <Group type="103" groupAlignment="0" attributes="0">
    5151                      <Group type="102" alignment="1" attributes="0">
    52                           <EmptySpace pref="267" max="32767" attributes="0"/>
     52                          <EmptySpace pref="260" max="32767" attributes="0"/>
    5353                          <Component id="renamerButton" min="-2" max="-2" attributes="0"/>
    5454                          <EmptySpace max="-2" attributes="0"/>
    5555                      </Group>
    56                       <Component id="streetScrollPane" alignment="0" pref="426" max="32767" attributes="0"/>
     56                      <Component id="streetScrollPane" alignment="0" pref="422" max="32767" attributes="0"/>
    5757                  </Group>
    5858                </DimensionLayout>
     
    6060                  <Group type="103" groupAlignment="0" attributes="0">
    6161                      <Group type="102" alignment="1" attributes="0">
    62                           <Component id="streetScrollPane" pref="342" max="32767" attributes="0"/>
     62                          <Component id="streetScrollPane" pref="334" max="32767" attributes="0"/>
    6363                          <EmptySpace max="-2" attributes="0"/>
    6464                          <Component id="renamerButton" min="-2" max="-2" attributes="0"/>
     
    114114                <DimensionLayout dim="0">
    115115                  <Group type="103" groupAlignment="0" attributes="0">
    116                       <Component id="jScrollPane1" alignment="0" pref="426" max="32767" attributes="0"/>
     116                      <Component id="jScrollPane1" alignment="0" pref="422" max="32767" attributes="0"/>
    117117                      <Group type="102" alignment="1" attributes="0">
    118                           <EmptySpace pref="363" max="32767" attributes="0"/>
     118                          <EmptySpace pref="352" max="32767" attributes="0"/>
    119119                          <Component id="dbEditButton" min="-2" max="-2" attributes="0"/>
    120120                          <EmptySpace max="-2" attributes="0"/>
     
    125125                  <Group type="103" groupAlignment="0" attributes="0">
    126126                      <Group type="102" alignment="1" attributes="0">
    127                           <Component id="jScrollPane1" pref="342" max="32767" attributes="0"/>
     127                          <Component id="jScrollPane1" pref="334" max="32767" attributes="0"/>
    128128                          <EmptySpace max="-2" attributes="0"/>
    129129                          <Component id="dbEditButton" min="-2" max="-2" attributes="0"/>
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ManagerDialog.java

    r18409 r22915  
    3232 *
    3333 * @author Radomír Černoch radomir.cernoch@gmail.com
     34 * @author Libor Pechacek, lpechacek@gmx.com
    3435 */
    3536public class ManagerDialog extends ExtendedDialog {
     
    4647        dbEditButton.setIcon(ImageProvider.get("actions", "edit.png"));
    4748
    48         Capitalizator cap = new Capitalizator(
    49                                 Main.main.getCurrentDataSet().allPrimitives(),
    50                                 CzechAddressPlugin.getLocation().getStreets());
    51 
    52         for (Street capStreet : cap.getCapitalised()) {
    53             assert cap.translate(capStreet).get("name") != null : capStreet;
    54 
    55             String elemName = capStreet.getName();
    56             String primName = cap.translate(capStreet).get("name");
    57 
    58             if (!elemName.equals(primName)) {
    59                 streetModel.elems.add(capStreet);
    60                 streetModel.names.add(primName);
     49        org.openstreetmap.josm.data.osm.DataSet dataSet = Main.main.getCurrentDataSet();
     50        if (dataSet != null) {
     51            Capitalizator cap = new Capitalizator(dataSet.allPrimitives(),
     52                                    CzechAddressPlugin.getLocation().getStreets());
     53
     54            for (Street capStreet : cap.getCapitalised()) {
     55                assert cap.translate(capStreet).get("name") != null : capStreet;
     56
     57                String elemName = capStreet.getName();
     58                String primName = cap.translate(capStreet).get("name");
     59
     60                if (!elemName.equals(primName)) {
     61                    streetModel.elems.add(capStreet);
     62                    streetModel.names.add(primName);
     63                }
    6164            }
    6265        }
Note: See TracChangeset for help on using the changeset viewer.