åå¤å·¥ä½ï¼
1ãä¸è½½JDKï¼
2ãä¸è½½Eclipseï¼
3ãä¸è½½ç¸åºçEMFãGEFãVEï¼
注æï¼ä¸ä¸ªæ件ççæ¬è¦åEclipseççæ¬é
å¥æè½æ£ç¡®ä½¿ç¨ï¼è³äºé
å¥ç说æ请åèä¸è½½é¡µé¢ç说æ
http://download.eclips.org/veå¼å§å®è£
ï¼
1ãå®è£
JDKï¼
è¿ä¸ªæ¯è¾å®¹æï¼æ åçWindowså®è£
ç¨åºï¼ä¸ä¸æ¥ï¼åä¸ä¸æ¥å³å¯ï¼å®è£
å®æåï¼ä¹ä¸éè¦éå¯ã
2ãå®è£
Eclipseï¼
Eclipseæ¯ç»¿è²è½¯ä»¶ï¼ä¸éè¦å®è£
ï¼åªéè¦è§£å缩ï¼ç¶åå³å¯è¿è¡ã
为äºè¯´ææ¹ä¾¿ï¼ææå®è§£å缩å°Cçæ ¹ç®å½ä¸ï¼å¾å°C:\eclipseç®å½ï¼è¿è¡C:\eclipse\eclipse.exeå³å¯ã
注æï¼ä¸é¢çå®è£
ï¼éè¦å
å
³éeclipseç¨åºã
3ãå®è£
EMFãGEFãVEï¼
对äºEclipseæ¥è¯´ï¼è¿äºé½æ¯å®çæ件ï¼æ以ï¼å®è£
æ¹æ³é½æ¯ä¸æ ·çãæ件ä¸è½½å°å
http://download.eclips.org/ve Aãå¨C:\eclipseç®å½ä¸ï¼å»ºç«å个åç®å½ï¼C:\eclipse\emfãC:\eclipse\gefãC:\eclipse\veãC:\eclipse\linksï¼
Bãæä¸è½½çEMFãGEFãVEé½è§£å缩å°ç¸åºçç®å½ä¸ï¼å³ï¼æEMFå缩å
解å缩å°C:\eclipse\emfä¸ï¼å¾å°C:\eclipse\emf\eclipseç®å½ï¼ä»¥æ¤ç±»æ¨ï¼å®æGEFãVEç解å缩ï¼
Cãå¨C:\eclipse\linksç®å½ä¸ï¼æ°å»ºä¸ä¸ªææ¬æ件ï¼ååå¯é便åï¼å¦ï¼link.txtã
ç¶åå¨link.txtæ件ä¸ï¼å å
¥ä»¥ä¸ä¸è¡æåï¼
path=emf
path=gef
path=VE
注æï¼è¿éç¨çæ¯ç¸å¯¹è·¯å¾ï¼ä¹å¯ä»¥æEMFãGEFãVE解å缩å°å
¶å®å°æ¹ï¼åç¨ç»å¯¹è·¯å¾å³å¯ã
å注æï¼ç»å¯¹è·¯å¾æ¯ç¨ â/â æè
â\\â åéï¼èä¸æ¯â\â
è¡¥å
ç¥è¯ï¼ä¸ºä»ä¹veéè¦emfågefï¼
Visual Editor æå©ç¨çæ为ææ¾çå·¥å
·æ¯ GEFï¼å³å¾å½¢åç¼è¾æ¡æ¶ï¼Graphical Editing
Frameworkï¼ãGEF 建ç«äºæ¬å° Eclipse å¾å½¢åå·¥å
·é SWT
ä¹ä¸ï¼ä»¥ä½¿å¾å¼åä¸ä¸ªå¾å½¢åç¼è¾å¨æè
æè§å³æå¾ææ¬ç¼è¾å¨æ´ä¸ºå®¹æãå¦ææ¨çæ SWT ï¼æè
AWT/Swingï¼å¨è¿æ¹é¢å®ä»¬æ¯ç±»ä¼¼çï¼ä¸çå¾å½¢åè¯ï¼é£ä¹æ¨ä¼ç¥éç»å¶åå¤çä»»æçå½¢ç¶ï¼æ¯å¦ç©å½¢ãç®å¤´åæ¤åï¼æ¯æ¯è¾å°é¾çï¼æ´ä¸ç¨è¯´ç®¡çå®ä»¬ä¹é´çå
³ç³»ä»¥åå®ä»¬æ代表çæ°æ®æ¨¡åäºã
GEF 被åå为两个é¨åï¼ç¬¬ä¸é¨åæ¯ Draw2D æ件ï¼è¿æ¯ä¸ä¸ªè½»é级çç»å¾ååç°å
ï¼ç¨äºå¸®å©æ¨ç»å¶å¾å½¢ã第äºé¨åæ¯ GEF æ件ï¼é¤äºå
¶ä»å·¥å
·ä»¥å¤ï¼è¿ä¸é¨åä¸è¿å¢å äºéæ©åå建工å
ዌᴌ
·é项æ¿ï¼ä»¥åç¨äºå¨æ°æ®æ¨¡ååè§å¾ä¹é´è¿è¡æ å°çæ§å¶å¨æ¡æ¶ã
GEF
æ¯ä¸ä¸ªæ¨¡åæ å
³çæ¡æ¶ï¼ä½æ¯ä½ä¸º Visual Editor ï¼ä»¥åå
¶ä»çæ代ç çå¾å½¢åå·¥å
·ï¼çä¸é¨åï¼å®å¨åå°ä½¿ç¨ Eclipse
建模æ¡æ¶ï¼Eclipse Modeling Framework, EMFï¼ï¼ä»¥å¨æ¨¡åãJava ç±»åå¾å½¢å表示ä¹é´è¿è¡æ å°ï¼å
¶ä¸æ¨¡åæ¯ä½¿ç¨
XML å
æ°æ®äº¤æ¢ï¼XML Metadata Interchange, XMIï¼å¨å
é¨åå¨çãEMF
çéè¦ç¹æ§ä¹ä¸æ¯å®ç¡®ä¿ææè¿äºæ å°é½æ¯ä¸å¯¹ä¸çï¼æ以尽管 XMI
å¯ä»¥è¢«è®¤ä¸ºæ¯æ¨¡åçæ å表示ï¼ä½æ¯å¨ä»£ç åå¾å½¢ä¹é´æ¥ååæ¢å¹¶ä¸ä¼ä¸¢å¤±ä»»ä½ä¿¡æ¯ãè¿å°±æ¯ä¸ºä»ä¹ Visual Editor
åªéè¦ä¿å模åçä¸ç§è¡¨ç¤ºï¼å³ Java æºä»£ç ï¼ï¼ä»¥åå¼å人åå¯ä»¥èªç±å°å¨å¾å½¢åç¼è¾å¨ä¹å¤ç¼è¾è¯¥æºä»£ç çåå ã
4ãå®è£
å®æ¯ï¼å次è¿è¡Eclipseï¼å®å¯å¨æ¶ä¼èªå¨æ¥æ¾linksç®å½ä¸ææçææ¬æ件ï¼å¹¶å è½½å
¶ä¸pathæåçæææ件ï¼è¿éå½ç¶å
æ¬VEã
Aãå¦æä¸è½ç¡®å®æ¯å¦å·²ç»å è½½ï¼å¯éæ©èåHelp->Software Updates->Manage Configurationï¼æå¼Product Configurationçªä½ï¼å¨å
¶å·¦è¾¹çæ å½¢æ éï¼å¯ä»¥çå°å·²å è½½çæ件ã
Bãå¦æå 载没ææåï¼å¯ä»¥è¯è¯ç¨Eclipse -clearæ¥è¿è¡ç¨åºã
Cãå¦æå è½½ä»æ²¡ææåï¼å¯ä»¥è¯è¯å é¤C:\eclipse\configurationä¸çå
容ï¼ä»
ä¿çconfig.iniæ件ãç¶ååç¨Eclipseæ¥è¿è¡ç¨åºã
================================================================
å¯å¨eclipseå¹³å°ãåå¼å§ï¼ä½ å¯è½è§å¾eclipse并没æä»ä¹ååãå
å«æ¥ï¼è¯·æ°å»ºä¸ä¸ªé¡¹ç®ï¼ç¹å»"æ件"èåä¸ç"æ°å»º"åèåï¼éæ©å¹¶å»ºç«ä¸ä¸ªæ°ç"java项ç®"ãç¶åå¨å·¥å
·æ ä¸ç"æ°å»ºJavaç±»" å¾æ ä¸ï¼ç¹å»å³è¾¹çå°ç®å¤´ï¼å°å±å¼å¦ä¸å¾çèåï¼
ãã
ããå¨æ¤èåä¸ï¼å¤äºä¸ä¸ª"Visual Calss"çåèå,è¿å°±æ¯è¿å
¥Visual Editorçå
¥å£ä¹ä¸ãç¹å»"Visual Class"ï¼å°±ä¼å¼¹åºå建GUIç¨åºç对è¯æ¡ï¼éæ©å®æ¯åï¼å°±ä¼è¿å
¥å¯è§åç¼è¾ç»é¢ï¼
ç¨VEå个Helloï¼
1ãæ°å»ºä¸ä¸ªé¡¹ç®ï¼
File->New->Project...ï¼éæ©âJava Projectâï¼ç¶åNextï¼è¾å
¥ä¸ä¸ªé¡¹ç®ååï¼Helloï¼å
¶å®å
¨é¨é»è®¤ï¼æåå车ï¼æè
ç¹å»âFinishâå®æã
2ã设置SWTåºï¼
Aãéæ©é¡¹ç®Helloï¼å³é®èåï¼æå¼Properties对è¯æ¡ã
Bãéæ©å·¦è¾¹æ å½¢ä¸çJava Build Pathï¼å¨å
¶è®¾ç½®é¡µä¸ï¼éæ©Libraries页ï¼ç¹å»âAdd Library...âï¼
Cãå¨æå¼çAdd Library对è¯æ¡éï¼éæ©Standard Widget Toolkit(SWT)ï¼Nextï¼
Dãå¨æå¼çSWT Library Options对è¯æ¡ä¸ï¼å¾éä¸âInclude support for JFace libraryâï¼Finishå³å¯ã
Eãåå°Properties对è¯æ¡ï¼OKå³å¯ã
3ãæ°å»ºHellworld.javaæ件ï¼
Aãéæ©é¡¹ç®Hello,å³é®èåï¼New->Other...ï¼æè
ç¹å»å·¥å
·æ éæ°å»ºå¾æ ï¼ï¼æå¼Select a wizard对è¯æ¡ï¼éæ©Java/Visual Class,Nextï¼
Bãå¨æå¼çJava Visual Class对è¯æ¡ä¸ï¼
å¨Packageéï¼è¾å
¥ï¼com.cnblogs.panï¼
å¨Nameéï¼è¾å
¥ï¼Helloworldï¼
å¨Styleéï¼éæ©SWT/Shellï¼
å¾éä¸public static void main(String[] args);
æåFinishã
4ãå°äºè¿ä¸æ¥ï¼åºè¯¥å°±å¯ä»¥çå°çªä½äºï¼é£äºæ§ä»¶é½å¨Paletteéï¼ç¹å¼å°±è½çå°äºã
Aãå¨çªä½ä¸å³å»ï¼éæ©Set Layoutï¼åéæ©nullï¼ï¼æ¤å¤ä¸ºä¸ªäººä¹ æ¯ï¼
Bãä»Paletteéï¼éä¸ä¸ä¸ªButtonï¼å¹¶å¨çªä½ä»»æä½ç½®ç»ä¸ä¸ªButtonï¼å¨ä¸é¢çPropertiesçªå£éï¼è®¾ç½®å
¶text为ClickMeï¼
Cãéä¸è¯¥æé®ï¼å³å»éæ©Events->Add Eventï¼å¨æå¼ç对è¯æ¡ä¸ï¼éæ©å·¦è¾¹çwidgetSelectedï¼Finishã
Dãè¿æ¶ï¼å
æ ä¼èªå¨å®ä½å°ç¨åºç¸åºçä½ç½®ï¼æ们å¨ç¨åºéå å
¥ä¸é¢è¯å¥ï¼
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
System.out.println("widgetSelected()");
MessageDialog.openInformation(null, "Hello", "Hello World!");//å å
¥è¿æ¡è¯å¥
}
Eãä¿åç¨åºï¼ç¹å»èåRun->Run As->Java Applicationï¼åµåµï¼è·å
¨ä¸çæ个æå¼å§ï¼