java.util.Vector groupKids = new java.util.Vector();
java.util.Vector cameraLight = new java.util.Vector();
java.util.Vector otherGroups = new java.util.Vector();
if( criterion.accept( root ) ) {
if( root.equals( currentValue ) ) {
structure.addElement( new StringObjectPair( "the entire " + (String)root.name.getValue(), new PopupItemWithIcon( factory.createItem( root ), currentValueIcon ) ) );
} else {
structure.addElement( new StringObjectPair( "the entire " + (String)root.name.getValue(), factory.createItem( root ) ) );
}
java.util.Vector openingSceneStructure = new java.util.Vector(); //CLK
if( root.getChildCount() > 0 ) {
Element [] children = root.getChildren();
for( int i = 0; i < children.length; i++ ) {
final Element child = children[i];
// add non-group kids to a new vector so they can be added later
if (criterion.accept( child )) {
if( child.equals( currentValue ) ) {
openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), new PopupItemWithIcon( factory.createItem( child ), currentValueIcon ) ) );
} else {
if ((child instanceof edu.cmu.cs.stage3.alice.core.Camera) || (child instanceof DirectionalLight)) {
cameraLight.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
} else {
openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
}
}
} else {
if( (child.search( criterion ).length > 0) || criterion.accept( child ) ) {
// if it's the current scene group its kids need to go in the main pop-up
if (child.equals(currentGroup)) {
groupKids = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
/*groupKids.add(0, structure.remove(0));
groupKids.addAll(structure);
structure = groupKids;*/
} else {
// otherwise just add it as a normal group
delayedBindingPopupItem = new DelayedBindingPopupItem() {
public Object createItem() {
java.util.Vector subStructure = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
if( (subStructure.size() == 1) && criterion.accept( child ) ) {
if( child.equals( currentValue ) ) {
return new PopupItemWithIcon( factory.createItem( child ), currentValueIcon );
} else {
return factory.createItem( child );
}
} else {
return subStructure;
}
}
};
otherGroups.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
}
}
}
}
// combine the group data with the normal structure.
groupKids.add(0, structure.remove(0));
groupKids.addAll(structure);
structure = groupKids;
structure.addAll(cameraLight);
// finally tack on the opening scene objects as a fake group
if( structure.size() > 1 ) {
structure.insertElementAt( new StringObjectPair( "Separator", javax.swing.JSeparator.class ),1 );
}
if( openingSceneStructure.size() >= 1 ) {
structure.addElement( new StringObjectPair( "Separator", javax.swing.JSeparator.class ) );
}
structure.addElement(new StringObjectPair("Opening Scene", openingSceneStructure));
structure.addAll(otherGroups);
}
} else {
//if we're in the main scene do the normal thing
if (currentGroup == null) return makeElementStructure(root, criterion, factory, context, currentValue);
else {
Element[] children = root.getChildren();
java.util.Vector openingSceneStructure = new java.util.Vector(); //CLK
for( int i = 0; i < children.length; i++ ) {
final Element child = children[i];
// add non-group kids to a new vector so they can be added later
if( child.getChildCount() == 0 ) {
if( criterion.accept( child ) ) {
if( child.equals( currentValue ) ) {
openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), new PopupItemWithIcon( factory.createItem( child ), currentValueIcon ) ) );
} else {
if ((child instanceof edu.cmu.cs.stage3.alice.core.Camera) || (child instanceof DirectionalLight)) {
cameraLight.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
} else {
openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
}
}
}
} else {
if (child.equals(currentGroup)) {
groupKids = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
} else if( (child.search( criterion ).length > 0) || criterion.accept( child ) ) {
delayedBindingPopupItem = new DelayedBindingPopupItem() {
public Object createItem() {
java.util.Vector subStructure = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
if( (subStructure.size() == 1) && criterion.accept( child ) ) {
if( child.equals( currentValue ) ) {
return new PopupItemWithIcon( factory.createItem( child ), currentValueIcon );
} else {
return factory.createItem( child );
}
} else {
return subStructure;
}
}
};
//structure.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
if (child instanceof edu.cmu.cs.stage3.alice.core.Group) {
otherGroups.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
} else {
openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
}
}
}
}
// finally tack on the opening scene objects as a fake group
if (currentGroup == null) {
openingSceneStructure.addAll(structure);
structure = openingSceneStructure;
structure.addAll(cameraLight);
if( otherGroups.size() >= 1 ) {
structure.addElement( new StringObjectPair( "Separator", javax.swing.JSeparator.class ) );
}
structure.addAll(otherGroups);
} else {
groupKids.addAll(structure);
structure = groupKids;
structure.addAll(cameraLight);
if (( openingSceneStructure.size() >= 1 ) || (otherGroups.size() >= 1)){
structure.addElement( new StringObjectPair( "Separator", javax.swing.JSeparator.class ) );
}
structure.addElement(new StringObjectPair("Opening Scene", openingSceneStructure));
structure.addAll(otherGroups);
}
}
}