Changeset 14418 in josm for trunk/src/org
- Timestamp:
- 2018-11-07T22:38:38+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/download
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r14391 r14418 11 11 import java.awt.GridBagLayout; 12 12 import java.awt.event.ActionEvent; 13 import java.awt.event.ComponentAdapter; 14 import java.awt.event.ComponentEvent; 13 15 import java.awt.event.InputEvent; 14 16 import java.awt.event.KeyEvent; … … 655 657 private DownloadSourceSizingPolicy policy; 656 658 private final JTabbedPane topComponent; 659 /** 660 * If the height was explicitly set by the user. 661 */ 662 private boolean heightAdjustedExplicitly; 657 663 658 664 DownloadDialogSplitPane(JTabbedPane newTopComponent, Component newBottomComponent) { 659 665 super(VERTICAL_SPLIT, newTopComponent, newBottomComponent); 660 666 this.topComponent = newTopComponent; 667 668 addComponentListener(new ComponentAdapter() { 669 @Override 670 public void componentResized(ComponentEvent e) { 671 // doLayout is called automatically when the component size decreases 672 // This seems to be the only way to call doLayout when the component size increases 673 // We need this since we sometimes want to increase the top component size. 674 revalidate(); 675 } 676 }); 677 678 addPropertyChangeListener(DIVIDER_LOCATION_PROPERTY, e -> { 679 heightAdjustedExplicitly = true; 680 }); 661 681 } 662 682 … … 674 694 // We cannot do this in the setDividerLocation, since the offset cannot be computed there. 675 695 int offset = computeOffset(); 676 if (policy.isHeightAdjustable() ) {696 if (policy.isHeightAdjustable() && heightAdjustedExplicitly) { 677 697 policy.storeHeight(Math.max(getDividerLocation() - offset, 0)); 678 698 } 679 super.setDividerLocation(policy.getComponentHeight() + offset); 699 // At least 30 pixel for map, if we have enough space 700 int maxValidDividerLocation = getHeight() > 150 ? getHeight() - 40 : getHeight(); 701 702 super.setDividerLocation(Math.min(policy.getComponentHeight() + offset, maxValidDividerLocation)); 680 703 super.doLayout(); 704 // Order is important (set this after setDividerLocation/doLayout called the listener) 705 this.heightAdjustedExplicitly = false; 681 706 } 682 707 -
trunk/src/org/openstreetmap/josm/gui/download/DownloadSourceSizingPolicy.java
r12707 r14418 3 3 4 4 import java.awt.Component; 5 import java.util.function.IntSupplier; 5 6 6 7 import org.openstreetmap.josm.data.preferences.AbstractProperty; … … 67 68 68 69 private final AbstractProperty<Integer> preference; 70 private IntSupplier minHeight; 69 71 70 72 /** 71 73 * Create a new {@link AdjustableDownloadSizePolicy} 72 * @param preference The preference keyto use74 * @param preference The preference to use 73 75 */ 74 76 public AdjustableDownloadSizePolicy(AbstractProperty<Integer> preference) { 77 this(preference, () -> 1); 78 } 79 80 /** 81 * Create a new {@link AdjustableDownloadSizePolicy} 82 * @param preference The preference to use 83 * @param minHeight A supplier that gives the minimum height of the component. Must be positive or 0. 84 * @since 14418 85 */ 86 public AdjustableDownloadSizePolicy(AbstractProperty<Integer> preference, IntSupplier minHeight) { 75 87 this.preference = preference; 88 this.minHeight = minHeight; 76 89 } 77 90 78 91 @Override 79 92 public int getComponentHeight() { 80 return Math.max(1, preference.get()); 93 int computedMinHeight = this.minHeight.getAsInt(); 94 if (computedMinHeight < 0) { 95 throw new IllegalStateException("Illegal minimum component height:" + computedMinHeight); 96 } 97 return Math.max(computedMinHeight, preference.get()); 81 98 } 82 99 -
trunk/src/org/openstreetmap/josm/gui/download/OverpassDownloadSource.java
r13930 r14418 16 16 17 17 import javax.swing.AbstractAction; 18 import javax.swing.BorderFactory; 18 19 import javax.swing.Icon; 19 20 import javax.swing.JButton; … … 164 165 .forEach(button -> leftPanel.add(button, GBC.eol().anchor(GBC.CENTER))); 165 166 leftPanel.add(new JLabel(), GBC.eol().fill(GBC.VERTICAL)); 167 leftPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 166 168 167 169 add(leftPanel, BorderLayout.WEST); … … 285 287 @Override 286 288 public DownloadSourceSizingPolicy getSizingPolicy() { 287 return new AdjustableDownloadSizePolicy(PANEL_SIZE_PROPERTY );289 return new AdjustableDownloadSizePolicy(PANEL_SIZE_PROPERTY, () -> 50); 288 290 } 289 291
Note:
See TracChangeset
for help on using the changeset viewer.