Examples of JosmTextField


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

    public void actionPerformed(ActionEvent e) {
        if (!isEnabled()) return;
        JPanel panel = new JPanel(new GridBagLayout());
        panel.add(new JLabel(tr("Supported Rectifier Services:")), GBC.eol());

        JosmTextField tfWmsUrl = new JosmTextField(30);

        String clip = Utils.getClipboardContent();
        clip = clip == null ? "" : clip.trim();
        ButtonGroup group = new ButtonGroup();

        JRadioButton firstBtn = null;
        for(RectifierService s : services) {
            JRadioButton serviceBtn = new JRadioButton(s.name);
            if(firstBtn == null) {
                firstBtn = serviceBtn;
            }
            // Checks clipboard contents against current service if no match has been found yet.
            // If the contents match, they will be inserted into the text field and the corresponding
            // service will be pre-selected.
            if(!clip.isEmpty() && tfWmsUrl.getText().isEmpty()
                    && (s.urlRegEx.matcher(clip).find() || s.idValidator.matcher(clip).matches())) {
                serviceBtn.setSelected(true);
                tfWmsUrl.setText(clip);
            }
            s.btn = serviceBtn;
            group.add(serviceBtn);
            if(!s.url.isEmpty()) {
                panel.add(serviceBtn, GBC.std());
                panel.add(new UrlLabel(s.url, tr("Visit Homepage")), GBC.eol().anchor(GridBagConstraints.EAST));
            } else {
                panel.add(serviceBtn, GBC.eol().anchor(GridBagConstraints.WEST));
            }
        }

        // Fallback in case no match was found
        if(tfWmsUrl.getText().isEmpty() && firstBtn != null) {
            firstBtn.setSelected(true);
        }

        panel.add(new JLabel(tr("WMS URL or Image ID:")), GBC.eol());
        panel.add(tfWmsUrl, GBC.eol().fill(GridBagConstraints.HORIZONTAL));

        ExtendedDialog diag = new ExtendedDialog(Main.parent,
                tr("Add Rectified Image"),

                new String[] {tr("Add Rectified Image"), tr("Cancel")});
        diag.setContent(panel);
        diag.setButtonIcons(new String[] {"OLmarker.png", "cancel.png"});

        // This repeatedly shows the dialog in case there has been an error.
        // The loop is break;-ed if the users cancels
        outer: while(true) {
            diag.showDialog();
            int answer = diag.getValue();
            // Break loop when the user cancels
            if(answer != 1) {
                break;
            }

            String text = tfWmsUrl.getText().trim();
            // Loop all services until we find the selected one
            for(RectifierService s : services) {
                if(!s.isSelected()) {
                    continue;
                }
View Full Code Here

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

        JCheckBox author = new JCheckBox(tr("Add author information"), Main.pref.getBoolean("lastAddAuthor", true));
        p.add(author, GBC.eol());
        JLabel nameLabel = new JLabel(tr("Real name"));
        p.add(nameLabel, GBC.std().insets(10, 0, 5, 0));
        JosmTextField authorName = new JosmTextField();
        p.add(authorName, GBC.eol().fill(GBC.HORIZONTAL));
        JLabel emailLabel = new JLabel(tr("E-Mail"));
        p.add(emailLabel, GBC.std().insets(10, 0, 5, 0));
        JosmTextField email = new JosmTextField();
        p.add(email, GBC.eol().fill(GBC.HORIZONTAL));
        JLabel copyrightLabel = new JLabel(tr("Copyright (URL)"));
        p.add(copyrightLabel, GBC.std().insets(10, 0, 5, 0));
        JosmTextField copyright = new JosmTextField();
        p.add(copyright, GBC.std().fill(GBC.HORIZONTAL));
        JButton predefined = new JButton(tr("Predefined"));
        p.add(predefined, GBC.eol().insets(5, 0, 0, 0));
        JLabel copyrightYearLabel = new JLabel(tr("Copyright year"));
        p.add(copyrightYearLabel, GBC.std().insets(10, 0, 5, 5));
        JosmTextField copyrightYear = new JosmTextField("");
        p.add(copyrightYear, GBC.eol().fill(GBC.HORIZONTAL));
        JLabel warning = new JLabel("<html><font size='-2'>&nbsp;</html");
        p.add(warning, GBC.eol().fill(GBC.HORIZONTAL).insets(15, 0, 0, 0));
        addDependencies(gpxData, author, authorName, email, copyright, predefined, copyrightYear, nameLabel, emailLabel,
                copyrightLabel, copyrightYearLabel, warning);

        p.add(new JLabel(tr("Keywords")), GBC.eol());
        JosmTextField keywords = new JosmTextField();
        keywords.setText((String) gpxData.attr.get(META_KEYWORDS));
        p.add(keywords, GBC.eop().fill(GBC.HORIZONTAL));

        ExtendedDialog ed = new ExtendedDialog(Main.parent,
                tr("Export options"),
                new String[] { tr("Export and Save"), tr("Cancel") });
        ed.setButtonIcons(new String[] { "exportgpx.png", "cancel.png" });
        ed.setContent(p);
        ed.showDialog();

        if (ed.getValue() != 1) {
            setCanceled(true);
            return;
        }
        setCanceled(false);

        Main.pref.put("lastAddAuthor", author.isSelected());
        if (authorName.getText().length() != 0) {
            Main.pref.put("lastAuthorName", authorName.getText());
        }
        if (copyright.getText().length() != 0) {
            Main.pref.put("lastCopyright", copyright.getText());
        }

        if (layer instanceof OsmDataLayer) {
            gpxData = ((OsmDataLayer) layer).toGpxData();
        } else if (layer instanceof GpxLayer) {
            gpxData = ((GpxLayer) layer).data;
        } else {
            gpxData = OsmDataLayer.toGpxData(getCurrentDataSet(), file);
        }

        // add author and copyright details to the gpx data
        if (author.isSelected()) {
            if (authorName.getText().length() > 0) {
                gpxData.attr.put(META_AUTHOR_NAME, authorName.getText());
                gpxData.attr.put(META_COPYRIGHT_AUTHOR, authorName.getText());
            }
            if (email.getText().length() > 0) {
                gpxData.attr.put(META_AUTHOR_EMAIL, email.getText());
            }
            if (copyright.getText().length() > 0) {
                gpxData.attr.put(META_COPYRIGHT_LICENSE, copyright.getText());
            }
            if (copyrightYear.getText().length() > 0) {
                gpxData.attr.put(META_COPYRIGHT_YEAR, copyrightYear.getText());
            }
        }

        // add the description to the gpx data
        if (desc.getText().length() > 0) {
            gpxData.attr.put(META_DESC, desc.getText());
        }

        // add keywords to the gpx data
        if (keywords.getText().length() > 0) {
            gpxData.attr.put(META_KEYWORDS, keywords.getText());
        }

       
        try (OutputStream fo = Compression.getCompressedFileOutputStream(file)) {
            new GpxWriter(fo).write(gpxData);
View Full Code Here

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

        pnl.add(new JLabel(tr("URL: ")), gc);

        gc.gridx = 1;
        gc.weightx = 1.0;
        gc.fill = GridBagConstraints.HORIZONTAL;
        pnl.add(tfUrl = new JosmTextField(), gc);
        tfUrl.getDocument().addDocumentListener(new ChangetQueryUrlValidator());
        tfUrl.addFocusListener(
                new FocusAdapter() {
                    @Override
                    public void focusGained(FocusEvent e) {
View Full Code Here

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

            gc.weightx = 0.0;
            gc.insets = new Insets(0,0,0,3);
            pnl.add(new JLabel(tr("User ID:")), gc);

            gc.gridx = 1;
            pnl.add(tfUid = new JosmTextField(10),gc);
            SelectAllOnFocusGainedDecorator.decorate(tfUid);
            valUid = UidInputFieldValidator.decorate(tfUid);

            // grab remaining space
            gc.gridx = 2;
View Full Code Here

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

            gc.weightx = 0.0;
            gc.insets = new Insets(0,0,0,3);
            pnl.add(new JLabel(tr("User name:")), gc);

            gc.gridx = 1;
            pnl.add(tfUserName = new JosmTextField(10),gc);
            SelectAllOnFocusGainedDecorator.decorate(tfUserName);
            valUserName = UserNameInputValidator.decorate(tfUserName);

            // grab remaining space
            gc.gridx = 2;
View Full Code Here

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

            gc.insets = new Insets(0,0,0,3);
            pnl.add(new JLabel(tr("Date: ")), gc);

            gc.gridx = 1;
            gc.weightx = 0.7;
            pnl.add(tfClosedAfterDate1 = new JosmTextField(),gc);
            SelectAllOnFocusGainedDecorator.decorate(tfClosedAfterDate1);
            valClosedAfterDate1 = DateValidator.decorate(tfClosedAfterDate1);
            tfClosedAfterDate1.setToolTipText(valClosedAfterDate1.getStandardTooltipTextAsHtml());

            gc.gridx = 2;
            gc.weightx = 0.0;
            pnl.add(new JLabel(tr("Time:")),gc);

            gc.gridx = 3;
            gc.weightx = 0.3;
            pnl.add(tfClosedAfterTime1 = new JosmTextField(),gc);
            SelectAllOnFocusGainedDecorator.decorate(tfClosedAfterTime1);
            valClosedAfterTime1 = TimeValidator.decorate(tfClosedAfterTime1);
            tfClosedAfterTime1.setToolTipText(valClosedAfterTime1.getStandardTooltipTextAsHtml());
            return pnl;
        }
View Full Code Here

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

            gc.insets = new Insets(0,0,0,3);
            pnl.add(new JLabel(tr("Date:")), gc);

            gc.gridx = 2;
            gc.weightx = 0.7;
            pnl.add(tfClosedAfterDate2 = new JosmTextField(),gc);
            SelectAllOnFocusGainedDecorator.decorate(tfClosedAfterDate2);
            valClosedAfterDate2 = DateValidator.decorate(tfClosedAfterDate2);
            tfClosedAfterDate2.setToolTipText(valClosedAfterDate2.getStandardTooltipTextAsHtml());
            gc.gridx = 3;
            gc.weightx = 0.0;
            pnl.add(new JLabel(tr("Time:")),gc);

            gc.gridx = 4;
            gc.weightx = 0.3;
            pnl.add(tfClosedAfterTime2 = new JosmTextField(),gc);
            SelectAllOnFocusGainedDecorator.decorate(tfClosedAfterTime2);
            valClosedAfterTime2 = TimeValidator.decorate(tfClosedAfterTime2);
            tfClosedAfterTime2.setToolTipText(valClosedAfterTime2.getStandardTooltipTextAsHtml());

            gc.gridy = 1;
            gc.gridx = 0;
            gc.fill = GridBagConstraints.HORIZONTAL;
            gc.weightx = 0.0;
            gc.insets = new Insets(0,0,0,3);
            pnl.add(new JLabel(tr("Created before - ")), gc);

            gc.gridx = 1;
            gc.fill = GridBagConstraints.HORIZONTAL;
            gc.weightx = 0.0;
            gc.insets = new Insets(0,0,0,3);
            pnl.add(new JLabel(tr("Date:")), gc);

            gc.gridx = 2;
            gc.weightx = 0.7;
            pnl.add(tfCreatedBeforeDate = new JosmTextField(),gc);
            SelectAllOnFocusGainedDecorator.decorate(tfCreatedBeforeDate);
            valCreatedBeforeDate = DateValidator.decorate(tfCreatedBeforeDate);
            tfCreatedBeforeDate.setToolTipText(valCreatedBeforeDate.getStandardTooltipTextAsHtml());

            gc.gridx = 3;
            gc.weightx = 0.0;
            pnl.add(new JLabel(tr("Time:")),gc);

            gc.gridx = 4;
            gc.weightx = 0.3;
            pnl.add(tfCreatedBeforeTime = new JosmTextField(),gc);
            SelectAllOnFocusGainedDecorator.decorate(tfCreatedBeforeTime);
            valCreatedBeforeTime = TimeValidator.decorate(tfCreatedBeforeTime);
            tfCreatedBeforeTime.setToolTipText(valCreatedBeforeDate.getStandardTooltipTextAsHtml());

            return pnl;
View Full Code Here

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

            gc.weightx = gc.weighty = 0.0;
            gc.fill = GridBagConstraints.NONE;
            gc.anchor = GridBagConstraints.WEST;
            panelTf.add(new JLabel(tr("Gps time (read from the above photo): ")), gc);

            tfGpsTime = new JosmTextField(12);
            tfGpsTime.setEnabled(false);
            tfGpsTime.setMinimumSize(new Dimension(155, tfGpsTime.getMinimumSize().height));
            gc.gridx = 1;
            gc.weightx = 1.0;
            gc.fill = GridBagConstraints.HORIZONTAL;
View Full Code Here

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

            timezone = parseTimezone(prefTimezone);
        } catch (ParseException e) {
            timezone = 0;
        }

        tfTimezone = new JosmTextField(10);
        tfTimezone.setText(formatTimezone(timezone));

        try {
            delta = parseOffset(Main.pref.get("geoimage.delta", "0"));
        } catch (ParseException e) {
            delta = 0;
        }
        delta = delta / 1000// milliseconds -> seconds

        tfOffset = new JosmTextField(10);
        tfOffset.setText(Long.toString(delta));

        JButton buttonViewGpsPhoto = new JButton(tr("<html>Use photo of an accurate clock,<br>"
                + "e.g. GPS receiver display</html>"));
        buttonViewGpsPhoto.setIcon(ImageProvider.get("clock"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.