use of com.codename1.ui.table.Table in project CodenameOne by codenameone.
the class NativeControlsSample method webviewLoginTest.
public void webviewLoginTest() {
Form f = new Form("Test Webview Login", new BorderLayout());
String html = "<!doctype html>" + "<html><body><table><tr><td>Username:</td><td><input type='text' autocomplete='username'/></td></tr><tr><td>Password</td>" + "<td><input type='password' autocomplete='current-password'/></td></tr></body></html>";
BrowserComponent c = new BrowserComponent();
c.setPage(html, "https://weblite.ca/");
f.add(BorderLayout.CENTER, c);
f.show();
}
use of com.codename1.ui.table.Table in project CodenameOne by codenameone.
the class SQLMap method createTable.
/**
* Creates a table matching the given property component if one doesn't exist yet
* @param cmp the business object
* @return true if the table was created false if it already existed
*/
public boolean createTable(PropertyBusinessObject cmp) throws IOException {
String tableName = getTableName(cmp);
Cursor cr = null;
boolean has = false;
try {
cr = executeQuery("SELECT * FROM sqlite_master WHERE type='table' AND name='" + tableName + "'");
has = cr.next();
} finally {
if (cr != null) {
cr.close();
}
}
if (has) {
return false;
}
StringBuilder createStatement = new StringBuilder("CREATE TABLE ");
createStatement.append(tableName);
createStatement.append(" (");
String pkName = (String) cmp.getPropertyIndex().getMetaDataOfClass("cn1$pk");
boolean autoIncrement = cmp.getPropertyIndex().getMetaDataOfClass("cn1$autoinc") != null;
boolean first = true;
for (PropertyBase p : cmp.getPropertyIndex()) {
SqlType tp = getSqlType(p);
if (tp == SqlType.SQL_EXCLUDE) {
continue;
}
if (!first) {
createStatement.append(",");
}
first = false;
String columnName = getColumnName(p);
createStatement.append(columnName);
createStatement.append(" ");
createStatement.append(tp.dbType);
if (columnName.equalsIgnoreCase(pkName)) {
createStatement.append(" PRIMARY KEY");
if (autoIncrement) {
createStatement.append(" AUTOINCREMENT");
}
}
}
createStatement.append(")");
execute(createStatement.toString());
return true;
}
use of com.codename1.ui.table.Table in project CodenameOne by codenameone.
the class ThemeEditor method initMIDlet.
private void initMIDlet() {
JavaSEPortWithSVGSupport.setShowEDTWarnings(false);
JavaSEPortWithSVGSupport.setShowEDTViolationStacks(false);
// its a UI form
if (uiPreviewContent.getSelectedIndex() == uiPreviewContent.getModel().getSize() - 1) {
previewPanel.removeAll();
if (com.codename1.ui.Display.isInitialized()) {
com.codename1.ui.Display.deinitialize();
}
JavaSEPortWithSVGSupport.setDefaultInitTarget(previewPanel);
com.codename1.ui.Display.init(previewPanel);
previewPanel.getComponent(0).setBounds(0, 0, get(widthResoltution), get(heightResolution));
previewPanel.getComponent(0).setPreferredSize(new java.awt.Dimension(get(widthResoltution), get(heightResolution)));
PickMIDlet.startMIDlet(themeHash);
} else {
Preferences.userNodeForPackage(getClass()).put("uiPreviewContent", (String) uiPreviewContent.getSelectedItem());
Accessor.setTheme(themeHash);
if (com.codename1.ui.Display.isInitialized()) {
com.codename1.ui.Display.deinitialize();
}
previewPanel.removeAll();
com.codename1.ui.Display.init(previewPanel);
previewPanel.getComponent(0).setBounds(0, 0, get(widthResoltution), get(heightResolution));
previewPanel.getComponent(0).setPreferredSize(new java.awt.Dimension(get(widthResoltution), get(heightResolution)));
com.codename1.ui.util.UIBuilder.registerCustomComponent("Table", com.codename1.ui.table.Table.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MediaPlayer", com.codename1.components.MediaPlayer.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ContainerList", com.codename1.ui.list.ContainerList.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ComponentGroup", com.codename1.ui.ComponentGroup.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Tree", com.codename1.ui.tree.Tree.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("HTMLComponent", com.codename1.ui.html.HTMLComponent.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("RSSReader", com.codename1.components.RSSReader.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("FileTree", com.codename1.components.FileTree.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("WebBrowser", com.codename1.components.WebBrowser.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("NumericSpinner", com.codename1.ui.spinner.NumericSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("DateSpinner", com.codename1.ui.spinner.DateSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("TimeSpinner", com.codename1.ui.spinner.TimeSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("DateTimeSpinner", com.codename1.ui.spinner.DateTimeSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("GenericSpinner", com.codename1.ui.spinner.GenericSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("LikeButton", com.codename1.facebook.ui.LikeButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("InfiniteProgress", com.codename1.components.InfiniteProgress.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MultiButton", com.codename1.components.MultiButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("SpanButton", com.codename1.components.SpanButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("SpanLabel", com.codename1.components.SpanLabel.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Ads", com.codename1.components.Ads.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MapComponent", com.codename1.maps.MapComponent.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MultiList", com.codename1.ui.list.MultiList.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ShareButton", com.codename1.components.ShareButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("OnOffSwitch", com.codename1.components.OnOffSwitch.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ImageViewer", com.codename1.components.ImageViewer.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("AutoCompleteTextField", com.codename1.ui.AutoCompleteTextField.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Picker", com.codename1.ui.spinner.Picker.class);
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
com.codename1.ui.util.UIBuilder builder = new com.codename1.ui.util.UIBuilder();
final com.codename1.ui.Container c = builder.createContainer(resources, (String) uiPreviewContent.getSelectedItem());
if (c instanceof com.codename1.ui.Form) {
if (c instanceof com.codename1.ui.Dialog) {
com.codename1.ui.animations.Transition t = ((com.codename1.ui.Dialog) c).getTransitionInAnimator();
((com.codename1.ui.Dialog) c).setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
((com.codename1.ui.Dialog) c).showModeless();
((com.codename1.ui.Dialog) c).setTransitionInAnimator(t);
} else {
com.codename1.ui.animations.Transition t = ((com.codename1.ui.Form) c).getTransitionInAnimator();
((com.codename1.ui.Form) c).setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
((com.codename1.ui.Form) c).show();
((com.codename1.ui.Form) c).setTransitionInAnimator(t);
}
} else {
com.codename1.ui.Form f = new Form();
f.setTransitionInAnimator(com.codename1.ui.animations.CommonTransitions.createEmpty());
f.setLayout(new com.codename1.ui.layouts.BorderLayout());
f.addComponent(com.codename1.ui.layouts.BorderLayout.CENTER, c);
f.show();
}
}
});
}
}
use of com.codename1.ui.table.Table in project CodenameOne by codenameone.
the class UserInterfaceEditor method appendComponentXMLBody.
private static void appendComponentXMLBody(com.codename1.ui.Container containerInstance, com.codename1.ui.Component cmp, StringBuilder build, EditableResources res, String indent) {
if (isPropertyModified(cmp, PROPERTY_LAYOUT_CONSTRAINT) || (cmp.getParent() != null && cmp.getParent().getLayout() instanceof com.codename1.ui.layouts.BorderLayout)) {
if (cmp.getParent() != null && cmp != containerInstance && cmp.getClientProperty("%base_form%") == null) {
com.codename1.ui.layouts.Layout l = cmp.getParent().getLayout();
if (l instanceof com.codename1.ui.layouts.BorderLayout) {
build.append(indent);
build.append("<layoutConstraint value=\"");
build.append((String) l.getComponentConstraint(cmp));
build.append("\" />\n");
} else {
if (l instanceof com.codename1.ui.table.TableLayout) {
build.append(indent);
com.codename1.ui.table.TableLayout.Constraint con = (com.codename1.ui.table.TableLayout.Constraint) l.getComponentConstraint(cmp);
build.append("<layoutConstraint row=\"");
build.append(getInt("row", con.getClass(), con));
build.append("\" column=\"");
build.append(getInt("column", con.getClass(), con));
build.append("\" height=\"");
build.append(getInt("height", con.getClass(), con));
build.append("\" width=\"");
build.append(getInt("width", con.getClass(), con));
build.append("\" align=\"");
build.append(getInt("align", con.getClass(), con));
build.append("\" spanHorizontal=\"");
build.append(getInt("spanHorizontal", con.getClass(), con));
build.append("\" valign=\"");
build.append(getInt("valign", con.getClass(), con));
build.append("\" spanVertical=\"");
build.append(getInt("spanVertical", con.getClass(), con));
build.append("\" />\n");
}
}
}
}
// don't persist children of subclasses like Table etc.
if (cmp.getClass() == com.codename1.ui.Container.class || cmp instanceof com.codename1.ui.Form || cmp instanceof com.codename1.ui.ComponentGroup) {
com.codename1.ui.Container cnt = (com.codename1.ui.Container) cmp;
if (cnt instanceof com.codename1.ui.Form) {
cnt = ((com.codename1.ui.Form) cnt).getContentPane();
}
for (int iter = 0; iter < cnt.getComponentCount(); iter++) {
persistToXML(containerInstance, cnt.getComponentAt(iter), build, res, indent);
}
}
if (cmp instanceof com.codename1.ui.List && !(cmp instanceof com.codename1.components.RSSReader)) {
com.codename1.ui.List lst = (com.codename1.ui.List) cmp;
for (int iter = 0; iter < lst.getModel().getSize(); iter++) {
Object o = lst.getModel().getItemAt(iter);
appendMapOrString(o, build, indent, res);
}
}
if (isPropertyModified(cmp, PROPERTY_CUSTOM)) {
for (String propName : cmp.getPropertyNames()) {
if (isCustomPropertyModified(cmp, propName) && !propName.startsWith("$")) {
build.append(indent);
build.append("<custom name=\"");
build.append(propName);
Class type = getPropertyCustomType(cmp, propName);
Object value = cmp.getPropertyValue(propName);
if (value == null) {
build.append("\" />\n");
continue;
}
if (type.isArray()) {
// 2d array
if (type.getComponentType().isArray()) {
build.append("\" type=\"");
build.append(type.getComponentType().getComponentType().getName());
build.append("\" array=\"true\" dimensions=\"2");
} else {
build.append("\" type=\"");
build.append(type.getComponentType().getName());
build.append("\" array=\"true\" dimensions=\"1");
}
} else {
build.append("\" type=\"");
build.append(type.getName());
}
build.append("\" ");
if (type == String.class) {
build.append("value=\"");
build.append(xmlize((String) value));
build.append("\" />\n");
continue;
}
if (type == String[].class) {
build.append(">\n");
String[] result = (String[]) value;
for (int i = 0; i < result.length; i++) {
build.append(indent);
build.append(" ");
build.append("<str>");
build.append(xmlize(result[i]));
build.append("</str>\n");
}
build.append(indent);
build.append("</custom>\n");
continue;
}
if (type == String[][].class) {
String[][] result = (String[][]) value;
build.append(">\n");
for (int i = 0; i < result.length; i++) {
build.append(indent);
build.append(" ");
build.append("<arr>");
for (int j = 0; j < result[i].length; j++) {
build.append(indent);
build.append(" ");
build.append("<str>");
build.append(xmlize(result[i][j]));
build.append("</str>\n");
}
build.append(indent);
build.append(" ");
build.append("</arr>\n");
}
build.append(indent);
build.append("</custom>\n");
continue;
}
if (type == Integer.class) {
build.append("value=\"");
build.append(((Number) value).intValue());
build.append("\" />\n");
continue;
}
if (type == Long.class) {
build.append("value=\"");
build.append(((Number) value).longValue());
build.append("\" />\n");
continue;
}
if (type == Double.class) {
build.append("value=\"");
build.append(((Number) value).doubleValue());
build.append("\" />\n");
continue;
}
if (type == Date.class) {
build.append("value=\"");
build.append(((Date) value).getTime());
build.append("\" />\n");
continue;
}
if (type == Float.class) {
build.append("value=\"");
build.append(((Number) value).floatValue());
build.append("\" />\n");
continue;
}
if (type == Byte.class) {
build.append("value=\"");
build.append(((Number) value).byteValue());
build.append("\" />\n");
continue;
}
if (type == Boolean.class) {
build.append("value=\"");
build.append(((Boolean) value).booleanValue());
build.append("\" />\n");
continue;
}
if (type == com.codename1.ui.Image[].class) {
com.codename1.ui.Image[] result = (com.codename1.ui.Image[]) value;
build.append(">\n");
for (int i = 0; i < result.length; i++) {
build.append(indent);
build.append(" ");
if (result[i] == null) {
build.append("<str/>\n");
} else {
String id = res.findId(result[i]);
if (id == null) {
build.append("<str/>\n");
} else {
build.append("<str>");
build.append(xmlize(id));
build.append("</str>\n");
}
}
}
build.append(indent);
build.append("</custom>\n");
continue;
}
if (type == com.codename1.ui.Image.class) {
com.codename1.ui.Image result = (com.codename1.ui.Image) value;
String id = res.findId(result);
if (id != null) {
build.append("value=\"");
build.append(xmlize(id));
}
build.append("\" />\n");
continue;
}
if (type == com.codename1.ui.Container.class) {
build.append("value=\"");
build.append(xmlize(((com.codename1.ui.Container) value).getName()));
build.append("\" />\n");
continue;
}
if (type == com.codename1.ui.list.CellRenderer.class) {
com.codename1.ui.list.GenericListCellRenderer g = (com.codename1.ui.list.GenericListCellRenderer) value;
if (g.getSelectedEven() == null) {
build.append(" selectedRenderer=\"");
build.append(xmlize(g.getSelected().getName()));
build.append("\" unselectedRenderer=\"");
build.append(xmlize(g.getUnselected().getName()));
build.append("\" ");
} else {
build.append(" selectedRenderer=\"");
build.append(xmlize(g.getSelected().getName()));
build.append("\" unselectedRenderer=\"");
build.append(xmlize(g.getUnselected().getName()));
build.append(" selectedRendererEven=\"");
build.append(xmlize(g.getSelectedEven().getName()));
build.append("\" unselectedRendererEven=\"");
build.append(xmlize(g.getUnselectedEven().getName()));
build.append("\" ");
}
build.append("\" />\n");
continue;
}
if (type == Object[].class) {
build.append(">\n");
Object[] arr = (Object[]) value;
for (int iter = 0; iter < arr.length; iter++) {
Object o = arr[iter];
appendMapOrString(o, build, indent, res);
}
build.append(indent);
build.append("</custom>\n");
continue;
}
// none of the above then its a char
build.append("value=\"");
build.append(xmlize("" + ((Character) value).charValue()));
build.append("\" />\n");
}
}
}
}
use of com.codename1.ui.table.Table in project CodenameOne by codenameone.
the class CodenameOneImplementation method hideTextEditor.
/**
* In case of scrolling we can hide the text editor unless the user starts typing again,
* this is only relevant for the async mode...
*/
public void hideTextEditor() {
Component c = editingText;
editingText = null;
// this might happen when the component is no longer a part of the form e.g. in the case of table editing.
if (c != null) {
c.repaint();
}
}
Aggregations