Changeset 13749 in josm for trunk/src/org
- Timestamp:
- 2018-05-13T12:25:15+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r13747 r13749 5 5 6 6 import java.awt.Point; 7 import java.awt.event.InputMethodEvent;8 import java.awt.event.InputMethodListener;9 7 import java.io.ByteArrayInputStream; 10 8 import java.io.IOException; 11 9 import java.io.InputStream; 12 10 import java.nio.charset.StandardCharsets; 11 import java.nio.file.InvalidPathException; 13 12 import java.util.ArrayList; 14 13 import java.util.Arrays; … … 30 29 31 30 import 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;39 31 import javax.xml.namespace.QName; 40 32 import javax.xml.stream.XMLStreamException; … … 61 53 import org.openstreetmap.josm.gui.layer.NativeScaleLayer.ScaleList; 62 54 import org.openstreetmap.josm.gui.layer.imagery.WMTSLayerSelection; 63 import org.openstreetmap.josm.gui.widgets.JosmTextArea;64 55 import org.openstreetmap.josm.io.CachedFile; 65 56 import org.openstreetmap.josm.spi.preferences.Config; 66 57 import org.openstreetmap.josm.tools.CheckParameterUtil; 67 import org.openstreetmap.josm.tools.GBC;68 58 import org.openstreetmap.josm.tools.Logging; 69 59 import org.openstreetmap.josm.tools.Utils; … … 273 263 super(cause); 274 264 } 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 } 275 273 } 276 274 … … 429 427 cf.clear(); 430 428 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); 433 433 } 434 434 } … … 958 958 } 959 959 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 */ 1030 964 public static List<Entry<String, List<Layer>>> groupLayersByNameAndTileMatrixSet(Collection<Layer> layers) { 1031 965 Map<String, List<Layer>> layerByName = layers.stream().collect(
Note:
See TracChangeset
for help on using the changeset viewer.