Changeset 11881 in josm


Ignore:
Timestamp:
2017-04-10T03:57:16+02:00 (5 months ago)
Author:
Don-vip
Message:

findbugs - BC_UNCONFIRMED_CAST_OF_RETURN

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
7 edited

Legend:

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

    r11877 r11881  
    291291            }
    292292        } else {
    293             this.defaultLayer = (WMTSDefaultLayer) info.getDefaultLayers().iterator().next();
     293            DefaultLayer defLayer = info.getDefaultLayers().iterator().next();
     294            if (defLayer instanceof WMTSDefaultLayer) {
     295                this.defaultLayer = (WMTSDefaultLayer) defLayer;
     296            } else {
     297                this.defaultLayer = null;
     298            }
    294299        }
    295300        if (this.layers.isEmpty())
  • trunk/src/org/openstreetmap/josm/gui/SplashScreen.java

    r10781 r11881  
    66import java.awt.Color;
    77import java.awt.Component;
     8import java.awt.Container;
    89import java.awt.Dimension;
    910import java.awt.GridBagConstraints;
     
    1718
    1819import javax.swing.BorderFactory;
     20import javax.swing.JComponent;
    1921import javax.swing.JFrame;
    2022import javax.swing.JLabel;
     
    5759
    5860        // Add a nice border to the main splash screen
    59         JPanel contentPane = (JPanel) this.getContentPane();
     61        Container contentPane = this.getContentPane();
    6062        Border margin = new EtchedBorder(1, Color.white, Color.gray);
    61         contentPane.setBorder(margin);
     63        if (contentPane instanceof JComponent) {
     64            ((JComponent) contentPane).setBorder(margin);
     65        }
    6266
    6367        // Add a margin from the border to the content
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r11374 r11881  
    99import java.awt.Font;
    1010import java.awt.GraphicsEnvironment;
    11 import java.awt.Point;
    12 import java.awt.Rectangle;
    1311import java.awt.event.ActionEvent;
    1412import java.awt.event.InputEvent;
     
    3331import javax.swing.JLabel;
    3432import javax.swing.JTable;
    35 import javax.swing.JViewport;
    3633import javax.swing.KeyStroke;
    3734import javax.swing.ListSelectionModel;
     
    7370import org.openstreetmap.josm.gui.widgets.JosmTextField;
    7471import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     72import org.openstreetmap.josm.gui.widgets.ScrollableTable;
    7573import org.openstreetmap.josm.tools.ImageProvider;
    7674import org.openstreetmap.josm.tools.InputMapUtils;
     
    10961094     * This component displays a list of layers and provides the methods needed by {@link LayerListModel}.
    10971095     */
    1098     static class LayerList extends JTable {
     1096    static class LayerList extends ScrollableTable {
    10991097
    11001098        LayerList(LayerListModel dataModel) {
     
    11081106        }
    11091107
    1110         public void scrollToVisible(int row, int col) {
    1111             if (!(getParent() instanceof JViewport))
    1112                 return;
    1113             JViewport viewport = (JViewport) getParent();
    1114             Rectangle rect = getCellRect(row, col, true);
    1115             Point pt = viewport.getViewPosition();
    1116             rect.setLocation(rect.x - pt.x, rect.y - pt.y);
    1117             viewport.scrollRectToVisible(rect);
    1118         }
    1119 
    11201108        @Override
    11211109        public LayerListModel getModel() {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r11856 r11881  
    1010import java.awt.GridBagLayout;
    1111import java.awt.Insets;
    12 import java.awt.Point;
    13 import java.awt.Rectangle;
    1412import java.awt.event.ActionEvent;
    1513import java.awt.event.KeyEvent;
     
    4139import javax.swing.JTabbedPane;
    4240import javax.swing.JTable;
    43 import javax.swing.JViewport;
    4441import javax.swing.ListSelectionModel;
    4542import javax.swing.SingleSelectionModel;
     
    5451import javax.swing.table.DefaultTableCellRenderer;
    5552import javax.swing.table.TableCellRenderer;
    56 import javax.swing.table.TableModel;
    5753
    5854import org.openstreetmap.josm.Main;
     
    7773import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    7874import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     75import org.openstreetmap.josm.gui.widgets.ScrollableTable;
    7976import org.openstreetmap.josm.tools.GBC;
    8077import org.openstreetmap.josm.tools.ImageOverlay;
     
    9188public class MapPaintDialog extends ToggleDialog {
    9289
    93     protected StylesTable tblStyles;
     90    protected ScrollableTable tblStyles;
    9491    protected StylesModel model;
    9592    protected final DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
     
    138135        cbWireframe.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    139136
    140         tblStyles = new StylesTable(model);
     137        tblStyles = new ScrollableTable(model);
    141138        tblStyles.setSelectionModel(selectionModel);
    142139        tblStyles.addMouseListener(new PopupMenuHandler());
     
    176173                new SideButton(PREFERENCE_ACTION, false)
    177174        ));
    178     }
    179 
    180     protected static class StylesTable extends JTable {
    181 
    182         public StylesTable(TableModel dm) {
    183             super(dm);
    184         }
    185 
    186         public void scrollToVisible(int row, int col) {
    187             if (!(getParent() instanceof JViewport))
    188                 return;
    189             JViewport viewport = (JViewport) getParent();
    190             Rectangle rect = getCellRect(row, col, true);
    191             Point pt = viewport.getViewPosition();
    192             rect.setLocation(rect.x - pt.x, rect.y - pt.y);
    193             viewport.scrollRectToVisible(rect);
    194         }
    195175    }
    196176
  • trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerListTransferHandler.java

    r11809 r11881  
    9292            int dropLocation;
    9393            if (support.isDrop()) {
    94                 JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
    95                 dropLocation = dl.getRow();
     94                DropLocation dl = support.getDropLocation();
     95                if (dl instanceof JTable.DropLocation) {
     96                    dropLocation = ((JTable.DropLocation) dl).getRow();
     97                } else {
     98                    dropLocation = 0;
     99                }
    96100            } else {
    97101                dropLocation = layers.getLayers().get(0).getDefaultLayerPosition().getPosition(layers.getManager());
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTransferHandler.java

    r10755 r11881  
    6161        final int insertRow;
    6262        if (support.isDrop()) {
    63             insertRow = ((JTable.DropLocation) support.getDropLocation()).getRow();
     63            DropLocation dl = support.getDropLocation();
     64            if (dl instanceof JTable.DropLocation) {
     65                insertRow = ((JTable.DropLocation) dl).getRow();
     66            } else {
     67                insertRow = 0;
     68            }
    6469        } else {
    6570            int selection = destination.getSelectedRow();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java

    r11553 r11881  
    33
    44import java.awt.Point;
     5import java.awt.Window;
    56import java.awt.event.WindowAdapter;
    67import java.awt.event.WindowEvent;
     
    194195    @Override
    195196    public void windowClosed(WindowEvent e) {
    196         RelationEditor editor = (RelationEditor) e.getWindow();
    197         for (Iterator<Entry<DialogContext, RelationEditor>> it = openDialogs.entrySet().iterator(); it.hasNext();) {
    198             if (editor.equals(it.next().getValue())) {
    199                 it.remove();
    200                 break;
     197        Window w = e.getWindow();
     198        if (w instanceof RelationEditor) {
     199            RelationEditor editor = (RelationEditor) w;
     200            for (Iterator<Entry<DialogContext, RelationEditor>> it = openDialogs.entrySet().iterator(); it.hasNext();) {
     201                if (editor.equals(it.next().getValue())) {
     202                    it.remove();
     203                    break;
     204                }
    201205            }
    202206        }
Note: See TracChangeset for help on using the changeset viewer.