sysmodelmgr/com.symbian.smt.gui/src/com/symbian/smt/gui/nature/Nature.java
changeset 0 522a326673b6
equal deleted inserted replaced
-1:000000000000 0:522a326673b6
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 package com.symbian.smt.gui.nature;
       
    17 
       
    18 import org.eclipse.core.resources.ICommand;
       
    19 import org.eclipse.core.resources.IProject;
       
    20 import org.eclipse.core.resources.IProjectDescription;
       
    21 import org.eclipse.core.resources.IProjectNature;
       
    22 import org.eclipse.core.runtime.CoreException;
       
    23 
       
    24 public class Nature implements IProjectNature {
       
    25 	public static final String ID = "com.symbian.smt.gui.nature";
       
    26 
       
    27 	private IProject project;
       
    28 
       
    29 	public void configure() throws CoreException {
       
    30 		IProjectDescription desc = project.getDescription();
       
    31 		ICommand[] commands = desc.getBuildSpec();
       
    32 
       
    33 		for (int i = 0; i < commands.length; ++i) {
       
    34 			if (commands[i].getBuilderName().equals(
       
    35 					"com.symbian.smt.gui.builder")) {
       
    36 				return;
       
    37 			}
       
    38 		}
       
    39 
       
    40 		ICommand[] newCommands = new ICommand[commands.length + 1];
       
    41 		System.arraycopy(commands, 0, newCommands, 0, commands.length);
       
    42 		ICommand command = desc.newCommand();
       
    43 		command.setBuilderName("com.symbian.smt.gui.builder");
       
    44 		newCommands[newCommands.length - 1] = command;
       
    45 		desc.setBuildSpec(newCommands);
       
    46 		project.setDescription(desc, null);
       
    47 	}
       
    48 
       
    49 	public void deconfigure() throws CoreException {
       
    50 	}
       
    51 
       
    52 	public IProject getProject() {
       
    53 		return project;
       
    54 	}
       
    55 
       
    56 	public void setProject(IProject project) {
       
    57 		this.project = project;
       
    58 	}
       
    59 }