Search in sources :

Example 1 with Controller

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);
}
Also used : FillSlotEvent(com.codename1.rad.events.FillSlotEvent)

Example 2 with Controller

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;
    }
}
Also used : Form(com.codename1.ui.Form)

Example 3 with Controller

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();
            });
        }
    }
}
Also used : Form(com.codename1.ui.Form) Command(com.codename1.ui.Command) ActionEvent(com.codename1.ui.events.ActionEvent) Toolbar(com.codename1.ui.Toolbar)

Example 4 with Controller

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);
        }
    }
}
Also used : Component(com.codename1.ui.Component)

Example 5 with Controller

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;
}
Also used : ActionNode(com.codename1.rad.nodes.ActionNode) ViewNode(com.codename1.rad.nodes.ViewNode)

Aggregations

Form (com.codename1.ui.Form)6 ActionNode (com.codename1.rad.nodes.ActionNode)5 Entity (com.codename1.rad.models.Entity)4 ViewNode (com.codename1.rad.nodes.ViewNode)3 Component (com.codename1.ui.Component)3 Toolbar (com.codename1.ui.Toolbar)3 IOException (java.io.IOException)3 Log (com.codename1.io.Log)2 NetworkEvent (com.codename1.io.NetworkEvent)2 ViewController (com.codename1.rad.controllers.ViewController)2 EntityList (com.codename1.rad.models.EntityList)2 EntityTypeBuilder.entityTypeBuilder (com.codename1.rad.models.EntityTypeBuilder.entityTypeBuilder)2 ListNode (com.codename1.rad.nodes.ListNode)2 Thing (com.codename1.rad.schemas.Thing)2 UI (com.codename1.rad.ui.UI)2 ProfileListView (com.codename1.rad.ui.entityviews.ProfileListView)2 CN (com.codename1.ui.CN)2 Dialog (com.codename1.ui.Dialog)2 Display (com.codename1.ui.Display)2 FontImage (com.codename1.ui.FontImage)2