package com.huazi.login;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import java.util.List;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Control;
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.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import com.huazi.bean.CallInf;
import com.huazi.bean.Company;
import com.huazi.bean.Config;
import com.huazi.bean.Loadometer;
import com.huazi.bean.Materiel;
import com.huazi.bean.Menu;
import com.huazi.bean.State;
import com.huazi.bean.User;
import com.huazi.company.AddCompany;
import com.huazi.company.UpdateCompany;
import com.huazi.config.UpdateConfig;
import com.huazi.materiel.AddMateriel;
import com.huazi.materiel.UpdateMateriel;
import com.huazi.menu.AddMenu;
import com.huazi.menu.UpdateMenu;
import com.huazi.menu.XLEDShow;
import com.huazi.menu.ZLEDShow;
import com.huazi.service.CallInfService;
import com.huazi.service.CompanyService;
import com.huazi.service.ConfigService;
import com.huazi.service.KpcxService;
import com.huazi.service.LoadometerService;
import com.huazi.service.MaterielService;
import com.huazi.service.MenuService;
import com.huazi.service.StateService;
import com.huazi.service.UserService;
import com.huazi.state.AddState;
import com.huazi.state.UpdateState;
import com.huazi.user.AddUser;
import com.huazi.user.UpdateUser;
import com.huazi.util.LayoutUtil;
import com.huazi.util.RcpUtils;
import com.huazi.util.Util;
public class MainShell {
private static Display display;
private static Shell shell;
private static Tree tree;
private static TreeItem treeItem;
private static ViewForm viewForm;
private static Composite composite;
private static Table table;
private static TableItem item;
private static TableColumn col;
private static TableColumn col1;
private static TableColumn col2;
private static TableColumn col3;
private static TableColumn col4;
private static TableColumn col5;
private static TableColumn col6;
private static TableColumn col7;
private static TableColumn col8;
private static TableColumn col9;
private static Combo materiel;
private static ToolItem add;
private static ToolItem update;
private static ToolItem delete;
private static ToolItem config;
private static Button search;
private static Button save;
private static Button callnum;
private static Button finish;
private static Button cancle;
private static Button up;
private static Button down;
private static CallInfService callInfService;
private static KpcxService kpcxService;
private static UserService userService;
private static StateService stateService;
private static LoadometerService loadoService;
private static MaterielService materielService;
private static CompanyService comService;
private static MenuService menuService;
private static ConfigService configService;
private static User user;
private static String ipstr;
private static String materstr;
private static int id;
private static Color red;
private static Color yellow;
/**
* Launch the application.
*
* @param args
*/
// public static void main(String[] args) {
public void getMainShell(String ipstr,User user) {
try {
this.ipstr = ipstr;
this.user = user;
display = Display.getCurrent();
shell = new Shell();
shell.setText("海越新材料车辆排队叫号系统管理平台");
shell.setSize(1200, 640);
LayoutUtil.centerShell(display, shell);
getCreateShell();
shell.open();
new Thread() {
public void run() {
while (true) {
try {
Thread.sleep(180000);// 3分钟
} catch (InterruptedException e) {
}
display.asyncExec(new Runnable() {
// 定时存贮
public void run() {
// saveCallInfList();
// saveCompanyList();
// saveMaterielList();
getKpcx();
getCallInf();
}
});
}
}
}.start();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
} catch (Exception e) {
e.printStackTrace();
}
display.dispose();
}
/**
* Create the shell.
*
* @param display
*/
public static void getCreateShell() {
tree = new Tree(shell, SWT.BORDER);
tree.setBounds(0, 0, 200, 600);
configService = Util.getConfigService(ipstr);
List<Config> list = configService.getByUid(user);
for (int i = 0; i < list.size(); i++) {
treeItem = new TreeItem(tree, SWT.NONE);
String menu = list.get(i).getMenuname();
treeItem.setText(menu);
}
tree.addSelectionListener(new select());
viewForm = new ViewForm(shell, SWT.BORDER);
viewForm.setBounds(200, 0, 980, 600);
}
public static class select extends SelectionAdapter {
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = tree.getSelection();
for (int i = 0; i < selection.length; i++) {
String str = selection[i] + "";
if (str.indexOf("保安") > 0) {
getKpcxShell();
}else if (str.indexOf("地磅房") > 0) {
getCallInfShell();
} else if (str.indexOf("装货信息") > 0) {
getLoading();
} else if (str.indexOf("卸货信息") > 0) {
getUnLoading();
} else if (str.indexOf("装货大屏") > 0) {
ZLEDShow show = new ZLEDShow();
show.getZLEDShowShell(ipstr);
} else if (str.indexOf("卸货大屏") > 0) {
XLEDShow show = new XLEDShow();
show.getXLEDShowShell(ipstr);
} else if (str.indexOf("历史数据") > 0) {
getHistoryShell();
} else if (str.indexOf("用户信息") > 0) {
getUser();
} else if (str.indexOf("状态信息") > 0) {
getState();
} else if (str.indexOf("物料信息") > 0) {
getMateriel();
} else if (str.indexOf("企业信息") > 0) {
getCompany();
} else if (str.indexOf("菜单信息") > 0) {
getMenu();
} else if (str.indexOf("配置用户") > 0) {
getConfig();
} else if (str.indexOf("系统退出") > 0) {
shell.dispose();
// LogoShell logo = new LogoShell();
// logo.getLogoShell();
}
}
}
}
// **************************保安操作界面 start******************************************
public static void getKpcxShell() {
composite = new Composite(viewForm, SWT.NONE);
viewForm.setContent(composite);
Label lblNewLabel = new Label(composite, SWT.NONE);
lblNewLabel.setBounds(50, 5, 50, 25);
lblNewLabel.setText("物料:");
materiel = new Combo(composite, SWT.NONE);
materiel.setBounds(100, 5, 150, 25);
kpcxService = Util.getKpcxService(ipstr);
List<Materiel> list = kpcxService.getMaterielList();
String str = "";
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Materiel mate = list.get(