use of com.codename1.ui.table.Table in project CodeRAD by shannah.
the class DefaultTableCellRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(Table table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Label out = new Label();
String strVal = value == null ? "" : String.valueOf(value);
out.setText(strVal);
if (isSelected) {
$(out).setBgColor(0xff0000).setBgTransparency(0xff);
}
$(out).setMargin(0);
return out;
}
use of com.codename1.ui.table.Table in project CodeRAD by shannah.
the class DefaultTableCellRenderer method createCellConstraint.
public TableLayout.Constraint createCellConstraint(Table table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
TableLayout tl = (TableLayout) table.getLayout();
TableLayout.Constraint cnst = tl.createConstraint(row, column);
return cnst;
}
use of com.codename1.ui.table.Table in project CodeRAD by shannah.
the class Table method editCellAt.
public void editCellAt(int row, int column) {
if (!editable) {
throw new IllegalStateException("Cannot edit cell because table is not editable.");
}
if (row < 0 || row >= model.getRowCount()) {
throw new IndexOutOfBoundsException("Attempt to edit cell in row " + row + " but row does not exist.");
}
if (column < 0 || column >= model.getColumnCount()) {
throw new IndexOutOfBoundsException("Attempt to edit cell in column " + column + " but column does not exist.");
}
if (editingRow == row && editingColumn == column) {
if (!editorComp.isEditing()) {
editorComp.startEditingAsync();
}
return;
}
if (isEditing()) {
editorComp.stopEditing(() -> {
int updateColumn = editingColumn;
int updateRow = editingRow;
editingColumn = -1;
editingRow = -1;
editorComp = null;
update(updateRow, updateRow, updateColumn);
editCellAt(row, column);
});
return;
}
editorComp = editor.getTableCellEditorComponent(this, model.getValueAt(row, column), selection.isSelected(row, column), row, column);
editingRow = row;
editingColumn = column;
TableLayout tl = (TableLayout) getLayout();
Component existing = tl.getComponentAt(row, column);
editorComp.setPreferredH(existing.getHeight());
editorComp.setPreferredW(existing.getWidth());
this.replace(existing, editorComp, null);
revalidateLater();
Tuple nextPos = findNextEditableCell(row, column);
if (nextPos != null) {
editorComp.setNextFocusRight(new FocusTarget(nextPos.row, nextPos.column));
}
Tuple prevPos = findPrevEditableCell(row, column);
if (prevPos != null) {
editorComp.setNextFocusLeft(new FocusTarget(prevPos.row, prevPos.column));
}
editorComp.startEditingAsync();
}
use of com.codename1.ui.table.Table in project CodeRAD by shannah.
the class EntityListTableCellEditor method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(Table table, Object value, boolean isSelected, int row, int column) {
EntityListTableModel model = (EntityListTableModel) table.getModel();
FieldNode field = model.getColumnField(column);
Entity entity = model.getEntity(row);
if (entity == null) {
if (parent != null) {
return parent.getTableCellEditorComponent(table, value, isSelected, row, column);
} else {
return new com.codename1.ui.Label();
}
}
return viewFactory.createPropertyView(entity, field);
}
use of com.codename1.ui.table.Table in project CodenameOne by codenameone.
the class PreviewInSimulator method main.
/**
* Called back from simulateDeviceActionPerformed to show the simulator skin
*/
public static void main(String[] argv) {
com.codename1.ui.Display.init(new Runnable() {
public void run() {
try {
Preferences pref = Preferences.userNodeForPackage(PreviewInSimulator.class);
String theme = pref.get("previewTheme", null);
File resFile = new File(pref.get("previewResource", null));
String baseResDir = pref.get("baseResourceDir", null);
if (baseResDir != null) {
JavaSEPort.setBaseResourceDir(new File(baseResDir));
}
String selection = pref.get("previewSelection", null);
Resources res = Resources.open(new FileInputStream(resFile));
if (theme == null || theme.length() == 0) {
if (com.codename1.ui.Display.getInstance().hasNativeTheme()) {
com.codename1.ui.Display.getInstance().installNativeTheme();
}
} else {
com.codename1.ui.plaf.UIManager.getInstance().setThemeProps(res.getTheme(theme));
}
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);
com.codename1.ui.util.UIBuilder builder = new com.codename1.ui.util.UIBuilder();
com.codename1.ui.Container c = builder.createContainer(res, selection);
if (c instanceof com.codename1.ui.Form) {
((com.codename1.ui.Form) c).refreshTheme();
if (c instanceof com.codename1.ui.Dialog) {
((com.codename1.ui.Dialog) c).showModeless();
} else {
((com.codename1.ui.Form) c).show();
}
} else {
com.codename1.ui.Form f = new com.codename1.ui.Form();
f.setLayout(new com.codename1.ui.layouts.BorderLayout());
f.addComponent(com.codename1.ui.layouts.BorderLayout.CENTER, c);
f.refreshTheme();
f.show();
}
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Error While Running In Simulator: " + ex, "Error", JOptionPane.ERROR_MESSAGE);
}
}
});
}
Aggregations