ÇÁ·ÎÁ§Æ® ¼Ó¼º

ÇÁ·ÎÁ§Æ® ¼Ó¼ºÀº Ç÷¯±×ÀÎÀÌ ÇÁ·ÎÁ§Æ®¸¦ ƯÁ¤ À¯ÇüÀÇ ÇÁ·ÎÁ§Æ®·Î ű×È­ÇÒ ¼ö ÀÖµµ·Ï ÇÕ´Ï´Ù. ¿¹¸¦ µé¾î, JDT(Java Development Tools)´Â "Java ¼Ó¼º"À» »ç¿ëÇÏ¿© ÇÁ·ÎÁ§Æ®¿¡ Java ƯÁ¤ ÀÛµ¿À» Ãß°¡ÇÕ´Ï´Ù.

¼Ó¼ºÀº ÇÁ·ÎÁ§Æ® ´ÜÀ§·Î ¼³Ä¡µÇ¸ç, ÇÁ·ÎÁ§Æ®¿¡ Ãß°¡µÇ¸é ÀÚµ¿À¸·Î ±¸¼ºµÇ°í Á¦°ÅµÉ ¶§ ±¸¼º ÇØÁ¦µË´Ï´Ù.  ÇÁ·ÎÁ§Æ®¿¡´Â µÑ ÀÌ»óÀÇ ¼Ó¼ºÀÌ ÀÖÀ» ¼ö ÀÖ½À´Ï´Ù.

°íÀ¯ÀÇ ¼Ó¼ºÀ» ±¸ÇöÇÏ·Á¸é È®ÀåÀÚ¸¦ Á¤ÀÇÇϰí IProjectNature¸¦ ±¸ÇöÇϴ Ŭ·¡½º¸¦ Á¦°øÇØ¾ß ÇÕ´Ï´Ù.

¼Ó¼º Á¤ÀÇ

org.eclipse.core.resources.natures È®ÀåÁ¡Àº ÇÁ·ÎÁ§Æ® ¼Ó¼º Á¤ÀǸ¦ Ãß°¡ÇÏ´Â µ¥ »ç¿ëµË´Ï´Ù. ´ÙÀ½ ¸¶Å©¾÷Àº °¡»óÀÇ com.example.natures Ç÷¯±×Àο¡ ¼Ó¼ºÀ» Ãß°¡ÇÕ´Ï´Ù.

<extension
    point="org.eclipse.core.resources.natures"
    id="mynature"
    name="My Nature">
    <runtime>
        <run class="com.example.natures.MyNature">
        </run>
    </runtime>
</extension>

È®ÀåÀÚ¿¡¼­ ½Äº°µÈ Ŭ·¡½º´Â Ç÷§Æû ÀÎÅÍÆäÀ̽º IProjectNature¸¦ ±¸ÇöÇØ¾ß ÇÕ´Ï´Ù. ÀÌ Å¬·¡½º´Â ¼Ó¼ºÀÌ ±¸¼ºµÉ ¶§ ¼Ó¼º ƯÁ¤ Á¤º¸¸¦ ÇÁ·ÎÁ§Æ®¿Í ¿¬°ü½Ã۱â À§ÇÑ Ç÷¯±×ÀΠƯÁ¤ ÀÛµ¿À» ±¸ÇöÇÕ´Ï´Ù.

public class MyNature implements IProjectNature {

    private IProject project;

    public void configure() throws CoreException {
        // Add nature-specific information
        // for the project, such as adding a builder
        // to a project's build spec.
    }
    public void deconfigure() throws CoreException {
        // Remove the nature-specific information here.
    }
    public IProject getProject() {
        return project;
    }
    public void setProject(IProject value) {
        project = value;
    }
}

configure() ¹× deconfigure() ¸Þ¼Òµå´Â ÇÁ·ÎÁ§Æ®¿¡ ¼Ó¼ºÀÌ Ãß°¡µÇ°Å³ª Á¦°ÅµÉ ¶§ Ç÷§Æû¿¡¼­ Àü¼ÛµË´Ï´Ù.  configure() ¸Þ¼Òµå¸¦ ±¸ÇöÇÏ¿© ºô´õ¿¡ ¼³¸íµÈ ´ë·Î ÇÁ·ÎÁ§Æ®¿¡ ºô´õ¸¦ Ãß°¡ÇÒ ¼ö ÀÖ½À´Ï´Ù.

¼Ó¼ºÀ» ÇÁ·ÎÁ§Æ®¿Í ¿¬°ü

¼Ó¼ºÀ» Á¤ÀÇÇϰí Ŭ·¡½º¸¦ ±¸ÇöÇßÀ¸¸é ÇÁ·ÎÁ§Æ®¿¡ ¼Ó¼ºÀ» ÁöÁ¤ÇØ¾ß ÇÕ´Ï´Ù. ´ÙÀ½ ½º´ÏÆêÀº ÁÖ¾îÁø ÇÁ·ÎÁ§Æ®¿¡ »õ ¼Ó¼ºÀ» ÁöÁ¤ÇÕ´Ï´Ù.

try {
    IProjectDescription description = project.getDescription();
    String[] natures = description.getNatureIds();
    String[] newNatures = new String[natures.length + 1];
    System.arraycopy(natures, 0, newNatures, 0, natures.length);
    newNatures[natures.length] = "com.example.natures.mynature";
    description.setNatureIds(newNatures);
    project.setDescription(description, null);
} catch (CoreException e) {
    // Something went wrong
}

¼Ó¼º¿¡ »ç¿ëµÇ´Â ID´Â ¼Ó¼º È®ÀåÀÇ ¿ÏÀüÇÑ À̸§(Ç÷¯±×ÀÎ ID + È®Àå ID)ÀÔ´Ï´Ù.

ÀϹÝÀûÀ¸·Î ¼Ó¼ºÀº ÇÁ·ÎÁ§Æ®°¡ ÀÛ¼ºµÉ ¶§ ÇÁ·ÎÁ§Æ®¿¡ Ãß°¡µË´Ï´Ù.  ÀϹÝÀûÀ¸·Î »ç¿ëÀÚ´Â ÇÁ·ÎÁ§Æ®¿¡ ´ëÇÑ Æ¯¼ö Á¤º¸¸¦ ĸóÇÏ´Â »ç¿ëÀÚ Á¤ÀÇµÈ »õ ÇÁ·ÎÁ§Æ® ¸¶¹ý»ç¸¦ Á¦°øÇÏ¿© ¼Ó¼ºÀ» ÁöÁ¤ÇÕ´Ï´Ù.