免费A级毛片无码专区网站-成人国产精品视频一区二区-啊 日出水了 用力乖乖在线-国产黑色丝袜在线观看下-天天操美女夜夜操美女-日韩网站在线观看中文字幕-AV高清hd片XXX国产-亚洲av中文字字幕乱码综合-搬开女人下面使劲插视频

Eclipse插件RCP桌面應(yīng)用開發(fā)的點(diǎn)點(diǎn)滴滴

Eclipse插件開發(fā)的點(diǎn)點(diǎn)滴滴新公司做的是桌面應(yīng)用程序,與之前一直在做的web頁面 ,相差甚大。這篇文章是寫于2022年10月底,這時(shí)在新公司已經(jīng)入職了快三月 。寫作目的是:國內(nèi)對(duì)于eclipse插件開發(fā)相關(guān)的文檔是少之又少,這三個(gè)月我們小組翻遍了國外文檔,勉強(qiáng)將軟件拼湊出并release出測(cè)試版本,為了方便同行以及自我學(xué)習(xí),所以想把這幾個(gè)月學(xué)到的eclipse rcp插件相關(guān)知識(shí)寫下來 。
一、 Wizard部分Wizard 一般用于向?qū)綄?duì)話框 ,eclipse的新建項(xiàng)目就是一個(gè)典型的wizard。wizard一般由幾個(gè)wizard page 組成 ,通過按鈕控制 上一頁下一頁完成取消。

Eclipse插件RCP桌面應(yīng)用開發(fā)的點(diǎn)點(diǎn)滴滴

文章插圖
1.wizardpages
wizardpage1package de.vogella.rcp.intro.wizards.wizard;import org.eclipse.jface.wizard.WizardPage;import org.eclipse.swt.SWT;import org.eclipse.swt.events.KeyEvent;import org.eclipse.swt.events.KeyListener;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 org.eclipse.swt.widgets.Text;public class MyPageOne extends WizardPage {private Text text1;private Composite container;public MyPageOne() {super("First Page");setTitle("First Page");setDescription("Fake Wizard: First page");}@Overridepublic void createControl(Composite parent) {container = new Composite(parent, SWT.NONE);GridLayout layout = new GridLayout();container.setLayout(layout);layout.numColumns = 2;Label label1 = new Label(container, SWT.NONE);label1.setText("Put a value here.");text1 = new Text(container, SWT.BORDER | SWT.SINGLE);text1.setText("");text1.addKeyListener(new KeyListener() {@Overridepublic void keyPressed(KeyEvent e) {}@Overridepublic void keyReleased(KeyEvent e) {if (!text1.getText().isEmpty()) {setPageComplete(true);}}});GridData gd = new GridData(GridData.FILL_HORIZONTAL);text1.setLayoutData(gd);// required to avoid an error in the systemsetControl(container);setPageComplete(false);}public String getText1() {return text1.getText();}}
wizardpage2package de.vogella.rcp.intro.wizards.wizard;import org.eclipse.jface.wizard.WizardPage;import org.eclipse.swt.SWT;import org.eclipse.swt.events.KeyEvent;import org.eclipse.swt.events.KeyListener;import org.eclipse.swt.layout.GridData;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Composite;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.widgets.Text;public class MyPageTwo extends WizardPage {private Text text1;private Composite container;public MyPageTwo() {super("Second Page");setTitle("Second Page");setDescription("Now this is the second page");setControl(text1);}@Overridepublic void createControl(Composite parent) {container = new Composite(parent, SWT.NONE);GridLayout layout = new GridLayout();container.setLayout(layout);layout.numColumns = 2;Label label1 = new Label(container, SWT.NONE);label1.setText("Say hello to Fred");text1 = new Text(container, SWT.BORDER | SWT.SINGLE);text1.setText("");text1.addKeyListener(new KeyListener() {@Overridepublic void keyPressed(KeyEvent e) {// TODO Auto-generated method stub}@Overridepublic void keyReleased(KeyEvent e) {if (!text1.getText().isEmpty()) {setPageComplete(true);}}});GridData gd = new GridData(GridData.FILL_HORIZONTAL);text1.setLayoutData(gd);Label labelCheck = new Label(container, SWT.NONE);labelCheck.setText("This is a check");Button check = new Button(container, SWT.CHECK);check.setSelection(true);// required to avoid an error in the systemsetControl(container);setPageComplete(false);}public String getText1() {return text1.getText();}}
①自定義wizardpage主要是繼承JFACE 的 WizardPage ,并重寫 createControl方法 。在createControl方法中,可以對(duì)你的向?qū)ы撁娼M件進(jìn)行布局、添加監(jiān)聽等動(dòng)作 。②對(duì)于當(dāng)前頁面的標(biāo)題、描述等信息,可以在構(gòu)造函數(shù)中通過setTitle 和 setDescription方法來設(shè)置

經(jīng)驗(yàn)總結(jié)擴(kuò)展閱讀