forked from microsoft/copilot-for-eclipse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAgentToolCancelLabel.java
More file actions
48 lines (40 loc) · 1.51 KB
/
Copy pathAgentToolCancelLabel.java
File metadata and controls
48 lines (40 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package com.microsoft.copilot.eclipse.ui.chat;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import com.microsoft.copilot.eclipse.ui.swt.CssConstants;
import com.microsoft.copilot.eclipse.ui.utils.UiUtils;
/**
* A label with icon that displays the cancel status of the agent tool.
*/
public class AgentToolCancelLabel extends Composite {
private Image cancelIcon;
/**
* Create the composite.
*
* @param parent the parent composite
* @param style the style
*/
public AgentToolCancelLabel(Composite parent, int style, String cancelMessage) {
super(parent, style);
setLayout(new GridLayout(2, false));
setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
this.cancelIcon = UiUtils.buildImageFromPngPath("/icons/cancel_status.png");
Label iconLabel = new Label(this, SWT.LEFT);
iconLabel.setImage(this.cancelIcon);
Label textLabel = new Label(this, SWT.LEFT | SWT.WRAP);
textLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
textLabel.setText(cancelMessage);
textLabel.setData(CssConstants.CSS_CLASS_NAME_KEY, "text-secondary");
this.addDisposeListener(e -> {
if (this.cancelIcon != null && !this.cancelIcon.isDisposed()) {
this.cancelIcon.dispose();
}
});
}
}