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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package com.gx.obe.evaluation.step.shell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.core.utils.SwtUtils;
import org.eclipse.swt.core.widgets.ImageButton;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
import com.gx.obe.evaluation.step.composite.AiEvalLeftButton;
import com.gx.obe.message.Messages;
import com.swtdesigner.SWTResourceManager;
/**
* @Description:
* @author guoyr
*/
public class ShowAiProcessShell extends Shell {
// private Composite composite;
private AiEvalLeftButton groupMenuBtn;
private ImageButton curBtn;
private Composite curComposite;
private Composite composite;
private Composite messageComposite;
private Label lblNewLabel_1;
private Listener deactivateListener;
// private int process;
// private String needTime;
/**
* Create the shell.
* @param display
*/
public ShowAiProcessShell(final Shell shell, AiEvalLeftButton shortMenu, int process, String needTime) {
super(shell, SWT.NO_TRIM | SWT.TOP);
this.groupMenuBtn = shortMenu;
// this.process = process;
// this.needTime = needTime;
// super(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.TOOL);
// addDisposeListener(new DisposeListener() {
// public void widgetDisposed(DisposeEvent e) {
// removeListener(SWT.Deactivate, deactivateListener);
// }
// });
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
gridLayout.marginHeight = 1;
gridLayout.marginWidth = 1;
setLayout(gridLayout);
setBackground(shortMenu.getActiveBackgroundColor());
// setBackground(shortMenu.getBackground());
setBackgroundMode(SWT.INHERIT_FORCE);
curComposite = new Composite(this, SWT.NONE);
curComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 2));
GridLayout gl_curComposite = new GridLayout(1, false);
gl_curComposite.marginHeight = 0;
gl_curComposite.marginWidth = 0;
gl_curComposite.marginRight = 5;
curComposite.setLayout(gl_curComposite);
curComposite.setBackground(shortMenu.getActiveBackgroundColor());
// curComposite.setBackground(SWTResourceManager.getColor(123, 13, 15));
curBtn = new ImageButton(curComposite, SWT.NONE);
curBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
curBtn.setImage(shortMenu.getImage());
// curBtn.setTopMargin(3);
// curBtn.setBottomMargin(3);
curBtn.setLeftMargin(5);
curBtn.setRightMargin(5);
composite = new Composite(this, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
GridLayout gl_composite = new GridLayout(1, false);
gl_composite.marginWidth = 0;
gl_composite.horizontalSpacing = 0;
gl_composite.marginHeight = 0;
gl_composite.verticalSpacing = 0;
composite.setLayout(gl_composite);
composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
Label labe = new Label(composite, SWT.None);
labe.setText("标书相似度分析进度");
messageComposite = new Composite(composite, SWT.NONE);
messageComposite.setLayout(new GridLayout(4, false));
messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
// messageComposite.setVisible(false);
Label lblNewLabel = new Label(messageComposite, SWT.NONE);
lblNewLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblNewLabel.setText(Messages.ShowViewAiProcessDialog_lblNewLabel_text);
lblNewLabel_1 = new Label(messageComposite, SWT.NONE);
lblNewLabel_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
GridData gd_lblNewLabel_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblNewLabel_1.widthHint = 40;
lblNewLabel_1.setLayoutData(gd_lblNewLabel_1);
lblNewLabel_1.setText(process + "%");
Label lblNewLabel_2 = new Label(messageComposite, SWT.NONE);
lblNewLabel_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblNewLabel_2.setText(" 预计还需要:");
Label lblNewLabel_3 = new Label(messageComposite, SWT.NONE);
lblNewLabel_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel_3.setText(needTime);
ProgressBar progressBar = new ProgressBar(composite, SWT.NONE);
progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
progressBar.setSelection(process);
init();
createContents();
}
private void init(){
deactivateListener = new Listener(){
public void handleEvent(Event arg0) {
close();
}
};
addListener(SWT.Deactivate, deactivateListener);
MouseTrackAdapter mouseExit = new MouseTrackAdapter() {
public void mouseExit(MouseEvent e) {
super.mouseExit(e);
Point mousePoint = SwtUtils.getMouseLoaction();
Point p = Display. getDefault ().map(composite, null , 0,0);
Point p2 = Display. getDefault ().map(curComposite, null , 0,0);
Rectangle rectangle1 = new Rectangle(p2.x + 1, p2.y + 0, curComposite.getBounds().width, curComposite.getBounds().height -0);
Rectangle rectangle2 = new Rectangle(p.x + 1, p.y + 0, composite.getBounds().width -0, composite.getBounds().height -2);
// System.out.println(rectangle1 +"\t"+rectangle2 +"\t"+ mousePoint +"\t"+ rectangle1.contains(mousePoint) +"\t"+rectangle2.contains(mousePoint));
if(rectangle1.contains(mousePoint) || rectangle2.contains(mousePoint)) {
}else {
close();
}
}
};
// addMouseTrackListener(mouseExit);
curBtn.addMouseTrackListener(mouseExit);
curComposite.addMouseTrackListener(mouseExit);
composite.addMouseTrackListener(mouseExit);
composite.addMouseTrackListener(mouseExit);
// SwtUtils.setCircleRegion(this, 3);
}
@Override
public void open() {
this.setMinimumSize(250, 80);
this.setAlpha(250);
this.pack();
Point point = groupMenuBtn.toDisplay(new Point(0,0));
Region region = new Region();
region.add(0, 0,curComposite.getBounds().width, curComposite.getBounds().height + 2);
region.add(curComposite.getBounds().width + 0, 0, this.getBounds().width, this.getBounds().height);
this.setRegion(region);
region.dispose();
setLocation(point.x , point.y);
super.open();
}
// @Override
// public void close() {
// super.close();
// }
/**
* Create contents of the shell.
*/
protected void createContents() {
setText("");
setSize(480, 68);
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}