1 21 22 package org.armedbear.j.mail; 23 24 import org.armedbear.j.Buffer; 25 import org.armedbear.j.Editor; 26 import org.armedbear.j.InputDialog; 27 28 public final class NewsCommands 29 { 30 public static void news() 31 { 32 if (!Editor.checkExperimental()) 33 return; 34 final Editor editor = Editor.currentEditor(); 35 NntpSession session = NntpSession.getSession(); 36 if (session != null) { 37 News news = new News(session); 38 editor.makeNext(news); 39 editor.activate(news); 40 } 41 } 42 43 public static void news(String host) 44 { 45 if (!Editor.checkExperimental()) 46 return; 47 final Editor editor = Editor.currentEditor(); 48 NntpSession session = NntpSession.getSession(host); 49 if (session != null) { 50 News news = new News(session); 51 editor.makeNext(news); 52 editor.activate(news); 53 } 54 } 55 56 public static void openGroupAtDot() 57 { 58 final Editor editor = Editor.currentEditor(); 59 final Buffer buffer = editor.getBuffer(); 60 if (buffer instanceof News && editor.getDot() != null) { 61 String groupName = editor.getDotLine().getText(); 62 NntpSession session = 63 NntpSession.getSession(((News)buffer).getHost()); 64 NewsGroupSummary summary = new NewsGroupSummary(session, groupName); 65 editor.makeNext(summary); 66 editor.activate(summary); 67 } 68 } 69 70 public static void openGroup() 71 { 72 if (!Editor.checkExperimental()) 73 return; 74 final Editor editor = Editor.currentEditor(); 75 String groupName = 76 InputDialog.showInputDialog(editor, "Group:","Open Group", null); 77 if (groupName == null || groupName.length() == 0) 78 return; 79 editor.repaintNow(); 80 NntpSession session = NntpSession.getSession(); 81 NewsGroupSummary summary = new NewsGroupSummary(session, groupName); 82 editor.makeNext(summary); 83 editor.activate(summary); 84 } 85 86 public static void readArticle() 87 { 88 readArticle(false); 89 } 90 91 public static void readArticleOtherWindow() 92 { 93 readArticle(true); 94 } 95 96 private static void readArticle(boolean useOtherWindow) 97 { 98 final Editor editor = Editor.currentEditor(); 99 final Buffer buffer = editor.getBuffer(); 100 if (buffer instanceof NewsGroupSummary && editor.getDot() != null) 101 ((NewsGroupSummary)buffer).readArticle(editor, 102 editor.getDotLine(), useOtherWindow); 103 } 104 } 105 | Popular Tags |