Changeset 17768 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2021-04-13T18:05:39+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
r17714 r17768 53 53 import org.openstreetmap.josm.gui.util.DocumentAdapter; 54 54 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField; 55 import org.openstreetmap.josm.gui.widgets.FilterField; 55 56 import org.openstreetmap.josm.gui.widgets.JosmTextField; 56 57 import org.openstreetmap.josm.spi.preferences.Config; … … 233 234 private JosmTextField setupFilter() { 234 235 final JosmTextField f = new DisableShortcutsOnFocusGainedTextField(); 236 FilterField.setSearchIcon(f); 235 237 f.setToolTipText(tr("Note filter")); 236 238 f.getDocument().addDocumentListener(DocumentAdapter.create(ignore -> { -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r17422 r17768 85 85 import org.openstreetmap.josm.gui.widgets.CompileSearchTextDecorator; 86 86 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField; 87 import org.openstreetmap.josm.gui.widgets.FilterField; 87 88 import org.openstreetmap.josm.gui.widgets.JosmTextField; 88 89 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; … … 322 323 private JosmTextField setupFilter() { 323 324 final JosmTextField f = new DisableShortcutsOnFocusGainedTextField(); 325 FilterField.setSearchIcon(f); 324 326 f.setToolTipText(tr("Relation list filter")); 325 327 final CompileSearchTextDecorator decorator = CompileSearchTextDecorator.decorate(f); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r17585 r17768 107 107 import org.openstreetmap.josm.gui.widgets.CompileSearchTextDecorator; 108 108 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField; 109 import org.openstreetmap.josm.gui.widgets.FilterField; 109 110 import org.openstreetmap.josm.gui.widgets.JosmTextField; 110 111 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; … … 544 545 private JosmTextField setupFilter() { 545 546 final JosmTextField f = new DisableShortcutsOnFocusGainedTextField(); 547 FilterField.setSearchIcon(f); 546 548 f.setToolTipText(tr("Tag filter")); 547 549 final CompileSearchTextDecorator decorator = CompileSearchTextDecorator.decorate(f); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r17713 r17768 27 27 import javax.swing.JButton; 28 28 import javax.swing.JFileChooser; 29 import javax.swing.JLabel;30 29 import javax.swing.JMenu; 31 30 import javax.swing.JOptionPane; … … 54 53 import org.openstreetmap.josm.gui.util.GuiHelper; 55 54 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 55 import org.openstreetmap.josm.gui.widgets.FilterField; 56 56 import org.openstreetmap.josm.gui.widgets.JosmTextField; 57 57 import org.openstreetmap.josm.spi.preferences.Config; … … 168 168 final JPanel txtFilterPanel = new JPanel(new GridBagLayout()); 169 169 p.add(txtFilterPanel, GBC.eol().fill(GBC.HORIZONTAL)); 170 txtFilter = new JosmTextField(); 171 JLabel lbFilter = new JLabel(tr("Search:")); 172 lbFilter.setLabelFor(txtFilter); 173 txtFilterPanel.add(lbFilter, GBC.std().insets(0, 0, 5, 0)); 174 txtFilterPanel.add(txtFilter, GBC.eol().fill(GBC.HORIZONTAL)); 170 txtFilter = new FilterField(); 171 txtFilterPanel.add(txtFilter, GBC.eol().insets(0, 0, 0, 5).fill(GBC.HORIZONTAL)); 175 172 txtFilter.getDocument().addDocumentListener(DocumentAdapter.create(ignore -> applyFilter())); 176 173 readPreferences(Preferences.main()); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r17648 r17768 373 373 JPanel panel = new JPanel(new GridBagLayout()); 374 374 panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 375 panel.add(colorFilter, GBC.eol().fill(HORIZONTAL)); 375 panel.add(colorFilter, GBC.eol().insets(0, 0, 0, 5).fill(HORIZONTAL)); 376 376 JScrollPane scrollpane = new JScrollPane(colors); 377 377 scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r17332 r17768 9 9 import java.awt.BorderLayout; 10 10 import java.awt.Component; 11 import java.awt.GridBagConstraints;12 11 import java.awt.GridBagLayout; 13 12 import java.awt.GridLayout; 14 import java.awt.Insets;15 13 import java.awt.event.ActionEvent; 16 14 import java.awt.event.ComponentAdapter; … … 28 26 29 27 import javax.swing.AbstractAction; 30 import javax.swing.BorderFactory;31 28 import javax.swing.ButtonGroup; 32 29 import javax.swing.DefaultListModel; … … 167 164 private JPanel buildSearchFieldPanel() { 168 165 JPanel pnl = new JPanel(new GridBagLayout()); 169 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));170 GridBagConstraints gc = new GridBagConstraints();171 172 gc.anchor = GridBagConstraints.NORTHWEST;173 gc.fill = HORIZONTAL;174 gc.weightx = 0.0;175 gc.insets = new Insets(0, 0, 0, 3);176 166 pnl.add(GBC.glue(0, 0)); 177 167 178 gc.weightx = 1.0;179 168 ButtonGroup bg = new ButtonGroup(); 180 169 JPanel radios = new JPanel(); 181 addRadioButton(bg, radios, new JRadioButton(trc("plugins", "All"), true), gc, PluginInstallation.ALL); 182 addRadioButton(bg, radios, new JRadioButton(trc("plugins", "Installed")), gc, PluginInstallation.INSTALLED); 183 addRadioButton(bg, radios, new JRadioButton(trc("plugins", "Available")), gc, PluginInstallation.AVAILABLE); 184 pnl.add(radios, gc); 185 186 gc.gridx = 0; 187 gc.weightx = 0.0; 188 pnl.add(new JLabel(tr("Search:")), gc); 189 190 gc.gridx = 1; 191 gc.weightx = 1.0; 170 addRadioButton(bg, radios, new JRadioButton(trc("plugins", "All"), true), PluginInstallation.ALL); 171 addRadioButton(bg, radios, new JRadioButton(trc("plugins", "Installed")), PluginInstallation.INSTALLED); 172 addRadioButton(bg, radios, new JRadioButton(trc("plugins", "Available")), PluginInstallation.AVAILABLE); 173 pnl.add(radios, GBC.eol().fill(HORIZONTAL)); 174 192 175 pnl.add(new FilterField().filter(expr -> { 193 176 model.filterDisplayedPlugins(expr); 194 177 pnlPluginPreferences.refreshView(); 195 }), gc);178 }), GBC.eol().insets(0, 0, 0, 5).fill(HORIZONTAL)); 196 179 return pnl; 197 180 } 198 181 199 private void addRadioButton(ButtonGroup bg, JPanel pnl, JRadioButton rb, GridBagConstraints gc,PluginInstallation value) {182 private void addRadioButton(ButtonGroup bg, JPanel pnl, JRadioButton rb, PluginInstallation value) { 200 183 bg.add(rb); 201 pnl.add(rb, gc);184 pnl.add(rb, GBC.std()); 202 185 rb.addActionListener(e -> { 203 186 model.filterDisplayedPlugins(value); -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CodeSelectionPanel.java
r16960 r17768 23 23 import org.openstreetmap.josm.gui.preferences.projection.CodeProjectionChoice.CodeComparator; 24 24 import org.openstreetmap.josm.gui.util.TableHelper; 25 import org.openstreetmap.josm.gui.widgets.FilterField; 25 26 import org.openstreetmap.josm.gui.widgets.JosmTextField; 26 27 import org.openstreetmap.josm.tools.GBC; … … 32 33 public class CodeSelectionPanel extends JPanel implements ListSelectionListener, DocumentListener { 33 34 34 private final JosmTextField filter = new JosmTextField(30);35 private final JosmTextField filter = new FilterField(); 35 36 private final ProjectionCodeModel model = new ProjectionCodeModel(); 36 37 private JTable table; … … 104 105 105 106 this.setLayout(new GridBagLayout()); 106 this.add(filter, GBC.eol().weight(1.0, 0.0)); 107 this.add(filter, GBC.eol().fill(GBC.HORIZONTAL).weight(1.0, 0.0)); 107 108 this.add(scroll, GBC.eol().fill(GBC.HORIZONTAL)); 108 109 } -
trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java
r17733 r17768 8 8 import java.awt.Component; 9 9 import java.awt.Dimension; 10 import java.awt.GridBagConstraints;11 10 import java.awt.GridBagLayout; 12 11 import java.awt.GridLayout; 13 import java.awt.Insets;14 12 import java.awt.Toolkit; 15 13 import java.awt.event.KeyEvent; … … 21 19 22 20 import javax.swing.AbstractAction; 23 import javax.swing.BorderFactory;24 21 import javax.swing.BoxLayout; 25 22 import javax.swing.DefaultComboBoxModel; … … 44 41 import org.openstreetmap.josm.gui.widgets.FilterField; 45 42 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 43 import org.openstreetmap.josm.tools.GBC; 46 44 import org.openstreetmap.josm.tools.KeyboardUtils; 47 45 import org.openstreetmap.josm.tools.Logging; … … 251 249 // copied from PluginPreference 252 250 JPanel pnl = new JPanel(new GridBagLayout()); 253 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 254 GridBagConstraints gc = new GridBagConstraints(); 255 256 gc.anchor = GridBagConstraints.NORTHWEST; 257 gc.fill = GridBagConstraints.HORIZONTAL; 258 gc.weightx = 0.0; 259 gc.insets = new Insets(0, 0, 0, 5); 260 pnl.add(new JLabel(tr("Search:")), gc); 261 262 gc.gridx = 1; 263 gc.weightx = 1.0; 264 pnl.add(filterField, gc); 265 pnl.setMaximumSize(new Dimension(300, 10)); 251 pnl.add(filterField, GBC.eol().insets(0, 0, 0, 5).fill(GBC.HORIZONTAL)); 252 pnl.setMaximumSize(new Dimension(Integer.MAX_VALUE, 10)); 266 253 return pnl; 267 254 } -
trunk/src/org/openstreetmap/josm/gui/widgets/FilterField.java
r16643 r17768 18 18 import javax.swing.table.TableRowSorter; 19 19 20 import org.openstreetmap.josm.tools.ImageProvider; 20 21 import org.openstreetmap.josm.tools.Logging; 21 22 import org.openstreetmap.josm.tools.Utils; … … 31 32 */ 32 33 public FilterField() { 34 setSearchIcon(this); 33 35 setToolTipText(tr("Enter a search expression")); 34 36 SelectAllOnFocusGainedDecorator.decorate(this); 37 } 38 39 /** 40 * Sets the search icon for the given text field 41 * @param textField the text field 42 * @since 17768 43 */ 44 public static void setSearchIcon(JosmTextField textField) { 45 textField.setIcon(ImageProvider.get("listsearch")); 35 46 } 36 47 -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java
r14977 r17768 11 11 import java.awt.event.FocusListener; 12 12 13 import javax.swing.BorderFactory; 14 import javax.swing.Icon; 13 15 import javax.swing.JTextField; 16 import javax.swing.border.Border; 14 17 import javax.swing.text.Document; 15 18 … … 31 34 private final PopupMenuLauncher launcher; 32 35 private String hint; 36 private Icon icon; 37 private int leftInsets; 33 38 34 39 /** … … 149 154 150 155 /** 156 * Returns the icon to display 157 * @return the icon to display 158 * @since 17768 159 */ 160 public Icon getIcon() { 161 return icon; 162 } 163 164 /** 165 * Sets the icon to display 166 * @param icon the icon to set 167 * @since 17768 168 */ 169 public void setIcon(Icon icon) { 170 this.icon = icon; 171 if (icon != null) { 172 this.leftInsets = getInsets().left; 173 Border original = getBorder(); 174 Border margin = BorderFactory.createEmptyBorder(0, icon.getIconWidth(), 0, 0); 175 setBorder(original == null ? margin : BorderFactory.createCompoundBorder(original, margin)); 176 } 177 } 178 179 /** 151 180 * Empties the internal undo manager. 152 181 * @since 14977 … … 159 188 public void paint(Graphics g) { 160 189 super.paint(g); 190 if (icon != null) { 191 int h = getHeight() - icon.getIconHeight(); 192 icon.paintIcon(this, g, Math.min(leftInsets, h / 2), h / 2); 193 } 161 194 if (hint != null && !hint.isEmpty() && getText().isEmpty() && !isFocusOwner()) { 162 195 // Taken from http://stackoverflow.com/a/24571681/2257172 -
trunk/src/org/openstreetmap/josm/gui/widgets/SearchTextResultListPanel.java
r17713 r17768 43 43 super(new BorderLayout()); 44 44 45 edSearchText = new JosmTextField();45 edSearchText = new FilterField(); 46 46 edSearchText.getDocument().addDocumentListener(DocumentAdapter.create(ignore -> filterItems())); 47 47 edSearchText.addKeyListener(new KeyAdapter() {
Note:
See TracChangeset
for help on using the changeset viewer.