reflow text to new width

This commit is contained in:
Dennis Ushakov
2018-02-09 17:21:03 +03:00
parent 667676d56d
commit 93a300f3e6
@@ -778,7 +778,6 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
myEditorPane.setCaretPosition(0);
}});
}
private void showHint() {
Editor editor = myManager.getEditor();
Component popupAnchor = getPopupAnchor(editor);
@@ -789,9 +788,14 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
Dimension preferredSize = myEditorPane.getPreferredSize();
int width = definitionPreferredWidth();
width = width < 0 ? preferredSize.width : width;
width = Math.min(maxWidth, Math.max(JBUI.scale(300), width));
myEditorPane.setBounds(0, 0, width, MAX_DEFAULT.height);
myEditorPane.setText(myEditorPane.getText());
preferredSize = myEditorPane.getPreferredSize();
int height = preferredSize.height + (needsToolbar() ? myControlPanel.getPreferredSize().height : 0);
hintSize = new Dimension(Math.min(maxWidth, Math.max(JBUI.scale(300), width)),
Math.min(MAX_DEFAULT.height, Math.max(MIN_DEFAULT.height, height)));
height = Math.min(MAX_DEFAULT.height, Math.max(MIN_DEFAULT.height, height));
hintSize = new Dimension(width, height);
} else {
hintSize = DimensionService.getInstance().getSize(DocumentationManager.NEW_JAVADOC_LOCATION_AND_SIZE, myManager.myProject);
hintSize = hintSize != null ? hintSize : MIN_DEFAULT;
@@ -883,7 +887,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
}
myIsShown = true;
if (myHint.getDimensionServiceKey() == null) {
SwingUtilities.invokeLater(() -> registerSizeTracker());
SwingUtilities.invokeLater(this::registerSizeTracker);
}
}
}