Changeset 10611 in josm for trunk/src/org/openstreetmap/josm/gui/widgets
- Timestamp:
- 2016-07-23T18:46:45+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/widgets
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/widgets/DateEditorWithSlider.java
r9078 r10611 16 16 import javax.swing.JSpinner; 17 17 import javax.swing.SpinnerDateModel; 18 import javax.swing.event.ChangeEvent;19 18 import javax.swing.event.ChangeListener; 20 19 … … 52 51 53 52 slider = new JSlider(0, MAX_SLIDER); 54 spinner.addChangeListener(new ChangeListener() { 55 @Override 56 public void stateChanged(ChangeEvent e) { 57 int i = slider.getValue(); 58 Date d = (Date) spinner.getValue(); 59 int j = intFromDate(d); 60 if (i != j) { 61 watchSlider = false; 62 slider.setValue(j); 63 watchSlider = true; 64 } 65 for (ChangeListener l : listeners) { 66 l.stateChanged(e); 67 } 53 spinner.addChangeListener(e -> { 54 int i = slider.getValue(); 55 Date d = (Date) spinner.getValue(); 56 int j = intFromDate(d); 57 if (i != j) { 58 watchSlider = false; 59 slider.setValue(j); 60 watchSlider = true; 61 } 62 for (ChangeListener l : listeners) { 63 l.stateChanged(e); 68 64 } 69 65 }); 70 slider.addChangeListener(new ChangeListener() { 71 @Override 72 public void stateChanged(ChangeEvent e) { 73 if (!watchSlider) return; 74 Date d = (Date) spinner.getValue(); 75 Date d1 = dateFromInt(slider.getValue()); 76 if (!d.equals(d1)) { 77 spinner.setValue(d1); 78 } 66 slider.addChangeListener(e -> { 67 if (!watchSlider) return; 68 Date d = (Date) spinner.getValue(); 69 Date d1 = dateFromInt(slider.getValue()); 70 if (!d.equals(d1)) { 71 spinner.setValue(d1); 79 72 } 80 73 }); -
trunk/src/org/openstreetmap/josm/gui/widgets/EditableList.java
r8509 r10611 7 7 import java.awt.Dimension; 8 8 import java.awt.GridBagLayout; 9 import java.awt.event.ActionEvent;10 import java.awt.event.ActionListener;11 9 import java.util.ArrayList; 12 10 import java.util.List; … … 46 44 setLayout(new BorderLayout()); 47 45 48 addSrcButton.addActionListener(new ActionListener() { 49 @Override 50 public void actionPerformed(ActionEvent e) { 51 String source = JOptionPane.showInputDialog( 52 Main.parent, 46 addSrcButton.addActionListener(e -> { 47 String source = JOptionPane.showInputDialog( 48 Main.parent, 49 title, 50 title, 51 JOptionPane.QUESTION_MESSAGE); 52 if (source != null) { 53 ((DefaultListModel<String>) sourcesList.getModel()).addElement(source); 54 } 55 sourcesList.clearSelection(); 56 }); 57 58 editSrcButton.addActionListener(e -> { 59 int row = sourcesList.getSelectedIndex(); 60 if (row == -1 && sourcesList.getModel().getSize() == 1) { 61 sourcesList.setSelectedIndex(0); 62 row = 0; 63 } 64 if (row == -1) { 65 if (sourcesList.getModel().getSize() == 0) { 66 String source1 = JOptionPane.showInputDialog(Main.parent, title, title, JOptionPane.QUESTION_MESSAGE); 67 if (source1 != null) { 68 ((DefaultListModel<String>) sourcesList.getModel()).addElement(source1); 69 } 70 } else { 71 JOptionPane.showMessageDialog( 72 Main.parent, 73 tr("Please select the row to edit."), 74 tr("Information"), 75 JOptionPane.INFORMATION_MESSAGE 76 ); 77 } 78 } else { 79 String source2 = (String) JOptionPane.showInputDialog(Main.parent, 53 80 title, 54 81 title, 55 JOptionPane.QUESTION_MESSAGE); 56 if (source != null) { 57 ((DefaultListModel<String>) sourcesList.getModel()).addElement(source); 82 JOptionPane.QUESTION_MESSAGE, null, null, 83 sourcesList.getSelectedValue()); 84 if (source2 != null) { 85 ((DefaultListModel<String>) sourcesList.getModel()).setElementAt(source2, row); 58 86 } 59 sourcesList.clearSelection();60 87 } 88 sourcesList.clearSelection(); 61 89 }); 62 90 63 editSrcButton.addActionListener(new ActionListener() { 64 @Override 65 public void actionPerformed(ActionEvent e) { 66 int row = sourcesList.getSelectedIndex(); 67 if (row == -1 && sourcesList.getModel().getSize() == 1) { 68 sourcesList.setSelectedIndex(0); 69 row = 0; 70 } 71 if (row == -1) { 72 if (sourcesList.getModel().getSize() == 0) { 73 String source = JOptionPane.showInputDialog(Main.parent, title, title, JOptionPane.QUESTION_MESSAGE); 74 if (source != null) { 75 ((DefaultListModel<String>) sourcesList.getModel()).addElement(source); 76 } 77 } else { 78 JOptionPane.showMessageDialog( 79 Main.parent, 80 tr("Please select the row to edit."), 81 tr("Information"), 82 JOptionPane.INFORMATION_MESSAGE 83 ); 84 } 85 } else { 86 String source = (String) JOptionPane.showInputDialog(Main.parent, 87 title, 88 title, 89 JOptionPane.QUESTION_MESSAGE, null, null, 90 sourcesList.getSelectedValue()); 91 if (source != null) { 92 ((DefaultListModel<String>) sourcesList.getModel()).setElementAt(source, row); 93 } 94 } 95 sourcesList.clearSelection(); 96 } 97 }); 98 99 deleteSrcButton.addActionListener(new ActionListener() { 100 @Override 101 public void actionPerformed(ActionEvent e) { 102 if (sourcesList.getSelectedIndex() == -1) { 103 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete."), tr("Information"), 104 JOptionPane.QUESTION_MESSAGE); 105 } else { 106 ((DefaultListModel<String>) sourcesList.getModel()).remove(sourcesList.getSelectedIndex()); 107 } 91 deleteSrcButton.addActionListener(e -> { 92 if (sourcesList.getSelectedIndex() == -1) { 93 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete."), tr("Information"), 94 JOptionPane.QUESTION_MESSAGE); 95 } else { 96 ((DefaultListModel<String>) sourcesList.getModel()).remove(sourcesList.getSelectedIndex()); 108 97 } 109 98 }); -
trunk/src/org/openstreetmap/josm/gui/widgets/NativeFileChooser.java
r10001 r10611 98 98 @Override 99 99 public void setFileFilter(final FileFilter cff) { 100 FilenameFilter filter = new FilenameFilter() { 101 @Override 102 public boolean accept(File directory, String fileName) { 103 return cff.accept(new File(directory.getAbsolutePath() + fileName)); 104 } 105 }; 100 FilenameFilter filter = (directory, fileName) -> cff.accept(new File(directory.getAbsolutePath() + fileName)); 106 101 fileDialog.setFilenameFilter(filter); 107 102 fileFilter = cff; -
trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
r10428 r10611 8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.KeyEvent; 10 import java.beans.PropertyChangeEvent;11 10 import java.beans.PropertyChangeListener; 12 11 … … 17 16 import javax.swing.JPopupMenu; 18 17 import javax.swing.KeyStroke; 19 import javax.swing.event.UndoableEditEvent;20 18 import javax.swing.event.UndoableEditListener; 21 19 import javax.swing.text.DefaultEditorKit; … … 51 49 protected final UndoManager undo = new UndoManager(); 52 50 53 protected final transient UndoableEditListener undoEditListener = new UndoableEditListener() { 54 @Override 55 public void undoableEditHappened(UndoableEditEvent e) { 56 undo.addEdit(e.getEdit()); 57 undoAction.updateUndoState(); 58 redoAction.updateRedoState(); 59 } 51 protected final transient UndoableEditListener undoEditListener = e -> { 52 undo.addEdit(e.getEdit()); 53 undoAction.updateUndoState(); 54 redoAction.updateRedoState(); 60 55 }; 61 56 62 protected final transient PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { 63 @Override 64 public void propertyChange(PropertyChangeEvent evt) { 65 if (EDITABLE.equals(evt.getPropertyName())) { 66 removeAll(); 67 addMenuEntries(); 68 } 57 protected final transient PropertyChangeListener propertyChangeListener = evt -> { 58 if (EDITABLE.equals(evt.getPropertyName())) { 59 removeAll(); 60 addMenuEntries(); 69 61 } 70 62 };
Note:
See TracChangeset
for help on using the changeset viewer.