Skip to content

Commit 234fca3

Browse files
committed
refactor: Simplify font creation and CSS class application in ModelHoverContentProvider
1 parent e16ab04 commit 234fca3

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/ModelHoverContentProvider.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.eclipse.swt.SWT;
66
import org.eclipse.swt.graphics.Color;
77
import org.eclipse.swt.graphics.Font;
8-
import org.eclipse.swt.graphics.FontData;
98
import org.eclipse.swt.graphics.Image;
109
import org.eclipse.swt.graphics.Rectangle;
1110
import org.eclipse.swt.layout.GridData;
@@ -216,39 +215,25 @@ private boolean hasAnyPrice(CopilotModelBillingTokenPrices prices) {
216215
}
217216

218217
private Font createBoldFont(Label label) {
219-
Display display = label.getDisplay();
220-
FontData[] fontData = label.getFont().getFontData();
221-
for (FontData data : fontData) {
222-
data.setStyle(SWT.BOLD);
223-
}
224-
Font boldFont = new Font(display, fontData);
218+
Font boldFont = UiUtils.getBoldFont(label.getDisplay(), label.getFont());
225219
label.addDisposeListener(event -> boldFont.dispose());
226220
return boldFont;
227221
}
228222

229223
private void addWarningRow(Composite parent, String warningText) {
230224
Label warningLabel = new Label(parent, SWT.WRAP);
231225
warningLabel.setText(warningText);
232-
setCssClass(warningLabel, POPUP_SECONDARY_TEXT_CLASS);
226+
UiUtils.applyCssClass(warningLabel, POPUP_SECONDARY_TEXT_CLASS, stylingEngine);
233227
warningLabel.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
234228
}
235229

236230
private Label createSecondaryTextLabel(Composite parent, String text) {
237231
Label label = new Label(parent, SWT.NONE);
238232
label.setText(text);
239-
setCssClass(label, POPUP_SECONDARY_TEXT_CLASS);
233+
UiUtils.applyCssClass(label, POPUP_SECONDARY_TEXT_CLASS, stylingEngine);
240234
return label;
241235
}
242236

243-
private void setCssClass(Label control, String className) {
244-
if (stylingEngine != null) {
245-
stylingEngine.setClassname(control, className);
246-
stylingEngine.style(control);
247-
} else {
248-
control.setData(CssConstants.CSS_CLASS_NAME_KEY, className);
249-
}
250-
}
251-
252237
private void addSeparator(Composite parent) {
253238
Composite separator = new Composite(parent, SWT.NONE);
254239
GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);

0 commit comments

Comments
 (0)