Package org.jmol.awtjs.swing
Interface SwingController
-
public interface SwingControllerSwingController is an interface that org.jmol.awtjs.swing classes will need. It must be implemented as a JavaScript object PRIOR to any calls to create any components. In JSmol it is Jmol.Swing (see JsmolCore.js) There should be one and only one SwingController on a page. It is called by its class name "SwingController" directly.- Author:
- hansonr
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclick(HTMLElement element, HTMLWindowEvent event)Fired from clicking an element such as a button or check box or table entry, or from entering text in a text box.voiddispose(Component dialog)Remove this component's HTML5 equivalent and clear references to it.voidgetScreenDimensions(Dimension d)Return the width and height of the window in d.voidregister(Component c, java.lang.String type)Set c's id to a unique identifier and add it to an associative array that will associate that id with c.voidsetDialog(Component dialog)The HTML for this dialog has been generated.voidsetSelected(Component chk)Convey to the HTML object that this check box's selection has been changed.voidsetSelectedIndex(Component cmb)Convey to the HTML object that this combo box's selected item has been changed.voidsetText(java.lang.String text)Convey to the HTML object that this component's text has been changed.voidsetVisible(Component c)Convey to the HTML object that this component's text has been changed.voidwindowClosing(HTMLElement element)Called by clicking the [x] in the corner of the dialog; send a notification back to the manager via processWindowClosing(key) var id = $("div.JDialog:has(#" + element.id + ")")[0].id var dialog = Jmol.Swing.htDialogs[id]; dialog.manager.processWindowClosing(dialog.registryKey);
-
-
-
Method Detail
-
click
void click(HTMLElement element, HTMLWindowEvent event)
Fired from clicking an element such as a button or check box or table entry, or from entering text in a text box. SwingController should make the changes in the underlying "Java" object directly, then send notification of the event to the manager. For instance: var component = Jmol.Swing.htDialogs[element.id]; var info = component.toString(); if (info.indexOf("JCheck") >= 0) component.selected = element.checked; var id = $("div.JDialog:has(#" + element.id + ")")[0].id var dialog = Jmol.Swing.htDialogs[id]; dialog.manager.actionPerformed(component ? component.name : dialog.registryKey + "/" + element.id);- Parameters:
element-event-
-
dispose
void dispose(Component dialog)
Remove this component's HTML5 equivalent and clear references to it.- Parameters:
dialog-
-
getScreenDimensions
void getScreenDimensions(Dimension d)
Return the width and height of the window in d. For example: d.width = $(window).width(); d.height = $(window).height();- Parameters:
d-
-
register
void register(Component c, java.lang.String type)
Set c's id to a unique identifier and add it to an associative array that will associate that id with c.- Parameters:
c-type-
-
setDialog
void setDialog(Component dialog)
The HTML for this dialog has been generated. Now create the HTML on the page for this dialog based on dialog.html and wrap it appropriately.- Parameters:
dialog-
-
setSelected
void setSelected(Component chk)
Convey to the HTML object that this check box's selection has been changed. $("#" + chk.id).prop('checked', !!chk.selected);- Parameters:
chk-
-
setSelectedIndex
void setSelectedIndex(Component cmb)
Convey to the HTML object that this combo box's selected item has been changed. $("#" + cmb.id).prop('selectedIndex', cmb.selectedIndex);- Parameters:
cmb-
-
setText
void setText(java.lang.String text)
Convey to the HTML object that this component's text has been changed. $("#" + btn.id).prop('value', btn.text);- Parameters:
text-
-
setVisible
void setVisible(Component c)
Convey to the HTML object that this component's text has been changed. if (c._visible) $("#" + c.id).show(); else $("#" + c.id).hide();- Parameters:
c-
-
windowClosing
void windowClosing(HTMLElement element)
Called by clicking the [x] in the corner of the dialog; send a notification back to the manager via processWindowClosing(key) var id = $("div.JDialog:has(#" + element.id + ")")[0].id var dialog = Jmol.Swing.htDialogs[id]; dialog.manager.processWindowClosing(dialog.registryKey);- Parameters:
element-
-
-