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 |
package com.nokia.s60tools.apiquery.shared.datatypes.config;
|
|
19 |
|
|
20 |
import com.nokia.s60tools.apiquery.settings.UserSettings;
|
|
21 |
import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtension;
|
|
22 |
import com.nokia.s60tools.apiquery.shared.searchmethod.ISearchMethodExtensionInfo;
|
|
23 |
import com.nokia.s60tools.apiquery.shared.searchmethodregistry.SearchMethodExtensionRegistry;
|
|
24 |
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Abstract entry base class that contains only id for the
|
|
28 |
* entry and method that are common for all entry types.
|
|
29 |
*
|
|
30 |
* To be subclassed in order to create concrete entry types.
|
|
31 |
*/
|
|
32 |
public abstract class AbstractEntry {
|
|
33 |
|
|
34 |
/**
|
|
35 |
* User configurable id for the entry. The entries
|
|
36 |
* are identified by there unique id per search method
|
|
37 |
* configuration storage.
|
|
38 |
*/
|
|
39 |
protected final String id;
|
|
40 |
/**
|
|
41 |
* Set to <code>true</code> if user has selected this entry to
|
|
42 |
* be part of the search, otherwise <code>false</code>,
|
|
43 |
*/
|
|
44 |
protected boolean isSelected;
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Constructor
|
|
48 |
* @param id Entry id.that is unique per search method.
|
|
49 |
* @param isSelected Is the entry used for queries by default.
|
|
50 |
*/
|
|
51 |
protected AbstractEntry(String id, boolean isSelected){
|
|
52 |
this.id = id;
|
|
53 |
this.isSelected = isSelected;
|
|
54 |
}
|
|
55 |
|
|
56 |
/**
|
|
57 |
* @return the id for the entry.
|
|
58 |
*/
|
|
59 |
public String getId() {
|
|
60 |
return id;
|
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
* @return the isSelected
|
|
65 |
*/
|
|
66 |
public boolean isSelected() {
|
|
67 |
return isSelected;
|
|
68 |
}
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Sets selection status for the entry
|
|
72 |
* and notifies storage about the modification.
|
|
73 |
* @param isSelected the isSelected to set
|
|
74 |
*/
|
|
75 |
public void setSelected(boolean isSelected) {
|
|
76 |
this.isSelected = isSelected;
|
|
77 |
if(isSelected){
|
|
78 |
notifyModification(IConfigurationChangedListener.ENTRY_CHECKED);
|
|
79 |
}
|
|
80 |
else{
|
|
81 |
notifyModification(IConfigurationChangedListener.ENTRY_UNCHECKED);
|
|
82 |
}
|
|
83 |
}
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Sets selection status for the entry
|
|
87 |
* and notifies storage about the modification.
|
|
88 |
* @param isSelected the isSelected to set
|
|
89 |
* @param dontNotifyListeners if <code>true</code> listeners will not be notified.
|
|
90 |
*/
|
|
91 |
public void setSelected(boolean isSelected, boolean dontNotifyListeners) {
|
|
92 |
if(dontNotifyListeners){
|
|
93 |
this.isSelected = isSelected;
|
|
94 |
}
|
|
95 |
else {
|
|
96 |
setSelected(isSelected);
|
|
97 |
}
|
|
98 |
}
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Notifies storage object that this entry has been modified.
|
|
102 |
* @param eventType Event type of the modification.
|
|
103 |
*/
|
|
104 |
protected void notifyModification(int eventType){
|
|
105 |
ISearchMethodExtensionInfo currSelExtInfo = UserSettings.getInstance().getCurrentlySelectedSearchMethodInfo();
|
|
106 |
String id = currSelExtInfo.getId();
|
|
107 |
ISearchMethodExtension currSelExt = SearchMethodExtensionRegistry.getInstance().getById(id);
|
|
108 |
AbstractEntryStorage storage = currSelExt.getEntryStorageInstance();
|
|
109 |
storage.entryModified(this, eventType);
|
|
110 |
}
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Calls template method to updates concrete type entry-specific data fields
|
|
114 |
* and notifies listeners about the modification.
|
|
115 |
* @param entryWithUpdatedData Entry with new data.
|
|
116 |
*/
|
|
117 |
public void updateDataFields(AbstractEntry entryWithUpdatedData){
|
|
118 |
updateEntryTypeSpecificDataFields(entryWithUpdatedData);
|
|
119 |
notifyModification(IConfigurationChangedListener.ENTRY_MODIFIED);
|
|
120 |
}
|
|
121 |
|
|
122 |
/**
|
|
123 |
* The following template method updates concrete type entry-specific data fields.
|
|
124 |
* @param entryWithUpdatedData Entry with new data.
|
|
125 |
*/
|
|
126 |
public abstract void updateEntryTypeSpecificDataFields(AbstractEntry entryWithUpdatedData);
|
|
127 |
|
|
128 |
|
|
129 |
}
|