01: package org.columba.addressbook.gui.action;
02:
03: import java.awt.event.ActionEvent;
04:
05: import org.columba.addressbook.folder.AddressbookFolder;
06: import org.columba.addressbook.gui.frame.AddressbookFrameMediator;
07: import org.columba.addressbook.model.IContactModel;
08: import org.columba.addressbook.util.AddressbookResourceLoader;
09: import org.columba.api.exception.ServiceNotFoundException;
10: import org.columba.api.gui.frame.IFrameMediator;
11: import org.columba.core.facade.ServiceFacadeRegistry;
12: import org.columba.core.resourceloader.IconKeys;
13: import org.columba.core.resourceloader.ImageLoader;
14: import org.columba.mail.facade.IDialogFacade;
15:
16: public class ComposeMessageAction extends DefaultTableAction {
17: /**
18: * @param frameMediator
19: * @param name
20: */
21: public ComposeMessageAction(IFrameMediator frameMediator) {
22: super (frameMediator, "Compose Message");
23:
24: putValue(SMALL_ICON, ImageLoader
25: .getSmallIcon(IconKeys.MAIL_NEW));
26: putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.MAIL_NEW));
27:
28: // tooltip text
29: putValue(SHORT_DESCRIPTION, "Compose Message");
30:
31: putValue(TOOLBAR_NAME, "Compose Message");
32: }
33:
34: /**
35: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
36: */
37: public void actionPerformed(ActionEvent arg0) {
38: AddressbookFrameMediator mediator = (AddressbookFrameMediator) frameMediator;
39:
40: // get selected folder
41: AddressbookFolder sourceFolder = (AddressbookFolder) mediator
42: .getTree().getSelectedFolder();
43:
44: // get selected contact/group card
45: String[] uids = mediator.getTable().getUids();
46:
47: try {
48: String[] adr = new String[uids.length];
49: for (int i = 0; i < uids.length; i++) {
50: IContactModel contact = sourceFolder.get(uids[i]);
51: adr[i] = contact.getPreferredEmail();
52: }
53:
54: IDialogFacade facade = (IDialogFacade) ServiceFacadeRegistry
55: .getInstance()
56: .getService(
57: org.columba.mail.facade.IDialogFacade.class);
58: facade.openComposer(adr);
59: } catch (ServiceNotFoundException e) {
60: e.printStackTrace();
61: }
62: }
63: }
|