Ignore:
Timestamp:
2014-05-09T15:47:48+02:00 (10 years ago)
Author:
Don-vip
Message:

code refactoring to avoid classes in methods (cause problems for code analysis tools)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r7005 r7090  
    126126        return group != null ? group.getRawName() + "/" + name : name;
    127127    }
    128    
     128
    129129    /**
    130130     * Returns the preset icon.
     
    254254            link.addToPanel(p, selected, presetInitiallyMatches);
    255255        }
    256        
     256
    257257        // "Add toolbar button"
    258258        JToggleButton tb = new JToggleButton(new ToolbarButtonAction());
     
    320320    }
    321321
    322     public int showDialog(Collection<OsmPrimitive> sel, final boolean showNewRelation) {
     322    private static class PresetDialog extends ExtendedDialog {
     323        public PresetDialog(Component content, String title, ImageIcon icon, boolean disableApply, boolean showNewRelation) {
     324            super(Main.parent, title,
     325                    showNewRelation?
     326                            new String[] { tr("Apply Preset"), tr("New relation"), tr("Cancel") }:
     327                                new String[] { tr("Apply Preset"), tr("Cancel") },
     328                                true);
     329            if (icon != null)
     330                setIconImage(icon.getImage());
     331            contentInsets = new Insets(10,5,0,5);
     332            if (showNewRelation) {
     333                setButtonIcons(new String[] {"ok.png", "dialogs/addrelation.png", "cancel.png" });
     334            } else {
     335                setButtonIcons(new String[] {"ok.png", "cancel.png" });
     336            }
     337            setContent(content);
     338            setDefaultButton(1);
     339            setupDialog();
     340            buttons.get(0).setEnabled(!disableApply);
     341            buttons.get(0).setToolTipText(title);
     342            // Prevent dialogs of being too narrow (fix #6261)
     343            Dimension d = getSize();
     344            if (d.width < 350) {
     345                d.width = 350;
     346                setSize(d);
     347            }
     348            showDialog();
     349        }
     350    }
     351
     352    public int showDialog(Collection<OsmPrimitive> sel, boolean showNewRelation) {
    323353        PresetPanel p = createPanel(sel);
    324354        if (p == null)
     
    336366            }
    337367
    338             class PresetDialog extends ExtendedDialog {
    339                 public PresetDialog(Component content, String title, ImageIcon icon, boolean disableApply) {
    340                     super(Main.parent,
    341                             title,
    342                             showNewRelation?
    343                                     new String[] { tr("Apply Preset"), tr("New relation"), tr("Cancel") }:
    344                                         new String[] { tr("Apply Preset"), tr("Cancel") },
    345                                         true);
    346                     if (icon != null)
    347                         setIconImage(icon.getImage());
    348                     contentInsets = new Insets(10,5,0,5);
    349                     if (showNewRelation) {
    350                         setButtonIcons(new String[] {"ok.png", "dialogs/addrelation.png", "cancel.png" });
    351                     } else {
    352                         setButtonIcons(new String[] {"ok.png", "cancel.png" });
    353                     }
    354                     setContent(content);
    355                     setDefaultButton(1);
    356                     setupDialog();
    357                     buttons.get(0).setEnabled(!disableApply);
    358                     buttons.get(0).setToolTipText(title);
    359                     // Prevent dialogs of being too narrow (fix #6261)
    360                     Dimension d = getSize();
    361                     if (d.width < 350) {
    362                         d.width = 350;
    363                         setSize(d);
    364                     }
    365                     showDialog();
    366                 }
    367             }
    368 
    369             answer = new PresetDialog(p, title, (ImageIcon) getValue(Action.SMALL_ICON), sel.isEmpty()).getValue();
     368            answer = new PresetDialog(p, title, (ImageIcon) getValue(Action.SMALL_ICON),
     369                    sel.isEmpty(), showNewRelation).getValue();
    370370        }
    371371        if (!showNewRelation && answer == 2)
     
    502502        });
    503503    }
    504    
     504
    505505    /**
    506506     * Action that adds or removes the button on main toolbar
     
    522522        }
    523523    }
    524    
     524
    525525    public String getToolbarString() {
    526526        ToolbarPreferences.ActionDefinition aDef
Note: See TracChangeset for help on using the changeset viewer.