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 |
import org.eclipse.swt.widgets.Composite;
|
|
23 |
import org.eclipse.swt.widgets.Control;
|
|
24 |
import org.eclipse.swt.widgets.Shell;
|
|
25 |
|
|
26 |
import com.nokia.s60tools.creator.components.AbstractComponent;
|
|
27 |
import com.nokia.s60tools.creator.components.AbstractValue;
|
|
28 |
import com.nokia.s60tools.creator.components.AbstractValue.ModeTypes;
|
|
29 |
import com.nokia.s60tools.creator.components.messaging.Message;
|
|
30 |
import com.nokia.s60tools.creator.components.messaging.MessageValue;
|
|
31 |
import com.nokia.s60tools.creator.components.messaging.MessageVariables;
|
|
32 |
import com.nokia.s60tools.creator.editors.IComponentProvider;
|
|
33 |
|
|
34 |
|
|
35 |
/**
|
|
36 |
*
|
|
37 |
*/
|
|
38 |
public class MessageDialog extends AbstractDialog {
|
|
39 |
|
|
40 |
|
|
41 |
private String messagingType = null;
|
|
42 |
|
|
43 |
|
|
44 |
public MessageDialog(Shell parentShell, IComponentProvider provider) {
|
|
45 |
|
|
46 |
super(parentShell, provider);
|
|
47 |
Message msg = (Message)provider.getEditable();
|
|
48 |
init(msg.getMessageType());
|
|
49 |
|
|
50 |
}
|
|
51 |
|
|
52 |
public MessageDialog(Shell parentShell, String messagingType, IComponentProvider provider) {
|
|
53 |
super(parentShell, provider);
|
|
54 |
this.messagingType = messagingType;
|
|
55 |
init(messagingType);
|
|
56 |
}
|
|
57 |
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Initialize, creates Contact object
|
|
61 |
*/
|
|
62 |
private void init(String messagingType){
|
|
63 |
this.messagingType = messagingType.toLowerCase();
|
|
64 |
if(getComponent() == null){
|
|
65 |
AbstractComponent comp = new Message(AbstractComponent.NULL_ID, messagingType);
|
|
66 |
setComponent(comp);
|
|
67 |
}
|
|
68 |
setAmountFieldsEnabled(false);
|
|
69 |
}
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
/* (non-Javadoc)
|
|
74 |
* @see com.nokia.s60tools.creator.dialogs.AbstractDialog#createNewComponent()
|
|
75 |
*/
|
|
76 |
protected Message createNewComponent(){
|
|
77 |
return new Message(AbstractComponent.NULL_ID, messagingType);
|
|
78 |
}
|
|
79 |
|
|
80 |
|
|
81 |
/* (non-Javadoc)
|
|
82 |
* @see com.nokia.s60tools.creator.dialogs.AbstractDialog#createNewValue(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
|
83 |
*/
|
|
84 |
protected MessageValue createNewValue(String type, String value, String random, String amount) {
|
|
85 |
|
|
86 |
int amout_ = 0;
|
|
87 |
ModeTypes random_ = ModeTypes.RandomTypeNotRandom;
|
|
88 |
String value_ = value;
|
|
89 |
|
|
90 |
//If amount is set
|
|
91 |
if(amount != null && amount.trim().length() > 0){
|
|
92 |
amout_ = Integer.parseInt(amount);
|
|
93 |
}
|
|
94 |
|
|
95 |
//if random is selected
|
|
96 |
if(random != null && random.trim().length() > 0 && !random.equals(AbstractValue.EMPTY_STRING)){
|
|
97 |
random_ = AbstractValue.getModeTypeByText(random);
|
|
98 |
if(random_ != ModeTypes.RandomTypeNotRandom && random_ != ModeTypes.ModeTypeIncValueForEachCopy){
|
|
99 |
value_ = AbstractValue.RANDOM_TEXT;
|
|
100 |
}
|
|
101 |
}
|
|
102 |
MessageValue mes = new MessageValue(value_, random_, amout_);
|
|
103 |
mes.setType(type);
|
|
104 |
return mes;
|
|
105 |
}
|
|
106 |
|
|
107 |
|
|
108 |
/* (non-Javadoc)
|
|
109 |
* @see com.nokia.s60tools.creator.dialogs.AbstractDialog#getItemValueAsString()
|
|
110 |
*/
|
|
111 |
protected String[] getItemTypesAsString() {
|
|
112 |
return MessageVariables.getInstance().getItemValuesAsString(messagingType);
|
|
113 |
}
|
|
114 |
|
|
115 |
/* Creating all items to dialog area
|
|
116 |
* (non-Javadoc)
|
|
117 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
118 |
*/
|
|
119 |
protected Control createDialogArea(Composite parent) {
|
|
120 |
Composite composite = createDialogAreaComposite(parent);
|
|
121 |
setTableColumnHeaderAmount(MAX_AMOUNT_TEXT);
|
|
122 |
|
|
123 |
//Create also add new contact set button
|
|
124 |
createAmountArea(composite, true);
|
|
125 |
|
|
126 |
createTableArea(composite);
|
|
127 |
|
|
128 |
if(wasErrors()){
|
|
129 |
showErrorDialog("Errors occured when dialog opened", getErrors());
|
|
130 |
}
|
|
131 |
return composite;
|
|
132 |
}
|
|
133 |
|
|
134 |
/* (non-Javadoc)
|
|
135 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
|
136 |
*/
|
|
137 |
protected void configureShell(Shell shell) {
|
|
138 |
super.configureShell(shell);
|
|
139 |
if(isInEditMode()){
|
|
140 |
shell.setText("Edit " + getComponent().getValueById( messagingType )+"(s)");
|
|
141 |
}else{
|
|
142 |
shell.setText("Add " + getComponent().getValueById( messagingType ) +"(s)");
|
|
143 |
}
|
|
144 |
}
|
|
145 |
|
|
146 |
|
|
147 |
}
|