use of com.codename1.rad.controllers.Controller in project CodeRAD by shannah.
the class Slot method fill.
/**
* Fires a {@link FillSlotEvent} to give the controller hierarchy an opportunity
* to fill this slot. The Controller can implement {@link Controller#fillSlot} to
* receive and respond to such notifications.
*/
void fill() {
FillSlotEvent fse = new FillSlotEvent(this);
ActionSupport.dispatchEvent(fse);
}
use of com.codename1.rad.controllers.Controller in project CodeRAD by shannah.
the class FormController method tryCloneAndReplaceCurrentForm.
/**
* Tries to {@link #cloneAndReplace(FormController)} the current FormController
* @return True if it succeeds. False if it fails. It will fail either the current form doesn't have a form controller,
* or there is no current form.
*/
public static boolean tryCloneAndReplaceCurrentForm() {
Form currentForm = CN.getCurrentForm();
if (currentForm == null) {
return false;
}
ViewController bc = ViewController.getViewController(currentForm);
if (bc == null)
return false;
FormController fc = bc.getFormController();
if (fc == null)
return false;
try {
cloneAndReplace(fc);
return true;
} catch (Exception ex) {
return false;
}
}
use of com.codename1.rad.controllers.Controller in project CodeRAD by shannah.
the class FormController method setView.
/**
* Sets the form associated with this controller. This will automatically set
* the back command of the form to call back() on this controller.
* @param form
*/
public void setView(Form form) {
Form currView = getView();
if (currView != null) {
currView.removeShowListener(showListener());
}
super.setView(form);
if (form != null) {
form.addShowListener(showListener());
}
if (form != null && hasBackCommand()) {
form.setBackCommand(new Command("") {
@Override
public void actionPerformed(ActionEvent evt) {
back();
}
});
Toolbar tb = form.getToolbar();
if (tb != null) {
tb.addMaterialCommandToLeftBar("", FontImage.MATERIAL_ARROW_BACK_IOS, evt -> {
back();
});
}
}
}
use of com.codename1.rad.controllers.Controller in project CodeRAD by shannah.
the class ActionSupport method dispatchEvent.
/**
* Dispatches an event, first using the source's action support,
* if it implements EventProducer interface. If event not consumed,
* it will find the nearest ViewController and dispatch the event
* up the controller chain. Latter also requires that event is ControllerEvent
* @param evt
*/
public static void dispatchEvent(ActionEvent evt) {
if (evt.isConsumed()) {
return;
}
Object source = evt.getSource();
if (source instanceof EventProducer) {
EventProducer ep = (EventProducer) source;
ep.getActionSupport().fireActionEvent(evt);
}
if (evt.isConsumed()) {
return;
}
if (evt instanceof ControllerEvent) {
if (source instanceof Component) {
Component cmp = (Component) source;
ViewController controller = ViewController.getViewController(cmp);
if (controller != null) {
controller.dispatchEvent((ControllerEvent) evt);
}
} else if (source instanceof Controller) {
Controller ctrl = (Controller) source;
ctrl.dispatchEvent((ControllerEvent) evt);
}
}
}
use of com.codename1.rad.controllers.Controller in project CodeRAD by shannah.
the class Controller method createViewNode.
/**
* Creates the view node that should be used as the node for the controller's view. This method should
* be overridden by subclasses to define the default view node, but this method shouldn't be called directly. Rather
* the {@link #getViewNode()} method should be called so that the view node is only created once. {@link #getViewNode() }
* will also set the parent node to the view node of the parent controller to more easily benefit from inherited attributes
* in the UI descriptor hierarchy.
* @return A ViewNode
*/
protected ViewNode createViewNode() {
startControllerInternal();
ViewNode n = new ViewNode();
if (actionMap != null) {
for (ActionNode.Category c : actionMap.keySet()) {
n.setAttributes(UI.actions(c, actionMap.get(c)));
}
}
return n;
}
Aggregations