Replace calls to deprecated FontMetrics.getAverageCharWidth() with
FontMetrics.getAverageCharacterWidth()
diff --git a/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/actions/AdjustWidthHandler.java b/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/actions/AdjustWidthHandler.java
index 4814199..d883410 100644
--- a/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/actions/AdjustWidthHandler.java
+++ b/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/actions/AdjustWidthHandler.java
@@ -151,9 +151,9 @@
try {
gc.setFont(viewer.getTextWidget().getFont());
final FontMetrics fontMetrics = gc.getFontMetrics();
- final int charWidth = fontMetrics.getAverageCharWidth();
+ final double charWidth = fontMetrics.getAverageCharacterWidth();
final int clientWidth = viewer.getTextWidget().getClientArea().width;
- return clientWidth/charWidth;
+ return (int)(clientWidth / charWidth + 0x0.FFFFFp0);
}
finally {
gc.dispose();
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/intable/RTextPainter.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/intable/RTextPainter.java
index a450400..5e35d23 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/intable/RTextPainter.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/intable/RTextPainter.java
@@ -142,48 +142,4 @@
gc.setClipping(originalClipping);
}
- private void createCurrentTextToDisplay(final GC gc, final int width, final String originalText) {
- int textWidth= getWidthFromCache(gc, originalText);
- if (textWidth <= width + 1) {
- this.currentText= originalText;
- this.currentTextWidth= textWidth;
- return;
- }
-
- int textLength= originalText.length();
- int tooLong;
- String shortedText;
- do {
- tooLong= textLength;
- textLength -= Math.max((width + 1 - textWidth) / gc.getFontMetrics().getAverageCharWidth(), 1 );
- if (textLength <= 0) {
- textLength= 0;
- shortedText= EMPTY;
- break;
- }
- this.tempText.setLength(0);
- this.tempText.append(originalText.substring(0, textLength));
- this.tempText.append(DOT);
- shortedText= this.tempText.toString();
- textWidth= getWidthFromCache(gc, shortedText);
- } while (textWidth > width + 1);
-
- this.currentText= shortedText;
- this.currentTextWidth= textWidth;
- while (++textLength < tooLong) {
- this.tempText.setLength(0);
- this.tempText.append(originalText.substring(0, textLength));
- this.tempText.append(DOT);
- shortedText= this.tempText.toString();
- textWidth= getWidthFromCache(gc, shortedText);
- if (textWidth <= width + 1) {
- this.currentText= shortedText;
- this.currentTextWidth= textWidth;
- }
- else {
- return;
- }
- }
- }
-
}
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/rhelp/RHelpInfoHoverCreator.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/rhelp/RHelpInfoHoverCreator.java
index 5636e98..abcd495 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/rhelp/RHelpInfoHoverCreator.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/rhelp/RHelpInfoHoverCreator.java
@@ -495,7 +495,7 @@
int widthHint= converter.convertWidthInCharsToPixels(60);
final GC gc= new GC(this.contentComposite);
gc.setFont(JFaceResources.getTextFont());
- widthHint= Math.max(widthHint, gc.getFontMetrics().getAverageCharWidth() * 60);
+ widthHint= Math.max(widthHint, (int)(gc.getFontMetrics().getAverageCharacterWidth() * 60 + 0x0.FFFFFp0));
gc.dispose();
final int heightHint= this.titleText.getLineHeight() * 12;