




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
┊┊┊┊┊┊┊┊┊┊┊┊┊裝┊┊┊┊┊訂┊┊┊┊┊線┊┊┊┊┊┊┊┊┊┊┊┊┊長春大學(xué)課程設(shè)計紙共35頁第7頁目錄一、設(shè)計目的………………2二、功能介紹………………2三、程序流程………………2四、設(shè)計步驟………………3五、設(shè)計總結(jié)………………6六、程序清單………………6一、設(shè)計目的通過課程設(shè)計,使自己提高理論聯(lián)系實際解決實際問題的能力;也使自己對基于面向?qū)ο蟮睦碚撨M(jìn)行系統(tǒng)設(shè)計過程中的諸多具體問題有感性的認(rèn)識和深入的理解;進(jìn)而提高自己的學(xué)習(xí)興趣為其將來順利進(jìn)入畢業(yè)環(huán)節(jié)作必要的準(zhǔn)備。按照教師給出的思路和計劃進(jìn)度安排獨(dú)立完成課程設(shè)計二、功能介紹1、具有新用戶注冊功能。2、具有注冊用戶登錄功能。3、具有數(shù)據(jù)的錄入功能。4、具有數(shù)據(jù)查詢功能,可以實現(xiàn)查詢?nèi)啃畔⒑桶礂l件執(zhí)行查詢。5、具有按條件刪除數(shù)據(jù)功能。6、具有統(tǒng)計功能 7、本程序采用RCP技術(shù),和SQL數(shù)據(jù)庫。三.程序流程圖1四、設(shè)計步驟(一)程序設(shè)計步驟1.建立RCP工程并構(gòu)建數(shù)據(jù)庫2.建立view和editor3.構(gòu)建基本框架,并主要修改Perspective和WorkbenchWindowAdvisor兩個文件4.構(gòu)建需要的輔助文件5.測試(二)詳細(xì)設(shè)計:1.登錄和注冊當(dāng)?shù)卿浢蚝兔艽a為空的時候,后邊會顯示×;當(dāng)點(diǎn)擊驗證碼的時候,調(diào)用Random函數(shù)產(chǎn)生隨機(jī)驗證碼,點(diǎn)擊登錄的時候,從三個框中獲得值,進(jìn)行對數(shù)據(jù)庫的操作。部分代碼如下:Stringname=text.getText();Stringsql="select*fromuserswherename='"+name+"'";DBHelperdb=newDBHelper();ResultSetrs=db.query(sql);效果如圖如下:圖2當(dāng)用戶點(diǎn)擊提交時,程序會將用戶輸入的信息通過SQL語句提交給數(shù)據(jù)庫,如果數(shù)據(jù)庫修改成功,會返回信息。主要代碼如下:Stringsql="insertintousers(name,sex,password,phone)"+"values('"+text1.getText()+"','"+sex1+"','"+text2.getText()+"','"+text4.getText()+"')";DBHelperdb=newDBHelper();db.update(sql);DBHelper是封裝好的數(shù)據(jù)庫的類,利用update()封裝的executeUpdate(sql)函數(shù)對數(shù)據(jù)庫進(jìn)行操作。具體如下圖:圖32.菜單功能部分利用Link實現(xiàn)view里的菜單功能,用以下代碼實現(xiàn)link的實例化:finalLinkeclipseorgLink=newLink(composite,SWT.NONE),用eclipseorgLink.setText("<a>查看職工信息</a>");實現(xiàn)Link文字內(nèi)容。如下圖: 圖43.功能實現(xiàn)模塊同樣是利用封裝好的類DBHelper對數(shù)據(jù)庫進(jìn)行查詢。 Stringsql="selectbid,bname,bjlfrombumen";ResultSetrs=newDBHelper().query(sql);rs是查詢出來的結(jié)果集,利用while循環(huán),將查詢出來的結(jié)果添加到TableItem中,代碼如下:TableItemtableitem=newTableItem(table,SWT.NONE);tableitem.setText(newString[]{rs.getString("bid"),rs.getString("bname"),rs.getString("bjl")});詳細(xì)結(jié)果如下圖:圖5利用封裝好的類DBHelper對數(shù)據(jù)庫進(jìn)行查詢。 Stringsql="selecteidenamesex,age,ctime,xuli,zhuanye,bytime,school,wyu,hunyin,bnamefromemployeebumenwhereemployee.bid=bumen.bid";ResultSetrs=newDBHelper().query(sql),rs是查詢出來的結(jié)果集,利用while循環(huán),將查詢出來的結(jié)果添加到TableItem中,代碼如下:TableItemtableitem=newTableItem(table,SWT.NONE);tableitem.setText(newString[]{rs.getString("eid"),rs.getString("ename"),rs.getString("sex"),rs.getString("age"),rs.getString("ctime"),rs.getString("xuli"),rs.getString("zhuanye"),rs.getString("bytime"),rs.getString("school"),rs.getString("wyu"),rs.getString("hunyin"),rs.getString("bname")});詳細(xì)結(jié)果如下圖:圖6利用封裝好的DBHelper中的update()方法對用戶輸入的東西進(jìn)行操作,若操作成功,利用SQL語句和相應(yīng)的處理方法將信息存入數(shù)據(jù)庫中。Stringsql="insertintoemployee(ename,sex,age,ctime,xuli,zhuanye,bytime,school,wyu,hunyin,bid)"+"values('"+text1.getText()+"','"+sex1+"',"+text2.getText()+",'"+text4.getText()+"','"+text5.getText()+"','"+text6.getText()+"','"+text7.getText()+"','"+text8.getText()+"','"+text10.getText()+"','"+text9.getText()+"',"+bid+")";db.update(sql);如下圖:圖7用戶可以輸入查找條件,當(dāng)按照查找按鈕的時候,程序會根據(jù)查找條從數(shù)據(jù)庫中查找相應(yīng)的信息,用戶可以根據(jù)查找然后輸入相應(yīng)的修改信息,點(diǎn)擊提交就會將數(shù)據(jù)庫中的信息進(jìn)行修改,主要的修改代碼如下:Stringsql="selecteidenamesex,age,ctime,wyu,xuli,hunyinfromemployeewhereename='"+name+"'";DBHelperdb=newDBHelper();ResultSetrs=db.query(sql);修改完事之后,程序會自動刷新表格信息,顯示修改之后信息。如下圖:圖8用戶可以輸入要刪除信息,當(dāng)按照查找按鈕的時候,程序會根據(jù)查找條從數(shù)據(jù)庫中查找相應(yīng)的信息,根據(jù)查找的信息刪除需要的信息,如果沒有找到,就會彈出提示框。主要代碼:Stringsql="deleteemployeewhereeid="+sign;DBHelperdb=newDBHelper();db.update(sql);效果如下圖:五、設(shè)計總結(jié)經(jīng)過將近一周的課程設(shè)計,對java有了更深一層次的認(rèn)識,感覺java很強(qiáng)大,Java用sun公司誕生到現(xiàn)今,一直很流行,很受歡迎。Java語言具有面向?qū)ο蟆⒎植际降摹⒑唵?、健壯、安全、結(jié)構(gòu)中立、可移植、多線程、動態(tài)等特點(diǎn)。Java提供了豐富的類庫,摒棄了C++中容易引發(fā)程序錯去的地方等優(yōu)點(diǎn),是在這次設(shè)計中徹底愛上了java這門語言,以后會更加努力的,將java這門語言學(xué)通乃至學(xué)精。雖然課程設(shè)計結(jié)束了,但是java的學(xué)習(xí)卻沒有結(jié)束,以后更加努力的。六.部分主要程序清單1.RCP中需要修改的ApplicationWorkbenchAdvisor文件importorg.eclipse.swt.SWT;importorg.eclipse.swt.widgets.Display;importorg.eclipse.ui.application.IWorkbenchWindowConfigurer;importorg.eclipse.ui.application.WorkbenchAdvisor;importorg.eclipse.ui.application.WorkbenchWindowAdvisor;importviews.Loginshell;publicclassApplicationWorkbenchAdvisorextendsWorkbenchAdvisor{ privatestaticfinalStringPERSPECTIVE_ID="rsgl.perspective"; publicstaticbooleantag=false;publicWorkbenchWindowAdvisorcreateWorkbenchWindowAdvisor(IWorkbenchWindowConfigurerconfigurer){try{ Displaydisplay=Display.getDefault(); Loginshellshell=newLoginshell(display,SWT.SHELL_TRIM); shell.open(); shell.layout(); while(!shell.isDisposed()){ if(!display.readAndDispatch()) display.sleep(); } }catch(Exceptione){ e.printStackTrace(); } if(tag){ returnnewApplicationWorkbenchWindowAdvisor(configurer); }else{ returnnull; }} publicStringgetInitialWindowPerspectiveId(){ returnPERSPECTIVE_ID; }}2.RCP中需要修改的Perspective文件importorg.eclipse.ui.IPageLayout;importorg.eclipse.ui.IPerspectiveFactory;importviews.Menus;importviews.MyInfo;publicclassPerspectiveimplementsIPerspectiveFactory{ publicvoidcreateInitialLayout(IPageLayoutlayout){ layout.addView(Menus.ID,IPageLayout.LEFT,0.45f,layout.getEditorArea()); layout.addView(MyInfo.ID,IPageLayout.BOTTOM,0.6f,Menus.ID); }}3.功能部分程序3.1importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.Random;importorg.eclipse.jface.dialogs.MessageDialog;importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.MouseAdapter;importorg.eclipse.swt.events.MouseEvent;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importorg.eclipse.swt.widgets.Button;importorg.eclipse.swt.widgets.Display;importorg.eclipse.swt.widgets.Label;importorg.eclipse.swt.widgets.Shell;importorg.eclipse.swt.widgets.Text;importrsgl.Activator;importrsgl.ApplicationWorkbenchAdvisor;importcom.swtdesigner.ResourceManager;importcom.swtdesigner.SWTResourceManager;importcommon.DBHelper;importcommon.Property;publicclassLoginshellextendsShell{ privateTexttext_2; privateTexttext_1; privateTexttext; publicstaticvoidmain(Stringargs[]){ try{ Displaydisplay=Display.getDefault(); Loginshellshell=newLoginshell(display,SWT.SHELL_TRIM); shell.open(); shell.layout(); while(!shell.isDisposed()){ if(!display.readAndDispatch()) display.sleep(); } }catch(Exceptione){ e.printStackTrace(); } } /** *Createtheshell *@paramdisplay *@paramstyle */ publicLoginshell(Displaydisplay,intstyle){ super(display,style); createContents(); setBackgroundImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/a-副本.jpg")); setBackground(SWTResourceManager.getColor(255,255,255)); setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/groupimage.gif")); setBackgroundMode(SWT.INHERIT_DEFAULT); setText("用戶登陸"); } /** *Createcontentsofthewindow */ protectedvoidcreateContents(){ setSize(507,400); finalLabellabel=newLabel(this,SWT.NONE); label.setBackground(SWTResourceManager.getColor(255,255,255)); label.setText("登錄名:"); label.setBounds(148,195,47,17); text=newText(this,SWT.BORDER); text.setBounds(220,192,116,20); finalLabellabel1=newLabel(this,SWT.NONE); label1.setBackground(SWTResourceManager.getColor(255,255,255)); label1.setText("密碼:"); label1.setBounds(148,235,39,17); text_1=newText(this,SWT.BORDER|SWT.PASSWORD); finalLabellabel4=newLabel(this,SWT.NONE); text_1.addMouseListener(newMouseAdapter(){ publicvoidmouseDown(finalMouseEvente){ label4.setBackground(SWTResourceManager.getColor(255,255,255)); if(text.getText().trim()!=""){ label4.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/4.PNG")); }else{ label4.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/3.PNG")); } label4.setBounds(342,195,23,17); } }); text_1.setBounds(220,232,116,20); finalLabellabel2=newLabel(this,SWT.NONE); label2.setBackground(SWTResourceManager.getColor(255,255,255)); label2.setText("驗證碼:"); label2.setBounds(148,274,47,17); text_2=newText(this,SWT.BORDER); finalLabellabel3=newLabel(this,SWT.NONE); label3.setForeground(SWTResourceManager.getColor(255,0,0)); label3.setFont(SWTResourceManager.getFont("@方正舒體",18,SWT.BOLD,true,false)); finalLabellabel4_1=newLabel(this,SWT.NONE); text_2.addMouseListener(newMouseAdapter(){ publicvoidmouseDown(finalMouseEvente){ String[]a2={"0","1","2","3","4","5","6","7","8", "9","a","b","c","d","e","f","g","h","i","j", "k","l","m","n","o","p","q","r","s","t","u", "v","w","x","y","z"}; Randomr=newRandom(); Stringresult=""; while(result.length()<4){ inttemp=r.nextInt(36); result=result+a2[temp]; } label3.setText(result); System.out.println(label3.getText()); label4_1.setBackground(SWTResourceManager.getColor(255,255,255));//獲取label的背景色 if(text_1.getText().trim()!=""){ label4_1.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/4.PNG")); }else{ label4_1.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/3.PNG")); } label4_1.setBounds(342,235,23,17); label3.setBackground(SWTResourceManager.getColor(255,255,255)); label3.setBounds(386,271,72,27); } }); text_2.setBounds(220,271,116,20); finalButtonbutton=newButton(this,SWT.NONE); finalLabellabel4_2=newLabel(this,SWT.NONE); button.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ //System.out.println(text_1.getText().trim()); System.out.println(text_2.getText()); if(text_1.getText().trim()!=""&&text_2.getText().equals(label3.getText())){ label4_2.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/4.PNG")); }else{ label4_2.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/3.PNG")); } label4_2.setBounds(342,274,23,17); label4_2.setText(""); Stringname=text.getText(); Stringpassword=text_1.getText(); Stringsql="select*fromuserswherename='"+name+"'"; DBHelperdb=newDBHelper(); ResultSetrs=db.query(sql); try{ if(rs.next()){ StringpasswordQ=rs.getString("password"); if(passwordQ.equals(password)&&text_2.getText().equals(label3.getText())){ ApplicationWorkbenchAdvisor.tag=true; Property.NAME=rs.getString("name"); Property.PASSWORD=rs.getString("password"); Property.ID=rs.getString("uid"); MessageDialog.openInformation(Loginshell.this,"登錄成功","登錄成功"); Loginshell.this.dispose(); }else{ MessageDialog.openError(Loginshell.this,"登錄失敗","登錄失敗,密碼或者驗證碼錯誤!"); } }else{ MessageDialog.openError(Loginshell.this,"登錄失敗","登錄失敗,不存在該用戶!"); } }catch(SQLExceptione1){ e1.printStackTrace(); } db.close(); } }); button.setBackground(SWTResourceManager.getColor(255,255,255)); button.setText("登陸"); button.setBounds(148,313,64,27); finalButtonbutton_2=newButton(this,SWT.NONE); button_2.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ try{ Displaydisplay=Display.getDefault(); Zhuceshell=newZhuce(display,SWT.SHELL_TRIM); shell.open(); shell.layout(); //MessageDialog.openInformation(Loginshell.this,"請進(jìn)入注冊頁面","歡迎您注冊!"); Loginshell.this.dispose(); while(!shell.isDisposed()){ if(!display.readAndDispatch()) display.sleep(); } }catch(Exceptione1){ e1.printStackTrace(); } } }); button_2.setText("注冊"); button_2.setBounds(272,313,64,27);} @Override protectedvoidcheckSubclass(){ //DisablethecheckthatpreventssubclassingofSWTcomponents }}3.2importinput.MyInput;importorg.eclipse.jface.action.IMenuManager;importorg.eclipse.jface.action.IToolBarManager;importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importorg.eclipse.swt.layout.FillLayout;importorg.eclipse.swt.widgets.Composite;importorg.eclipse.swt.widgets.ExpandBar;importorg.eclipse.swt.widgets.ExpandItem;importorg.eclipse.swt.widgets.Link;importorg.eclipse.ui.PartInitException;importorg.eclipse.ui.PlatformUI;importorg.eclipse.ui.part.ViewPart;importrsgl.Activator;importcom.swtdesigner.ResourceManager;importcom.swtdesigner.SWTResourceManager;importcommon.InputFactory;importcommon.Property;importeditors.AddCoach;importeditors.Addstu;importeditors.Bumen;importeditors.DelCoach;importeditors.Delstu;importeditors.ReCoach;importeditors.Restu;importeditors.Zhigong;publicclassMenusextendsViewPart{ publicstaticfinalStringID="views.Menus";//$NON-NLS-1$ publicvoidcreatePartControl(Compositeparent){ Compositecontainer=newComposite(parent,SWT.NONE); container.setLayout(newFillLayout(SWT.VERTICAL));//控件充滿界面 finalExpandBarexpandBar=newExpandBar(container,SWT.NONE); expandBar.setBackground(SWTResourceManager.getColor(128,128,255)); expandBar.setBounds(0,0,199,513); finalExpandItemnewItemExpandItem=newExpandItem(expandBar,SWT.NONE); newItemExpandItem.setExpanded(true); newItemExpandItem.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/group.png")); newItemExpandItem.setHeight(100); newItemExpandItem.setText("員工信息管理"); finalCompositecomposite=newComposite(expandBar,SWT.NONE); newItemExpandItem.setControl(composite); finalLinkeclipseorgLink=newLink(composite,SWT.NONE); eclipseorgLink.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput("zhigong"); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,Zhigong.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink.setText("<a>查看職工信息</a>"); eclipseorgLink.setBounds(34,10,82,17); finalLinkeclipseorgLink_1=newLink(composite,SWT.NONE); eclipseorgLink_1.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput("zhigong1"); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,Addstu.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink_1.setText("<a>添加職工信息</a>"); eclipseorgLink_1.setBounds(34,30,82,17); finalLinkeclipseorgLink_2=newLink(composite,SWT.NONE); eclipseorgLink_2.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput("zhigong2"); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,Restu.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink_2.setBounds(34,50,82,17); eclipseorgLink_2.setText("<a>修改職工信息</a>"); finalLinkeclipseorgLink_2_1=newLink(composite,SWT.NONE); eclipseorgLink_2_1.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput(Property.USERNAME); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,Delstu.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink_2_1.setBounds(34,70,82,17); eclipseorgLink_2_1.setText("<a>注銷職工信息</a>"); finalExpandItemnewItemExpandItem_1=newExpandItem(expandBar,SWT.NONE); newItemExpandItem_1.setExpanded(true); newItemExpandItem_1.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/login.ico")); newItemExpandItem_1.setHeight(100); newItemExpandItem_1.setText("部門信息管理"); finalCompositecomposite_1=newComposite(expandBar,SWT.NONE); newItemExpandItem_1.setControl(composite_1); finalLinkeclipseorgLink_3=newLink(composite_1,SWT.NONE); eclipseorgLink_3.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput("bumen1"); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,Bumen.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink_3.setBounds(34,10,82,17); eclipseorgLink_3.setText("<a>查看部門信息</a>"); finalLinkeclipseorgLink_4=newLink(composite_1,SWT.NONE); eclipseorgLink_4.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput("bumen2"); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,AddCoach.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink_4.setBounds(34,30,82,17); eclipseorgLink_4.setText("<a>添加部門信息</a>"); finalLinkeclipseorgLink_5=newLink(composite_1,SWT.NONE); eclipseorgLink_5.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput("bumen3"); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,ReCoach.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink_5.setBounds(34,50,82,17); eclipseorgLink_5.setText("<a>修改部門信息</a>"); finalLinkeclipseorgLink_6=newLink(composite_1,SWT.NONE); eclipseorgLink_6.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput(Property.coach); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,DelCoach.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink_6.setBounds(34,70,82,17); eclipseorgLink_6.setText("<a>刪除部門信息</a>"); // createActions(); initializeToolBar(); initializeMenu(); } privatevoidcreateActions(){ //Createtheactions } privatevoidinitializeToolBar(){ IToolBarManagertoolbarManager=getViewSite().getActionBars() .getToolBarManager(); } privatevoidinitializeMenu(){ IMenuManagermenuManager=getViewSite().getActionBars() .getMenuManager(); } @Override publicvoidsetFocus(){ //Setthefocus }}3.3importinput.MyInput;importorg.eclipse.jface.action.IMenuManager;importorg.eclipse.jface.action.IToolBarManager;importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.MouseAdapter;importorg.eclipse.swt.events.MouseEvent;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importorg.eclipse.swt.layout.FillLayout;importorg.eclipse.swt.widgets.Composite;importorg.eclipse.swt.widgets.ExpandBar;importorg.eclipse.swt.widgets.ExpandItem;importorg.eclipse.swt.widgets.Label;importorg.eclipse.swt.widgets.Link;importorg.eclipse.ui.PartInitException;importorg.eclipse.ui.PlatformUI;importorg.eclipse.ui.part.ViewPart;importrsgl.Activator;importcom.swtdesigner.ResourceManager;importcom.swtdesigner.SWTResourceManager;importcommon.InputFactory;importcommon.Property;importeditors.Key;publicclassMyInfoextendsViewPart{ publicstaticfinalStringID="views.MyInfo";//$NON-NLS-1$ @Override publicvoidcreatePartControl(Compositeparent){ Compositecontainer=newComposite(parent,SWT.NONE); container.setLayout(newFillLayout(SWT.VERTICAL)); finalExpandBarexpandBar=newExpandBar(container,SWT.NONE); expandBar.setBackground(SWTResourceManager.getColor(128,128,255)); finalExpandItemnewItemExpandItem=newExpandItem(expandBar,SWT.NONE); newItemExpandItem.setHeight(150); newItemExpandItem.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/house.png")); newItemExpandItem.setExpanded(true); newItemExpandItem.setText("當(dāng)前登錄用戶"); finalCompositecomposite=newComposite(expandBar,SWT.NONE); newItemExpandItem.setControl(composite); finalLabellabel_1=newLabel(composite,SWT.NONE); label_1.setForeground(SWTResourceManager.getColor(255,0,0)); label_1.setBounds(0,15,184,39); label_1.setFont(SWTResourceManager.getFont("華文琥珀",22,SWT.BOLD)); label_1.setText(Property.NAME+"您好!"); finalLabellabel=newLabel(composite,SWT.NONE); label.setForeground(SWTResourceManager.getColor(0,255,0)); label.setBounds(0,70,184,39); label.setFont(SWTResourceManager.getFont("幼圓",15,SWT.NONE)); finalExpandItemnewItemExpandItem_1=newExpandItem(expandBar,SWT.NONE); newItemExpandItem_1.setHeight(60); newItemExpandItem_1.setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/lock.png")); newItemExpandItem_1.setExpanded(true); newItemExpandItem_1.setText("密碼修改"); finalCompositecomposite_1=newComposite(expandBar,SWT.NONE); newItemExpandItem_1.setControl(composite_1); finalLinkeclipseorgLink=newLink(composite_1,SWT.NONE); eclipseorgLink.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ MyInputinput=InputFactory.getInput("mima"); try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input,Key.ID); }catch(PartInitExceptione1){ e1.printStackTrace(); } } }); eclipseorgLink.setText("<a>修改密碼</a>"); eclipseorgLink.setBounds(49,10,64,17); finalLinkeclipseorgLink_1=newLink(composite_1,SWT.NONE); eclipseorgLink_1.addMouseListener(newMouseAdapter(){ publicvoidmouseDown(finalMouseEvente){ System.exit(0);//結(jié)束java虛擬機(jī) } }); eclipseorgLink_1.setBounds(49,30,64,17); eclipseorgLink_1.setText("<a>退出</a>"); createActions(); initializeToolBar(); initializeMenu(); } privatevoidcreateActions(){ //Createtheactions } privatevoidinitializeToolBar(){ IToolBarManagertoolbarManager=getViewSite().getActionBars() .getToolBarManager(); } privatevoidinitializeMenu(){ IMenuManagermenuManager=getViewSite().getActionBars() .getMenuManager(); } @Override publicvoidsetFocus(){ //Setthefocus }}3.4importorg.eclipse.jface.dialogs.MessageDialog;importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.MouseAdapter;importorg.eclipse.swt.events.MouseEvent;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importorg.eclipse.swt.widgets.Button;importorg.eclipse.swt.widgets.Display;importorg.eclipse.swt.widgets.Label;importorg.eclipse.swt.widgets.Shell;importorg.eclipse.swt.widgets.Text;importrsgl.Activator;importcom.swtdesigner.ResourceManager;importcom.swtdesigner.SWTResourceManager;importcommon.DBHelper;publicclassZhuceextendsShell{ privateTexttext3; privateTexttext2; privateTexttext4; privateTexttext1; publicZhuce(Displaydisplay,intstyle){ super(display,style); createContents(); setBackground(SWTResourceManager.getColor(255,255,255)); setBackgroundImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/20070318013605792.jpg")); setBackgroundMode(SWT.INHERIT_DEFAULT); setImage(ResourceManager.getPluginImage(Activator.getDefault(),"lmages/png-0550.png")); } protectedvoidcreateContents(){ setText("用戶注冊"); setSize(555,453); finalLabellabel=newLabel(this,SWT.WRAP); label.setText("用戶名:"); label.setBounds(236,50,64,17); finalLabellabel1=newLabel(this,SWT.WRAP); label1.setText("性別:"); label1.setBounds(236,90,64,17); finalLabellabel2=newLabel(this,SWT.NONE); label2.setText("密碼:"); label2.setBounds(236,130,50,17);finalLabellabel3=newLabel(this,SWT.NONE); label3.setText("確認(rèn)密碼:"); label3.setBounds(236,170,64,17); finalLabellabel4=newLabel(this,SWT.WRAP); label4.setText("聯(lián)系電話:"); label4.setBounds(236,210,64,17); text1=newText(this,SWT.BORDER); text1.setBounds(349,50,155,23); finalButtonbutton=newButton(this,SWT.RADIO); button.addMouseListener(newMouseAdapter(){ publicvoidmouseDown(finalMouseEvente){ //if(!(text1.getText().trim()!="")){ if(text1.getText().trim()==""){ MessageDialog.openError(Zhuce.this,"提示!","姓名不能為空!"); } } });button.setText("男"); button.setBounds(349,90,33,17); finalButtonbutton_1=newButton(this,SWT.RADIO); button_1.addMouseListener(newMouseAdapter(){ publicvoidmouseDown(finalMouseEvente){ //if(!(text1.getText().trim()!="")){ if(text1.getText().trim()==""){ MessageDialog.openWarning(Zhuce.this,"提示!","姓名不能為空!"); } } }); button_1.setBounds(467,90,33,17); button_1.setText("女"); text2=newText(this,SWT.BORDER|SWT.PASSWORD); text2.addMouseListener(newMouseAdapter(){ publicvoidmouseDown(finalMouseEvente){ if(!(button.getSelection())&&!(button_1.getSelection())){ MessageDialog.openWarning(Zhuce.this,"提示!","請選擇性別!"); } } }); text2.setBounds(349,127,155,23); text3=newText(this,SWT.BORDER|SWT.PASSWORD); text3.setBounds(349,167,155,23); text4=newText(this,SWT.BORDER); text4.addMouseListener(newMouseAdapter(){ publicvoidmouseDown(finalMouseEvente){ if(text2.getText().equals("")){ MessageDialog.openWarning(Zhuce.this,"提示!","必須輸入密碼!"); }elseif(!text2.getText().equals(text3.getText())){ MessageDialog.openError(Zhuce.this,"錯誤!","兩次密碼不同,請重新輸入!"); } } }); text4.setBounds(349,207,155,23); finalButtonbutton_2=newButton(this,SWT.NONE); button_2.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ Stringsex1=""; if(button.getSelection()){ sex1=button.getText(); }elseif(button_1.getSelection()){ sex1=button_1.getText(); } Stringsql="insertintousers(name,sex,password,phone)"+ "values('"+text1.getText()+"','"+sex1+"','"+text2.getText()+"','"+text4.getText()+"')"; System.out.println(sql); DBHelperdb=newDBHelper(); intm=db.update(sql); if(m>0){ MessageDialog.openInformation(Zhuce.this,"恭喜你","注冊成功"); Zhuce.this.dispose(); try{ Displaydisplay=Display.getDefault(); Loginshellshell=newLoginshell(display,SWT.SHELL_TRIM); shell.open(); shell.layout(); Zhuce.this.dispose(); while(!shell.isDisposed()){ if(!display.readAndDispatch()) display.sleep(); } }catch(Exceptione2){ e2.printStackTrace(); } }else{ MessageDialog.openError(Zhuce.this,"很遺憾","注冊失敗!"); } } }); button_2.setBackground(SWTResourceManager.getColor(255,255,255)); button_2.setText("提交"); button_2.setBounds(236,259,104,23); finalButtonbutton_3=newButton(this,SWT.NONE); button_3.addSelectionListener(newSelectionAdapter(){ publicvoidwidgetSelected(finalSelectionEvente){ try{ Displaydisplay=Display.getDefault(); Loginshellshell=newLoginshell(display,SWT.SHELL_TRIM); shell.open(); shell.layout(); Zhuce.this.dispose(); while(!shell.isDisposed()){ if(!display.readAndDispatch()) display.sleep();
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 墩、臺身和蓋梁工程現(xiàn)場質(zhì)量檢驗報告單(五)
- 智能交通管理平臺開發(fā)協(xié)議
- 辦公用品采購預(yù)算與實際使用對比表格
- 專業(yè)資料出版合作協(xié)議
- 水利水電工程施工承包協(xié)議
- 企業(yè)品牌授權(quán)使用協(xié)議書
- 小學(xué)生體育運(yùn)動啟蒙故事讀后感
- 太陽能光伏系統(tǒng)安裝維護(hù)合同
- 2024-2025學(xué)年高二數(shù)學(xué)湘教版選擇性必修第二冊教學(xué)課件 第2章-2.4空間向量在立體幾何中的應(yīng)用-2.4.3 向量與夾角
- 水系統(tǒng)基礎(chǔ)知識培訓(xùn)課件
- 計算機(jī)網(wǎng)絡(luò)技術(shù)基礎(chǔ)高職PPT完整全套教學(xué)課件
- 安徽各市(精確到縣區(qū))地圖PPT課件(可編輯版)
- 大動脈粥樣硬化型腦梗死總(內(nèi)科學(xué)課件)
- 學(xué)士學(xué)位個人思想政治表現(xiàn)【六篇】
- 初中數(shù)學(xué)-生活中的“一次模型”教學(xué)課件設(shè)計
- 張養(yǎng)浩《翠陰亭記》原文,注釋,譯文,賞析
- 公共租賃住房直管公房租金收繳管理制度
- 離心泵畢業(yè)設(shè)計
- 部編版語文二年級下冊《彩色的夢》說課稿(附教學(xué)反思、板書)課件
- 天津市南開區(qū)2023年中考英語二模試卷及答案
- 中興 ZXNOE 9700 系統(tǒng)介紹
評論
0/150
提交評論