Changeset 34229 in osm


Ignore:
Timestamp:
2018-05-30T10:04:11+02:00 (6 years ago)
Author:
biswesh
Message:

Add title bar to PT Wizard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/PTWizardAction.java

    r34203 r34229  
    3232import javax.swing.JCheckBox;
    3333import javax.swing.JLabel;
     34import javax.swing.JOptionPane;
    3435import javax.swing.JPanel;
    3536import javax.swing.JScrollPane;
     
    4647import org.openstreetmap.josm.gui.MainApplication;
    4748import org.openstreetmap.josm.gui.MainMenu;
     49import org.openstreetmap.josm.gui.Notification;
    4850import org.openstreetmap.josm.gui.download.UserQueryList.SelectorItem;
    4951import org.openstreetmap.josm.gui.io.CustomConfigurator;
     
    5860
    5961        public boolean noDialogBox;
     62        private int closeCheck = 0;
    6063        /**
    6164     * Constructs a new {@code PTWizardAction}
     
    97100                } else {
    98101                        action = true;
     102                        String pages = Main.pref.get("pt_assistant.wizard.pages");
     103                        if (pages.isEmpty()) {
     104                                readPreferencesFromXML();
     105                                addDefaultValues();
     106                        }
    99107                }
    100108
     
    104112                panel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10));
    105113
    106                 ExtendedDialog ed = new ExtendedDialog(Main.parent,
    107                         tr("PT Wizard"),
    108                         tr("OK"), tr("Close"));
    109                 ed.setPreferredSize(new Dimension(250, 300));
    110                 ed.setButtonIcons("ok", "cancel");
     114                DoubleSplitDialog dsd = new DoubleSplitDialog();
     115                dsd.setPreferredSize(new Dimension(250, 300));
     116                dsd.setButtonIcons("ok", "cancel");
    111117                JScrollPane scrollPanel = new JScrollPane(panel);
    112                 ed.setContent(scrollPanel, false);
    113                     ed.setUndecorated(true);
    114 
     118                dsd.setContent(scrollPanel, false);
    115119                nextAct(0, panel);
    116 
    117120                String pages = Main.pref.get("pt_assistant.wizard.pages");
    118 
     121                int lastCheck = -1;
    119122                try {
    120123                                for(int i=1;i<=Integer.parseInt(pages)+1;i++) {
    121                                         ExtendedDialog dialog = ed.showDialog();
     124                                        if (lastCheck == closeCheck)
     125                                                return;
     126                                        else
     127                                                lastCheck = closeCheck;
     128                                        ExtendedDialog dialog = dsd.showDialog();
    122129                                        switch (dialog.getValue()) {
    123130                                                case 1: nextAct(i, panel); break;
     
    136143                try {
    137144                        CachedFile cf = getCachedFile();
     145                        if (cf == null)
     146                                return;
    138147                        List<String> lines = new ArrayList<>();
    139148                        try (BufferedReader in = cf.getContentReader()){
     
    166175
    167176        @SuppressWarnings("resource")
    168     public CachedFile getCachedFile() throws IOException {
    169         return new CachedFile("https://josm.openstreetmap.de/wiki/Plugin/PT_Assistant/Wizard?format=txt").setHttpAccept("text");
     177    public CachedFile getCachedFile() {
     178                try {
     179                        return new CachedFile("https://josm.openstreetmap.de/wiki/Plugin/PT_Assistant/Wizard?format=txt").setHttpAccept("text");
     180                } catch (Exception e) {
     181                        new Notification(tr("Unable to connect to https://josm.openstreetmap.de/wiki/Plugin/PT_Assistant/Wizard")).setIcon(JOptionPane.WARNING_MESSAGE).show();
     182                }
     183                return null;
    170184    }
    171185
     
    357371        panel.add(new JLabel("<html><br></html>"),GBC.eol().fill(GBC.HORIZONTAL));
    358372        panel.add(checkBoxPanel, GBC.eol().fill(GBC.HORIZONTAL));
    359 
    360373        }
    361374
     
    633646            }
    634647        }
     648
     649    private class DoubleSplitDialog extends ExtendedDialog {
     650
     651                public DoubleSplitDialog() {
     652                        super(Main.parent, tr("PT Wizard"), new String[] { tr("Ok"), tr("Cancel") },
     653                                        true);
     654                }
     655
     656                @Override
     657                protected void buttonAction(int buttonIndex, ActionEvent evt) {
     658                        closeCheck++;
     659                        super.buttonAction(buttonIndex, evt);
     660                }
     661
     662    }
    635663}
Note: See TracChangeset for help on using the changeset viewer.