Ignore:
Timestamp:
2017-08-22T22:26:32+02:00 (20 months ago)
Author:
Don-vip
Message:

see #15182 - deprecate all Main logging methods and introduce suitable replacements in Logging for most of them

Location:
trunk/src/org/openstreetmap/josm/gui/io
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java

    r12452 r12620  
    3434import org.openstreetmap.josm.tools.ExceptionUtil;
    3535import org.openstreetmap.josm.tools.ImageProvider;
     36import org.openstreetmap.josm.tools.Logging;
    3637import org.openstreetmap.josm.tools.Pair;
    3738import org.openstreetmap.josm.tools.date.DateUtils;
     
    298299            }
    299300        }
    300         Main.warn(tr("Error header \"{0}\" did not match with an expected pattern", errorHeader));
     301        Logging.warn(tr("Error header \"{0}\" did not match with an expected pattern", errorHeader));
    301302        handleUploadConflictForUnknownConflict();
    302303    }
     
    313314            handleUploadPreconditionFailedConflict(e, conflict);
    314315        } else {
    315             Main.warn(tr("Error header \"{0}\" did not match with an expected pattern", e.getErrorHeader()));
     316            Logging.warn(tr("Error header \"{0}\" did not match with an expected pattern", e.getErrorHeader()));
    316317            ExceptionDialogUtil.explainPreconditionFailed(e);
    317318        }
  • trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java

    r12452 r12620  
    3939import org.openstreetmap.josm.tools.ImageProvider;
    4040import org.openstreetmap.josm.tools.InputMapUtils;
     41import org.openstreetmap.josm.tools.Logging;
    4142import org.openstreetmap.josm.tools.WindowGeometry;
    4243
     
    113114            setAlwaysOnTop(true);
    114115        } catch (SecurityException e) {
    115             Main.warn(e, tr("Failed to put Credential Dialog always on top. Caught security exception."));
     116            Logging.log(Logging.LEVEL_WARN, tr("Failed to put Credential Dialog always on top. Caught security exception."), e);
    116117        }
    117118        build();
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java

    r11100 r12620  
    1919import java.util.zip.ZipFile;
    2020
    21 import org.openstreetmap.josm.Main;
    2221import org.openstreetmap.josm.gui.PleaseWaitDialog;
    2322import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    2423import org.openstreetmap.josm.tools.HttpClient;
     24import org.openstreetmap.josm.tools.Logging;
    2525import org.openstreetmap.josm.tools.Utils;
    2626import org.xml.sax.SAXException;
     
    133133            }
    134134            if (!canceled) {
    135                 Main.info(tr("Download finished"));
     135                Logging.info(tr("Download finished"));
    136136                if (unpack) {
    137                     Main.info(tr("Unpacking {0} into {1}", file.getAbsolutePath(), file.getParent()));
     137                    Logging.info(tr("Unpacking {0} into {1}", file.getAbsolutePath(), file.getParent()));
    138138                    unzipFileRecursively(file, file.getParent());
    139139                    Utils.deleteFile(file);
     
    143143            String msg = tr("Cannot download file ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.",
    144144                    file.getName(), address);
    145             Main.warn(msg);
     145            Logging.warn(msg);
    146146            throw new DownloadException(msg, e);
    147147        } catch (IOException e) {
     
    160160            download();
    161161        } catch (DownloadException e) {
    162             Main.error(e);
     162            Logging.error(e);
    163163        }
    164164    }
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTask.java

    r12012 r12620  
    2525import org.openstreetmap.josm.io.OsmServerUserInfoReader;
    2626import org.openstreetmap.josm.io.OsmTransferException;
     27import org.openstreetmap.josm.tools.Logging;
    2728import org.xml.sax.SAXException;
    2829
     
    6566                    + "You have either chosen to work anonymously or you are not entitled<br>"
    6667                    + "to know the identity of the user on whose behalf you are working.");
    67             Main.warn(msg);
     68            Logging.warn(msg);
    6869            if (!GraphicsEnvironment.isHeadless()) {
    6970                JOptionPane.showMessageDialog(GuiHelper.getFrameForComponent(parent),
     
    113114                im.setPartiallyIdentified(im.getUserName());
    114115            }
    115             Main.warn(e, tr("Failed to retrieve user infos for the current JOSM user. Exception was: {0}", e.toString()));
     116            Logging.log(Logging.LEVEL_WARN,
     117                    tr("Failed to retrieve user infos for the current JOSM user. Exception was: {0}", e.toString()), e);
    116118        }
    117119    }
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java

    r11746 r12620  
    66import java.util.Optional;
    77
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.actions.SaveAction;
    109import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     
    1211import org.openstreetmap.josm.tools.CheckParameterUtil;
    1312import org.openstreetmap.josm.tools.JosmRuntimeException;
     13import org.openstreetmap.josm.tools.Logging;
    1414
    1515/**
     
    5757            }
    5858        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    59             Main.error(e);
     59            Logging.error(e);
    6060            setLastException(e);
    6161        }
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r12452 r12620  
    5555import org.openstreetmap.josm.tools.ImageProvider;
    5656import org.openstreetmap.josm.tools.InputMapUtils;
     57import org.openstreetmap.josm.tools.Logging;
    5758import org.openstreetmap.josm.tools.UserCancelException;
    5859import org.openstreetmap.josm.tools.Utils;
     
    446447                closeDialog();
    447448            } catch (UserCancelException ignore) {
    448                 Main.trace(ignore);
     449                Logging.trace(ignore);
    449450            }
    450451        }
     
    575576                    currentFuture.get();
    576577                } catch (CancellationException e) {
    577                     Main.trace(e);
     578                    Logging.trace(e);
    578579                    model.setUploadState(layer, UploadOrSaveState.CANCELED);
    579580                } catch (InterruptedException | ExecutionException e) {
    580                     Main.error(e);
     581                    Logging.error(e);
    581582                    model.setUploadState(layer, UploadOrSaveState.FAILED);
    582583                    ExceptionDialogUtil.explainException(e);
     
    585586                    model.setUploadState(layer, UploadOrSaveState.CANCELED);
    586587                } else if (currentTask.isFailed()) {
    587                     Main.error(currentTask.getLastException());
     588                    Logging.error(currentTask.getLastException());
    588589                    ExceptionDialogUtil.explainException(currentTask.getLastException());
    589590                    model.setUploadState(layer, UploadOrSaveState.FAILED);
     
    616617                    currentFuture.get();
    617618                } catch (CancellationException e) {
    618                     Main.trace(e);
     619                    Logging.trace(e);
    619620                    model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.CANCELED);
    620621                } catch (InterruptedException | ExecutionException e) {
    621                     Main.error(e);
     622                    Logging.error(e);
    622623                    model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.FAILED);
    623624                    ExceptionDialogUtil.explainException(e);
     
    627628                } else if (currentTask.isFailed()) {
    628629                    if (currentTask.getLastException() != null) {
    629                         Main.error(currentTask.getLastException());
     630                        Logging.error(currentTask.getLastException());
    630631                        ExceptionDialogUtil.explainException(currentTask.getLastException());
    631632                    }
     
    642643            if (numProblems == 0)
    643644                return;
    644             Main.warn(numProblems + " problems occured during upload/save");
     645            Logging.warn(numProblems + " problems occured during upload/save");
    645646            String msg = trn(
    646647                    "<html>An upload and/or save operation of one layer with modifications<br>"
  • trunk/src/org/openstreetmap/josm/gui/io/UploadLayerTask.java

    r11604 r12620  
    99import java.util.Set;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException;
    1312import org.openstreetmap.josm.data.APIDataSet;
     
    2524import org.openstreetmap.josm.io.OsmTransferException;
    2625import org.openstreetmap.josm.tools.CheckParameterUtil;
     26import org.openstreetmap.josm.tools.Logging;
    2727
    2828/**
     
    9191        if (p.isDeleted()) {
    9292            // we tried to delete an already deleted primitive.
    93             Main.warn(tr("Object ''{0}'' is already deleted on the server. Skipping this object and retrying to upload.",
     93            Logging.warn(tr("Object ''{0}'' is already deleted on the server. Skipping this object and retrying to upload.",
    9494                    p.getDisplayName(DefaultNameFormatter.getInstance())));
    9595            processedPrimitives.addAll(writer.getProcessedPrimitives());
     
    134134        } catch (OsmTransferException sxe) {
    135135            if (isCanceled()) {
    136                 Main.info("Ignoring exception caught because upload is canceled. Exception is: " + sxe);
     136                Logging.info("Ignoring exception caught because upload is canceled. Exception is: " + sxe);
    137137                return;
    138138            }
  • trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java

    r11686 r12620  
    3838import org.openstreetmap.josm.io.OsmTransferException;
    3939import org.openstreetmap.josm.tools.ImageProvider;
     40import org.openstreetmap.josm.tools.Logging;
    4041
    4142/**
     
    200201            }
    201202            monitor.appendLogMessage(msg);
    202             Main.warn(msg);
     203            Logging.warn(msg);
    203204            processedPrimitives.addAll(writer.getProcessedPrimitives());
    204205            processedPrimitives.add(p);
     
    224225            SwingUtilities.invokeAndWait(r);
    225226        } catch (InterruptedException e) {
    226             Main.trace(e);
     227            Logging.trace(e);
    227228            lastException = e;
    228229            Thread.currentThread().interrupt();
    229230        } catch (InvocationTargetException e) {
    230             Main.trace(e);
     231            Logging.trace(e);
    231232            lastException = new OsmTransferException(e.getCause());
    232233        }
     
    249250                    break;
    250251                } catch (OsmTransferCanceledException e) {
    251                     Main.error(e);
     252                    Logging.error(e);
    252253                    uploadCanceled = true;
    253254                    break uploadloop;
     
    292293        } catch (OsmTransferException e) {
    293294            if (uploadCanceled) {
    294                 Main.info(tr("Ignoring caught exception because upload is canceled. Exception is: {0}", e.toString()));
     295                Logging.info(tr("Ignoring caught exception because upload is canceled. Exception is: {0}", e.toString()));
    295296            } else {
    296297                lastException = e;
  • trunk/src/org/openstreetmap/josm/gui/io/UploadStrategy.java

    r12370 r12620  
    77
    88import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.tools.Logging;
    910
    1011/**
     
    9697        UploadStrategy strategy = fromPreference(v);
    9798        if (strategy == null) {
    98             Main.warn(tr("Unexpected value for key ''{0}'' in preferences, got ''{1}''", "osm-server.upload-strategy", v));
     99            Logging.warn(tr("Unexpected value for key ''{0}'' in preferences, got ''{1}''", "osm-server.upload-strategy", v));
    99100            return DEFAULT_UPLOAD_STRATEGY;
    100101        }
  • trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java

    r12370 r12620  
    3636import org.openstreetmap.josm.io.Capabilities;
    3737import org.openstreetmap.josm.io.OsmApi;
     38import org.openstreetmap.josm.tools.Logging;
    3839
    3940/**
     
    336337        } catch (NumberFormatException e) {
    337338            // don't save invalid value to preferences
    338             Main.trace(e);
     339            Logging.trace(e);
    339340        }
    340341    }
Note: See TracChangeset for help on using the changeset viewer.