author | Eugene Ostroukhov <eugeneo@symbian.org> |
Mon, 23 Aug 2010 17:20:11 -0700 | |
changeset 474 | e2f461f0a9e0 |
child 484 | f5df819c1852 |
permissions | -rw-r--r-- |
474
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1 |
/** |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
3 |
* All rights reserved. |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
8 |
* |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
10 |
* Symbian Foundation - initial contribution. |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
11 |
* Contributors: |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
12 |
* Description: |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
13 |
* Overview: |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
14 |
* Details: |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
15 |
* Platforms/Drives/Compatibility: |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
16 |
* Assumptions/Requirement/Pre-requisites: |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
17 |
* Failures and causes: |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
18 |
*/ |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
19 |
package org.symbian.tools.tmw.ui.project; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
20 |
|
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
21 |
import java.util.Collection; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
22 |
import java.util.LinkedList; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
23 |
|
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
24 |
import org.eclipse.core.databinding.Binding; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
25 |
import org.eclipse.core.databinding.DataBindingContext; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
26 |
import org.eclipse.core.databinding.UpdateValueStrategy; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
27 |
import org.eclipse.core.databinding.validation.IValidator; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
28 |
import org.eclipse.jface.databinding.swt.ISWTObservableValue; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
29 |
import org.eclipse.jface.databinding.swt.SWTObservables; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
30 |
import org.eclipse.jface.wizard.WizardPage; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
31 |
import org.eclipse.swt.SWT; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
32 |
import org.eclipse.swt.layout.GridData; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
33 |
import org.eclipse.swt.widgets.Composite; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
34 |
import org.eclipse.swt.widgets.Label; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
35 |
import org.eclipse.swt.widgets.Text; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
36 |
import org.symbian.tools.tmw.internal.ui.wizard.CompoundValidator; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
37 |
import org.symbian.tools.tmw.internal.ui.wizard.NonEmptyStringValidator; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
38 |
|
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
39 |
/** |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
40 |
* Boilerplate code to make it easier creating such wizard pages. |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
41 |
* |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
42 |
* @author Eugene Ostroukhov (eugeneo@symbian.org) |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
43 |
*/ |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
44 |
public abstract class AbstractNewApplicationWizardPage extends WizardPage implements INewApplicationWizardPage { |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
45 |
protected DataBindingContext bindingContext; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
46 |
protected final Collection<Binding> bindings = new LinkedList<Binding>(); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
47 |
protected IProjectTemplateContext context; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
48 |
|
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
49 |
public AbstractNewApplicationWizardPage(String name, String title, String description) { |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
50 |
super(name); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
51 |
setTitle(title); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
52 |
setDescription(description); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
53 |
} |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
54 |
|
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
55 |
public void init(IProjectTemplateContext context, DataBindingContext bindingContext) { |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
56 |
this.context = context; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
57 |
this.bindingContext = bindingContext; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
58 |
} |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
59 |
|
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
60 |
public void remove() { |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
61 |
for (Binding binding : bindings) { |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
62 |
bindingContext.removeBinding(binding); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
63 |
} |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
64 |
} |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
65 |
|
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
66 |
protected void createLabel(Composite root, String text) { |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
67 |
Label label = new Label(root, SWT.NONE); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
68 |
label.setText(text); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
69 |
} |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
70 |
|
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
71 |
protected Text createText(Composite root, String property, String propertyName, DataBindingContext bindingContext, |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
72 |
IValidator... validators) { |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
73 |
Text text = new Text(root, SWT.BORDER); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
74 |
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
75 |
ISWTObservableValue view = SWTObservables.observeText(text, SWT.Modify); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
76 |
UpdateValueStrategy strategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
77 |
NonEmptyStringValidator validator = new NonEmptyStringValidator(propertyName); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
78 |
strategy.setBeforeSetValidator(validators.length == 0 ? validator |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
79 |
: new CompoundValidator(validator, validators)); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
80 |
bindings.add(bindingContext.bindValue(view, context.getParameterObservable(property), strategy, null)); |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
81 |
return text; |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
82 |
} |
e2f461f0a9e0
All templates are ported to a new framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
83 |
} |