Ignore:
Timestamp:
2009-12-03T22:15:17+01:00 (16 years ago)
Author:
bastiK
Message:

Moved the code from agpifoj plugin to JOSM core. Thanks to Christian Gallioz for this great (ex-)plugin.
In the current state it might be a little unstable.

  • Did a view modification so it fits in better.
  • Added the Thumbnail feature, but still work to be done.

New in JOSM core: Possibility to add toggle dialogs not only on startup, but also later.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java

    • Property svn:eol-style set to native
    r2525 r2566  
    3232    }
    3333
    34     private boolean initialized = false;
    35     public void initialize(List<ToggleDialog> allDialogs) {
     34    public boolean initialized = false; // read only from outside
     35   
     36    public void initialize(List<ToggleDialog> pAllDialogs) {
    3637        if (initialized)
    3738            throw new IllegalStateException();
    3839        initialized = true;
    39         this.allDialogs = allDialogs;
    40 
    41         for (Integer i=0; i < allDialogs.size(); ++i) {
    42             final ToggleDialog dlg = allDialogs.get(i);
    43             dlg.setDialogsPanel(this);
    44             dlg.setVisible(false);
    45         }
    46         for (int i=0; i < allDialogs.size() + 1; ++i) {
    47             final JPanel p = new JPanel() {
    48                 /**
    49                  * Honoured by the MultiSplitPaneLayout when the
    50                  * entire Window is resized.
    51                  */
    52                 @Override
    53                 public Dimension getMinimumSize() {
    54                     return new Dimension(0, 40);
    55                 }
    56             };
    57             p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    58             p.setVisible(false);
    59 
    60             mSpltPane.add(p, "L"+i);
    61             panels.add(p);
    62         }
    63 
    64         for (Integer i=0; i < allDialogs.size(); ++i) {
    65             final ToggleDialog dlg = allDialogs.get(i);
    66             if (dlg.isDialogShowing()) {
    67                 dlg.showDialog();
    68                 if (dlg.isDialogInCollapsedView()) {
    69                     dlg.isCollapsed = false;    // pretend to be in Default view, this will be set back by collapse()
    70                     dlg.collapse();
    71                 }
    72             } else {
    73                 dlg.hideDialog();
    74             }
    75         }
     40        allDialogs = new ArrayList<ToggleDialog>();
     41
     42        for (Integer i=0; i < pAllDialogs.size(); ++i) {
     43            add(pAllDialogs.get(i), false);
     44        }
     45       
    7646        this.add(mSpltPane);
    7747        reconstruct(Action.ELEMENT_SHRINKS, null);
     48    }
     49
     50    public void add(ToggleDialog dlg) {
     51        add(dlg, true);
     52    }
     53   
     54    public void add(ToggleDialog dlg, boolean doReconstruct) {
     55        allDialogs.add(dlg);
     56        int i = allDialogs.size() - 1;
     57        dlg.setDialogsPanel(this);
     58        dlg.setVisible(false);
     59        final JPanel p = new JPanel() {
     60            /**
     61             * Honoured by the MultiSplitPaneLayout when the
     62             * entire Window is resized.
     63             */
     64            @Override
     65            public Dimension getMinimumSize() {
     66                return new Dimension(0, 40);
     67            }
     68        };
     69        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
     70        p.setVisible(false);
     71
     72        mSpltPane.add(p, "L"+i);
     73        panels.add(p);
     74
     75        if (dlg.isDialogShowing()) {
     76            dlg.showDialog();
     77            if (dlg.isDialogInCollapsedView()) {
     78                dlg.isCollapsed = false;    // pretend to be in Default view, this will be set back by collapse()
     79                dlg.collapse();
     80            }
     81            if (doReconstruct) {
     82                reconstruct(Action.INVISIBLE_TO_DEFAULT, dlg);
     83            }
     84        } else {
     85            dlg.hideDialog();
     86        }
    7887    }
    7988
Note: See TracChangeset for help on using the changeset viewer.