Java ÆíÁý±â¿¡¼­ ¹Ì¸®º¸±â·Î ÄÚµå Á¶ÀÛ

JDT ÄÚ¾î Ç÷¯±×ÀÎÀº ÇÁ·Î±×·¡¹ÖÇÏ¿© Java ¿ä¼Ò¸¦ ÀÛ¼º, »èÁ¦, ¼öÁ¤ÇÏ´Â ¿©·¯ °¡Áö ¸ÞÄ¿´ÏÁòÀ» Á¦°øÇÕ´Ï´Ù. JDT Äھ Á¦°øÇÏ´Â API¿¡ ´ëÇÑ ¼Ò°³´Â Java ÄÚµå Á¶ÀÛÀ» ÂüÁ¶ÇϽʽÿÀ.

UI ºÐ¾ß¿¡¼­ À̰ÍÀº Á¾Á¾ º¯°æ»çÇ×À» ÀúÀåÇϱâ Àü¿¡ »ç¿ëÀÚ°¡ ¹Ì¸®º¸±â¸¦ È®ÀÎÇÏ°Ô ÇÒ °æ¿ì À¯¿ëÇÕ´Ï´Ù. À̰ÍÀº ¼öÁ¤ÇÒ ÄÄÆÄÀÏ ´ÜÀ§ÀÇ Java ÆíÁý±â¸¦ ¿­¾î ¼öÇàÇÒ ¼ö ÀÖ½À´Ï´Ù. ±×·¯¸é »ç¿ëÀÚ°¡ Java ÆíÁý±âÀÇ ÄÁÅÙÃ÷¸¦ µð½ºÅ©¿¡ ÀúÀåÇϰųª ´Ù½Ã ¿ø·¡ ÄÁÅÙÃ÷·Î µÇµ¹¸± ¼ö ÀÖ½À´Ï´Ù. ´ÙÀ½Àº ÆíÁý±â¿¡¼­ ÄÄÆÄÀÏ ´ÜÀ§¸¦ ¿¬ ´ÙÀ½ ÆíÁý±â¿¡¼­ ÀÛ¼ºÇÑ ÀÛ¾÷ ÁßÀÎ »çº»À» »ç¿ëÇÏ¿© º¯°æ»çÇ×À» ¼öÇàÇÏ´Â ÄÚµå ½º´ÏÆêÀÔ´Ï´Ù.

void modifyCompilationUnit(ICompilationUnit cunit) throws PartInitException, CoreException {
IEditorPart editor= JavaUI.openInEditor(cunit);
IEditorInput input= editor.getEditorInput();
IWorkingCopyManager manager= JavaUI.getWorkingCopyManager();
manager.connect(input);
try {
ICompilationUnit workingCopy= manager.getWorkingCopy(input);
// do the modifications on workingCopy using the normal JDT Core API. } finally {
manager.disconnect(input);
}
// either keep the editor dirty or use editor.doSave(IProgressMonitor monitor) // to save the changes programmatically.
}

Copyright IBM Corporation and others 2000, 2002. All Rights Reserved.