org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WizardNewProjectCreationPage.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Wed, 09 Jun 2010 14:44:32 -0700
changeset 366 715f288b552a
permissions -rw-r--r--
Bug 2779 - Better naming for Application templates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
366
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
package org.symbian.tools.wrttools.wizards;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
import java.net.URI;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
import org.eclipse.core.resources.IProject;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
import org.eclipse.core.resources.IResource;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
import org.eclipse.core.resources.IWorkspace;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
import org.eclipse.core.resources.ResourcesPlugin;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
import org.eclipse.core.runtime.IPath;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
import org.eclipse.core.runtime.IStatus;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
import org.eclipse.core.runtime.Path;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
import org.eclipse.jface.dialogs.Dialog;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
import org.eclipse.jface.viewers.IStructuredSelection;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
import org.eclipse.jface.wizard.WizardPage;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
import org.eclipse.swt.SWT;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
import org.eclipse.swt.layout.GridData;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
import org.eclipse.swt.layout.GridLayout;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
import org.eclipse.swt.widgets.Composite;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
import org.eclipse.swt.widgets.Event;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
import org.eclipse.swt.widgets.Label;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import org.eclipse.swt.widgets.Listener;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
import org.eclipse.swt.widgets.Text;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
import org.eclipse.ui.IWorkingSet;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
import org.eclipse.ui.PlatformUI;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.ui.dialogs.WorkingSetGroup;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
/**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
 * Standard main page for a wizard that is creates a project resource.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
 * <p>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
 * This page may be used by clients as-is; it may be also be subclassed to suit.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
 * </p>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
 * <p>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
 * Example usage:
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
 * <pre>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
 * mainPage = new WizardNewProjectCreationPage("basicNewProjectPage");
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
 * mainPage.setTitle("Project");
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
 * mainPage.setDescription("Create a new project resource.");
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
 * </pre>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
 * </p>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
 */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
