use of com.codename1.ui.SideMenuBar in project CodenameOne by codenameone.
the class TestUtils method showSidemenu.
/**
* Shows the sidemenu UI
*/
public static void showSidemenu() {
Form f = Display.getInstance().getCurrent();
Toolbar tb = f.getToolbar();
if (tb != null) {
tb.openSideMenu();
} else {
((SideMenuBar) f.getMenuBar()).openMenu(null);
}
}
use of com.codename1.ui.SideMenuBar in project CodenameOne by codenameone.
the class SideMenuBar method closeCurrentMenu.
/**
* Folds the current side menu if it is open, when the menu is closed it
* will invoke the runnable callback method
*
* @param callback will be invoked when the menu is actually closed
*/
public static void closeCurrentMenu(final Runnable callback) {
if (Toolbar.isOnTopSideMenu() && (Toolbar.isGlobalToolbar() || Display.getInstance().getCommandBehavior() != Display.COMMAND_BEHAVIOR_SIDE_NAVIGATION)) {
Display.getInstance().getCurrent().getToolbar().closeSideMenu();
callback.run();
return;
}
Form f = Display.getInstance().getCurrent();
final SideMenuBar b = (SideMenuBar) f.getClientProperty("cn1$sideMenuParent");
if (b != null && !b.transitionRunning) {
b.parent.addShowListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
b.parent.removeShowListener(this);
callback.run();
}
});
b.closeMenu();
} else {
callback.run();
}
}
use of com.codename1.ui.SideMenuBar in project CodenameOne by codenameone.
the class LazyValueC method createForm.
Form createForm(Form f) {
Form currentForm = Display.getInstance().getCurrent();
if (currentForm != null && currentForm instanceof Dialog) {
((Dialog) Display.getInstance().getCurrent()).dispose();
currentForm = Display.getInstance().getCurrent();
}
Vector formNavigationStack = baseFormNavigationStack;
if (formNavigationStack != null && !(f instanceof Dialog) && !f.getName().equals(homeForm)) {
if (currentForm != null) {
String nextForm = (String) f.getClientProperty("%next_form%");
// we are in the sidemenu view we should really be using the parent form
SideMenuBar b = (SideMenuBar) currentForm.getClientProperty("cn1$sideMenuParent");
if (b != null) {
currentForm = b.getParentForm();
}
// don't add back commands to transitional forms
if (nextForm == null) {
String commandAction = currentForm.getName();
if (allowBackTo(commandAction) && f.getBackCommand() == null) {
Command backCommand;
if (isSameBackDestination(currentForm, f)) {
backCommand = currentForm.getBackCommand();
} else {
backCommand = createCommandImpl(getBackCommandText(currentForm.getTitle()), null, BACK_COMMAND_ID, commandAction, true, "");
backCommand.putClientProperty(COMMAND_ARGUMENTS, "");
backCommand.putClientProperty(COMMAND_ACTION, commandAction);
}
if (backCommand != null) {
setBackCommand(f, backCommand);
}
// trigger listener creation if this is the only command in the form
getFormListenerInstance(f, null);
formNavigationStack.addElement(getFormState(currentForm));
}
}
}
}
return f;
}
use of com.codename1.ui.SideMenuBar in project CodenameOne by codenameone.
the class LazyValueC method showForm.
private void showForm(Form f, Command sourceCommand, Component sourceComponent) {
Form currentForm = Display.getInstance().getCurrent();
if (currentForm != null && currentForm instanceof Dialog) {
((Dialog) Display.getInstance().getCurrent()).dispose();
currentForm = Display.getInstance().getCurrent();
}
Vector formNavigationStack = baseFormNavigationStack;
if (sourceCommand != null && currentForm != null && currentForm.getBackCommand() == sourceCommand) {
if (currentForm != null) {
exitForm(currentForm);
}
if (formNavigationStack != null && formNavigationStack.size() > 0) {
String name = f.getName();
if (name != null && name.equals(homeForm)) {
if (formNavigationStack.size() > 0) {
setFormState(f, (Hashtable) formNavigationStack.elementAt(formNavigationStack.size() - 1));
}
formNavigationStack.clear();
} else {
initBackForm(f);
}
}
onBackNavigation();
beforeShow(f);
f.showBack();
postShowImpl(f);
} else {
if (currentForm != null) {
exitForm(currentForm);
}
if (formNavigationStack != null && !(f instanceof Dialog) && !f.getName().equals(homeForm)) {
if (currentForm != null) {
String nextForm = (String) f.getClientProperty("%next_form%");
// we are in the sidemenu view we should really be using the parent form
SideMenuBar b = (SideMenuBar) currentForm.getClientProperty("cn1$sideMenuParent");
if (b != null) {
currentForm = b.getParentForm();
}
// don't add back commands to transitional forms
if (nextForm == null) {
String commandAction = currentForm.getName();
if (allowBackTo(commandAction) && f.getBackCommand() == null) {
Command backCommand;
if (isSameBackDestination(currentForm, f)) {
backCommand = currentForm.getBackCommand();
} else {
backCommand = createCommandImpl(getBackCommandText(currentForm.getTitle()), null, BACK_COMMAND_ID, commandAction, true, "");
backCommand.putClientProperty(COMMAND_ARGUMENTS, "");
backCommand.putClientProperty(COMMAND_ACTION, commandAction);
}
if (backCommand != null) {
setBackCommand(f, backCommand);
}
// trigger listener creation if this is the only command in the form
getFormListenerInstance(f, null);
formNavigationStack.addElement(getFormState(currentForm));
}
}
}
}
if (f instanceof Dialog) {
beforeShow(f);
if (sourceComponent != null) {
// we are cheating with the post show here since we are using a modal
// dialog to prevent the "double clicking button" problem by using
// a modal dialog
sourceComponent.setEnabled(false);
postShowImpl(f);
f.show();
sourceComponent.setEnabled(true);
exitForm(f);
} else {
((Dialog) f).showModeless();
postShowImpl(f);
}
} else {
beforeShow(f);
f.show();
postShowImpl(f);
}
}
}
Aggregations