Ticket #12536: 12536.2.patch
| File 12536.2.patch, 3.3 KB (added by , 6 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
11 11 import java.awt.FlowLayout; 12 12 import java.awt.GraphicsEnvironment; 13 13 import java.awt.event.ActionEvent; 14 import java.awt.event.WindowAdapter;15 import java.awt.event.WindowEvent;16 14 import java.beans.PropertyChangeEvent; 17 15 import java.beans.PropertyChangeListener; 18 16 import java.util.Collection; … … 182 180 protected final void build() { 183 181 getContentPane().setLayout(new BorderLayout()); 184 182 updateTitle(); 185 spTagConflictTypes = new AutoAdjustingSplitPane(JSplitPane.VERTICAL_SPLIT); 183 spTagConflictTypes = new AutoAdjustingSplitPane(JSplitPane.VERTICAL_SPLIT) { 184 @Override 185 public void propertyChange(PropertyChangeEvent evt) { 186 // see #12536 187 if (JSplitPane.DIVIDER_LOCATION_PROPERTY.equals(evt.getPropertyName())) { 188 adjustDividerLocation(); 189 } 190 super.propertyChange(evt); 191 } 192 }; 186 193 spTagConflictTypes.setTopComponent(buildTagConflictResolverPanel()); 187 194 spTagConflictTypes.setBottomComponent(buildRelationMemberConflictResolverPanel()); 188 195 pnlButtons = buildButtonPanel(); 189 196 getContentPane().add(pnlButtons, BorderLayout.SOUTH); 190 addWindowListener(new AdjustDividerLocationAction());191 197 HelpUtil.setHelpContext(getRootPane(), ht("/")); 192 198 InputMapUtils.addEscapeAction(getRootPane(), new CancelAction()); 193 199 } … … 343 349 } 344 350 345 351 getContentPane().add(pnlButtons, BorderLayout.SOUTH); 346 validate();352 getContentPane().validate(); 347 353 adjustDividerLocation(); 348 354 pnlRelationMemberConflictResolver.prepareForEditing(); 349 355 } … … 444 450 private void adjustDividerLocation() { 445 451 int numTagDecisions = modelTagConflictResolver.getNumDecisions(); 446 452 int numRelationDecisions = modelRelConflictResolver.getNumDecisions(); 447 if (numTagDecisions > 0 && numRelationDecisions > 0) {448 double nTop = 1.0 + numTagDecisions;449 double nBottom = 2.5 + numRelationDecisions;450 spTagConflictTypes.setDividerLocation(nTop/(nTop+nBottom));451 }452 }453 453 454 class AdjustDividerLocationAction extends WindowAdapter { 455 @Override 456 public void windowOpened(WindowEvent e) { 457 adjustDividerLocation(); 454 455 if (numTagDecisions > 0 && numRelationDecisions > 0 && getHeight() > 0) { 456 // see #12536: Take the space for buttons and checkbox into account. 457 double hPopup = getHeight(); 458 double h1 = (pnlRelationMemberConflictResolver.getHeight() + pnlTagConflictResolver.getHeight()); 459 double correction = h1 > 0 ? ((hPopup-h1)/hPopup) : 0; 460 461 double nTop = 3.5 + numTagDecisions; 462 double nBottom = 5.5 + numRelationDecisions; 463 spTagConflictTypes.setDividerLocation(nTop/(nTop+nBottom) - correction); 458 464 } 459 465 } 460 466