public class WizardNewProjectCreationPage extends WizardPage {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    48
       // initial value stores
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
    private String initialProjectFieldValue;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    51
    // widgets
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
    Text projectNameField;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    53
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    54
    private final Listener nameModifyListener = new Listener() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    55
        public void handleEvent(Event e) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    56
        	setLocationForSelection();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    57
            boolean valid = validatePage();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    58
            setPageComplete(valid);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    59
                
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    60
        }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    61
    };
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    62
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    63
	private ProjectContentsLocationArea locationArea;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    64
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    65
	private WorkingSetGroup workingSetGroup;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    66
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    67
    // constants
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    68
    private static final int SIZING_TEXT_FIELD_WIDTH = 250;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    69
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    70
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    71
     * Creates a new project creation wizard page.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    72
     *
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    73
     * @param pageName the name of this page
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    74
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    75
    public WizardNewProjectCreationPage(String pageName) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    76
    	super(pageName);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    77
	    setPageComplete(false);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    78
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    79
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    80
	/** (non-Javadoc)
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    81
     * Method declared on IDialogPage.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    82
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    83
    public void createControl(Composite parent) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    84
        Composite composite = new Composite(parent, SWT.NULL);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    85
    
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    86
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    87
        initializeDialogUnits(parent);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    88
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    89
        PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    90
                IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    91
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    92
        composite.setLayout(new GridLayout());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    93
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    94
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    95
        createProjectNameGroup(composite);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    96
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    97
        createChildControls(composite);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    98
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    99
        locationArea = new ProjectContentsLocationArea(getErrorReporter(), composite);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   100
        if(initialProjectFieldValue != null) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   101
			locationArea.updateProjectName(initialProjectFieldValue);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   102
		}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   103
        
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   104
		// Scale the button based on the rest of the dialog
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   105
		setButtonLayoutData(locationArea.getBrowseButton());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   106
		
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   107
        setPageComplete(validatePage());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   108
        // Show description on opening
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   109
        setErrorMessage(null);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   110
        setMessage(null);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   111
        setControl(composite);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   112
        Dialog.applyDialogFont(composite);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   113
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   114
    
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   115
    protected void createChildControls(Composite composite) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   116
        // TODO Auto-generated method stub
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   117
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   118
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   119
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   120
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   121
	 * Create a working set group for this page. This method can only be called
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   122
	 * once.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   123
	 * 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   124
	 * @param composite
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   125
	 *            the composite in which to create the group
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   126
	 * @param selection
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   127
	 *            the current workbench selection
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   128
	 * @param supportedWorkingSetTypes
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   129
	 *            an array of working set type IDs that will restrict what types
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   130
	 *            of working sets can be chosen in this group
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   131
	 * @return the created group. If this method has been called previously the
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   132
	 *         original group will be returned.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   133
	 * @since 3.4
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   134
	 */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   135
	public WorkingSetGroup createWorkingSetGroup(Composite composite,
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   136
			IStructuredSelection selection, String[] supportedWorkingSetTypes) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   137
		if (workingSetGroup != null) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   138
            return workingSetGroup;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   139
        }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   140
		workingSetGroup = new WorkingSetGroup(composite, selection,
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   141
				supportedWorkingSetTypes);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   142
		return workingSetGroup;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   143
	}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   144
    
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   145
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   146
	 * Get an error reporter for the receiver.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   147
	 * @return IErrorMessageReporter
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   148
	 */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   149
	private IErrorMessageReporter getErrorReporter() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   150
		return new IErrorMessageReporter(){
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   151
			/* (non-Javadoc)
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   152
			 * @see org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter#reportError(java.lang.String)
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   153
			 */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   154
			public void reportError(String errorMessage, boolean infoOnly) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   155
				if (infoOnly) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   156
					setMessage(errorMessage, IStatus.INFO);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   157
					setErrorMessage(null);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   158
				} else {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   159
                    setErrorMessage(errorMessage);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   160
                }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   161
				boolean valid = errorMessage == null;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   162
				if(valid) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   163
					valid = validatePage();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   164
				}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   165
				
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   166
				setPageComplete(valid);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   167
			}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   168
		};
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   169
	}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   170
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   171
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   172
     * Creates the project name specification controls.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   173
     *
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   174
     * @param parent the parent composite
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   175
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   176
    private final void createProjectNameGroup(Composite parent) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   177
        // project specification group
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   178
        Composite projectGroup = new Composite(parent, SWT.NONE);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   179
        GridLayout layout = new GridLayout();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   180
        layout.numColumns = 2;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   181
        projectGroup.setLayout(layout);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   182
        projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   183
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   184
        // new project label
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   185
        Label projectLabel = new Label(projectGroup, SWT.NONE);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   186
        projectLabel.setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   187
        projectLabel.setFont(parent.getFont());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   188
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   189
        // new project name entry field
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   190
        projectNameField = new Text(projectGroup, SWT.BORDER);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   191
        GridData data = new GridData(GridData.FILL_HORIZONTAL);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   192
        data.widthHint = SIZING_TEXT_FIELD_WIDTH;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   193
        projectNameField.setLayoutData(data);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   194
        projectNameField.setFont(parent.getFont());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   195
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   196
        // Set the initial value first before listener
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   197
        // to avoid handling an event during the creation.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   198
        if (initialProjectFieldValue != null) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   199
			projectNameField.setText(initialProjectFieldValue);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   200
		}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   201
        projectNameField.addListener(SWT.Modify, nameModifyListener);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   202
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   203
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   204
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   205
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   206
     * Returns the current project location path as entered by 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   207
     * the user, or its anticipated initial value.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   208
     * Note that if the default has been returned the path
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   209
     * in a project description used to create a project
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   210
     * should not be set.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   211
     *
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   212
     * @return the project location path or its anticipated initial value.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   213
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   214
    public IPath getLocationPath() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   215
        return new Path(locationArea.getProjectLocation());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   216
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   217
    
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   218
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   219
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   220
     * Returns the current project location URI as entered by 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   221
     * the user, or <code>null</code> if a valid project location
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   222
     * has not been entered.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   223
     *
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   224
     * @return the project location URI, or <code>null</code>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   225
     * @since 3.2
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   226
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   227
    public URI getLocationURI() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   228
    	return locationArea.getProjectLocationURI();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   229
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   230
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   231
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   232
	 * Creates a project resource handle for the current project name field
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   233
	 * value. The project handle is created relative to the workspace root.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   234
	 * <p>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   235
	 * This method does not create the project resource; this is the
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   236
	 * responsibility of <code>IProject::create</code> invoked by the new
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   237
	 * project resource wizard.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   238
	 * </p>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   239
	 * 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   240
	 * @return the new project resource handle
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   241
	 */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   242
    public IProject getProjectHandle() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   243
        return ResourcesPlugin.getWorkspace().getRoot().getProject(
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   244
                getProjectName());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   245
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   246
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   247
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   248
     * Returns the current project name as entered by the user, or its anticipated
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   249
     * initial value.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   250
     *
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   251
     * @return the project name, its anticipated initial value, or <code>null</code>
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   252
     *   if no project name is known
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   253
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   254
    public String getProjectName() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   255
        if (projectNameField == null) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   256
			return initialProjectFieldValue;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   257
		}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   258
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   259
        return getProjectNameFieldValue();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   260
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   261
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   262
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   263
     * Returns the value of the project name field
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   264
     * with leading and trailing spaces removed.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   265
     * 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   266
     * @return the project name in the field
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   267
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   268
    private String getProjectNameFieldValue() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   269
        if (projectNameField == null) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   270
			return ""; //$NON-NLS-1$
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   271
		}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   272
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   273
        return projectNameField.getText().trim();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   274
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   275
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   276
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   277
     * Sets the initial project name that this page will use when
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   278
     * created. The name is ignored if the createControl(Composite)
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   279
     * method has already been called. Leading and trailing spaces
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   280
     * in the name are ignored.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   281
     * Providing the name of an existing project will not necessarily 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   282
     * cause the wizard to warn the user.  Callers of this method 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   283
     * should first check if the project name passed already exists 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   284
     * in the workspace.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   285
     * 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   286
     * @param name initial project name for this page
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   287
     * 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   288
     * @see IWorkspace#validateName(String, int)
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   289
     * 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   290
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   291
    public void setInitialProjectName(String name) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   292
        if (name == null) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   293
			initialProjectFieldValue = null;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   294
		} else {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   295
            initialProjectFieldValue = name.trim();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   296
            if(locationArea != null) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   297
				locationArea.updateProjectName(name.trim());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   298
			}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   299
        }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   300
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   301
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   302
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   303
     * Set the location to the default location if we are set to useDefaults.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   304
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   305
    void setLocationForSelection() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   306
    	locationArea.updateProjectName(getProjectNameFieldValue());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   307
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   308
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   309
  
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   310
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   311
     * Returns whether this page's controls currently all contain valid 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   312
     * values.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   313
     *
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   314
     * @return <code>true</code> if all controls are valid, and
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   315
     *   <code>false</code> if at least one is invalid
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   316
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   317
    protected boolean validatePage() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   318
        IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   319
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   320
        String projectFieldContents = getProjectNameFieldValue();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   321
        if (projectFieldContents.equals("")) { //$NON-NLS-1$
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   322
            setErrorMessage(null);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   323
            setMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   324
            return false;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   325
        }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   326
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   327
        IStatus nameStatus = workspace.validateName(projectFieldContents,
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   328
                IResource.PROJECT);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   329
        if (!nameStatus.isOK()) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   330
            setErrorMessage(nameStatus.getMessage());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   331
            return false;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   332
        }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   333
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   334
        IProject handle = getProjectHandle();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   335
        if (handle.exists()) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   336
            setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   337
            return false;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   338
        }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   339
                
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   340
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   341
				getProjectNameFieldValue());
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   342
		locationArea.setExistingProject(project);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   343
		
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   344
		String validLocationMessage = locationArea.checkValidLocation();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   345
		if (validLocationMessage != null) { // there is no destination location given
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   346
			setErrorMessage(validLocationMessage);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   347
			return false;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   348
		}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   349
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   350
        setErrorMessage(null);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   351
        setMessage(null);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   352
        return true;
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   353
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   354
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   355
    /*
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   356
     * see @DialogPage.setVisible(boolean)
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   357
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   358
    public void setVisible(boolean visible) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   359
        super.setVisible(visible);
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   360
        if (visible) {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   361
			projectNameField.setFocus();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   362
		}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   363
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   364
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   365
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   366
     * Returns the useDefaults.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   367
     * @return boolean
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   368
     */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   369
    public boolean useDefaults() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   370
        return locationArea.isDefault();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   371
    }
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   372
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   373
    /**
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   374
	 * Return the selected working sets, if any. If this page is not configured
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   375
	 * to interact with working sets this will be an empty array.
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   376
	 * 
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   377
	 * @return the selected working sets
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   378
	 * @since 3.4
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   379
	 */
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   380
	public IWorkingSet[] getSelectedWorkingSets() {
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   381
		return workingSetGroup == null ? new IWorkingSet[0] : workingSetGroup
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   382
				.getSelectedWorkingSets();
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   383
	}
715f288b552a Bug 2779 - Better naming for Application templates
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   384
}