Ignore:
Timestamp:
2009-01-10T20:32:33+01:00 (16 years ago)
Author:
hampelratte
Message:

made the display of button texts configurable

Location:
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/ConfigKeys.java

    r12778 r13135  
    11/* Copyright (c) 2008, Henrik Niehaus
    22 * All rights reserved.
    3  *
     3 * 
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are met:
    6  *
     6 * 
    77 * 1. Redistributions of source code must retain the above copyright notice,
    88 *    this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright notice,
    10  *    this list of conditions and the following disclaimer in the documentation
     9 * 2. Redistributions in binary form must reproduce the above copyright notice, 
     10 *    this list of conditions and the following disclaimer in the documentation 
    1111 *    and/or other materials provided with the distribution.
    12  * 3. Neither the name of the project nor the names of its
    13  *    contributors may be used to endorse or promote products derived from this
     12 * 3. Neither the name of the project nor the names of its 
     13 *    contributors may be used to endorse or promote products derived from this 
    1414 *    software without specific prior written permission.
    15  *
     15 * 
    1616 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1717 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     
    3636    public static final String OSB_NICKNAME = "osb.nickname";
    3737    public static final String OSB_AUTO_DOWNLOAD = "osb.auto_download";
     38    public static final String OSB_BUTTON_LABELS = "osb.button_labels";
    3839}
  • applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/OsbPlugin.java

    r12778 r13135  
    2828package org.openstreetmap.josm.plugins.osb;
    2929
    30 import static org.openstreetmap.josm.tools.I18n.tr;
    31 
    3230import java.awt.event.ActionEvent;
    3331import java.awt.event.ActionListener;
  • applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/OsbDialog.java

    r12778 r13135  
    11/* Copyright (c) 2008, Henrik Niehaus
    22 * All rights reserved.
    3  *
     3 * 
    44 * Redistribution and use in source and binary forms, with or without
    55 * modification, are permitted provided that the following conditions are met:
    6  *
     6 * 
    77 * 1. Redistributions of source code must retain the above copyright notice,
    88 *    this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright notice,
    10  *    this list of conditions and the following disclaimer in the documentation
     9 * 2. Redistributions in binary form must reproduce the above copyright notice, 
     10 *    this list of conditions and the following disclaimer in the documentation 
    1111 *    and/or other materials provided with the distribution.
    12  * 3. Neither the name of the project nor the names of its
    13  *    contributors may be used to endorse or promote products derived from this
     12 * 3. Neither the name of the project nor the names of its 
     13 *    contributors may be used to endorse or promote products derived from this 
    1414 *    software without specific prior written permission.
    15  *
     15 * 
    1616 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1717 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     
    6666import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    6767import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;
     68import org.openstreetmap.josm.plugins.osb.ConfigKeys;
    6869import org.openstreetmap.josm.plugins.osb.OsbObserver;
    6970import org.openstreetmap.josm.plugins.osb.OsbPlugin;
     
    8990    private JToggleButton newIssue = new JToggleButton();
    9091
     92    private boolean buttonLabels = Main.pref.getBoolean(ConfigKeys.OSB_BUTTON_LABELS);
     93
    9194    public OsbDialog(final OsbPlugin plugin) {
    9295        super(tr("Open OpenStreetBugs"), "icon_error22",
    93                 tr("Opens the OpenStreetBugs window and activates the automatic download"),
    94                 Shortcut.registerShortcut(
    95                         "view:openstreetbugs",
    96                         tr("Toggle: {0}", tr("Open OpenStreetBugs")),
    97                         KeyEvent.VK_O, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT),
    98                 150);
     96                tr("Open the OpenStreetBugs window and activates the automatic download"), Shortcut.registerShortcut(
     97                        "view:openstreetbugs", tr("Toggle: {0}", tr("Open OpenStreetBugs")), KeyEvent.VK_O,
     98                        Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), 150);
    9999
    100100        osbPlugin = plugin;
     
    109109
    110110        // create dialog buttons
    111         JPanel buttonPanel = new JPanel(new GridLayout(2, 2));
     111        GridLayout layout = buttonLabels ? new GridLayout(2, 2) : new GridLayout(1, 4);
     112        JPanel buttonPanel = new JPanel(layout);
    112113        add(buttonPanel, BorderLayout.SOUTH);
    113114        refresh = new JButton(tr("Refresh"));
    114115        refresh.setToolTipText(tr("Refresh"));
    115116        refresh.setIcon(OsbPlugin.loadIcon("view-refresh22.png"));
    116         refresh.setHorizontalAlignment(SwingConstants.LEFT);
    117117        refresh.addActionListener(new ActionListener() {
    118118
    119119            public void actionPerformed(ActionEvent e) {
    120120                // check zoom level
    121                 if(Main.map.mapView.zoom() > 15 || Main.map.mapView.zoom() < 9) {
     121                if (Main.map.mapView.zoom() > 15 || Main.map.mapView.zoom() < 9) {
    122122                    JOptionPane.showMessageDialog(Main.parent,
    123123                            tr("The visible area is either too small or too big to download data from OpenStreetBugs"),
    124                             tr("Warning"),
    125                             JOptionPane.INFORMATION_MESSAGE);
     124                            tr("Warning"), JOptionPane.INFORMATION_MESSAGE);
    126125                    return;
    127126                }
     
    134133        addComment.setToolTipText((String) addComment.getAction().getValue(Action.NAME));
    135134        addComment.setIcon(OsbPlugin.loadIcon("add_comment22.png"));
    136         addComment.setHorizontalAlignment(SwingConstants.LEFT);
    137135        closeIssue.setEnabled(false);
    138136        closeIssue.setToolTipText((String) closeIssue.getAction().getValue(Action.NAME));
    139137        closeIssue.setIcon(OsbPlugin.loadIcon("icon_valid22.png"));
    140         closeIssue.setHorizontalAlignment(SwingConstants.LEFT);
    141138        NewIssueAction nia = new NewIssueAction(newIssue, osbPlugin);
    142139        newIssue.setAction(nia);
    143140        newIssue.setToolTipText((String) newIssue.getAction().getValue(Action.NAME));
    144141        newIssue.setIcon(OsbPlugin.loadIcon("icon_error_add22.png"));
    145         newIssue.setHorizontalAlignment(SwingConstants.LEFT);
    146142
    147143        buttonPanel.add(refresh);
     
    149145        buttonPanel.add(addComment);
    150146        buttonPanel.add(closeIssue);
     147
     148        if (buttonLabels) {
     149            refresh.setHorizontalAlignment(SwingConstants.LEFT);
     150            addComment.setHorizontalAlignment(SwingConstants.LEFT);
     151            closeIssue.setHorizontalAlignment(SwingConstants.LEFT);
     152            newIssue.setHorizontalAlignment(SwingConstants.LEFT);
     153        } else {
     154            refresh.setText(null);
     155            addComment.setText(null);
     156            closeIssue.setText(null);
     157            newIssue.setText(null);
     158        }
    151159
    152160        // add a selection listener to the data
     
    158166                    for (int i = 0; i < model.getSize(); i++) {
    159167                        OsbListItem item = (OsbListItem) model.get(i);
    160                         if(item.getNode() == osmPrimitive) {
     168                        if (item.getNode() == osmPrimitive) {
    161169                            list.addSelectionInterval(i, i);
    162170                        }
     
    187195
    188196    public void valueChanged(ListSelectionEvent e) {
    189         if(list.getSelectedValues().length == 0) {
     197        if (list.getSelectedValues().length == 0) {
    190198            addComment.setEnabled(false);
    191199            closeIssue.setEnabled(false);
     
    218226
    219227    private void scrollToSelected(Node node) {
    220         for (int i = 0; i < model.getSize();i++) {
    221             Node current = ((OsbListItem)model.get(i)).getNode();
    222             if(current.id == node.id) {
     228        for (int i = 0; i < model.getSize(); i++) {
     229            Node current = ((OsbListItem) model.get(i)).getNode();
     230            if (current.id == node.id) {
    223231                list.scrollRectToVisible(list.getCellBounds(i, i));
    224232                list.setSelectedIndex(i);
     
    228236    }
    229237
    230     public void activeLayerChange(Layer oldLayer, Layer newLayer) {}
     238    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     239    }
    231240
    232241    public void layerAdded(Layer newLayer) {
    233         if(newLayer == osbPlugin.getLayer()) {
     242        if (newLayer == osbPlugin.getLayer()) {
    234243            update(osbPlugin.getDataSet());
    235244            Main.map.mapView.moveLayer(newLayer, 0);
     
    238247
    239248    public void layerRemoved(Layer oldLayer) {
    240         if(oldLayer == osbPlugin.getLayer()) {
     249        if (oldLayer == osbPlugin.getLayer()) {
    241250            model.removeAllElements();
    242251        }
     
    253262
    254263    public void mouseClicked(MouseEvent e) {
    255         if(e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
    256             OsbListItem item = (OsbListItem)list.getSelectedValue();
     264        if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
     265            OsbListItem item = (OsbListItem) list.getSelectedValue();
    257266            zoomToNode(item.getNode());
    258267        }
     
    268277
    269278    private void mayTriggerPopup(MouseEvent e) {
    270         if(e.isPopupTrigger()) {
     279        if (e.isPopupTrigger()) {
    271280            int selectedRow = list.locationToIndex(e.getPoint());
    272281            list.setSelectedIndex(selectedRow);
    273             Node n = ((OsbListItem)list.getSelectedValue()).getNode();
     282            Node n = ((OsbListItem) list.getSelectedValue()).getNode();
    274283            OsbAction.setSelectedNode(n);
    275284            PopupFactory.createPopup(n).show(e.getComponent(), e.getX(), e.getY());
     
    277286    }
    278287
    279     public void mouseEntered(MouseEvent e) {}
    280 
    281     public void mouseExited(MouseEvent e) {}
     288    public void mouseEntered(MouseEvent e) {
     289    }
     290
     291    public void mouseExited(MouseEvent e) {
     292    }
    282293
    283294    public void actionPerformed(OsbAction action) {
    284         if(action instanceof AddCommentAction || action instanceof CloseIssueAction) {
     295        if (action instanceof AddCommentAction || action instanceof CloseIssueAction) {
    285296            update(osbPlugin.getDataSet());
    286297        }
     
    292303            String state1 = o1.get("state");
    293304            String state2 = o2.get("state");
    294             if(state1.equals(state2)) {
     305            if (state1.equals(state2)) {
    295306                return o1.get("note").compareTo(o2.get("note"));
    296307            }
Note: See TracChangeset for help on using the changeset viewer.