tinydtnature.java

来自「plugin for eclipse」· Java 代码 · 共 73 行

JAVA
73
字号
package isis.tinydt;

import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;

public class TinydtNature implements IProjectNature
{
    public static final String NATURE_ID = "isis.tinydt.tinydtnature";

    private IProject           project   = null;

    public TinydtNature()
    {

    }

    public void configure() throws CoreException
    {
        addParser();
    }       

    private void addParser() throws CoreException
    {
        // Get project description and then the associated build commands
        IProjectDescription desc = project.getDescription();
        ICommand[] commands = desc.getBuildSpec();

        // Determine if builder already associated
        boolean found = false;
        for (int i = 0; i < commands.length; ++i)
        {
            if (commands[i].getBuilderName().equals(TinydtParser.BUILDER_ID))
            {
                found = true;
                break;
            }
        }

        // Add builder if not already in project
        if (!found)
        {
            ICommand command = desc.newCommand();
            command.setBuilderName(TinydtParser.BUILDER_ID);
            // Create map with arguments specific to builder in project here
            // command.setArguments(Map args);
            ICommand[] newCommands = new ICommand[commands.length + 1];

            // Add it before other builders.
            System.arraycopy(commands, 0, newCommands, 1, commands.length);
            newCommands[0] = command;
            desc.setBuildSpec(newCommands);
            project.setDescription(desc, null);
        }
    }

    public void deconfigure() throws CoreException
    {
    }

    public IProject getProject()
    {
        return project;
    }

    public void setProject(IProject p)
    {
        project = p;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?