1 package org.catacomb.druid.dialog; 2 3 4 import java.io.File; 5 6 import org.catacomb.druid.util.FileChooser; 7 import org.catacomb.interlish.content.StringValue; 8 import org.catacomb.interlish.report.Logger; 9 10 11 12 public class Dialoguer { 13 14 15 static CheckSeenDialogController csdController; 16 static NamingDialogController namingDialogController; 17 static MessageDialogController messageDialogController; 18 static ConfirmationDialogController confirmationDialogController; 19 static QuestionDialogController questionDialogController; 20 static TextDialogController textDialogController; 21 22 static FolderDialogController folderDialogController; 23 24 static ProgressLogDialogController progressLogController; 25 26 27 28 29 public static void checkSeen(String label, String msg, int[] xy) { 30 if (csdController == null) { 31 csdController = new CheckSeenDialogController(); 32 } 33 34 csdController.showIfNotYetSeen(label, msg, xy); 35 } 36 37 38 39 public static String getNewName(int[] xy, String msg) { 40 return getNewName(xy, msg, ""); 41 } 42 43 44 public static String getNewName(int[] xy, String msg, String initValue) { 45 String ret = null; 46 if (namingDialogController == null) { 47 namingDialogController = new NamingDialogController(); 48 } 49 ret = namingDialogController.getNewName(xy, msg, initValue); 50 return ret; 51 } 52 53 54 public static File getFolder(int[] xy, String msg, File fdef) { 55 File ret = null; 56 if (folderDialogController == null) { 57 folderDialogController = new FolderDialogController(); 58 } 59 ret = folderDialogController.getFolder(xy, msg, fdef); 60 return ret; 61 } 62 63 public static File getFile(String mode) { 64 return FileChooser.getChooser().getFileToOpen(mode); 65 } 66 67 68 public static File getFileToWrite(String mode, File fdir, String ext, String extDef) { 69 FileChooser.getChooser().setDefaultFolderForMode(mode, fdir); 70 return FileChooser.getChooser().getFileToWrite(mode, ext, extDef); 71 } 72 73 public static File getFileToWrite(String mode) { 74 return FileChooser.getChooser().getFileToWrite(mode); 75 } 76 77 78 public static File getFileToRead(String mode) { 79 return getFile(mode); 80 } 81 82 83 84 public static boolean getConfirmation(int[] xy, String msg) { 85 boolean ret = false; 86 if (confirmationDialogController == null) { 87 confirmationDialogController = new ConfirmationDialogController(); 88 } 89 ret = confirmationDialogController.getResponse(xy, msg); 90 return ret; 91 } 92 93 public static void message(String msg) { 94 int[] ixy = {400, 300}; 95 message(ixy, msg); 96 } 97 98 99 public static void message(int[] xy, String msg) { 100 message(xy, "", msg); 101 } 102 103 public static void message(int[] xy, String title, String msg) { 104 if (messageDialogController == null) { 105 messageDialogController = new MessageDialogController(); 106 107 } 108 messageDialogController.show(xy, title, msg); 109 } 110 111 112 113 public static int multiChoiceLongQuestion(String ques, String[] answers) { 114 if (questionDialogController == null) { 115 questionDialogController = new QuestionDialogController(); 116 } 117 int ret = questionDialogController.getResponse(ques, answers); 118 return ret; 119 } 120 121 122 public static void showText(String s) { 123 int[] ixy = {400, 300}; 124 StringValue txtsv = new StringValue(s); 125 showText(ixy, txtsv); 126 } 127 128 public static void showText(int[] xy, StringValue txtsv) { 129 if (textDialogController == null) { 130 textDialogController = new TextDialogController(); 131 132 } 133 textDialogController.showNonModal(xy, txtsv); 134 } 135 136 137 138 public static Logger getProgressLogger() { 139 if (progressLogController == null) { 140 progressLogController = new ProgressLogDialogController(); 141 progressLogController.checkInit(); 142 } 143 return progressLogController; 144 } 145 146 147 148 public static void closeProgressLogger() { 149 progressLogController.close(); 150 151 } 152 153 154 155 }