package net.qysoft.com.GsmDemo.gui;
import java.util.ArrayList;
import java.util.Arrays;
import net.qysoft.framwork.smscom.utils.SMSCom;
import net.qysoft.framwork.smscom.utils.SM_PARAM;
import net.qysoft.framwork.swt.util.SWTUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.swtdesigner.SWTResourceManager;
/**
*
* @author 注册方式:QQ:76310701 或邮箱:zheng_wh@163.com
*
*/
public class GsmDemo {
private Button send8Bit_button;
private List sms_list;
private Button send7Bit_button;
private Text msg_text;
private Text phone_text;
private Combo comport_combo;
protected Shell shell;
private Label sca_Label;
private Label message_label;
private Button open_button;
private Button close_button;
private Button gsminfo_button;
private Button send_button;
private CTabFolder tabFolder;
private Button read_button;
/**
* Launch the application
*
* @param args
*/
public static void main(String[] args) {
try {
GsmDemo window = new GsmDemo();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the dialog
*
* @param parent
*/
public GsmDemo() {
createContents();
}
/**
* Open the window
*/
public void open() {
int isDataOk = setDefaultView();
if (isDataOk == -1) {
shell.close();
return;
}
shell.open();
shell.layout();
final Display display = Display.getDefault();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
/**
* Create contents of the window
*/
protected void createContents() {
shell = new Shell(SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL);
shell
.setImage(SWTResourceManager.getImage(GsmDemo.class,
"/ico/1.ico"));
final GridLayout gridLayout = new GridLayout();
gridLayout.verticalSpacing = 0;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
shell.setLayout(gridLayout);
shell.setSize(485, 465);
shell.setText("Sms 测试");
SWTUtils.setCenter(shell);
shell.setMaximized(true);
shell.setBackgroundMode(SWT.INHERIT_FORCE);
final Composite top_composite = new Composite(shell, SWT.BORDER);
final GridData gd_top_composite = new GridData(SWT.FILL, SWT.TOP, true,
false);
gd_top_composite.heightHint = 65;
top_composite.setLayoutData(gd_top_composite);
final GridLayout gridLayout_1 = new GridLayout();
gridLayout_1.numColumns = 4;
top_composite.setLayout(gridLayout_1);
final Label label = new Label(top_composite, SWT.NONE);
label.setForeground(SWTResourceManager.getColor(128, 0, 0));
label.setText("串口名称:");
comport_combo = new Combo(top_composite, SWT.READ_ONLY);
final GridData gd_comport_combo = new GridData(182, SWT.DEFAULT);
comport_combo.setLayoutData(gd_comport_combo);
open_button = new Button(top_composite, SWT.NONE);
open_button.setText("打开串口");
close_button = new Button(top_composite, SWT.NONE);
close_button.setEnabled(false);
close_button.setText("关闭串口");
final Label label_1 = new Label(top_composite, SWT.NONE);
label_1.setForeground(SWTResourceManager.getColor(128, 0, 0));
label_1.setText("短信中心:");
sca_Label = new Label(top_composite, SWT.NONE);
sca_Label.setForeground(SWTResourceManager.getColor(0, 0, 255));
final GridData gd_sca_Label = new GridData(SWT.FILL, SWT.CENTER, false,
false);
sca_Label.setLayoutData(gd_sca_Label);
gsminfo_button = new Button(top_composite, SWT.NONE);
final GridData gd_gsminfo_button = new GridData(SWT.FILL, SWT.CENTER,
false, false);
gsminfo_button.setLayoutData(gd_gsminfo_button);
gsminfo_button.setText("初始化");
read_button = new Button(top_composite, SWT.NONE);
final GridData gd_read_button = new GridData(SWT.FILL, SWT.CENTER,
false, false);
read_button.setLayoutData(gd_read_button);
read_button.setText("读短信");
new Label(top_composite, SWT.NONE);
final Composite main__composite = new Composite(shell, SWT.BORDER);
final GridData gd_main__composite = new GridData(SWT.FILL, SWT.FILL,
true, true);
main__composite.setLayoutData(gd_main__composite);
final GridLayout gridLayout_3 = new GridLayout();
gridLayout_3.marginBottom = 1;
gridLayout_3.marginTop = 1;
gridLayout_3.marginRight = 1;
gridLayout_3.marginLeft = 1;
gridLayout_3.verticalSpacing = 0;
gridLayout_3.marginWidth = 0;
gridLayout_3.marginHeight = 0;
gridLayout_3.horizontalSpacing = 0;
main__composite.setLayout(gridLayout_3);
tabFolder = new CTabFolder(main__composite, SWT.NONE);
tabFolder.setSimple(false);
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tabFolder.setUnselectedImageVisible(false);
tabFolder.setUnselectedCloseVisible(false);
tabFolder.setMinimizeVisible(true);
tabFolder.setMaximizeVisible(true);
final CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
tabItem.setText("发送短信");
final Composite composite = new Composite(tabFolder, SWT.NONE);
composite.setLayout(new GridLayout());
tabItem.setControl(composite);
final Label label_6 = new Label(composite, SWT.NONE);
label_6.setForeground(SWTResourceManager.getColor(128, 0, 0));
label_6.setText("目标手机:");
phone_text = new Text(composite, SWT.BORDER);
phone_text.setText("13682205980");
final GridData gd_phone_text = new GridData(195, SWT.DEFAULT);
phone_text.setLayoutData(gd_phone_text);
final Label label_4 = new Label(composite, SWT.NONE);
label_4.setForeground(SWTResourceManager.getColor(128, 0, 0));
label_4.setText("消息内容:");
msg_text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP);
msg_text.setText("Hello World!");
final GridData gd_msg_text = new GridData(SWT.FILL, SWT.FILL, true,
true, 2, 1);
msg_text.setLayoutData(gd_msg_text);
send_button = new Button(composite, SWT.NONE);
send_button.setToolTipText("PDU发送模式支持长短信");
final GridData gd_send_button = new GridData(SWT.FILL, SWT.CENTER,
true, false);
gd_send_button.heightHint = 35;
send_button.setLayoutData(gd_send_button);
send_button.setText("中文发送");
send7Bit_button = new Button(composite, SWT.NONE);
final GridData gd_send7Bit_button = new GridData(SWT.FILL, SWT.CENTER,
true, false);
gd_send7Bit_button.heightHint = 35;
send7Bit_button.setLayoutData(gd_send7Bit_button);
send7Bit_button.setToolTipText("纯英文发送");
send7Bit_button.setText("英文7Bit发送(最大160个字符)");
send8Bit_button = new Button(composite, SWT.NONE);
final GridData gd_send8Bit_button = new GridData(SWT.FILL, SWT.CENTER,
true, false);
gd_send8Bit_button.heightHint = 35;
send8Bit_button.setLayoutData(gd_send8Bit_button);
send8Bit_button.setToolTipText("纯英文发送");
send8Bit_button.setText("英文8Bit发送(最大140个字符)");
final CTabItem tabItem_1 = new CTabItem(tabFolder, SWT.NONE);
tabItem_1.setText("接收短信");
final Composite composite_1 = new Composite(tabFolder, SWT.NONE);
final GridLayout gridLayout_4 = new GridLayout();
gridLayout_4.verticalSpacing = 0;
gridLayout_4.marginWidth = 0;
gridLayout_4.marginHeight = 0;
gridLayout_4.horizontalSpacing = 0;
composite_1.setLayout(gridLayout_4);
tabItem_