use of com.codename1.ui.Container in project CodenameOne by codenameone.
the class Tree method expandNodeImpl.
private Container expandNodeImpl(boolean animate, Component c, boolean revalidate) {
Container p = c.getParent().getLeadParent();
if (p != null) {
c = p;
}
c.putClientProperty(KEY_EXPANDED, "true");
if (openFolder == null) {
FontImage.setMaterialIcon(c, FontImage.MATERIAL_FOLDER, 3);
} else {
setNodeIcon(openFolder, c);
}
int depth = ((Integer) c.getClientProperty(KEY_DEPTH)).intValue();
Container parent = c.getParent();
Object o = c.getClientProperty(KEY_OBJECT);
Container dest = new Container(new BoxLayout(BoxLayout.Y_AXIS));
parent.addComponent(BorderLayout.CENTER, dest);
buildBranch(o, depth, dest);
if (isInitialized() && animate) {
// prevent a race condition on node expansion contraction
parent.animateHierarchyAndWait(300);
if (multilineMode) {
revalidate();
}
} else {
if (revalidate) {
parent.revalidate();
}
}
return dest;
}
use of com.codename1.ui.Container in project CodenameOne by codenameone.
the class Tree method buildBranch.
/**
* Adds the child components of a tree branch to the given container.
*/
private void buildBranch(Object parent, int depth, Container destination) {
Vector children = model.getChildren(parent);
int size = children.size();
Integer depthVal = new Integer(depth + 1);
for (int iter = 0; iter < size; iter++) {
final Object current = children.elementAt(iter);
Component nodeComponent = createNode(current, depth);
if (model.isLeaf(current)) {
destination.addComponent(nodeComponent);
bindNodeListener(new Handler(current), nodeComponent);
} else {
Container componentArea = new Container(new BorderLayout());
componentArea.addComponent(BorderLayout.NORTH, nodeComponent);
destination.addComponent(componentArea);
bindNodeListener(expansionListener, nodeComponent);
}
nodeComponent.putClientProperty(KEY_OBJECT, current);
nodeComponent.putClientProperty(KEY_PARENT, parent);
nodeComponent.putClientProperty(KEY_DEPTH, depthVal);
}
}
use of com.codename1.ui.Container in project CodenameOne by codenameone.
the class Tree method collapsePathNode.
private void collapsePathNode(Container parent, Object node) {
int cc = parent.getComponentCount();
for (int iter = 0; iter < cc; iter++) {
Component current = parent.getComponentAt(iter);
if (isExpanded(current)) {
BorderLayout bl = (BorderLayout) ((Container) current).getLayout();
// the tree component is always at north expanded or otherwise
current = bl.getNorth();
Object o = current.getClientProperty(KEY_OBJECT);
if (o != null && o.equals(node)) {
if (isExpanded(current)) {
collapseNode(current, null);
}
return;
}
}
}
}
use of com.codename1.ui.Container in project CodenameOne by codenameone.
the class Tree method collapseNode.
private void collapseNode(Component c, Transition t) {
Container lead = c.getParent().getLeadParent();
if (lead != null) {
c = lead;
}
c.putClientProperty(KEY_EXPANDED, null);
setNodeIcon(folder, c);
Container p = c.getParent();
for (int iter = 0; iter < p.getComponentCount(); iter++) {
if (p.getComponentAt(iter) != c) {
if (t == null) {
p.removeComponent(p.getComponentAt(iter));
// there should only be one container with all children
break;
} else {
Label dummy = new Label();
p.replaceAndWait(p.getComponentAt(iter), dummy, t, true);
p.removeComponent(dummy);
}
}
}
}
use of com.codename1.ui.Container 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;
}
Aggregations