Examples of StringObjectPair


Examples of edu.cmu.cs.stage3.util.StringObjectPair

    protected java.util.Vector createPopupStructure() {
      java.util.Vector structure = createExpressionStructure();
      if( (structure != null) && isNullValid ) {
        if( structure.size() > 0 ) {
          structure.insertElementAt( new StringObjectPair( "Separator", javax.swing.JSeparator.class ), 0 );
        }
        //structure.insertElementAt( new StringObjectPair( "<None>", objectRunnableFactory.createRunnable( null ) ), 0 );
      }
      return structure;
    }
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

        structure.add( new edu.cmu.cs.stage3.util.StringObjectPair( "Expressions which evaluate to " + className, expressionStructure ) );
      }

      if( isNullValid ) {
        if( structure.size() > 0 ) {
          structure.insertElementAt( new StringObjectPair( "Separator", javax.swing.JSeparator.class ), 0 );
        }
        //structure.insertElementAt( new StringObjectPair( "<None>", objectRunnableFactory.createRunnable( null ) ), 0 );
      }

      return structure;
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

      Object o = enum1.nextElement();
      if( !(o instanceof StringObjectPair) ) {
        throw new IllegalArgumentException( "structure must be made only of StringObjectPairs, found: " + o );
      }

      StringObjectPair pair = (StringObjectPair)o;
      String name = pair.getString();

      //hack
      if( name != null ) {
        for( java.util.Iterator iter = specialStringMap.keySet().iterator(); iter.hasNext(); ) {
          String s = (String)iter.next();
          if( name.indexOf( s ) > -1 ) {
            StringBuffer sb = new StringBuffer( name );
            sb.replace( name.indexOf( s ), name.indexOf( s ) + s.length(), (String)specialStringMap.get( s ) );
            name = sb.toString();
          }
        }
      }

      Object content = pair.getObject();
      if( content instanceof DelayedBindingPopupItem ) {
        content = ((DelayedBindingPopupItem)content).createItem();
      }

      javax.swing.Icon icon = null;
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

    return item;
  }

  public static boolean isStringInStructure( String s, java.util.Vector structure ) {
    for( java.util.Enumeration enum1 = structure.elements(); enum1.hasMoreElements(); ) {
      StringObjectPair pair = (StringObjectPair)enum1.nextElement();
      String string = pair.getString();
      Object content = pair.getObject();
      if( string == s ) {
        return true;
      }
      else if( content instanceof java.util.Vector ) {
        if( isStringInStructure( s, (java.util.Vector)content ) ) {
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

    return false;
  }

  public static boolean isObjectInStructure( Object o, java.util.Vector structure ) {
    for( java.util.Enumeration enum1 = structure.elements(); enum1.hasMoreElements(); ) {
      StringObjectPair pair = (StringObjectPair)enum1.nextElement();
      Object content = pair.getObject();
      if( content == o ) {
        return true;
      }
      else if( content instanceof java.util.Vector ) {
        if( isObjectInStructure( o, (java.util.Vector)content ) ) {
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

      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);
           }
          
        }
      }
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

    java.util.Vector groups = new Vector();
    java.util.Vector otherModels = new Vector();
    //System.out.println("making structure: root: "+root+", context: "+context);
    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 ) ) );
      }
      if( root.getChildCount() > 0 ) {
        Element [] children = root.getChildren();
        for( int i = 0; i < children.length; i++ ) {
          final Element child = children[i];
          if( child.getChildCount() == 0 ) {
            if( criterion.accept( child ) ) {
              if( child.equals( currentValue ) ) {
                structure.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 {
                  otherModels.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
                }
              }
            }
          } else {
            if( (child.search( criterion ).length > 0) || criterion.accept( child ) ) {
              delayedBindingPopupItem = new DelayedBindingPopupItem() {
                public Object createItem() {
                  //edu.cmu.cs.stage3.alice.core.Group cGroup = edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool.getSceneManager().getCurrentGroup();
                  java.util.Vector subStructure = makeSceneElementStructure( child, criterion, factory, context, currentValue,currentGroup );
                  //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;
                  }
                }
              };
              if (child instanceof Group) {
                groups.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
              } else {
                otherModels.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
              }
            }
          }
        }

        if( structure.size() > 1 ) {
          structure.insertElementAt( new StringObjectPair( "Separator", javax.swing.JSeparator.class ), 1 );
        }
      }
    } else {
      Element[] children = root.getChildren();
      for( int i = 0; i < children.length; i++ ) {
        final Element child = children[i];
        if( child.getChildCount() == 0 ) {
          if( criterion.accept( child ) ) {
            if( child.equals( currentValue ) ) {
              structure.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 {
                otherModels.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
              }
             
            }
          }
        } 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;
                }
              }
            };
           
            if (child instanceof Group) {
              groups.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
            } else {
              otherModels.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
            }
          }
        }
      }
     
    }
   
    if (otherModels.size() > 0) {
      structure.addAll(otherModels);
    }
    if (cameraLight.size() > 0) {
      structure.addAll(cameraLight);
    }
    if (groups.size() > 0) {
      if( groups.size() >= 1 ) {
        structure.addElement( new StringObjectPair( "Separator", javax.swing.JSeparator.class ) );
      }
      structure.addAll(groups);
    }
   
    return structure;
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

      String text = edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getReprForValue( elements[i] );
      if( context != null ) {
        text = edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getNameInContext( elements[i], context );
      }
      if( elements[i].equals( currentValue ) ) {
        structure.addElement( new StringObjectPair( text, new PopupItemWithIcon( factory.createItem( elements[i] ), currentValueIcon ) ) );
      } else {
        structure.addElement( new StringObjectPair( text, factory.createItem( elements[i] ) ) );
      }
    }
   
    return structure;
  }
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

            text = edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getNameInContext( expressions[i], context );
          }
          if( expressions[i] instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.UserDefinedQuestion ) {
            edu.cmu.cs.stage3.alice.authoringtool.util.CallToUserDefinedQuestionPrototype prototype = new edu.cmu.cs.stage3.alice.authoringtool.util.CallToUserDefinedQuestionPrototype( (edu.cmu.cs.stage3.alice.core.question.userdefined.UserDefinedQuestion)expressions[i] );
            if( prototype.getDesiredProperties().length > 0 ) {
              structure.addElement( new StringObjectPair( text, makePrototypeStructure( prototype, factory, context ) ) );
            } else {
              structure.addElement( new StringObjectPair( text, factory.createItem( prototype.createNewElement() ) ) );
            }
          } else {
            if( expressions[i].equals( currentValue ) ) {
              structure.addElement( new StringObjectPair( text, new PopupItemWithIcon( factory.createItem( expressions[i] ), currentValueIcon ) ) );
            } else {
              structure.addElement( new StringObjectPair( text, factory.createItem( expressions[i] ) ) );
            }
          }
        }
      }
    }
