org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WizardContext.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Tue, 13 Jul 2010 11:11:00 -0700
changeset 441 85f06000ab13
parent 439 57fff6202b74
permissions -rw-r--r--
Bug 3184 - Reorganize new project wizard
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     1
/**
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     2
 * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     3
 * All rights reserved.
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     8
 *
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
     9
 * Initial Contributors:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    11
 * Contributors:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    12
 * Description:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    13
 * Overview:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    14
 * Details:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    17
 * Failures and causes:
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    18
 */
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    19
package org.symbian.tools.wrttools.wizards;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    20
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    21
import java.beans.PropertyChangeListener;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    22
import java.beans.PropertyChangeSupport;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    23
import java.text.MessageFormat;
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
    24
import java.util.Arrays;
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
    25
import java.util.Collections;
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
    26
import java.util.HashSet;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    27
import java.util.Map;
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
    28
import java.util.Set;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    29
import java.util.TreeMap;
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    30
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    31
import org.eclipse.core.databinding.DataBindingContext;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    32
import org.eclipse.core.databinding.UpdateValueStrategy;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    33
import org.eclipse.core.databinding.beans.BeansObservables;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    34
import org.eclipse.core.databinding.observable.Observables;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    35
import org.eclipse.core.databinding.observable.map.IObservableMap;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    36
import org.eclipse.core.databinding.observable.value.IObservableValue;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    37
import org.eclipse.core.databinding.validation.IValidator;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    38
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    39
import org.eclipse.jface.databinding.swt.SWTObservables;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    40
import org.eclipse.swt.SWT;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    41
import org.eclipse.swt.layout.GridData;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    42
import org.eclipse.swt.widgets.Composite;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    43
import org.eclipse.swt.widgets.Label;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    44
import org.eclipse.swt.widgets.Text;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    45
import org.symbian.tools.wrttools.core.ProjectTemplate;
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
    46
import org.symbian.tools.wrttools.core.libraries.JSLibrary;
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    47
import org.symbian.tools.wrttools.util.CompoundValidator;
17
f1b0259bb410 Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents: 3
diff changeset
    48
