use of com.codename1.ui.validation.Constraint in project CodenameOne by codenameone.
the class GameCanvasImplementation method editString.
/**
* @inheritDoc
*/
public void editString(Component cmp, int maxSize, int constraint, String text, int keyCode) {
UIManager m = UIManager.getInstance();
CONFIRM_COMMAND = new Command(m.localize("ok", "OK"), Command.OK, 1);
CANCEL_COMMAND = new Command(m.localize("cancel", "Cancel"), Command.CANCEL, 2);
if (mid.getAppProperty("forceBackCommand") != null) {
canvas.addCommand(MIDP_BACK_COMMAND);
}
currentTextBox = new TextBox("", "", maxSize, TextArea.ANY);
currentTextBox.setCommandListener((CommandListener) canvas);
currentTextBox.addCommand(CONFIRM_COMMAND);
currentTextBox.addCommand(CANCEL_COMMAND);
currentTextComponent = cmp;
currentTextBox.setMaxSize(maxSize);
currentTextBox.setString(text);
currentTextBox.setConstraints(constraint);
display.setCurrent(currentTextBox);
((C) canvas).setDone(false);
Display.getInstance().invokeAndBlock(((C) canvas));
}
use of com.codename1.ui.validation.Constraint in project CodenameOne by codenameone.
the class GridBagLayoutInfo method addLayoutComponent.
public void addLayoutComponent(Object constraints, Component comp, Container c) {
GridBagConstraints cons;
if (constraints != null) {
if (!(constraints instanceof GridBagConstraints)) {
// $NON-NLS-1$
throw new IllegalArgumentException("AddLayoutComponent: constraint object must be GridBagConstraints");
}
cons = (GridBagConstraints) constraints;
} else {
if (comptable.containsKey(comp)) {
// don't replace constraints with default ones
return;
}
cons = defaultConstraints;
}
/*try {
//cons.verify();
} catch (IllegalArgumentException e) {
// awt.81=AddLayoutComponent: {0}
throw new IllegalArgumentException("AddLayoutComponent: " + e.getMessage()); //$NON-NLS-1$
}*/
GridBagConstraints consClone = (GridBagConstraints) cons.clone();
comptable.put(comp, consClone);
Container parent = comp.getParent();
updateParentInfo(parent, consClone);
}
use of com.codename1.ui.validation.Constraint in project CodenameOne by codenameone.
the class LayeredLayout method calcPreferredValues.
private void calcPreferredValues(Component cmp) {
if (tmpLaidOut.contains(cmp)) {
return;
}
tmpLaidOut.add(cmp);
LayeredLayoutConstraint constraint = (LayeredLayoutConstraint) getComponentConstraint(cmp);
if (constraint != null) {
constraint.fixDependencies(cmp.getParent());
for (LayeredLayoutConstraint.Inset inset : constraint.insets) {
if (inset.referenceComponent != null && inset.referenceComponent.getParent() == cmp.getParent()) {
calcPreferredValues(inset.referenceComponent);
}
inset.calcPreferredValue(cmp.getParent(), cmp);
}
}
}
use of com.codename1.ui.validation.Constraint in project CodenameOne by codenameone.
the class MigLayout method setComponentConstraintsImpl.
/**
* Sets the component constraint for the component that already must be
* handled by this layout manager.
* <p>
* See the class JavaDocs for information on how this string is formatted.
*
* @param constr The component constraints as a String or
* {@link net.miginfocom.layout.CC}. <code>null</code> is ok.
* @param comp The component to set the constraints for.
* @param noCheck Doe not check if the component is handled if true
* @throws RuntimeException if the constraint was not valid.
* @throws IllegalArgumentException If the component is not handling the
* component.
*/
private void setComponentConstraintsImpl(Component comp, Object constr, boolean noCheck) {
Container parent = comp.getParent();
if (noCheck == false && scrConstrMap.containsKey(comp) == false) {
throw new IllegalArgumentException("Component must already be added to parent!");
}
ComponentWrapper cw = new CodenameOneMiGComponentWrapper(comp);
if (constr == null || constr instanceof String) {
String cStr = ConstraintParser.prepare((String) constr);
scrConstrMap.put(comp, constr);
ccMap.put(cw, ConstraintParser.parseComponentConstraint(cStr));
} else if (constr instanceof CC) {
scrConstrMap.put(comp, constr);
ccMap.put(cw, (CC) constr);
} else {
throw new IllegalArgumentException("Constraint must be String or ComponentConstraint: " + constr.getClass().toString());
}
dirty = true;
}
use of com.codename1.ui.validation.Constraint in project CodenameOne by codenameone.
the class CodenameOneView method setInputType.
public void setInputType(EditorInfo editorInfo) {
/**
* do not use the enter key to fire some kind of action!
*/
// editorInfo.imeOptions |= EditorInfo.IME_ACTION_NONE;
Component txtCmp = Display.getInstance().getCurrent().getFocused();
if (txtCmp != null && txtCmp instanceof TextArea) {
TextArea txt = (TextArea) txtCmp;
if (txt.isSingleLineTextArea()) {
editorInfo.imeOptions |= EditorInfo.IME_ACTION_DONE;
} else {
editorInfo.imeOptions |= EditorInfo.IME_ACTION_NONE;
}
int inputType = 0;
int constraint = txt.getConstraint();
if ((constraint & TextArea.PASSWORD) == TextArea.PASSWORD) {
constraint = constraint ^ TextArea.PASSWORD;
}
switch(constraint) {
case TextArea.NUMERIC:
inputType = EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_SIGNED;
break;
case TextArea.DECIMAL:
inputType = EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL;
break;
case TextArea.PHONENUMBER:
inputType = EditorInfo.TYPE_CLASS_PHONE;
break;
case TextArea.EMAILADDR:
inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
break;
case TextArea.URL:
inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_URI;
break;
default:
inputType = EditorInfo.TYPE_CLASS_TEXT;
break;
}
editorInfo.inputType = inputType;
}
}
Aggregations