diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-05 14:52:09 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-05 14:52:09 +0000 |
commit | 3ca68fef66997aa500f28cd9c1d5ba6d565d004f (patch) | |
tree | aff5e458a8902abaf8af4bac03f7999e096e47f7 /client/trunk/src/com/fourisland | |
parent | 1566230aefb3aa471e0ef75a2af6919a791918f1 (diff) | |
download | instadisc-3ca68fef66997aa500f28cd9c1d5ba6d565d004f.tar.gz instadisc-3ca68fef66997aa500f28cd9c1d5ba6d565d004f.tar.bz2 instadisc-3ca68fef66997aa500f28cd9c1d5ba6d565d004f.zip |
Client: Fixed yet another client item bug
This once was caused by a combination of having more than one subscription in the database and a bug in the subscription retrieval method. The bug has been fixed which allows us to add back the Item buffer (removed in [68] because it was thought to be the cause of another Client Item bug) Fixes #18.
Diffstat (limited to 'client/trunk/src/com/fourisland')
3 files changed, 26 insertions, 47 deletions
diff --git a/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java b/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java index a5c59e8..6ab0c72 100644 --- a/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java +++ b/client/trunk/src/com/fourisland/instadisc/Database/Wrapper.java | |||
@@ -12,6 +12,7 @@ import com.sleepycat.persist.EntityStore; | |||
12 | import com.sleepycat.persist.PrimaryIndex; | 12 | import com.sleepycat.persist.PrimaryIndex; |
13 | import com.sleepycat.persist.StoreConfig; | 13 | import com.sleepycat.persist.StoreConfig; |
14 | import java.io.File; | 14 | import java.io.File; |
15 | import java.util.Collection; | ||
15 | import java.util.Iterator; | 16 | import java.util.Iterator; |
16 | import java.util.logging.Level; | 17 | import java.util.logging.Level; |
17 | import java.util.logging.Logger; | 18 | import java.util.logging.Logger; |
@@ -169,26 +170,16 @@ public class Wrapper { | |||
169 | 170 | ||
170 | public static Subscription[] getAllSubscription() { | 171 | public static Subscription[] getAllSubscription() { |
171 | synchronized (subscription) { | 172 | synchronized (subscription) { |
172 | try { | 173 | Collection vals = subscription.map().values(); |
173 | Iterator<Subscription> i = subscription.entities().iterator(); | 174 | Subscription subs[] = new Subscription[vals.size()]; |
174 | Subscription[] temp = new Subscription[0]; | 175 | Iterator<Subscription> i = vals.iterator(); |
175 | int len = 0; | 176 | int j=0; |
176 | 177 | while (i.hasNext()) | |
177 | while (i.hasNext()) { | 178 | { |
178 | Subscription[] temp2 = new Subscription[len + 1]; | 179 | subs[j] = i.next(); |
179 | int j = 0; | 180 | j++; |
180 | for (j = 0; j < len; j++) { | ||
181 | temp2[j] = temp[j]; | ||
182 | } | ||
183 | temp2[len] = i.next(); | ||
184 | temp = temp2; | ||
185 | } | ||
186 | |||
187 | return temp; | ||
188 | } catch (DatabaseException ex) { | ||
189 | Logger.getLogger(Wrapper.class.getName()).log(Level.SEVERE, null, ex); | ||
190 | return new Subscription[0]; | ||
191 | } | 181 | } |
182 | return subs; | ||
192 | } | 183 | } |
193 | } | 184 | } |
194 | 185 | ||
@@ -240,26 +231,16 @@ public class Wrapper { | |||
240 | 231 | ||
241 | public static Filter[] getAllFilter() { | 232 | public static Filter[] getAllFilter() { |
242 | synchronized (filter) { | 233 | synchronized (filter) { |
243 | try { | 234 | Collection vals = filter.map().values(); |
244 | Iterator<Filter> i = filter.entities().iterator(); | 235 | Filter fils[] = new Filter[vals.size()]; |
245 | Filter[] temp = new Filter[0]; | 236 | Iterator<Filter> i = vals.iterator(); |
246 | int len = 0; | 237 | int j=0; |
247 | 238 | while (i.hasNext()) | |
248 | while (i.hasNext()) { | 239 | { |
249 | Filter[] temp2 = new Filter[len + 1]; | 240 | fils[j] = i.next(); |
250 | int j = 0; | 241 | j++; |
251 | for (j = 0; j < len; j++) { | ||
252 | temp2[j] = temp[j]; | ||
253 | } | ||
254 | temp2[len] = i.next(); | ||
255 | temp = temp2; | ||
256 | } | ||
257 | |||
258 | return temp; | ||
259 | } catch (DatabaseException ex) { | ||
260 | Logger.getLogger(Wrapper.class.getName()).log(Level.SEVERE, null, ex); | ||
261 | return new Filter[0]; | ||
262 | } | 242 | } |
243 | return fils; | ||
263 | } | 244 | } |
264 | } | 245 | } |
265 | } | 246 | } |
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java b/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java index eae52a1..e6ba795 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * To change this template, choose Tools | Templates | 2 | * To change this template, choose Tools | Templates |
3 | * and open the template in the editor. | 3 | * and open the template in the editor. |
4 | */ | 4 | */ |
diff --git a/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.java b/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.java index 94a8075..b1190f4 100644 --- a/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.java +++ b/client/trunk/src/com/fourisland/instadisc/ManageSubscriptionsForm.java | |||
@@ -9,6 +9,7 @@ package com.fourisland.instadisc; | |||
9 | import com.fourisland.instadisc.Database.Subscription; | 9 | import com.fourisland.instadisc.Database.Subscription; |
10 | import com.fourisland.instadisc.Database.Wrapper; | 10 | import com.fourisland.instadisc.Database.Wrapper; |
11 | import com.fourisland.instadisc.Item.SubscriptionFile; | 11 | import com.fourisland.instadisc.Item.SubscriptionFile; |
12 | import java.util.Arrays; | ||
12 | import javax.swing.DefaultListModel; | 13 | import javax.swing.DefaultListModel; |
13 | 14 | ||
14 | /** | 15 | /** |
@@ -23,7 +24,6 @@ public class ManageSubscriptionsForm extends javax.swing.JDialog { | |||
23 | initComponents(); | 24 | initComponents(); |
24 | 25 | ||
25 | jList1.setCellRenderer(new IDSubscriptionListCellRenderer()); | 26 | jList1.setCellRenderer(new IDSubscriptionListCellRenderer()); |
26 | jList1.setModel(lm); | ||
27 | refreshSubscriptionPane(); | 27 | refreshSubscriptionPane(); |
28 | } | 28 | } |
29 | 29 | ||
@@ -156,14 +156,12 @@ public class ManageSubscriptionsForm extends javax.swing.JDialog { | |||
156 | DefaultListModel lm = new DefaultListModel(); | 156 | DefaultListModel lm = new DefaultListModel(); |
157 | 157 | ||
158 | public void refreshSubscriptionPane() { | 158 | public void refreshSubscriptionPane() { |
159 | lm.clear(); | ||
160 | Subscription[] subscriptions = Wrapper.getAllSubscription(); | 159 | Subscription[] subscriptions = Wrapper.getAllSubscription(); |
161 | int i = 0; | 160 | System.out.println(Arrays.deepToString(subscriptions)); |
162 | for (i = 0; i < subscriptions.length; i++) { | 161 | jList1.setListData(subscriptions); |
163 | lm.addElement(subscriptions[i]); | 162 | jList1.repaint(); |
164 | } | ||
165 | 163 | ||
166 | jList1.setEnabled(!lm.isEmpty()); | 164 | jList1.setEnabled((subscriptions.length != 0)); |
167 | jButton1.setEnabled(!lm.isEmpty()); | 165 | jButton1.setEnabled((subscriptions.length != 0)); |
168 | } | 166 | } |
169 | } | 167 | } |