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.bookmark.Bookmark;
|
|
30 |
import com.nokia.s60tools.creator.components.bookmark.BookmarkValue;
|
|
31 |
import com.nokia.s60tools.creator.components.bookmark.BookmarkVariables;
|
|
32 |
import com.nokia.s60tools.creator.editors.IComponentProvider;
|
|
33 |
|
|
34 |
|
|
35 |
/**
|
|
36 |
*
|
|
37 |
*/
|
|
38 |
public class BookmarkDialog extends AbstractDialog {
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
public BookmarkDialog(Shell sh, IComponentProvider provider) {
|
|
43 |
super(sh, provider);
|
|
44 |
init();
|
|
45 |
}
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Initialize, creates Contact object
|
|
49 |
*/
|
|
50 |
private void init(){
|
|
51 |
if(getComponent() == null){
|
|
52 |
AbstractComponent comp = new Bookmark(AbstractComponent.NULL_ID);
|
|
53 |
setComponent(comp);
|
|
54 |
}
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
protected Bookmark createNewComponent(){
|
|
60 |
return new Bookmark(AbstractComponent.NULL_ID);
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
protected BookmarkValue createNewValue(String type, String value, String random, String amount) {
|
|
65 |
|
|
66 |
int amout_ = 0;
|
|
67 |
ModeTypes random_ = ModeTypes.RandomTypeNotRandom;
|
|
68 |
String value_ = value;
|
|
69 |
|
|
70 |
//If amount is set
|
|
71 |
if(amount != null && amount.trim().length() > 0){
|
|
72 |
amout_ = Integer.parseInt(amount);
|
|
73 |
}
|
|
74 |
|
|
75 |
//if random is selected
|
|
76 |
if(random != null && random.trim().length() > 0 && !random.equals(AbstractValue.EMPTY_STRING)){
|
|
77 |
random_ = AbstractValue.getModeTypeByText(random);
|
|
78 |
if(random_ != ModeTypes.RandomTypeNotRandom){
|
|
79 |
value_ = AbstractValue.RANDOM_TEXT;
|
|
80 |
}
|
|
81 |
}
|
|
82 |
return new BookmarkValue(value_, random_, amout_);
|
|
83 |
}
|
|
84 |
|
|
85 |
|
|
86 |
/* (non-Javadoc)
|
|
87 |
* @see com.nokia.s60tools.creator.dialogs.AbstractDialog#getItemValueAsString()
|
|
88 |
*/
|
|
89 |
protected String[] getItemTypesAsString() {
|
|
90 |
return BookmarkVariables.getInstance().getItemValuesAsString();
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
/*
|
|
95 |
* (non-Javadoc)
|
|
96 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
97 |
*/
|
|
98 |
protected Control createDialogArea(Composite parent) {
|
|
99 |
|
|
100 |
setAmountFieldsEnabled(false);
|
|
101 |
|
|
102 |
return super.createDialogArea(parent);
|
|
103 |
}
|
|
104 |
|
|
105 |
}
|