View Full Code Here

Examples of edu.cmu.cs.stage3.util.StringObjectPair

                  if (collection instanceof edu.cmu.cs.stage3.alice.core.List){
                    //Item at beginning
                    question = new edu.cmu.cs.stage3.alice.core.question.visualization.list.ItemAtBeginning();
                    ((edu.cmu.cs.stage3.alice.core.question.visualization.list.ItemAtBeginning)question).subject.set( visualization );
                    java.util.Vector responseStructure = PopupMenuUtilities.makeResponseStructure( question, factory, context );
                    subStructure.add( new StringObjectPair( "item at the beginning", responseStructure ) );
                   
                    //Item at index
                    for( int i = 0; i < items.length; i++ ) {
                      question = new edu.cmu.cs.stage3.alice.core.question.visualization.list.ItemAtIndex();
                      ((edu.cmu.cs.stage3.alice.core.question.visualization.list.ItemAtIndex)question).subject.set( visualization );
                      ((edu.cmu.cs.stage3.alice.core.question.visualization.list.ItemAtIndex)question).index.set( new Double( i ));
                      responseStructure = PopupMenuUtilities.makeResponseStructure( question, factory, context );
                      subStructure.add( new StringObjectPair( "item "+i, responseStructure ) );
                    }
                   
                    //Item at end
                    question = new edu.cmu.cs.stage3.alice.core.question.visualization.list.ItemAtEnd();
                    ((edu.cmu.cs.stage3.alice.core.question.visualization.list.ItemAtEnd)question).subject.set( visualization );
                    responseStructure = PopupMenuUtilities.makeResponseStructure( question, factory, context );
                    subStructure.add( new StringObjectPair( "item at the end", responseStructure ) );
                  }
                  else if( collection instanceof edu.cmu.cs.stage3.alice.core.Array ) {
                    for( int i = 0; i < items.length; i++ ) {
                      question = new edu.cmu.cs.stage3.alice.core.question.visualization.array.ItemAtIndex();
                      ((edu.cmu.cs.stage3.alice.core.question.visualization.array.ItemAtIndex)question).subject.set( visualization );
                      ((edu.cmu.cs.stage3.alice.core.question.visualization.array.ItemAtIndex)question).index.set( new Double( i ));
                      java.util.Vector responseStructure = PopupMenuUtilities.makeResponseStructure( question, factory, context );
                      subStructure.add( new StringObjectPair( "element "+i, responseStructure ) );
                    }
                  }
                  return subStructure;
                }
              };
              structure.add( new StringObjectPair( "item responses", delayedBindingPopupItem ) );
            }
        }
      }
      if( element instanceof edu.cmu.cs.stage3.alice.core.visualization.ModelVisualization) {
        edu.cmu.cs.stage3.alice.core.visualization.ModelVisualization visualization = (edu.cmu.cs.stage3.alice.core.visualization.ModelVisualization)element;
        structure.add( new edu.cmu.cs.stage3.util.StringObjectPair( "Separator", javax.swing.JSeparator.class ) );
        edu.cmu.cs.stage3.alice.core.Question question = new edu.cmu.cs.stage3.alice.core.question.visualization.model.Item();
        ((edu.cmu.cs.stage3.alice.core.question.visualization.model.Item)question).subject.set( visualization );
        java.util.Vector responseStructure = PopupMenuUtilities.makeResponseStructure( question, factory, context );
        structure.add( new StringObjectPair( "item", responseStructure ) );
      }
    }

    return structure;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.