0
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
package com.nokia.s60tools.creator.dialogs;
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
import org.eclipse.jface.window.IShellProvider;
|
|
24 |
import org.eclipse.swt.widgets.Composite;
|
|
25 |
import org.eclipse.swt.widgets.Control;
|
|
26 |
import org.eclipse.swt.widgets.Shell;
|
|
27 |
|
|
28 |
import com.nokia.s60tools.creator.components.AbstractComponent;
|
|
29 |
import com.nokia.s60tools.creator.components.AbstractValue;
|
|
30 |
import com.nokia.s60tools.creator.components.AbstractVariables;
|
|
31 |
import com.nokia.s60tools.creator.components.AbstractValue.ModeTypes;
|
|
32 |
import com.nokia.s60tools.creator.components.contact.Contact;
|
|
33 |
import com.nokia.s60tools.creator.components.contact.ContactValue;
|
|
34 |
import com.nokia.s60tools.creator.components.contact.ContactVariables;
|
|
35 |
import com.nokia.s60tools.creator.editors.IComponentProvider;
|
|
36 |
|
|
37 |
|
|
38 |
/**
|
|
39 |
*
|
|
40 |
*/
|
|
41 |
public class ContactDialog extends AbstractDialog {
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
public ContactDialog(Shell parentShell, IComponentProvider provider) {
|
|
47 |
super(parentShell, provider);
|
|
48 |
init();
|
|
49 |
}
|
|
50 |
|
|
51 |
public ContactDialog(IShellProvider parentShell, IComponentProvider provider) {
|
|
52 |
super(parentShell, provider);
|
|
53 |
init();
|
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Initialize, creates Contact object
|
|
60 |
*/
|
|
61 |
private void init(){
|
|
62 |
if(getComponent() == null){
|
|
63 |
AbstractComponent con = new Contact(AbstractComponent.NULL_ID);
|
|
64 |
setComponent(con);
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
protected AbstractComponent createNewComponent(){
|
|
69 |
return new Contact(AbstractComponent.NULL_ID);
|
|
70 |
}
|
|
71 |
|
|
72 |
|
|
73 |
protected ContactValue createNewValue(String type, String value, String random, String amount) {
|
|
74 |
|
|
75 |
int amout_ = 0;
|
|
76 |
ModeTypes random_ = ModeTypes.RandomTypeNotRandom;
|
|
77 |
String value_ = value;
|
|
78 |
|
|
79 |
//If amount is set
|
|
80 |
if(amount != null && amount.trim().length() > 0){
|
|
81 |
amout_ = Integer.parseInt(amount);
|
|
82 |
}
|
|
83 |
|
|
84 |
//if random is selected
|
|
85 |
if(random != null && random.trim().length() > 0 && !random.equals(AbstractValue.EMPTY_STRING)){
|
|
86 |
random_ = AbstractValue.getModeTypeByText(random);
|
|
87 |
if(random_ != ModeTypes.RandomTypeNotRandom && random_ != ModeTypes.ModeTypeIncValueForEachCopy){
|
|
88 |
value_ = AbstractValue.RANDOM_TEXT;
|
|
89 |
}
|
|
90 |
}
|
|
91 |
return new ContactValue(value_, random_, amout_);
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
/* (non-Javadoc)
|
|
96 |
* @see com.nokia.s60tools.creator.dialogs.AbstractDialog#getItemValueAsString()
|
|
97 |
*/
|
|
98 |
protected String[] getItemTypesAsString() {
|
|
99 |
return ContactVariables.getInstance().getItemValuesAsString();
|
|
100 |
}
|
|
101 |
|
|
102 |
/* Creating all items to dialog area
|
|
103 |
* (non-Javadoc)
|
|
104 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
105 |
*/
|
|
106 |
protected Control createDialogArea(Composite parent) {
|
|
107 |
|
|
108 |
Composite composite = createDialogAreaComposite(parent);
|
|
109 |
try {
|
|
110 |
//create Amount area
|
|
111 |
String [] contactSetsAsString = null;
|
|
112 |
String contactSetSelection = null;
|
|
113 |
if(getProvider() != null && getProvider().getComponents() != null){
|
|
114 |
contactSetsAsString = getContactSetsAsString();
|
|
115 |
}
|
|
116 |
if(getComponent().hasReferenceToAnotherComponent()){
|
|
117 |
contactSetSelection = getComponent().getReferenceToAnotherComponent().toString();
|
|
118 |
}
|
|
119 |
|
|
120 |
|
|
121 |
// create contact set link area with amount
|
|
122 |
createAmountAreaAndLinkToOtherComponentCombo(
|
|
123 |
composite, getContactSetRefernceText(), contactSetsAsString, contactSetSelection, true, true);
|
|
124 |
|
|
125 |
createTableArea(composite);
|
|
126 |
addInformation(composite, AbstractVariables.DATE_FORMAT_HELP_TEXT);
|
|
127 |
|
|
128 |
if(wasErrors()){
|
|
129 |
showErrorDialog("Errors occured when dialog opened", getErrors());
|
|
130 |
}
|
|
131 |
|
|
132 |
return composite;
|
|
133 |
|
|
134 |
} catch (Exception e) {
|
|
135 |
// Show error, should not be able to occur if ewerything is ok.
|
|
136 |
e.printStackTrace();
|
|
137 |
super.showUnableToOpenDialogErrorMsg(e);
|
|
138 |
}
|
|
139 |
return null;
|
|
140 |
}
|
|
141 |
|
|
142 |
|
|
143 |
}
|