File size: 3,717 Bytes
233f6d4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | Clazz.declarePackage ("JSV.dialog");
Clazz.load (null, "JSV.dialog.DialogManager", ["java.util.Hashtable", "JU.PT", "JSV.common.JSVFileManager"], function () {
c$ = Clazz.decorateAsClass (function () {
this.vwr = null;
this.htSelectors = null;
this.htDialogs = null;
this.options = null;
Clazz.instantialize (this, arguments);
}, JSV.dialog, "DialogManager");
Clazz.defineMethod (c$, "set",
function (viewer) {
this.vwr = viewer;
this.htSelectors = new java.util.Hashtable ();
this.htDialogs = new java.util.Hashtable ();
return this;
}, "JSV.common.JSViewer");
Clazz.defineMethod (c$, "registerDialog",
function (jsvDialog) {
var id = jsvDialog.optionKey;
if (!id.endsWith ("!")) id += " " + ("" + Math.random ()).substring (3);
if (this.htDialogs.containsKey (id)) this.htDialogs.get (id).dispose ();
this.htDialogs.put (id, jsvDialog);
return id;
}, "JSV.dialog.JSVDialog");
Clazz.defineMethod (c$, "registerSelector",
function (selectorName, columnSelector) {
this.htSelectors.put (columnSelector, selectorName);
}, "~S,~O");
Clazz.defineMethod (c$, "getSelectorName",
function (selector) {
return this.htSelectors.get (selector);
}, "~O");
Clazz.defineMethod (c$, "showSourceErrors",
function (frame, currentSource) {
if (currentSource == null) {
this.showMessageDialog (frame, "Please Select a Spectrum.", "Select Spectrum", 2);
return;
}var errorLog = currentSource.getErrorLog ();
if (errorLog != null && errorLog.length > 0) this.showMessage (frame, errorLog, JSV.dialog.DialogManager.fixTitle (currentSource.getFilePath ()));
else this.showMessageDialog (frame, "No errors found.", "Error Log", 1);
}, "~O,JSV.source.JDXSource");
Clazz.defineMethod (c$, "showSource",
function (frame, filePath) {
if (filePath == null) {
this.showMessageDialog (frame, "Please Select a Spectrum", "Select Spectrum", 2);
return;
}try {
var s = JSV.common.JSVFileManager.getFileAsString (filePath);
if (this.vwr.isJS) s = JU.PT.rep (s, "<", "<");
this.showMessage (null, s, JSV.dialog.DialogManager.fixTitle (filePath));
} catch (ex) {
if (Clazz.exceptionOf (ex, Exception)) {
this.showMessageDialog (frame, "File Not Found", "SHOWSOURCE", 0);
} else {
throw ex;
}
}
}, "~O,~S");
Clazz.defineMethod (c$, "processClick",
function (eventId) {
var pt = eventId.lastIndexOf ("/");
var id = eventId.substring (pt + 1);
var dialog = eventId.substring (0, pt);
this.dialogCallback (dialog, id, null);
}, "~S");
Clazz.defineMethod (c$, "processTableEvent",
function (eventId, index1, index2, adjusting) {
var pt = eventId.lastIndexOf ("/");
var dialog = eventId.substring (0, pt);
var selector = eventId.substring (pt + 1);
var msg = "&selector=" + selector + "&index=" + index1 + (index2 < 0 ? "&adjusting=" + adjusting : "&index2=" + index2);
this.dialogCallback (dialog, "tableSelect", msg);
}, "~S,~N,~N,~B");
Clazz.defineMethod (c$, "processWindowClosing",
function (dialogId) {
this.dialogCallback (dialogId, "windowClosing", null);
this.htDialogs.remove (dialogId);
}, "~S");
Clazz.defineMethod (c$, "dialogCallback",
function (dialogId, id, msg) {
var jsvDialog = this.htDialogs.get (dialogId);
if (jsvDialog != null) jsvDialog.callback (id, msg);
}, "~S,~S,~S");
Clazz.defineMethod (c$, "getDialogOptions",
function () {
if (this.options == null) this.options = new java.util.Hashtable ();
return this.options;
});
c$.fixTitle = Clazz.defineMethod (c$, "fixTitle",
function (title) {
return (title.length > 50 ? title.substring (0, 50) + "..." : title);
}, "~S");
Clazz.defineStatics (c$,
"PLAIN_MESSAGE", -1,
"ERROR_MESSAGE", 0,
"INFORMATION_MESSAGE", 1,
"WARNING_MESSAGE", 2,
"QUESTION_MESSAGE", 3);
});
|