import org.symbian.tools.wrttools.util.Util;
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    49
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    50
public class WizardContext {
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    51
    public static final String CSS_FILE = "cssFile";
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    52
    public static final String HTML_FILE = "htmlFile";
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    53
    public static final String JS_FILE = "jsFile";
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    54
    public static final String TEMPLATE = "template";
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    55
    public static final String WIDGET_ID = "widgetId";
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    56
    public static final String WIDGET_NAME = "widgetName";
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    57
    public static final String HOME_SCREEN = "homeScreen";
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
    58
    public static final String LIBRARIES = "libraries";
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    59
    public static final String PROJECT_NAME = "projectName";
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    60
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    61
    private String cssFile;
441
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
    62
    private String projectName = "";
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    63
    private String htmlFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    64
    private String jsFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    65
    private final PropertyChangeSupport propertySupport = new PropertyChangeSupport(
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    66
            this);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    67
    private ProjectTemplate template;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    68
    private String widgetId;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    69
    private String widgetName;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    70
    private Map<String, String> extensions = new TreeMap<String, String>();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    71
    private boolean homeScreen;
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
    72
    private Set<JSLibrary> libraries = new HashSet<JSLibrary>();
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    73
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    74
    public WizardContext() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    75
        setTemplate(getFirstTemplate(ProjectTemplate.getAllTemplates()));
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    76
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    77
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    78
    private ProjectTemplate getFirstTemplate(ProjectTemplate[] allTemplates) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    79
        ProjectTemplate template = null;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    80
        for (ProjectTemplate projectTemplate : allTemplates) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    81
            if (template == null
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    82
                    || template.getOrder() > projectTemplate.getOrder()) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    83
                template = projectTemplate;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    84
            }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    85
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    86
        return template;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    87
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    88
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    89
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    90
    public void addPropertyChangeListener(PropertyChangeListener arg0) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    91
        propertySupport.addPropertyChangeListener(arg0);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    92
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    93
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    94
    public void addPropertyChangeListener(String arg0,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    95
            PropertyChangeListener arg1) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    96
        propertySupport.addPropertyChangeListener(arg0, arg1);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    97
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
    98
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
    99
    public String getProjectName() {
441
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   100
        return projectName;
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   101
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   102
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   103
    public void setProjectName(String projectName) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   104
        String prev = getProjectName();
441
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   105
        String prevId = getWidgetId();
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   106
        String prevName = getWidgetName();
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   107
        this.projectName = projectName;
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   108
        propertySupport.firePropertyChange(PROJECT_NAME, getProjectName(), prev);
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   109
        if (widgetName == null) {
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   110
            propertySupport.firePropertyChange(WIDGET_NAME, getWidgetName(), prevName);
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   111
            if (widgetId == null) {
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   112
                propertySupport.firePropertyChange(WIDGET_ID, getWidgetId(), prevId);
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   113
            }
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   114
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   115
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   116
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   117
    public String getCssFile() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   118
        if (cssFile == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   119
            if (template != null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   120
                return template.getDefaultCssFile();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   121
            }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   122
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   123
        return cssFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   124
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   125
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   126
    private String getDefaultWidgetId() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   127
        String name = Util.removeSpaces(getWidgetName());
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   128
        return MessageFormat.format("com.company.{0}", name.length() > 0 ? name
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   129
                : "ApplicationName");
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   130
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   131
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   132
    public String getHtmlFile() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   133
        if (htmlFile == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   134
            if (template != null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   135
                return template.getDefaultHtmlFile();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   136
            }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   137
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   138
        return htmlFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   139
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   140
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   141
    public String getJsFile() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   142
        if (jsFile == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   143
            if (template != null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   144
                return template.getDefaultJsFile();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   145
            }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   146
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   147
        return jsFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   148
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   149
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   150
    public ProjectTemplate getTemplate() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   151
        return template;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   152
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   153
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   154
    public String getWidgetId() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   155
        if (widgetId == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   156
            return getDefaultWidgetId();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   157
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   158
        return widgetId;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   159
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   160
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   161
    public String getWidgetName() {
441
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   162
        return widgetName == null ? getProjectName() : widgetName;
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   163
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   164
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   165
    public void removePropertyChangeListener(PropertyChangeListener arg0) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   166
        propertySupport.removePropertyChangeListener(arg0);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   167
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   168
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   169
    public void removePropertyChangeListener(String arg0,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   170
            PropertyChangeListener arg1) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   171
        propertySupport.removePropertyChangeListener(arg0, arg1);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   172
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   173
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   174
    public void setCssFile(String cssFile) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   175
        if (template != null && template.getDefaultCssFile().equals(cssFile)) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   176
            cssFile = null;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   177
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   178
        String prev = this.cssFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   179
        this.cssFile = cssFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   180
        propertySupport.firePropertyChange(CSS_FILE, cssFile, prev);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   181
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   182
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   183
    public void setHtmlFile(String htmlFile) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   184
        if (template != null && template.getDefaultHtmlFile().equals(htmlFile)) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   185
            htmlFile = null;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   186
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   187
        String prev = this.htmlFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   188
        this.htmlFile = htmlFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   189
        propertySupport.firePropertyChange(HTML_FILE, htmlFile, prev);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   190
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   191
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   192
    public void setJsFile(String jsFile) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   193
        if (template != null && template.getDefaultJsFile().equals(jsFile)) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   194
            jsFile = null;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   195
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   196
        String prev = this.jsFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   197
        this.jsFile = jsFile;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   198
        propertySupport.firePropertyChange(JS_FILE, jsFile, prev);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   199
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   200
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   201
    public void setTemplate(ProjectTemplate template) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   202
        String html = getHtmlFile();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   203
        String js = getJsFile();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   204
        String css = getCssFile();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   205
        ProjectTemplate prev = this.template;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   206
        this.template = template;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   207
        propertySupport.firePropertyChange(TEMPLATE, template, prev);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   208
        if (htmlFile == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   209
            propertySupport.firePropertyChange(HTML_FILE, getHtmlFile(), html);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   210
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   211
        if (jsFile == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   212
            propertySupport.firePropertyChange(JS_FILE, getJsFile(), js);
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   213
        }
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   214
        if (cssFile == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   215
            propertySupport.firePropertyChange(CSS_FILE, getCssFile(), css);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   216
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   217
        if (cssFile == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   218
            propertySupport.firePropertyChange(LIBRARIES, getLibraries(),
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   219
                    libraries);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   220
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   221
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   222
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   223
    public void setWidgetId(String widgetId) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   224
        String prev = getWidgetId();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   225
        if (getDefaultWidgetId().equals(widgetId)) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   226
            widgetId = null;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   227
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   228
        this.widgetId = widgetId;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   229
        propertySupport.firePropertyChange(WIDGET_ID, getWidgetId(), prev);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   230
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   231
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   232
    public void setWidgetName(String widgetName) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   233
        String prevId = getWidgetId();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   234
        String prev = getWidgetName();
441
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   235
        if (widgetName == getProjectName()) {
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   236
            this.widgetName = null;
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   237
        } else {
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   238
            this.widgetName = widgetName;
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   239
        }
85f06000ab13 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 439
diff changeset
   240
        propertySupport.firePropertyChange(WIDGET_NAME, getWidgetName(), prev);
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   241
        if (widgetId == null) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   242
            propertySupport
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   243
                    .firePropertyChange(WIDGET_ID, getWidgetId(), prevId);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   244
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   245
    }
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   246
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   247
    public void setExtensions(Map<String, String> extensions) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   248
        this.extensions = extensions;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   249
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   250
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   251
    public Map<String, String> getExtensions() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   252
        return extensions;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   253
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   254
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   255
    public Map<String, String> getTemplateVars() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   256
        Map<String, String> vars = new TreeMap<String, String>();
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   257
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   258
        vars.put("widgetName", getWidgetName());
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   259
        vars.put("widgetId", getWidgetId());
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   260
        vars.put("mainHtml", getHtmlFileName());
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   261
        vars.put("mainCss", getCssFileName());
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   262
        vars.put("mainJs", getJsFileName());
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   263
        vars.put("homeScreen", String.valueOf(isHomeScreen()));
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   264
        vars.putAll(extensions);
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   265
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   266
        return vars;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   267
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   268
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   269
    public boolean isHomeScreen() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   270
        return homeScreen;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   271
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   272
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   273
    public void setHomeScreen(boolean homeScreen) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   274
        boolean old = homeScreen;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   275
        this.homeScreen = homeScreen;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   276
        propertySupport.firePropertyChange(HOME_SCREEN, old, homeScreen);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   277
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   278
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   279
    public String getHtmlFileName() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   280
        return stripExtension(getHtmlFile(), "htm", "html");
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   281
    }
17
f1b0259bb410 Validation was added to new project creation wizard
Eugene Ostroukhov <eostroukhov@symbian.org>
parents: 3
diff changeset
   282
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   283
    public String getJsFileName() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   284
        return stripExtension(getJsFile(), "js");
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   285
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   286
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   287
    public String getCssFileName() {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   288
        return stripExtension(getCssFile(), "css");
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   289
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   290
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   291
    private String stripExtension(String fileName, String... extensions) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   292
        for (String extension : extensions) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   293
            String extensionAndDot = "." + extension;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   294
            if (fileName.endsWith(extensionAndDot)) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   295
                return fileName.substring(0, fileName.length()
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   296
                        - extensionAndDot.length());
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   297
            }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   298
        }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   299
        return fileName;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   300
    }
309
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   301
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   302
    public boolean isRequiredLibrary(JSLibrary element) {
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   303
        return template != null && template.requires(element);
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   304
    }
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   305
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   306
    public Set<JSLibrary> getLibraries() {
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   307
        final Set<JSLibrary> set = new HashSet<JSLibrary>(libraries);
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   308
        if (template != null) {
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   309
            set.addAll(Arrays.asList(template.getRequiredLibraries()));
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   310
        }
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   311
        return set;
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   312
    }
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   313
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   314
    public void setLibraries(Set<JSLibrary> libraries) {
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   315
        Set<JSLibrary> prev = this.libraries;
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   316
        this.libraries = libraries;
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   317
        propertySupport.firePropertyChange(LIBRARIES, prev, libraries);
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   318
    }
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   319
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   320
    public Map<String, String> getLibraryParameters(JSLibrary library) {
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   321
        return Collections.emptyMap();
c01f5ab28a11 Refactored to add extended support for JS Libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 17
diff changeset
   322
    }
439
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   323
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   324
    protected Text createText(Composite root, String property,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   325
            String propertyName, DataBindingContext bindingContext,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   326
            AbstractDataBindingPage page, IValidator... validators) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   327
        return createText(root, BeansObservables.observeValue(this, property),
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   328
                propertyName, bindingContext, page, validators);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   329
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   330
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   331
    protected Text createTextForExt(Composite root, String property,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   332
            String propertyName, DataBindingContext bindingContext,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   333
            AbstractDataBindingPage page) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   334
        IObservableMap map = BeansObservables.observeMap(this, "extensions");
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   335
        IObservableValue entry = Observables.observeMapEntry(map, property,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   336
                String.class);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   337
        return createText(root, entry, propertyName, bindingContext, page);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   338
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   339
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   340
    private Text createText(Composite root, IObservableValue model,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   341
            String propertyName, DataBindingContext bindingContext,
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   342
            AbstractDataBindingPage page, IValidator... validators) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   343
        Text text = new Text(root, SWT.BORDER);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   344
        text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   345
        ISWTObservableValue view = SWTObservables.observeText(text, SWT.Modify);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   346
        UpdateValueStrategy strategy = new UpdateValueStrategy(
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   347
                UpdateValueStrategy.POLICY_UPDATE);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   348
        NonEmptyStringValidator validator = new NonEmptyStringValidator(
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   349
                propertyName, page);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   350
        strategy.setBeforeSetValidator(validators.length == 0 ? validator
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   351
                : new CompoundValidator(validator, validators));
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   352
        bindingContext.bindValue(view, model, strategy, null);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   353
        return text;
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   354
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   355
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   356
    protected void createLabel(Composite root, String text) {
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   357
        Label label = new Label(root, SWT.NONE);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   358
        label.setText(text);
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   359
    }
57fff6202b74 Bug 3184 - Reorganize new project wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 353
diff changeset
   360
3
d3477de62514 Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff changeset
   361
}