Changeset 4948 in josm for trunk/src


Ignore:
Timestamp:
2012-02-15T23:19:43+01:00 (12 years ago)
Author:
xeen
Message:

fix #5117 – the selection buffer (middle mouse paste) on *nix systems shouldn’t be overwritten anymore by the search oder add/edit properties dialog. Please reopen the ticket, if there are any more occurences.

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r4842 r4948  
    33
    44import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    5 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences.ActionParser;
    65import static org.openstreetmap.josm.tools.I18n.tr;
    76import static org.openstreetmap.josm.tools.I18n.trc;
     
    3534import org.openstreetmap.josm.Main;
    3635import org.openstreetmap.josm.actions.ActionParameter;
    37 import org.openstreetmap.josm.actions.ActionParameter.SearchSettingsActionParameter;
    3836import org.openstreetmap.josm.actions.JosmAction;
    3937import org.openstreetmap.josm.actions.ParameterizedAction;
     38import org.openstreetmap.josm.actions.ActionParameter.SearchSettingsActionParameter;
    4039import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    4140import org.openstreetmap.josm.data.osm.DataSet;
     
    4443import org.openstreetmap.josm.gui.ExtendedDialog;
    4544import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
     45import org.openstreetmap.josm.gui.preferences.ToolbarPreferences.ActionParser;
    4646import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    4747import org.openstreetmap.josm.tools.GBC;
     
    211211        final HistoryComboBox hcbSearchString = new HistoryComboBox();
    212212        hcbSearchString.setText(initialValues.text);
    213         hcbSearchString.getEditor().selectAll();
    214         hcbSearchString.getEditor().getEditorComponent().requestFocusInWindow();
    215213        hcbSearchString.setToolTipText(tr("Enter the search expression"));
    216214        // we have to reverse the history, because ComboBoxHistory will reverse it again
     
    251249            left.add(allElements, GBC.eol());
    252250            left.add(regexSearch, GBC.eol());
    253             left.add(addOnToolbar, GBC.eol()); 
     251            left.add(addOnToolbar, GBC.eol());
    254252        }
    255253
     
    309307        initialValues.allElements = allElements.isSelected();
    310308        initialValues.regexSearch = regexSearch.isSelected();
    311        
     309
    312310        if (addOnToolbar.isSelected()) {
    313             ToolbarPreferences.ActionDefinition aDef = 
     311            ToolbarPreferences.ActionDefinition aDef =
    314312                    new ToolbarPreferences.ActionDefinition(Main.main.menu.search);
    315313            aDef.getParameters().put("searchExpression", initialValues);
     
    317315            ActionParser actionParser = new ToolbarPreferences.ActionParser(null);
    318316            String res = actionParser.saveAction(aDef);
    319            
     317
    320318            Collection<String> t = new LinkedList<String>(ToolbarPreferences.getToolString());
    321319            // add custom search button to toolbar preferences
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r4947 r4948  
    77import java.awt.BorderLayout;
    88import java.awt.Component;
    9 import java.awt.Dialog.ModalityType;
    109import java.awt.Dimension;
    1110import java.awt.Font;
    1211import java.awt.GridBagLayout;
    1312import java.awt.Point;
     13import java.awt.Toolkit;
     14import java.awt.Dialog.ModalityType;
     15import java.awt.datatransfer.Clipboard;
     16import java.awt.datatransfer.Transferable;
    1417import java.awt.event.ActionEvent;
    1518import java.awt.event.ActionListener;
     
    3336import java.util.List;
    3437import java.util.Map;
    35 import java.util.Map.Entry;
    3638import java.util.Set;
    3739import java.util.TreeMap;
    3840import java.util.TreeSet;
    3941import java.util.Vector;
     42import java.util.Map.Entry;
    4043
    4144import javax.swing.AbstractAction;
     
    8588import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
    8689import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
     90import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
    8791import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
    88 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
    8992import org.openstreetmap.josm.gui.DefaultNameFormatter;
    9093import org.openstreetmap.josm.gui.ExtendedDialog;
     
    302305        final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) {
    303306            @Override public void selectInitialValue() {
     307                // save unix system selection (middle mouse paste)
     308                Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();
     309                if(sysSel != null) {
     310                    Transferable old = sysSel.getContents(null);
    304311                values.requestFocusInWindow();
    305312                values.getEditor().selectAll();
     313                    sysSel.setContents(old, null);
     314                } else {
     315                    values.requestFocusInWindow();
     316                    values.getEditor().selectAll();
     317                }
    306318            }
    307319        };
     
    498510        JOptionPane pane = new JOptionPane(p, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION){
    499511            @Override public void selectInitialValue() {
     512                // save unix system selection (middle mouse paste)
     513                Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();
     514                if(sysSel != null) {
     515                    Transferable old = sysSel.getContents(null);
    500516                keys.requestFocusInWindow();
    501517                keys.getEditor().selectAll();
     518                    sysSel.setContents(old, null);
     519                } else {
     520                    keys.requestFocusInWindow();
     521                    keys.getEditor().selectAll();
     522                }
    502523            }
    503524        };
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java

    r4576 r4948  
    33
    44import java.awt.Component;
     5import java.awt.Toolkit;
     6import java.awt.datatransfer.Clipboard;
     7import java.awt.datatransfer.Transferable;
    58import java.awt.event.FocusEvent;
    69import java.awt.event.FocusListener;
     
    2831
    2932    private boolean autocompleteEnabled = true;
    30    
     33
    3134    private int maxTextLength = -1;
    3235
     
    5356            if (selecting || (offs == 0 && str.equals(getText(0, getLength()))))
    5457                return;
    55             if (maxTextLength > -1 && str.length()+getLength() > maxTextLength) {
    56                 return;
    57             }
     58            if (maxTextLength > -1 && str.length()+getLength() > maxTextLength)
     59                return;
    5860            boolean initial = (offs == 0 && getLength() == 0 && str.length() > 1);
    5961            super.insertString(offs, str, a);
     
    110112            }
    111113            JTextComponent editor = (JTextComponent)comboBox.getEditor().getEditorComponent();
    112             editor.setSelectionStart(start);
    113             editor.setSelectionEnd(end);
     114            // save unix system selection (middle mouse paste)
     115            Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();
     116            if(sysSel != null) {
     117                Transferable old = sysSel.getContents(null);
     118                editor.select(start, end);
     119                sysSel.setContents(old, null);
     120            } else {
     121                editor.select(start, end);
     122            }
    114123        }
    115124
     
    125134            for (int i = 0, n = model.getSize(); i < n; i++) {
    126135                AutoCompletionListItem currentItem = (AutoCompletionListItem) model.getElementAt(i);
    127                 if (currentItem.getValue().equals(pattern)) {
     136                if (currentItem.getValue().equals(pattern))
    128137                    return currentItem;
    129                 }
    130138                if (!match && currentItem.getValue().startsWith(pattern)) {
    131139                    if (bestItem == null || currentItem.getPriority().compareTo(bestItem.getPriority()) > 0) {
     
    147155                    }
    148156                    public void focusGained(FocusEvent e) {
     157                        // save unix system selection (middle mouse paste)
     158                        Clipboard sysSel = Toolkit.getDefaultToolkit().getSystemSelection();
     159                        if(sysSel != null) {
     160                            Transferable old = sysSel.getContents(null);
    149161                        editor.selectAll();
     162                            sysSel.setContents(old, null);
     163                        } else {
     164                            editor.selectAll();
     165                        }
    150166                    }
    151167                }
     
    154170        setMaximumRowCount(maxsize);
    155171    }
    156    
     172
    157173    public void setMaxTextLength(int length)
    158174    {
     
    212228            model.addElement(new AutoCompletionListItem(elem, AutoCompletionItemPritority.UNKNOWN));
    213229        }
     230        // disable autocomplete to prevent unnecessary actions in
     231        // AutoCompletingComboBoxDocument#insertString
     232        autocompleteEnabled = false;
    214233        this.getEditor().setItem(oldValue);
     234        autocompleteEnabled = true;
    215235    }
    216236
Note: See TracChangeset for help on using the changeset viewer.