KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > gui > Whiteboard


1 package sellwin.gui;
2
3 import sellwin.domain.*;
4 import sellwin.server.*;
5 import sellwin.utils.*;
6
7 import java.util.*;
8 import java.util.ArrayList JavaDoc;
9 import java.rmi.*;
10
11 import javax.swing.*;
12
13 // SellWin http://sourceforge.net/projects/sellwincrm
14
//Contact support@open-app.com for commercial help with SellWin
15
//This software is provided "AS IS", without a warranty of any kind.
16

17 /**
18  * This class represents a global 'whiteboard' or 'clipboard'
19  * for the GUI to read and write values to.
20  * There is only one whiteboard for the GUI.
21  */

22 public class Whiteboard {
23     private MainWindow parent;
24     private Login login=null;
25     private String JavaDoc speed = null;
26     private String JavaDoc dataDir = null;
27     private ResourceBundle langBundle;
28     private SellwinSession remIF = null;
29     private UserGroup currentGroup = null;
30     private TreeMap custNamesList = null;
31     private ArrayList JavaDoc opportunityNames = null;
32     private ArrayList JavaDoc roleList = null;
33     private TreeMap salesPersons = null;
34     private ArrayList JavaDoc taxList = null;
35     private TreeMap allGroups = null;
36     private ArrayList JavaDoc allGroupsForUser = null;
37     private ArrayList JavaDoc opportunities = new ArrayList JavaDoc();
38     private boolean loggedOn = false;
39     private SalesPerson currentUser = null;
40     private Opportunity currentOpportunity = null;
41     private Customer cust = new Customer();
42     private ArrayList JavaDoc oppIndex;
43     private Properties props;
44
45     /**
46      * construct the Whiteboard and set the default language
47      * and user properties
48      */

49     public Whiteboard(MainWindow p) {
50         try {
51             parent = p;
52             setProps(Prefs.getApplProps());
53             String JavaDoc lang = (String JavaDoc)(props.getProperty(Prefs.DEF_LANG));
54             setLang(lang);
55         } catch (Exception JavaDoc e) {
56             ErrorHandler.show(MainWindow.getMainParent(), e);
57         }
58     }
59
60
61     /**
62      * set the user's default Properties
63      * @param p the new Properties we are setting with
64      */

65     public final void setProps(Properties p) {
66         props = p;
67     }
68
69     /**
70      * get the user's default Properties
71      * @return the current user Properties
72      */

73     public final Properties getProps() {
74         return props;
75     }
76
77     /**
78      * set the connection speed (not currently implemented)
79      * @param name description
80      * @return description
81      * @exception AngError thrown for all application errors
82      */

83     public final void setSpeed(String JavaDoc s) {
84         this.speed = s;
85     }
86
87     /**
88      * not currently implemented
89      * @param name description
90      * @return description
91      * @exception AngError thrown for all application errors
92      */

93     public final String JavaDoc getSpeed() { return speed; }
94
95     /**
96      * set the remote interface
97      * by remote interface, we are referring to the
98      * means of talking to the server, this can be
99      * anything that implements the SellwinSession
100      *
101      * @param r the remote interface we will be using
102      */

103     public final void setRemIF(SellwinSession r) {
104         remIF = r;
105     }
106
107     /**
108      * get the remote interface
109      * @return the remote interface
110      */

111     public final SellwinSession getRemIF() {
112         return remIF;
113     }
114
115     /**
116      * get the current Opportunity which should
117      * also be the Opportunity on the screen at
118      * the moment
119      * @return the current Opportunity
120      */

121     public final Opportunity getCurrentOpportunity() {
122         return currentOpportunity;
123     }
124
125     /**
126      * set the current Opportunity
127      * @param o the Opportunity we are setting with
128      */

129     public final void setCurrentOpportunity(Opportunity o) {
130         currentOpportunity = o;
131     }
132
133     /**
134      * add a customer name to the current cache of
135      * customer names
136      * @param name the Customer name we are adding
137      * @exception AngError thrown when an application error occurs
138      */

139     public final void addCustName(String JavaDoc name)
140         throws AngError {
141
142         if (custNamesList == null)
143             custNamesList = getAllCustNames(true);
144         custNamesList.put(name, name);
145
146         //update the opp panel's customer combo box to reflect changes
147
OppPanel oppPanel = MainWindow.getOppPanel();
148         if (oppPanel != null)
149             oppPanel.updateCustomerList();
150     }
151
152
153     /**
154      * get the current list of customer names
155      * @param refresh if true, then force database query
156      * @return the list of customer names
157      * @exception AngError thrown for all application errors
158      */

159     public final TreeMap getAllCustNames(boolean refresh)
160         throws AngError {
161
162         if ((custNamesList == null) || (refresh)) {
163             try {
164                 custNamesList = new TreeMap();
165                 Object JavaDoc[] values = getRemIF().getAllCustomerNames();
166                 for (int i=0;i<values.length;i++)
167                     custNamesList.put((String JavaDoc)values[i], (String JavaDoc)values[i]);
168             } catch (RemoteException e) {
169                 throw new AngError(e.getMessage());
170             }
171         }
172
173         return custNamesList;
174     }
175
176     /**
177      * get a list of all current user roles
178      * @return the list of user roles
179      * @exception AngError thrown for all application errors
180      */

181     public final ArrayList JavaDoc getAllUserRoles()
182         throws AngError {
183
184         if (roleList == null) {
185             try {
186                 roleList = getRemIF().getAllUserRoles(null);
187             } catch (RemoteException e) {
188                 throw new AngError(e.getMessage());
189             }
190         }
191
192         return roleList;
193     }
194
195     /**
196      * get the UserGroupMembers for a given group
197      * @param groupName the group we are using as a search
198      * criteria
199      * @return the TreeMap of members in that group
200      * @exception AngError thrown for all application errors
201      */

202     public final TreeMap getGroupMembers(String JavaDoc groupName)
203         throws AngError {
204
205         TreeMap members=null;
206         try {
207             Object JavaDoc[] values = getRemIF().getUsersInGroup(groupName);
208             members = new TreeMap();
209             SalesPerson sp;
210             for (int i=0;i<values.length;i++) {
211                 sp = (SalesPerson)values[i];
212                 members.put(sp.getID(), sp);
213             }
214         } catch (RemoteException r) {
215             throw new AngError(r.getMessage());
216         }
217         return members;
218     }
219
220     /**
221      * delete a user within a user group
222      * @param group the UserGroup we are to delete from
223      * @param user the SalesPerson we are to delete from the group
224      * @exception AngError thrown for all application errors
225      */

226     public final void deleteUserInGroup(UserGroup group, SalesPerson user)
227         throws AngError {
228
229         try {
230             getRemIF().deleteUserInGroup(group, user.getPK());
231         } catch (RemoteException r) {
232             throw new AngError(r.getMessage());
233         }
234     }
235
236     /**
237      * get the current UserGroup
238      * @return the UserGroup
239      * @exception AngError thrown for all application errors
240      */

241     public final UserGroup getCurrentGroup() {
242         return currentGroup;
243     }
244
245     /**
246      * set the current UserGroup
247      * @param g the UserGroup
248      * @exception AngError thrown for all application errors
249      */

250     public final void setCurrentGroup(UserGroup g) {
251         currentGroup = g;
252     }
253
254     /**
255      * get the current list of users in a group
256      * @param groupName the user group name we are using
257      * as a search criteria
258      * @return the list of users in the group
259      * @exception AngError thrown for all application errors
260      */

261     public final TreeMap getUsersInGroup(String JavaDoc groupName)
262         throws AngError {
263
264         try {
265             Object JavaDoc[] values = getRemIF().getUsersInGroup(groupName);
266             TreeMap userNames = new TreeMap();
267             SalesPerson sp;
268             for (int i=0;i<values.length;i++) {
269                 sp = (SalesPerson)values[i];
270                 userNames.put(sp.getID(), sp);
271             }
272             return userNames;
273         } catch (RemoteException e) {
274             throw new AngError(e.getMessage());
275         }
276     }
277
278     /**
279      * get a list of the current set of user groups
280      * @return the TreeMap of user groups
281      * @exception AngError thrown for all application errors
282      */

283     public final TreeMap getAllGroups()
284         throws AngError {
285
286         try {
287             Object JavaDoc[] values = getRemIF().getUserGroups(null);
288             allGroups = new TreeMap();
289             UserGroup ug;
290             for (int i=0;i<values.length;i++) {
291                 ug = (UserGroup)values[i];
292                 allGroups.put(ug.getName(), ug);
293             }
294         } catch (RemoteException e) {
295             throw new AngError(e.getMessage());
296         }
297         return allGroups;
298     }
299
300     /**
301      * get the current list of groups that a user belongs
302      * to
303      * @return an ArrayList of UserGroup Strings
304      * @exception AngError thrown for all application errors
305      */

306     public final ArrayList JavaDoc getGroupsForUser()
307         throws AngError {
308
309         if (allGroupsForUser != null)
310             return allGroupsForUser;
311
312         try {
313             allGroupsForUser = getRemIF().getGroupsForUser(currentUser.getPK());
314         } catch (RemoteException e) {
315             throw new AngError(e.getMessage());
316         }
317         return allGroupsForUser;
318     }
319
320     /**
321      * get the current list of user groups
322      * @return the list of user groups
323      * @exception AngError thrown for all application errors
324      */

325     public final TreeMap getUserGroups()
326         throws AngError {
327
328         try {
329             Object JavaDoc[] values = getRemIF().getUserGroups(null);
330             TreeMap map = new TreeMap();
331             UserGroup ug;
332             for (int i=0;i<values.length;i++) {
333                 ug = (UserGroup)values[i];
334                 map.put(ug.getName(), ug);
335             }
336             return map;
337         } catch (RemoteException r) {
338             throw new AngError(r.getMessage());
339         }
340     }
341
342     /**
343      * add a user to a user group
344      * @param user the user we are adding
345      * @param group the group we are adding to
346      * @exception AngError thrown for all application errors
347      */

348     public final void addUserToGroup(SalesPerson user, UserGroup group)
349         throws AngError {
350
351         try {
352             //add to local cache
353
if (user.getPK() == currentUser.getPK()) {
354                 if (allGroupsForUser == null)
355                     allGroupsForUser = new ArrayList JavaDoc();
356                 allGroupsForUser.add(group);
357             }
358
359             group.setModifiedBy(currentUser.getID());
360             getRemIF().addUserToGroup(user.getPK(), group);
361             user.addUserGroup(group);
362         } catch (RemoteException r) {
363             throw new AngError(r.getMessage());
364         }
365     }
366
367     /**
368      * add a new user group
369      * @param group the user group to add
370      * @exception AngError thrown for all application errors
371      */

372     public final void addUserGroup(UserGroup group)
373         throws AngError {
374         
375         try {
376             group.setModifiedBy(currentUser.getID());
377             getRemIF().addUserGroup(group); //add to persistent store
378
allGroups.put(group.getName(), group); //add to cache
379
} catch (RemoteException r) {
380             throw new AngError(r.getMessage());
381         }
382     }
383
384     /**
385      * delete a user group
386      * @param groupName the name of the user group we delete
387      * @exception AngError thrown for all application errors
388      */

389     public final void deleteUserGroup(String JavaDoc groupName)
390         throws AngError {
391
392         try {
393             getRemIF().deleteUserGroup(groupName);
394         } catch (RemoteException r) {
395             throw new AngError(r.getMessage());
396         }
397     }
398
399
400     /**
401      * set the current list of Opportunities
402      * @param o the list of Opportunities we set with
403      * @exception AngError thrown for all application errors
404      */

405     public final void setOpportunities(ArrayList JavaDoc o) {
406         opportunities = o;
407     }
408
409     /**
410      * get the Opportunity index. This index is a quick
411      * reference for the application to do Opportunity
412      * lookups using the Opportunity name, especially important
413      * when operating in 'disconnected' mode
414      * @return the Opportunity Index list
415      * @exception AngError thrown for all application errors
416      */

417     public final ArrayList JavaDoc getOpportunityIndex()
418         throws AngError {
419         
420         ArrayList JavaDoc oppIndex = null;
421         try {
422             oppIndex = getRemIF().getOpportunityIndex(getCurrentUser());
423         } catch (RemoteException r) {
424             throw new AngError(r.getMessage());
425         }
426         return oppIndex;
427     }
428
429     /**
430      * lookup an Opportunity by it's name
431      * @param name the Opportunity name we look up with
432      * @return the Opportunity if found
433      * @exception AngError thrown for all application errors
434      */

435     public final Opportunity getOpportunityByName(String JavaDoc name)
436         throws AngError {
437
438         Opportunity opp=null;
439
440         //check the cache first
441
for (int i=0;i<opportunities.size();i++) {
442             opp = (Opportunity)opportunities.get(i);
443             if (opp.getName().equals(name))
444                 return opp;
445         }
446
447         //at this point the opp was not in the cache so look else where
448
if (oppIndex == null) {
449             try {
450                 oppIndex = getRemIF().getOpportunityIndex(getCurrentUser());
451             } catch (RemoteException r) {
452                 throw new AngError(r.getMessage());
453             }
454         }
455
456         long pk=-1;
457         OppIndex oi = null;
458         for (int k=0;k<oppIndex.size();k++) {
459             oi = (OppIndex)oppIndex.get(k);
460             if (oi.getName().equals(name))
461                 pk = oi.getPK();
462         }
463
464         if (pk == -1)
465             throw new AngError("getOppByName lookup failed [name]="+name);
466         try {
467             opp = getRemIF().getOpportunity(pk);
468         } catch (RemoteException r) {
469             throw new AngError(r.getMessage());
470         }
471         if (opp == null)
472             throw new AngError("getOppByName opp not found [name]="+name);
473         return opp;
474     }
475
476     /**
477      * get the current list of Alarms
478      * @return the list of Alarms
479      * @exception AngError thrown for all application errors
480      */

481     public final ArrayList JavaDoc getAlarms()
482         throws AngError {
483         
484         try {
485             //this 'if' handles the case when a person doesn't log in for
486
//a period longer than the activity checker time (5 mins)
487

488             ArrayList JavaDoc acts;
489             if ((getRemIF() != null) && (getCurrentUser() != null)) {
490                 acts = getRemIF().getAlarms(getCurrentUser().getPK());
491                 System.out.println("Whiteboard acts="+ acts.size());
492             } else
493                 acts = new ArrayList JavaDoc();
494             return acts;
495         } catch (RemoteException r) {
496             r.printStackTrace();
497             throw new AngError(r.getMessage());
498         }
499     }
500
501     /**
502      * add a new Activity
503      * @param oppPK the current Opportunity primary key of
504      * the Opportunity that will get the Activity added to
505      * @param a the Activity we are adding
506      * @return the primary key of the newly added Activity
507      * @exception AngError thrown for all application errors
508      */

509     public final long addActivity(long oppPK, Activity a)
510         throws AngError {
511     
512         try {
513             a.setModifiedBy(currentUser.getID());
514             return getRemIF().addActivity(oppPK, a);
515         } catch (RemoteException r) {
516             r.printStackTrace();
517             throw new AngError(r.getMessage());
518         }
519     }
520
521     /**
522      * delete an Activity from a given Opportunity
523      * @param oppPK the Opportunity primary key we are
524      * to delete from
525      * @param actPK the Activity primary key we are to
526      * delete
527      * @exception AngError thrown for all application errors
528      */

529     public final void deleteActivity(long oppPK, long actPK)
530         throws AngError {
531
532         try {
533             getRemIF().deleteActivity(oppPK, actPK);
534         } catch (RemoteException r) {
535             r.printStackTrace();
536             throw new AngError(r.getMessage());
537         }
538     }
539
540     /**
541      * update an Activity
542      * @param oppPK the Opportunity primary key the Activity
543      * belongs to
544      * @param a the Activity we are updating
545      * @exception AngError thrown for all application errors
546      */

547     public final void updateActivity(long oppPK, Activity a)
548         throws AngError {
549         
550         try {
551             a.setModifiedBy(currentUser.getID());
552             getRemIF().updateActivity(oppPK, a);
553         } catch (RemoteException r) {
554             r.printStackTrace();
555             throw new AngError(r.getMessage());
556         }
557     }
558
559     /**
560      * udpate an Opportunity
561      * @param o the Opportunity we are updating
562      * @exception AngError thrown for all application errors
563      */

564     public final void updateOpportunity(Opportunity o)
565         throws AngError {
566
567         try {
568             o.setModifiedBy(currentUser.getID());
569             getRemIF().updateOpportunity(o);
570         } catch (RemoteException r) {
571             r.printStackTrace();
572             throw new AngError(r.getMessage());
573         }
574     }
575
576     /**
577      * get a list of Opportunity names
578      * @return the list of names
579      * @exception AngError thrown for all application errors
580      */

581     public final ArrayList JavaDoc getOpportunityNames()
582         throws AngError {
583
584         try {
585             opportunityNames = getRemIF().getOpportunityNames(getCurrentUser());
586         } catch (RemoteException r) {
587             throw new AngError(r.getMessage());
588         }
589         return opportunityNames;
590     }
591         
592             
593     /**
594      * get all the Opportunities for this current user
595      * @return the list of Opportunities
596      */

597     public final ArrayList JavaDoc getOpportunities() {
598         return opportunities;
599     }
600
601     /**
602      * check to see if the current user is logged on
603      * @return true if logged on or false otherwise
604      */

605     public final boolean isLoggedOn() {
606         return loggedOn;
607     }
608
609     /**
610      * set the logon status
611      * @param t true if the user is logged on, false otherwize
612      */

613     public final void setLoggedOn(boolean t) {
614         loggedOn = t;
615     }
616
617     /**
618      * set the current Customer
619      * @param c the Customer we are to set as current
620      */

621     public final void setCustomer(Customer c) {
622         cust = c;
623     }
624
625     /**
626      * get the current Customer
627      * @return the Customer
628      */

629     public final Customer getCustomer() {
630         return cust;
631     }
632
633     /**
634      * get the Customer that has a given name
635      * @param custName the Customer name we are searching with
636      * @return the found Customer
637      * @exception AngError thrown for all application errors
638      */

639     public final Customer getCustomer(String JavaDoc custName)
640         throws AngError {
641
642         try {
643             return getRemIF().getCustomer(custName);
644         } catch (RemoteException r) {
645             throw new AngError(r.getMessage());
646         }
647     }
648
649     /**
650      * add a Customer to the system's list of Customers
651      * @param c the Customer to add
652      * @return the primary key of the new Customer
653      * @exception AngError thrown for all application errors
654      */

655     public final long addCustomer(Customer c)
656         throws AngError {
657
658         try {
659             c.setModifiedBy(currentUser.getID());
660             return getRemIF().addCustomer(c);
661         } catch (RemoteException r) {
662             throw new AngError(r.getMessage());
663         }
664     }
665
666     /**
667      * delete a SalesPerson
668      * @param pk the primary key of the SalesPerson to delete
669      * @exception AngError thrown for all application errors
670      */

671     public final void deleteSalesPerson(SalesPerson person)
672         throws AngError {
673         
674         try {
675             getRemIF().deleteSalesPerson(person); //delete the perm copy
676
Object JavaDoc sp = salesPersons.remove(person.getID()); //delete mem copy
677
if (sp == null)
678                 throw new AngError("sp pk not found");
679         } catch (RemoteException r) {
680             throw new AngError(r.getMessage());
681         }
682     }
683             
684     /**
685      * add a SalesPerson
686      * @param s the SalesPerson to add
687      * @exception AngError thrown for all application errors
688      */

689     public final void addSalesPerson(SalesPerson s)
690         throws AngError {
691         
692         try {
693             s.setModifiedBy(currentUser.getID());
694             System.out.println(s.getModifiedBy() + " is the modified value in whiteboard");
695             s.setPK(getRemIF().addSalesPerson(s)); //add to db
696
salesPersons.put(s.getID(), s); //add to memory copy
697
} catch (RemoteException r) {
698             throw new AngError(r.getMessage());
699         }
700     }
701
702     /**
703      * get a SalesPerson using a formatted name
704      * @param formatted the SalesPerson's formatted name to
705      * search with
706      * @return the found SalesPerson
707      * @exception AngError thrown for all application errors
708      */

709 // public final SalesPerson getSalesPerson(String formatted)
710
// throws AngError {
711
//
712
// try {
713
// return getRemIF().getSalesPerson(formatted);
714
// } catch (RemoteException r) {
715
// throw new AngError(r.getMessage());
716
// }
717
// }
718

719     /**
720      * add an Opportunity
721      * @param o the Opportunity we are adding
722      * @return the primary key of the new Opportunity
723      * @exception AngError thrown for all application errors
724      */

725     public final long addOpportunity(Opportunity o)
726         throws AngError {
727     
728         try {
729             o.setModifiedBy(currentUser.getID());
730             long pk = getRemIF().addOpportunity(o);
731             o.setPK(pk);
732             opportunities.add(o);
733             return pk;
734         } catch (RemoteException r) {
735             throw new AngError(r.getMessage());
736         }
737     }
738
739     /**
740      * delete an Opportunity
741      * @param pk the primary key we find the Opportunity with
742      * @exception AngError thrown for all application errors
743      */

744     public final void deleteOpportunity(long pk)
745         throws AngError {
746         try {
747             getRemIF().deleteOpportunity(pk);
748             Opportunity opp = null;
749             for (int i = 0;i<opportunities.size();i++) {
750                 opp = (Opportunity)opportunities.get(i);
751                 if (opp.getPK() == pk)
752                     opportunities.remove(i);
753             }
754         } catch (RemoteException r) {
755             throw new AngError(r.getMessage());
756         }
757     }
758
759     /**
760      * get a list of SalesPersons
761      * @return the list of SalesPersons
762      * @exception AngError thrown for all application errors
763      */

764     public final TreeMap getSalesPersons()
765         throws AngError {
766
767         try {
768             
769             Object JavaDoc[] values = getRemIF().getSalesPersons(null);
770             salesPersons = new TreeMap();
771             SalesPerson sp;
772             for (int i=0;i<values.length;i++) {
773                 sp = (SalesPerson)values[i];
774                 salesPersons.put(sp.getID(), sp);
775             }
776
777             return salesPersons;
778         } catch (RemoteException r) {
779             throw new AngError(r.getMessage());
780         }
781     }
782
783     /**
784      * get a list of SalesPerson names
785      * @return the list of names
786      * @exception AngError thrown for all application errors
787      */

788     public final ArrayList JavaDoc getSalesPersonNames()
789         throws AngError {
790
791         try {
792             return getRemIF().getSalesPersonNames();
793         } catch (RemoteException r) {
794             throw new AngError(r.getMessage());
795         }
796     }
797
798     /**
799      * update a SalesPerson
800      * @param u the SalesPerson to update
801      * @exception AngError thrown for all application errors
802      */

803     public final void updateSalesPerson(SalesPerson u)
804         throws AngError {
805
806         try {
807             u.setModifiedBy(currentUser.getID());
808             getRemIF().updateSalesPerson(u); //update the db copy
809

810             if (salesPersons == null)
811                 salesPersons = getSalesPersons();
812
813             Object JavaDoc sp = salesPersons.remove(u.getID());
814             if (sp == null)
815                 throw new AngError("sp not found in memory");
816             salesPersons.put(u.getID(), u);
817         } catch (RemoteException r) {
818             r.printStackTrace();
819             throw new AngError(r.getMessage());
820         }
821     }
822
823     /**
824      * set the current Login information, this is done
825      * after a person logs into the system successfully
826      * @param l the Login creditials
827      */

828     public final void setCurrentLogin(Login l) {
829         System.out.println("setting current login to " + l.getSalesPerson().getID());
830         setCurrentUser(l.getSalesPerson());
831         login = l;
832     }
833
834     /**
835      * get the current Login creditials
836      * @return the current Login
837      */

838     public final Login getLogin()
839         throws AngError {
840
841         if (login == null)
842             throw new AngError("User not logged in. Please log in.");
843         return login;
844     }
845     
846     /**
847      * set the current user or SalesPerson
848      * @param s the SalesPerson we set with (yuck)
849      */

850     public final void setCurrentUser(SalesPerson s) {
851         currentUser = s;
852     }
853
854     /**
855      * get the current SalesPerson or logged on user
856      * @return the current SalesPerson
857      */

858     public final SalesPerson getCurrentUser() {
859         return currentUser;
860     }
861
862     /**
863      * delete a Forecast from an Opportunity
864      * @param oppPK the primary key of the Opportunity that this
865      * Forecast belongs to
866      * @param forePK the primary key of the Forecast we are deleting
867      * @exception AngError thrown for all application errors
868      */

869     public final void deleteForecast(long oppPK, long forePK)
870         throws AngError {
871
872         try {
873             getRemIF().deleteForecast(oppPK, forePK);
874         } catch (RemoteException r) {
875             throw new AngError(r.getMessage());
876         }
877     }
878
879     /**
880      * delete a Quote from a given Opportunity
881      * @param oppPK the primary key of the Opportunity we delete this
882      * Quote from
883      * @param quotePK the Quote primary key we delete with
884      * @exception AngError thrown for all application errors
885      */

886     public final void deleteQuote(long oppPK, long quotePK)
887         throws AngError {
888         try {
889             getRemIF().deleteQuote(oppPK, quotePK);
890         } catch (RemoteException r) {
891             throw new AngError(r.getMessage());
892         }
893     }
894
895     /**
896      * update a Quote
897      * @param q the Quote we update
898      * @exception AngError thrown for all application errors
899      */

900     public final void updateQuote(Quote q)
901         throws AngError {
902         try {
903             Opportunity opp = getCurrentOpportunity();
904             q.setModifiedBy(currentUser.getID());
905             getRemIF().updateQuote(opp.getPK(), q);
906         } catch (RemoteException r) {
907             throw new AngError(r.getMessage());
908         }
909     }
910     /**
911      * add a Quote
912      * @param oppPK the primary key of the Opportunity we are adding to
913      * @param q the Quote we are adding
914      * @return the primary key of the newly added Quote
915      * @exception AngError thrown for all application errors
916      */

917     public final long addQuote(long oppPK, Quote q)
918         throws AngError {
919         try {
920             q.setModifiedBy(currentUser.getID());
921             return getRemIF().addQuote(oppPK, q);
922         } catch (RemoteException r) {
923             throw new AngError(r.getMessage());
924         }
925     }
926
927         
928     /**
929      * delete a QuoteLine
930      * @param oppPK the primary key of the containing Opportunity
931      * @param quotePK the primary key of the containing Quote
932      * @param linePK the primary key of the QuoteLine we want to delete
933      * @exception AngError thrown for all application errors
934      */

935     public final void deleteQuoteLine(long oppPK, long quotePK, long linePK)
936         throws AngError {
937         
938         try {
939             getRemIF().deleteQuoteLine(oppPK, quotePK, linePK);
940         } catch (RemoteException r) {
941             throw new AngError(r.getMessage());
942         }
943     }
944
945     /**
946      * add a new QuoteLine
947      * @param oppPK the primary key of the containing Opportunity
948      * @param quotePK the primary key of the containing Quote
949      * @param q the QuoteLine to add
950      * @return the primary key of the newly added QuoteLine
951      * @exception AngError thrown for all application errors
952      */

953     public final long addQuoteLine(long oppPK, long quotePK, QuoteLine q)
954         throws AngError {
955         
956         try {
957             q.setModifiedBy(getCurrentUser().getID());
958             return getRemIF().addQuoteLine(oppPK, quotePK, q);
959         } catch (RemoteException r) {
960             throw new AngError(r.getMessage());
961         }
962     }
963
964     /**
965      * delete a Contact
966      * @param pk the primary key of the Contact we wish to delete
967      * @exception AngError thrown for all application errors
968      */

969     public final void deleteContact(long pk)
970         throws AngError {
971
972         Opportunity opp = getCurrentOpportunity();
973         try {
974             getRemIF().deleteContact(opp.getPK(), pk);
975         } catch (RemoteException e) {
976             throw new AngError(e.getMessage());
977         }
978     }
979
980     /**
981      * add a Contact to the current Opportunity
982      * @param c the Contact we want to add
983      * @return the primay key of the new Contact
984      * @exception AngError thrown for all application errors
985      */

986     public final long addContact(Contact c)
987         throws AngError {
988
989         Opportunity opp = getCurrentOpportunity();
990         try {
991             c.setModifiedBy(currentUser.getID());
992             return getRemIF().addContact(opp.getPK(), c);
993         } catch (RemoteException e) {
994             throw new AngError(e.getMessage());
995         }
996     }
997
998     /**
999      * update a Contact of the current Opportunity
1000     * @param c the Contact to update
1001     * @exception AngError thrown for all application errors
1002     */

1003    public final void updateContact(Contact c)
1004        throws AngError {
1005
1006        Opportunity opp = getCurrentOpportunity();
1007        try {
1008            c.setModifiedBy(currentUser.getID());
1009            getRemIF().updateContact(opp.getPK(), c);
1010        } catch (RemoteException e) {
1011            throw new AngError(e.getMessage());
1012        }
1013    }
1014
1015    /**
1016     * add a Forecast to a given Opportunity
1017     * @param oppPK the primary key of the containing Opportunity
1018     * @param f the Forecast to add
1019     * @exception AngError thrown for all application errors
1020     */

1021    public final void addForecast(long oppPK, Forecast f)
1022        throws AngError {
1023
1024        try {
1025            f.setModifiedBy(currentUser.getID());
1026            long pk = getRemIF().addForecast(oppPK, f);
1027            f.setPK(pk);
1028            getCurrentOpportunity().addForecast(f);
1029        } catch (RemoteException r) {
1030            throw new AngError(r.getMessage());
1031        }
1032    }
1033
1034    /**
1035     * update a Forecast of the current Opportunity
1036     * @param f the Forecast to update
1037     * @exception AngError thrown for all application errors
1038     */

1039    public final void updateForecast(Forecast f)
1040        throws AngError {
1041
1042        try {
1043            long oppPK = getCurrentOpportunity().getPK();
1044            f.setModifiedBy(currentUser.getID());
1045            getRemIF().updateForecast(oppPK, f);
1046        } catch (RemoteException r) {
1047            throw new AngError(r.getMessage());
1048        }
1049    }
1050
1051    /**
1052     * update an Order of the current Opportunity
1053     * @param o the Order to update
1054     * @exception AngError thrown for all application errors
1055     */

1056    public final void updateOrder(Order o)
1057        throws AngError {
1058        try {
1059            long oppPK = getCurrentOpportunity().getPK();
1060            o.setModifiedBy(currentUser.getID());
1061            getRemIF().updateOrder(oppPK, o);
1062        } catch (RemoteException r) {
1063            throw new AngError(r.getMessage());
1064        }
1065    }
1066
1067    /**
1068     * add an Order to the current Opportunity
1069     * @param o the Order to add
1070     * @return the primary key of the new Order
1071     * @exception AngError thrown for all application errors
1072     */

1073    public final long addOrder(Order o)
1074        throws AngError {
1075        try {
1076            o.setModifiedBy(getCurrentUser().getID());
1077            long oppPK = getCurrentOpportunity().getPK();
1078            return getRemIF().addOrder(oppPK, o);
1079        } catch (RemoteException r) {
1080            throw new AngError(r.getMessage());
1081        }
1082    }
1083
1084    /**
1085     * update a Customer
1086     * @param c the Customer to update
1087     * @exception AngError thrown for all application errors
1088     */

1089    public final void updateCustomer(Customer c)
1090        throws AngError {
1091
1092        try {
1093            c.setModifiedBy(currentUser.getID());
1094            getRemIF().updateCustomer(c);
1095        } catch (RemoteException r) {
1096            throw new AngError(r.getMessage());
1097        }
1098    }
1099
1100    /**
1101     * delete a Customer using a name as search criteria
1102     * @param custName the customer's name we search with
1103     * @exception AngError thrown for all application errors
1104     */

1105    public final void deleteCustomer(String JavaDoc custName)
1106        throws AngError {
1107
1108        try {
1109            getRemIF().deleteCustomer(custName);
1110        } catch (RemoteException r) {
1111            throw new AngError(r.getMessage());
1112        }
1113    }
1114
1115    /**
1116     * udpate a Lead
1117     * @param campPK the Campaign this lead is contained in
1118     * @param l the Lead we wish to update
1119     * @exception AngError thrown for all application errors
1120     */

1121    public final void updateLead(long campPK, Lead l)
1122        throws AngError {
1123        try {
1124            l.setModifiedBy(currentUser.getID());
1125            getRemIF().updateLead(campPK, l);
1126        } catch (RemoteException r) {
1127            throw new AngError(r.getMessage());
1128        }
1129    }
1130
1131    /**
1132     * get the list of Campaigns
1133     * @return the list of Campaigns
1134     * @exception AngError thrown for all application errors
1135     */

1136    public final ArrayList JavaDoc getCampaigns()
1137        throws AngError {
1138
1139        ArrayList JavaDoc camps = null;
1140        try {
1141            camps = getRemIF().getCampaigns(null);
1142        } catch (RemoteException e) {
1143            throw new AngError(e.getMessage());
1144        }
1145        return camps;
1146    }
1147
1148    /**
1149     * get a list of Leads for a given Campaign
1150     * @param campPK the Campaign primary key to find with
1151     * @return the list of Leads
1152     * @exception AngError thrown for all application errors
1153     */

1154    public final ArrayList JavaDoc getCampaignLeads(long campPK)
1155        throws AngError {
1156
1157        ArrayList JavaDoc leads = null;
1158
1159        try {
1160            leads = getRemIF().getCampaignLeads(campPK);
1161        } catch (RemoteException e) {
1162            throw new AngError(e.getMessage());
1163        }
1164        return leads;
1165    }
1166
1167    /**
1168     * get a Product using some search criteria
1169     * @param group the product group to search
1170     * @param line the product line to search
1171     * @param name the product name to search
1172     * @return the found Product
1173     * @exception AngError thrown for all application errors
1174     */

1175    public final Product getProduct(String JavaDoc group, String JavaDoc line, String JavaDoc name)
1176        throws AngError {
1177
1178        Product prod = null;
1179
1180        try {
1181            prod = getRemIF().getProduct(group, line, name);
1182        } catch (RemoteException e) {
1183            throw new AngError(e.getMessage());
1184        }
1185        return prod;
1186    }
1187
1188    /**
1189     * get the ArrayList of products for a given group and line
1190     * @param group the product group to search
1191     * @param line the product line to search
1192     * @return an ArrayList of product matrix data
1193     * @exception AngError thrown for all application errors
1194     */

1195    public final ArrayList JavaDoc getProductsForLine(String JavaDoc group, String JavaDoc line)
1196        throws AngError {
1197
1198        try {
1199            return getRemIF().getProductsForLine(group, line);
1200        } catch (RemoteException e) {
1201            throw new AngError(e.getMessage());
1202        }
1203
1204    }
1205
1206    /**
1207     * get the product matrix
1208     * @return an Arraylist of product matrix data
1209     * @exception AngError thrown for all application errors
1210     */

1211    public final ArrayList JavaDoc getProductMatrix()
1212        throws AngError {
1213
1214        try {
1215            return getRemIF().getProductMatrix();
1216        } catch (RemoteException e) {
1217            throw new AngError(e.getMessage());
1218        }
1219    }
1220
1221    /**
1222     * gets the resource bundle that is currently set
1223     * for the user's language preference
1224     * @return the resource bundle for a specific language
1225     */

1226    public final ResourceBundle getLang() {
1227        return langBundle;
1228    }
1229
1230    /**
1231     * sets the resource bundle that is currently set
1232     * for the user's language preference
1233     * @param r resource bundle for a specific language
1234     */

1235    public final void setLang(String JavaDoc lang) {
1236        try {
1237
1238            if (lang.equals("French")) {
1239                System.out.println("French selected");
1240                langBundle = ResourceBundle.getBundle("French", new Locale("fr", "FR"));
1241            }
1242            else
1243            if (lang.equals("German")) {
1244                System.out.println("German selected");
1245                langBundle = ResourceBundle.getBundle("German", new Locale("de", "DE"));
1246            }
1247            else
1248            if (lang.equals("Spanish")) {
1249                System.out.println("Spanish selected");
1250                langBundle = ResourceBundle.getBundle("Spanish", new Locale("es", "MX"));
1251            }
1252            else {
1253                //default to English
1254
System.out.println("English selected");
1255                langBundle = ResourceBundle.getBundle("English", new Locale("en", "US"));
1256            }
1257        } catch (MissingResourceException e) {
1258            ErrorHandler.show(MainWindow.getMainParent(), e);
1259        }
1260    }
1261
1262    /**
1263     * get the current list of state tax codes
1264     * @param refresh if true, then force database query
1265     * @return the list of state tax codes
1266     * @exception AngError thrown for all application errors
1267     */

1268    public final ArrayList JavaDoc getStateTax(boolean refresh)
1269        throws AngError {
1270
1271        if ((taxList == null) || (refresh)) {
1272            try {
1273                taxList = getRemIF().getStateTax(null);
1274            } catch (RemoteException e) {
1275                throw new AngError(e.getMessage());
1276            }
1277        }
1278
1279        return taxList;
1280    }
1281
1282    /**
1283     * add a CustomerInventory
1284     * @param c the Customer to add
1285     * @return the primary key of the new Customer
1286     * @exception AngError thrown for all application errors
1287     */

1288    public final long addCustomerInventory(CustomerInventory c)
1289        throws AngError {
1290
1291        try {
1292            c.setModifiedBy(currentUser.getID());
1293            return getRemIF().addCustomerInventory(c);
1294        } catch (RemoteException r) {
1295            throw new AngError(r.getMessage());
1296        }
1297    }
1298
1299    /**
1300     * delete a CustomerInventory
1301     * @param custName the customer's name we search with
1302     * @exception AngError thrown for all application errors
1303     */

1304    public final void deleteCustomerInventory(CustomerInventory ci)
1305        throws AngError {
1306
1307        try {
1308            getRemIF().deleteCustomerInventory(ci);
1309        } catch (RemoteException r) {
1310            throw new AngError(r.getMessage());
1311        }
1312    }
1313
1314    /**
1315     * get CustomerInventory for current opp's customer
1316     * @return the list of CustomerInventory
1317     * @exception AngError thrown for all application errors
1318     */

1319    public final ArrayList JavaDoc getCustomerInventory()
1320        throws AngError {
1321
1322        try {
1323            return getRemIF().getCustomerInventory(getCurrentOpportunity().getCustomer().getPK());
1324        } catch (RemoteException r) {
1325            throw new AngError(r.getMessage());
1326        }
1327    }
1328
1329    /**
1330     * get the main window or mother parent of the whole gui
1331     * @return a reference to the MainWindow
1332     */

1333    public final MainWindow getMainWindow() {
1334        return parent;
1335    }
1336
1337}
1338
Popular Tags