Changeset 13749 in josm for trunk


Ignore:
Timestamp:
2018-05-13T12:25:15+02:00 (6 years ago)
Author:
wiktorn
Message:

Remove unused function & better error reporting

See: #16249

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r13747 r13749  
    55
    66import java.awt.Point;
    7 import java.awt.event.InputMethodEvent;
    8 import java.awt.event.InputMethodListener;
    97import java.io.ByteArrayInputStream;
    108import java.io.IOException;
    119import java.io.InputStream;
    1210import java.nio.charset.StandardCharsets;
     11import java.nio.file.InvalidPathException;
    1312import java.util.ArrayList;
    1413import java.util.Arrays;
     
    3029
    3130import javax.imageio.ImageIO;
    32 import javax.swing.JLabel;
    33 import javax.swing.JPanel;
    34 import javax.swing.JTable;
    35 import javax.swing.ListSelectionModel;
    36 import javax.swing.RowFilter;
    37 import javax.swing.table.AbstractTableModel;
    38 import javax.swing.table.TableRowSorter;
    3931import javax.xml.namespace.QName;
    4032import javax.xml.stream.XMLStreamException;
     
    6153import org.openstreetmap.josm.gui.layer.NativeScaleLayer.ScaleList;
    6254import org.openstreetmap.josm.gui.layer.imagery.WMTSLayerSelection;
    63 import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    6455import org.openstreetmap.josm.io.CachedFile;
    6556import org.openstreetmap.josm.spi.preferences.Config;
    6657import org.openstreetmap.josm.tools.CheckParameterUtil;
    67 import org.openstreetmap.josm.tools.GBC;
    6858import org.openstreetmap.josm.tools.Logging;
    6959import org.openstreetmap.josm.tools.Utils;
     
    273263            super(cause);
    274264        }
     265
     266        /**
     267         * @param cause description of cause
     268         * @param t nested exception
     269         */
     270        public WMTSGetCapabilitiesException(String cause, Throwable t) {
     271            super(cause, t);
     272        }
    275273    }
    276274
     
    429427                cf.clear();
    430428                Logging.warn(new String(data, StandardCharsets.UTF_8));
    431                 throw new WMTSGetCapabilitiesException(tr("Error during parsing of WMTS Capabilities document: {1}", e.getMessage()));
    432             }
     429                throw new WMTSGetCapabilitiesException(tr("Error during parsing of WMTS Capabilities document: {0}", e.getMessage()), e);
     430            }
     431        } catch (InvalidPathException e) {
     432            throw new WMTSGetCapabilitiesException(tr("Invalid path for GetCapabilities document: {0}", e.getMessage()), e);
    433433        }
    434434    }
     
    958958    }
    959959
    960     public static JPanel getLayerSelectionPanel(List<Entry<String, List<Layer>>> layers) {
    961         JTable list = new JTable(
    962                 new AbstractTableModel() {
    963                     @Override
    964                     public Object getValueAt(int rowIndex, int columnIndex) {
    965                         switch (columnIndex) {
    966                         case 0:
    967                             return layers.get(rowIndex).getValue()
    968                                     .stream()
    969                                     .map(Layer::getUserTitle)
    970                                     .collect(Collectors.joining(", ")); //this should be only one
    971                         case 1:
    972                             return layers.get(rowIndex).getValue()
    973                                     .stream()
    974                                     .map(x -> x.tileMatrixSet.crs)
    975                                     .collect(Collectors.joining(", "));
    976                         case 2:
    977                             return layers.get(rowIndex).getValue()
    978                                     .stream()
    979                                     .map(x -> x.tileMatrixSet.identifier)
    980                                     .collect(Collectors.joining(", ")); //this should be only one
    981                         default:
    982                             throw new IllegalArgumentException();
    983                         }
    984                     }
    985 
    986                     @Override
    987                     public int getRowCount() {
    988                         return layers.size();
    989                     }
    990 
    991                     @Override
    992                     public int getColumnCount() {
    993                         return 3;
    994                     }
    995 
    996                     @Override
    997                     public String getColumnName(int column) {
    998                         switch (column) {
    999                         case 0: return tr("Layer name");
    1000                         case 1: return tr("Projection");
    1001                         case 2: return tr("Matrix set identifier");
    1002                         default:
    1003                             throw new IllegalArgumentException();
    1004                         }
    1005                     }
    1006                 });
    1007         list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    1008         list.setAutoCreateRowSorter(true);
    1009         list.setRowSelectionAllowed(true);
    1010         list.setColumnSelectionAllowed(false);
    1011         JPanel ret = new JPanel();
    1012         ret.add(new JLabel(tr("Filter layers:")), GBC.eol().fill(GBC.HORIZONTAL));
    1013         final JosmTextArea filter = new JosmTextArea();
    1014         filter.addInputMethodListener(new InputMethodListener() {
    1015             @SuppressWarnings({ "unchecked", "rawtypes" })
    1016             @Override
    1017             public void inputMethodTextChanged(InputMethodEvent event) {
    1018                 ((TableRowSorter) list.getRowSorter()).setRowFilter(RowFilter.regexFilter(filter.getText()));
    1019             }
    1020 
    1021             @Override
    1022             public void caretPositionChanged(InputMethodEvent event) {
    1023                 return;
    1024             }
    1025         });
    1026         ret.add(list, GBC.eol().fill());
    1027         return ret;
    1028     }
    1029 
     960    /**
     961     * @param layers to be grouped
     962     * @return list with entries - grouping identifier + list of layers
     963     */
    1030964    public static List<Entry<String, List<Layer>>> groupLayersByNameAndTileMatrixSet(Collection<Layer> layers) {
    1031965        Map<String, List<Layer>> layerByName = layers.stream().collect(
Note: See TracChangeset for help on using the changeset viewer.