Changeset 11387 in josm


Ignore:
Timestamp:
2016-12-13T02:42:20+01:00 (7 years ago)
Author:
Don-vip
Message:

javadoc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r11367 r11387  
    104104public abstract class SourceEditor extends JPanel {
    105105
     106    /** the type of source entry **/
    106107    protected final SourceType sourceType;
     108    /** determines if the entry type can be enabled (set as active) **/
    107109    protected final boolean canEnable;
    108110
     111    /** the table of active sources **/
    109112    protected final JTable tblActiveSources;
     113    /** the underlying model of active sources **/
    110114    protected final ActiveSourcesModel activeSourcesModel;
     115    /** the list of available sources **/
    111116    protected final JList<ExtendedSourceEntry> lstAvailableSources;
     117    /** the underlying model of available sources **/
    112118    protected final AvailableSourcesListModel availableSourcesModel;
     119    /** the URL from which the available sources are fetched **/
    113120    protected final String availableSourcesUrl;
     121    /** the list of source providers **/
    114122    protected final transient List<SourceProvider> sourceProviders;
    115123
     
    117125    private IconPathTableModel iconPathsModel;
    118126
     127    /** determines if the source providers have been initially loaded **/
    119128    protected boolean sourcesInitiallyLoaded;
    120129
     
    397406    public abstract boolean finish();
    398407
     408    /**
     409     * Default implementation of {@link #finish}.
     410     * @param prefHelper Helper class for specialized extensions preferences
     411     * @param iconPref icons path preference
     412     * @return true if restart is required
     413     */
    399414    protected boolean doFinish(SourcePrefHelper prefHelper, String iconPref) {
    400415        boolean changed = prefHelper.put(activeSourcesModel.getSources());
     
    512527    }
    513528
     529    /**
     530     * Reload available sources.
     531     * @param url the URL from which the available sources are fetched
     532     * @param sourceProviders the list of source providers
     533     */
    514534    protected void reloadAvailableSources(String url, List<SourceProvider> sourceProviders) {
    515535        Main.worker.submit(new SourceLoader(url, sourceProviders));
     
    526546    }
    527547
     548    /**
     549     * List model of available sources.
     550     */
    528551    protected static class AvailableSourcesListModel extends DefaultListModel<ExtendedSourceEntry> {
    529552        private final transient List<ExtendedSourceEntry> data;
    530553        private final DefaultListSelectionModel selectionModel;
    531554
     555        /**
     556         * Constructs a new {@code AvailableSourcesListModel}
     557         * @param selectionModel selection model
     558         */
    532559        public AvailableSourcesListModel(DefaultListSelectionModel selectionModel) {
    533560            data = new ArrayList<>();
     
    535562        }
    536563
     564        /**
     565         * Sets the source list.
     566         * @param sources source list
     567         */
    537568        public void setSources(List<ExtendedSourceEntry> sources) {
    538569            data.clear();
     
    554585        }
    555586
     587        /**
     588         * Deletes the selected sources.
     589         */
    556590        public void deleteSelected() {
    557591            Iterator<ExtendedSourceEntry> it = data.iterator();
     
    567601        }
    568602
     603        /**
     604         * Returns the selected sources.
     605         * @return the selected sources
     606         */
    569607        public List<ExtendedSourceEntry> getSelected() {
    570608            List<ExtendedSourceEntry> ret = new ArrayList<>();
     
    578616    }
    579617
     618    /**
     619     * Table model of active sources.
     620     */
    580621    protected class ActiveSourcesModel extends AbstractTableModel {
    581622        private transient List<SourceEntry> data;
    582623        private final DefaultListSelectionModel selectionModel;
    583624
     625        /**
     626         * Constructs a new {@code ActiveSourcesModel}.
     627         * @param selectionModel selection model
     628         */
    584629        public ActiveSourcesModel(DefaultListSelectionModel selectionModel) {
    585630            this.selectionModel = selectionModel;
     
    626671        }
    627672
     673        /**
     674         * Sets active sources.
     675         * @param sources active sources
     676         */
    628677        public void setActiveSources(Collection<? extends SourceEntry> sources) {
    629678            data.clear();
     
    636685        }
    637686
     687        /**
     688         * Adds an active source.
     689         * @param entry source to add
     690         */
    638691        public void addSource(SourceEntry entry) {
    639692            if (entry == null) return;
     
    646699        }
    647700
     701        /**
     702         * Removes the selected sources.
     703         */
    648704        public void removeSelected() {
    649705            Iterator<SourceEntry> it = data.iterator();
     
    659715        }
    660716
     717        /**
     718         * Removes the sources at given indexes.
     719         * @param idxs indexes to remove
     720         */
    661721        public void removeIdxs(Collection<Integer> idxs) {
    662722            List<SourceEntry> newData = new ArrayList<>();
     
    670730        }
    671731
     732        /**
     733         * Adds multiple sources.
     734         * @param sources source entries
     735         */
    672736        public void addExtendedSourceEntries(List<ExtendedSourceEntry> sources) {
    673737            if (sources == null) return;
     
    687751        }
    688752
     753        /**
     754         * Returns the active sources.
     755         * @return the active sources
     756         */
    689757        public List<SourceEntry> getSources() {
    690758            return new ArrayList<>(data);
     
    832900    }
    833901
     902    /**
     903     * Dialog to edit a source entry.
     904     */
    834905    protected class EditSourceEntryDialog extends ExtendedDialog {
    835906
     
    838909        private JCheckBox cbActive;
    839910
     911        /**
     912         * Constructs a new {@code EditSourceEntryDialog}.
     913         * @param parent parent component
     914         * @param title dialog title
     915         * @param e source entry to edit
     916         */
    840917        public EditSourceEntryDialog(Component parent, String title, SourceEntry e) {
    841918            super(parent, title, new String[] {tr("Ok"), tr("Cancel")});
     
    9351012        }
    9361013
     1014        /**
     1015         * Returns the entered URL / File.
     1016         * @return the entered URL / File
     1017         */
    9371018        public String getURL() {
    9381019            return tfURL.getText();
    9391020        }
    9401021
     1022        /**
     1023         * Determines if the active combobox is selected.
     1024         * @return {@code true} if the active combobox is selected
     1025         */
    9411026        public boolean active() {
    9421027            if (!canEnable)
     
    11601245    }
    11611246
     1247    /**
     1248     * Table model for icons paths.
     1249     */
    11621250    protected static class IconPathTableModel extends AbstractTableModel {
    11631251        private final List<String> data;
    11641252        private final DefaultListSelectionModel selectionModel;
    11651253
     1254        /**
     1255         * Constructs a new {@code IconPathTableModel}.
     1256         * @param selectionModel selection model
     1257         */
    11661258        public IconPathTableModel(DefaultListSelectionModel selectionModel) {
    11671259            this.selectionModel = selectionModel;
     
    11941286        }
    11951287
     1288        /**
     1289         * Sets the icons paths.
     1290         * @param paths icons paths
     1291         */
    11961292        public void setIconPaths(Collection<String> paths) {
    11971293            data.clear();
     
    12031299        }
    12041300
     1301        /**
     1302         * Adds an icon path.
     1303         * @param path icon path to add
     1304         */
    12051305        public void addPath(String path) {
    12061306            if (path == null) return;
     
    12141314        }
    12151315
     1316        /**
     1317         * Updates icon path at given index.
     1318         * @param pos position
     1319         * @param path new path
     1320         */
    12161321        public void updatePath(int pos, String path) {
    12171322            if (path == null) return;
     
    12261331        }
    12271332
     1333        /**
     1334         * Removes the selected path.
     1335         */
    12281336        public void removeSelected() {
    12291337            Iterator<String> it = data.iterator();
     
    12401348        }
    12411349
     1350        /**
     1351         * Sorts paths lexicographically.
     1352         */
    12421353        protected void sort() {
    12431354            data.sort((o1, o2) -> {
     
    12501361        }
    12511362
     1363        /**
     1364         * Returns the icon paths.
     1365         * @return the icon paths
     1366         */
    12521367        public List<String> getIconPaths() {
    12531368            return new ArrayList<>(data);
     
    17461861    }
    17471862
     1863    /**
     1864     * Returns the title of the given source entry.
     1865     * @param entry source entry
     1866     * @return the title of the given source entry, or null if empty
     1867     */
    17481868    protected String getTitleForSourceEntry(SourceEntry entry) {
    17491869        return "".equals(entry.title) ? null : entry.title;
Note: See TracChangeset for help on using the changeset viewer.