01: package org.airtodo;
02:
03: import java.awt.Desktop;
04: import java.awt.Dialog;
05: import java.io.File;
06: import java.net.URI;
07:
08: import org.air.framework.core.GuiUtils;
09: import org.airtodo.db.types.AttachmentType;
10: import org.airtodo.gui_common.components.lookup_data.LookupDataAttachment;
11:
12: public class LinkUtils {
13: public static void launch(Dialog owner,
14: AttachmentType attachmentType, String text) {
15: Desktop desktop = Desktop.getDesktop();
16: try {
17: if (attachmentType.getValue() == LookupDataAttachment.NLS.ATTACHMENT_TYPE_FILE
18: .ordinal())
19: desktop.open(new File(text));
20: else if (attachmentType.getValue() == LookupDataAttachment.NLS.ATTACHMENT_TYPE_URL
21: .ordinal())
22: desktop.browse(new URI(text));
23: else if (attachmentType.getValue() == LookupDataAttachment.NLS.ATTACHMENT_TYPE_EMAIL
24: .ordinal())
25: desktop.mail(new URI("mailto://" + text));
26: } catch (Throwable t) {
27: GuiUtils.showThrowableMessage(owner, t);
28: }
29: }
30:
31: }
|