use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.
the class GenericListCellRenderer method findComponentsOfInterest.
private void findComponentsOfInterest(Component cmp, ArrayList dest) {
if (cmp instanceof Container) {
Container c = (Container) cmp;
int count = c.getComponentCount();
for (int iter = 0; iter < count; iter++) {
findComponentsOfInterest(c.getComponentAt(iter), dest);
}
return;
}
// performance optimization for fixed images in lists
if (cmp.getName() != null) {
if (cmp instanceof Label) {
Label l = (Label) cmp;
if (l.getName().toLowerCase().endsWith("fixed") && l.getIcon() != null) {
l.getIcon().lock();
}
dest.add(cmp);
return;
}
if (cmp instanceof TextArea) {
dest.add(cmp);
return;
}
}
}
use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.
the class GenericListCellRenderer method setComponentValue.
/**
* Initializes the given component with the given value
*
* @param cmp one of the components that is or is a part of the renderer
* @param value the value to install into the component
*/
private void setComponentValue(Component cmp, Object value, Component parent, Component rootRenderer) {
// process so renderer selected/unselected styles are applied
if (cmp.getName().toLowerCase().endsWith("fixed")) {
return;
}
if (cmp instanceof Label) {
if (value instanceof Image) {
Image i = (Image) value;
if (i.isAnimation()) {
if (pendingAnimations == null) {
pendingAnimations = new ArrayList<Image>();
}
if (!pendingAnimations.contains(i)) {
pendingAnimations.add(i);
if (parentList == null) {
parentList = parent;
}
if (parentList != null) {
Form f = parentList.getComponentForm();
if (f != null) {
f.registerAnimated(mon);
waitingForRegisterAnimation = false;
} else {
waitingForRegisterAnimation = true;
}
}
} else {
if (waitingForRegisterAnimation) {
if (parentList != null) {
Form f = parentList.getComponentForm();
if (f != null) {
f.registerAnimated(mon);
waitingForRegisterAnimation = false;
}
}
}
}
}
Image oldImage = ((Label) cmp).getIcon();
((Label) cmp).setIcon(i);
((Label) cmp).setText("");
if (oldImage == null || oldImage.getWidth() != i.getWidth() || oldImage.getHeight() != i.getHeight()) {
((Container) rootRenderer).revalidate();
}
return;
} else {
((Label) cmp).setIcon(null);
}
if (cmp instanceof CheckBox) {
((CheckBox) cmp).setSelected(isSelectedValue(value));
return;
}
if (cmp instanceof RadioButton) {
((RadioButton) cmp).setSelected(isSelectedValue(value));
return;
}
if (cmp instanceof Slider) {
((Slider) cmp).setProgress(((Integer) value).intValue());
return;
}
Label l = (Label) cmp;
if (value == null) {
l.setText("");
} else {
if (value instanceof Label) {
l.setText(((Label) value).getText());
l.setIcon(((Label) value).getIcon());
} else {
l.setText(value.toString());
}
}
if (firstCharacterRTL) {
String t = l.getText();
if (t.length() > 0) {
l.setRTL(Display.getInstance().isRTL(t.charAt(0)));
}
}
return;
}
if (cmp instanceof TextArea) {
if (value == null) {
((TextArea) cmp).setText("");
} else {
((TextArea) cmp).setText(value.toString());
}
}
}
use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.
the class MigLayout method checkCache.
/**
* Check if something has changed and if so recreate it to the cached
* objects.
*
* @param parent The parent that is the target for this layout manager.
*/
private void checkCache(Container parent) {
if (parent == null) {
return;
}
if (dirty) {
grid = null;
}
cleanConstraintMaps(parent);
// Check if the grid is valid
int mc = PlatformDefaults.getModCount();
if (lastModCount != mc) {
grid = null;
lastModCount = mc;
}
// if (!parent.isValid()) {
if (!lastWasInvalid) {
lastWasInvalid = true;
int hash = 0;
// Added in 3.7.3 to resolve a timing regression introduced in 3.7.1
boolean resetLastInvalidOnParent = false;
for (ComponentWrapper wrapper : ccMap.keySet()) {
Object component = wrapper.getComponent();
if (component instanceof TextArea) {
resetLastInvalidOnParent = true;
}
hash ^= wrapper.getLayoutHashCode();
hash += 285134905;
}
if (resetLastInvalidOnParent) {
resetLastInvalidOnParent(parent);
}
if (hash != lastHash) {
grid = null;
lastHash = hash;
}
Dimension ps = new Dimension(parent.getWidth(), parent.getHeight());
if (lastInvalidSize == null || !lastInvalidSize.equals(ps)) {
grid = null;
lastInvalidSize = ps;
}
}
/*} else {
lastWasInvalid = false;
}*/
ContainerWrapper par = checkParent(parent);
setDebug(par, getDebugMillis() > 0);
if (grid == null) {
grid = new Grid(par, lc, rowSpecs, colSpecs, ccMap, callbackList);
}
dirty = false;
}
use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.
the class ListFilesTest method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", new BorderLayout());
Button add = new Button("Add Directory");
add.addActionListener(e -> {
callSerially(() -> {
Command ok = new Command("OK");
Command cancel = new Command("Cancel");
TextField fileName = new TextField("", "File Path", 20, TextField.NON_PREDICTIVE);
if (ok == Dialog.show("File Path", fileName, new Command[] { ok, cancel })) {
File f = new File(fileName.getText());
if (!f.mkdir()) {
ToastBar.showErrorMessage("Failed to create directory");
}
}
});
});
Button rename = new Button("Rename File");
rename.addActionListener(e -> {
callSerially(() -> {
Command ok = new Command("OK");
Command cancel = new Command("Cancel");
TextField fileName = new TextField("", "File Path", 20, TextField.NON_PREDICTIVE);
TextField newName = new TextField("", "New Name", 20, TextField.NON_PREDICTIVE);
if (ok == Dialog.show("File Path", BoxLayout.encloseY(fileName, newName), new Command[] { ok, cancel })) {
File f = new File(fileName.getText());
FileSystemStorage fs = FileSystemStorage.getInstance();
fs.rename(f.getPath(), newName.getText());
}
});
});
TextArea listing = new TextArea();
Button refresh = new Button("Refresh");
refresh.addActionListener(e -> {
File f = new File(FileSystemStorage.getInstance().getAppHomePath());
StringBuilder sb = new StringBuilder();
appendChildren(sb, f, 0);
listing.setText(sb.toString());
});
hi.add(BorderLayout.NORTH, FlowLayout.encloseCenter(add, rename)).add(BorderLayout.CENTER, listing).add(BorderLayout.SOUTH, refresh);
hi.show();
}
use of com.vaadin.v7.ui.TextArea in project CodenameOne by codenameone.
the class RSSReader method updateComponentValues.
void updateComponentValues(Container root, Hashtable h) {
int c = root.getComponentCount();
for (int iter = 0; iter < c; iter++) {
Component current = root.getComponentAt(iter);
// subclasses
if (current.getClass() == com.codename1.ui.Container.class || current.getClass() == com.codename1.ui.Tabs.class) {
updateComponentValues((Container) current, h);
continue;
}
String n = current.getName();
if (n != null) {
String val = (String) h.get(n);
if (val != null) {
if (current instanceof Button) {
final String url = (String) val;
((Button) current).addActionListener(new Listener(url));
continue;
}
if (current instanceof Label) {
((Label) current).setText(val);
continue;
}
if (current instanceof TextArea) {
((TextArea) current).setText(val);
continue;
}
if (current instanceof WebBrowser) {
((WebBrowser) current).setPage(val, null);
continue;
}
}
}
}
}
Aggregations