Package org.openstreetmap.josm.gui.widgets

Examples of org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel


    private final JosmTextField autosaveInterval = new JosmTextField(8);
    private final JosmTextField backupPerLayer = new JosmTextField(8);

    @Override
    public void addGui(PreferenceTabbedPane gui) {
        JPanel panel = new VerticallyScrollablePanel();
        panel.setLayout(new GridBagLayout());
        panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));

        autosave = new JCheckBox(tr("Auto save enabled"));
        autosave.setSelected(AutosaveTask.PROP_AUTOSAVE_ENABLED.get());
        panel.add(autosave, GBC.eol());

        final JLabel autosaveIntervalLabel = new JLabel(tr("Auto save interval (seconds)"));
        panel.add(autosaveIntervalLabel, GBC.std().insets(60,0,0,0));
        autosaveInterval.setText(Integer.toString(AutosaveTask.PROP_INTERVAL.get()));
        autosaveInterval.setToolTipText(tr("Default value: {0}", AutosaveTask.PROP_INTERVAL.getDefaultValue()));
        autosaveInterval.setMinimumSize(autosaveInterval.getPreferredSize());
        panel.add(autosaveInterval, GBC.eol().insets(5,0,0,5));

        final JLabel backupPerLayerLabel = new JLabel(tr("Auto saved files per layer"));
        panel.add(backupPerLayerLabel, GBC.std().insets(60,0,0,0));
        backupPerLayer.setText(Integer.toString(AutosaveTask.PROP_FILES_PER_LAYER.get()));
        backupPerLayer.setToolTipText(tr("Default value: {0}", AutosaveTask.PROP_FILES_PER_LAYER.getDefaultValue()));
        backupPerLayer.setMinimumSize(backupPerLayer.getPreferredSize());
        panel.add(backupPerLayer, GBC.eol().insets(5,0,0,10));

        panel.add(new HtmlPanel(
            tr("<i>(Autosave stores the changed data layers in periodic intervals. " +
                "The backups are saved in JOSM''s preference folder. " +
                "In case of a crash, JOSM tries to recover the unsaved changes " +
                "on next start.)</i>")),
            GBC.eop().fill(GBC.HORIZONTAL).insets(5,0,0,10));

        panel.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL));

        keepBackup = new JCheckBox(tr("Keep backup files when saving data layers"));
        keepBackup.setSelected(PROP_KEEP_BACKUP.get());
        keepBackup.setToolTipText(tr("When saving, keep backup files ending with a ~"));
        panel.add(keepBackup, GBC.eop());

        panel.add(new HtmlPanel(
            tr("<i>(JOSM can keep a backup file when saving data layers. "+
                "It appends ''~'' to the file name and saves it in the same folder.)</i>")),
            GBC.eop().fill(GBC.HORIZONTAL).insets(5,0,0,0));

        panel.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL));

        notification = new JCheckBox(tr("Notification at each save"));
        notification.setSelected(AutosaveTask.PROP_NOTIFICATION.get());
        notification.setToolTipText(tr("When saving, display a small notification"));
        panel.add(notification, GBC.eop());
       
        ActionListener autosaveEnabled = new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e) {
                boolean enabled = autosave.isSelected();
                autosaveIntervalLabel.setEnabled(enabled);
                autosaveInterval.setEnabled(enabled);
                backupPerLayerLabel.setEnabled(enabled);
                backupPerLayer.setEnabled(enabled);
            }
        };
        autosave.addActionListener(autosaveEnabled);
        autosaveEnabled.actionPerformed(null);

        panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
        JScrollPane sp = GuiHelper.embedInVerticalScrollPane(panel);

        gui.getMapPreference().addSubTab(this, tr("File backup"), sp, tr("Configure whether to create backup files"));
    }
