3 import javajs.awt.Component;
\r
4 import javajs.awt.Dimension;
\r
7 * SwingController is an interface that javajs.swing classes will need.
\r
8 * It must be implemented as a JavaScript object PRIOR to
\r
9 * any calls to create any components.
\r
11 * In JSmol it is Jmol.Swing (see JsmolCore.js)
\r
13 * There should be one and only one SwingController on a page.
\r
14 * It is called by its class name "SwingController" directly.
\r
19 public interface SwingController {
\r
22 * Fired from clicking an element such as a button or
\r
23 * check box or table entry, or from entering text in a text box.
\r
25 * SwingController should make the changes in the underlying
\r
26 * "Java" object directly, then send notification of the event to the manager.
\r
29 * var component = Jmol.Swing.htDialogs[element.id];
\r
30 * var info = component.toString();
\r
32 * if (info.indexOf("JCheck") >= 0)
\r
33 * component.selected = element.checked;
\r
34 * var id = $("div.JDialog:has(#" + element.id + ")")[0].id
\r
35 * var dialog = Jmol.Swing.htDialogs[id];
\r
36 * dialog.manager.actionPerformed(component ? component.name : dialog.registryKey + "/" + element.id);
\r
41 void click(HTMLElement element, HTMLWindowEvent event);
\r
45 * Remove this component's HTML5 equivalent and clear references to it.
\r
49 void dispose(Component dialog);
\r
52 * Return the width and height of the window in d.
\r
55 * d.width = $(window).width();
\r
56 * d.height = $(window).height();
\r
60 void getScreenDimensions(Dimension d);
\r
63 * Set c's id to a unique identifier
\r
64 * and add it to an associative array that will
\r
65 * associate that id with c.
\r
70 void register(Component c, String type);
\r
73 * The HTML for this dialog has been generated.
\r
74 * Now create the HTML on the page for this dialog
\r
75 * based on dialog.html and wrap it appropriately.
\r
79 void setDialog(Component dialog);
\r
82 * Convey to the HTML object that this check box's selection
\r
85 * $("#" + chk.id).prop('checked', !!chk.selected);
\r
89 void setSelected(Component chk);
\r
92 * Convey to the HTML object that this combo box's selected item
\r
95 * $("#" + cmb.id).prop('selectedIndex', cmb.selectedIndex);
\r
99 void setSelectedIndex(Component cmb);
\r
102 * Convey to the HTML object that this component's text
\r
103 * has been changed.
\r
105 * $("#" + btn.id).prop('value', btn.text);
\r
109 void setText(String text);
\r
112 * Convey to the HTML object that this component's text
\r
113 * has been changed.
\r
116 * $("#" + c.id).show();
\r
118 * $("#" + c.id).hide();
\r
122 void setVisible(Component c);
\r
125 * Called by clicking the [x] in the corner of the dialog;
\r
126 * send a notification back to the manager via processWindowClosing(key)
\r
128 * var id = $("div.JDialog:has(#" + element.id + ")")[0].id
\r
129 * var dialog = Jmol.Swing.htDialogs[id];
\r
130 * dialog.manager.processWindowClosing(dialog.registryKey);
\r
134 void windowClosing(HTMLElement element);
\r