Java Code Examples for com.codename1.ui.Form#getName()
The following examples show how to use
com.codename1.ui.Form#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIBuilder.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * Returns the state of the current form which we are about to leave as part * of the navigation logic. When a back command will return to this form the * state would be restored using setFormState. * The default implementation of this method restores focus and list selection. * You can add arbitrary keys to the form state, keys starting with a $ sign * are reserved for the UIBuilder base class use. * * @param f the form whose state should be preserved * @return arbitrary state object */ protected Hashtable getFormState(Form f) { Component c = f.getFocused(); Hashtable h = new Hashtable(); // can happen if we navigate away from a form that was shown without the GUI builder if(f.getName() != null) { h.put(FORM_STATE_KEY_NAME, f.getName()); } if(c != null) { if(c instanceof List) { h.put(FORM_STATE_KEY_SELECTION, new Integer(((List)c).getSelectedIndex())); } if(c.getName() != null) { h.put(FORM_STATE_KEY_FOCUS, c.getName()); } if(f.getTitle() != null) { h.put(FORM_STATE_KEY_TITLE, f.getTitle()); } } storeComponentState(f, h); return h; }
Example 2
Source File: TestRecorder.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private void recordingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recordingActionPerformed if(isRecording()) { Form f = Display.getInstance().getCurrent(); if(f.getName() != null && f.getTitle().length() > 0) { generatedCode += " waitForFormName(\"" + f.getName() + "\");\n"; } else { if(f.getTitle() != null && f.getTitle().length() > 0) { generatedCode += " waitForFormTitle(\"" + f.getTitle() + "\");\n"; } } updateTestCode(); } }
Example 3
Source File: UIBuilder.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
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; }
Example 4
Source File: UIBuilder.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
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, sourceCommand); 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, sourceCommand); 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, sourceCommand); f.show(); postShowImpl(f); } } }