View Full Code Here


     * Builds the panel for entering the username and password
     *
     * @return constructed panel for the creditentials
     */
    protected VerticallyScrollablePanel buildUserNamePasswordPanel() {
        VerticallyScrollablePanel pnl = new VerticallyScrollablePanel(new GridBagLayout());
        GridBagConstraints gc = new GridBagConstraints();
        pnl.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));

        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.fill = GridBagConstraints.HORIZONTAL;
        gc.weightx = 1.0;
        gc.gridwidth = 2;
        HtmlPanel pnlMessage = new HtmlPanel();
        HTMLEditorKit kit = (HTMLEditorKit)pnlMessage.getEditorPane().getEditorKit();
        kit.getStyleSheet().addRule(".warning-body {background-color:rgb(253,255,221);padding: 10pt; border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}");
        kit.getStyleSheet().addRule("ol {margin-left: 1cm}");
        pnlMessage.setText("<html><body><p class=\"warning-body\">"
                + tr("Please enter your OSM user name and password. The password will <strong>not</strong> be saved "
                        + "in clear text in the JOSM preferences and it will be submitted to the OSM server <strong>only once</strong>. "
                        + "Subsequent data upload requests don''t use your password any more.")
                        + "</p>"
                        + "</body></html>");
        pnl.add(pnlMessage, gc);

        // the user name input field
        gc.gridy = 1;
        gc.gridwidth = 1;
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.fill = GridBagConstraints.HORIZONTAL;
        gc.weightx = 0.0;
        gc.insets = new Insets(0,0,3,3);
        pnl.add(new JLabel(tr("Username: ")), gc);

        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(tfUserName = new JosmTextField(), gc);
        SelectAllOnFocusGainedDecorator.decorate(tfUserName);
        valUserName = new UserNameValidator(tfUserName);
        valUserName.validate();

        // the password input field
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.fill = GridBagConstraints.HORIZONTAL;
        gc.gridy = 2;
        gc.gridx = 0;
        gc.weightx = 0.0;
        pnl.add(new JLabel(tr("Password: ")), gc);

        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(tfPassword = new JosmPasswordField(), gc);
        SelectAllOnFocusGainedDecorator.decorate(tfPassword);
        valPassword = new PasswordValidator(tfPassword);
        valPassword.validate();

        gc.gridy = 3;
        gc.gridx = 0;
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.fill = GridBagConstraints.HORIZONTAL;
        gc.weightx = 1.0;
        gc.gridwidth = 2;
        pnlMessage = new HtmlPanel();
        kit = (HTMLEditorKit)pnlMessage.getEditorPane().getEditorKit();
        kit.getStyleSheet().addRule(".warning-body {background-color:rgb(253,255,221);padding: 10pt; border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}");
        kit.getStyleSheet().addRule("ol {margin-left: 1cm}");
        pnlMessage.setText("<html><body>"
                + "<p class=\"warning-body\">"
                + tr("<strong>Warning:</strong> JOSM does login <strong>once</strong> using a secure connection.")
                + "</p>"
                + "</body></html>");
        pnl.add(pnlMessage, gc);

        // filler - grab remaining space
        gc.gridy = 4;
        gc.gridwidth = 2;
        gc.fill = GridBagConstraints.BOTH;
        gc.weightx = 1.0;
        gc.weighty = 1.0;
        pnl.add(new JPanel(), gc);

        return pnl;
    }
View Full Code Here

    private TimeRestrictionPanel pnlTimeRestriction;
    private BBoxRestrictionPanel pnlBoundingBoxRestriction;

    protected JPanel buildQueryPanel() {
        ItemListener stateChangeHandler = new RestrictionGroupStateChangeHandler();
        JPanel pnl  = new VerticallyScrollablePanel();
        pnl.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
        pnl.setLayout(new GridBagLayout());
        GridBagConstraints gc = new GridBagConstraints();

        // -- select changesets by a specific user
        //
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.weightx = 0.0;
        gc.fill = GridBagConstraints.HORIZONTAL;
        pnl.add(cbUserRestriction = new JCheckBox(), gc);
        cbUserRestriction.addItemListener(stateChangeHandler);

        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(new JMultilineLabel(tr("Select changesets owned by specific users")),gc);

        gc.gridy = 1;
        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(pnlUserRestriction = new UserRestrictionPanel(), gc);

        // -- restricting the query to open and closed changesets
        //
        gc.gridy = 2;
        gc.gridx = 0;
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.weightx = 0.0;
        gc.fill = GridBagConstraints.HORIZONTAL;
        pnl.add(cbOpenAndCloseRestrictions = new JCheckBox(), gc);
        cbOpenAndCloseRestrictions.addItemListener(stateChangeHandler);

        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(new JMultilineLabel(tr("Select changesets depending on whether they are open or closed")),gc);

        gc.gridy = 3;
        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(pnlOpenAndCloseRestriction = new OpenAndCloseStateRestrictionPanel(), gc);

        // -- restricting the query to a specific time
        //
        gc.gridy = 4;
        gc.gridx = 0;
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.weightx = 0.0;
        gc.fill = GridBagConstraints.HORIZONTAL;
        pnl.add(cbTimeRestrictions = new JCheckBox(), gc);
        cbTimeRestrictions.addItemListener(stateChangeHandler);

        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(new JMultilineLabel(tr("Select changesets based on the date/time they have been created or closed")),gc);

        gc.gridy = 5;
        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(pnlTimeRestriction = new TimeRestrictionPanel(), gc);


        // -- restricting the query to a specific bounding box
        //
        gc.gridy = 6;
        gc.gridx = 0;
        gc.anchor = GridBagConstraints.NORTHWEST;
        gc.weightx = 0.0;
        gc.fill = GridBagConstraints.HORIZONTAL;
        pnl.add(cbBoundingBoxRestriction = new JCheckBox(), gc);
        cbBoundingBoxRestriction.addItemListener(stateChangeHandler);

        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(new JMultilineLabel(tr("Select only changesets related to a specific bounding box")),gc);

        gc.gridy = 7;
        gc.gridx = 1;
        gc.weightx = 1.0;
        pnl.add(pnlBoundingBoxRestriction = new BBoxRestrictionPanel(), gc);


        gc.gridy = 8;
        gc.gridx = 0;
        gc.gridwidth = 2;
        gc.fill  =GridBagConstraints.BOTH;
        gc.weightx = 1.0;
        gc.weighty = 1.0;
        pnl.add(new JPanel(), gc);

        return pnl;
    }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.