@Override public void addWidget(UIWidget element, CCHint hint) { final ComponentWrapper cw = getWrapper(element); final String cStr = ConstraintParser.prepare(hint != null ? hint.cc : ""); CC constraint = AccessController.doPrivileged((PrivilegedAction<CC>) () -> ConstraintParser.parseComponentConstraint(cStr)); ccMap.put(cw, constraint); wrappers.put(element, cw); children.add(cw); dirty = true; }
/** Parses all component constraints and stores the parsed values in the transient (cache) member variables. * @param constrMap The constraints as <code>String</code>s. Strings <b>must be lower case and trimmed</b> * @return The parsed constraints. Never <code>null</code>. */ public static Map<ComponentWrapper, CC> parseComponentConstraints(Map<ComponentWrapper, String> constrMap) { HashMap<ComponentWrapper, CC> flowConstrMap = new HashMap<ComponentWrapper, CC>(); for (Iterator<Map.Entry<ComponentWrapper, String>> it = constrMap.entrySet().iterator(); it.hasNext();) { Map.Entry<ComponentWrapper, String> entry = it.next(); flowConstrMap.put(entry.getKey(), parseComponentConstraint(entry.getValue())); } return flowConstrMap; }
public MigPane add(Node node, String sCc) { CC cc = ConstraintParser.parseComponentConstraint(ConstraintParser.prepare(sCc)); add(node, cc); return this; }
public MigPane add(int index, Node node, String sCc) { CC cc = ConstraintParser.parseComponentConstraint(ConstraintParser.prepare(sCc)); add(index, node, cc); return this; }
public static void setCc(Node node, String cc) { CC lCC = ConstraintParser.parseComponentConstraint( ConstraintParser.prepare( cc ) ); setCc(node, lCC); }
/** 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 Doesn't check if control already is managed. * @throws RuntimeException if the constraint was not valid. * @throws IllegalArgumentException If the component is not handling the component. */ private void setComponentConstraintsImpl(Control comp, Object constr, boolean noCheck) { if (noCheck == false && scrConstrMap.containsKey(comp) == false) throw new IllegalArgumentException("Component must already be added to parent!"); ComponentWrapper cw = new SwtComponentWrapper(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()); } grid = null; }
/** 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 Does 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(); synchronized(parent != null ? parent.getTreeLock() : new Object()) { // 3.7.2. No sync if not added to a hierarchy. Defeats a NPE. if (noCheck == false && scrConstrMap.containsKey(comp) == false) throw new IllegalArgumentException("Component must already be added to parent!"); ComponentWrapper cw = new SwingComponentWrapper(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; } }
/** Sets the constraints for the node * @param node The node. Must already be in the pane. * @param ccs The component constraints. Can be null. */ public void setComponentConstraints(Node node, String ccs) { FXComponentWrapper wrapper = new FXComponentWrapper(node); if (!wrapperToCCMap.containsKey(wrapper)) throw new IllegalArgumentException("Node not in pane: " + node); CC cc = ConstraintParser.parseComponentConstraint(ConstraintParser.prepare(ccs)); wrapperToCCMap.put(wrapper, cc); invalidateGrid(); requestLayout(); }