Example #1
0
 @Override
 protected void stopListening() {
   super.stopListening();
   if (m_condition != null) {
     m_condition.removePropertyListener(this);
   }
 }
Example #2
0
 @Override
 protected void generateGUI() {
   super.generateGUI();
   if (endHeader == null) {
     endHeader = new javax.swing.JLabel();
   }
 }
 public void propertyChanged(edu.cmu.cs.stage3.alice.core.event.PropertyEvent propertyEvent) {
   if (propertyEvent.getProperty() == m_each) {
     if (m_each.get() != null) {
       edu.cmu.cs.stage3.alice.core.Element l =
           (edu.cmu.cs.stage3.alice.core.Element) m_list.get();
       Class valueClass = null;
       if (l instanceof edu.cmu.cs.stage3.alice.core.List) {
         valueClass = (Class) ((edu.cmu.cs.stage3.alice.core.List) l).valueClass.get();
       } else if (l instanceof edu.cmu.cs.stage3.alice.core.Variable) {
         valueClass =
             (Class)
                 ((edu.cmu.cs.stage3.alice.core.List)
                         ((edu.cmu.cs.stage3.alice.core.Variable) l).value.get())
                     .valueClass.get();
       }
       ((edu.cmu.cs.stage3.alice.core.Variable) m_each.get()).valueClass.set(valueClass);
       setVariableName();
     }
   }
   if (propertyEvent.getProperty() == m_list) {
     if (m_list.get() != null && !nameListening) {
       ((edu.cmu.cs.stage3.alice.core.Element) m_list.get()).name.addPropertyListener(this);
       nameListening = true;
     }
     setVariable();
   } else if (m_list.get() != null
       && propertyEvent.getProperty()
           == ((edu.cmu.cs.stage3.alice.core.Element) m_list.get()).name) {
     setVariableName();
   } else {
     super.propertyChanged(propertyEvent);
   }
 }
Example #4
0
 @Override
 protected void startListening() {
   super.startListening();
   if (m_condition != null) {
     m_condition.addPropertyListener(this);
   }
 }
Example #5
0
 @Override
 protected void updateGUI() {
   super.updateGUI();
   edu.cmu.cs.stage3.alice.authoringtool.util.PopupItemFactory pif =
       new edu.cmu.cs.stage3.alice.authoringtool.util.SetPropertyImmediatelyFactory(m_condition);
   conditionalInput =
       edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getPropertyViewController(
           m_condition,
           true,
           true,
           edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.shouldGUIOmitPropertyName(
               m_condition),
           pif);
   headerPanel.remove(glue);
   headerPanel.add(
       conditionalInput,
       new java.awt.GridBagConstraints(
           3,
           0,
           1,
           1,
           0,
           0,
           java.awt.GridBagConstraints.CENTER,
           java.awt.GridBagConstraints.NONE,
           new java.awt.Insets(0, 2, 0, 2),
           0,
           0));
   headerPanel.add(
       endHeader,
       new java.awt.GridBagConstraints(
           4,
           0,
           1,
           1,
           0,
           0,
           java.awt.GridBagConstraints.CENTER,
           java.awt.GridBagConstraints.NONE,
           new java.awt.Insets(0, 2, 0, 2),
           0,
           0));
   headerPanel.add(
       glue,
       new java.awt.GridBagConstraints(
           5,
           0,
           1,
           1,
           1,
           0,
           java.awt.GridBagConstraints.CENTER,
           java.awt.GridBagConstraints.BOTH,
           new java.awt.Insets(0, 0, 0, 0),
           0,
           0));
 }
Example #6
0
 @Override
 protected void variableInit() {
   super.variableInit();
   if (m_element instanceof edu.cmu.cs.stage3.alice.core.response.WhileLoopInOrder) {
     edu.cmu.cs.stage3.alice.core.response.WhileLoopInOrder proxy =
         (edu.cmu.cs.stage3.alice.core.response.WhileLoopInOrder) m_element;
     m_condition = proxy.condition;
   } else if (m_element instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.While) {
     edu.cmu.cs.stage3.alice.core.question.userdefined.While proxy =
         (edu.cmu.cs.stage3.alice.core.question.userdefined.While) m_element;
     m_condition = proxy.condition;
   }
 }
 protected void variableInit() {
   super.variableInit();
   if (m_element instanceof edu.cmu.cs.stage3.alice.core.response.ForEach) {
     edu.cmu.cs.stage3.alice.core.response.ForEach proxy =
         (edu.cmu.cs.stage3.alice.core.response.ForEach) m_element;
     m_list = proxy.list;
     m_each = proxy.each;
   } else if (m_element instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.ForEach) {
     edu.cmu.cs.stage3.alice.core.question.userdefined.ForEach proxy =
         (edu.cmu.cs.stage3.alice.core.question.userdefined.ForEach) m_element;
     m_list = proxy.list;
     m_each = proxy.each;
   }
 }
 protected void stopListening() {
   super.stopListening();
   if (m_list != null) {
     m_list.removePropertyListener(this);
     if (m_list.get() != null) {
       ((edu.cmu.cs.stage3.alice.core.Element) m_list.get()).name.removePropertyListener(this);
       nameListening = true;
     }
   }
   if (m_each != null) {
     m_each.removePropertyListener(this);
   }
   stopListenToChildren(this.m_components);
 }
Example #9
0
 @Override
 protected void restoreDrag() {
   super.restoreDrag();
   addDragSourceComponent(endHeader);
 }
 protected void setDropTargets() {
   super.setDropTargets();
   endHeader.setDropTarget(new java.awt.dnd.DropTarget(endHeader, componentElementPanel));
 }
 protected void updateGUI() {
   super.updateGUI();
   edu.cmu.cs.stage3.alice.authoringtool.util.PopupItemFactory pif =
       new edu.cmu.cs.stage3.alice.authoringtool.util.SetPropertyImmediatelyFactory(m_list) {
         public void run(Object v) {
           edu.cmu.cs.stage3.alice.core.Element inputList;
           String name;
           if (v instanceof edu.cmu.cs.stage3.alice.core.List) {
           } else if (v instanceof edu.cmu.cs.stage3.alice.core.Variable) {
             if (!(((edu.cmu.cs.stage3.alice.core.Variable) v).value.get()
                 instanceof edu.cmu.cs.stage3.alice.core.List)) {
               return;
             }
           } else {
             return;
           }
           super.run(v);
         }
       };
   if (m_list.get() != null) {
     setVariable();
   }
   variable =
       edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getVariableDnDPanel(
           (edu.cmu.cs.stage3.alice.core.Variable) m_each.get());
   listInput =
       edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getPropertyViewController(
           m_list,
           false,
           true,
           edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.shouldGUIOmitPropertyName(
               m_list),
           pif);
   headerPanel.remove(glue);
   headerPanel.add(
       listInput,
       new java.awt.GridBagConstraints(
           3,
           0,
           1,
           1,
           0,
           0,
           java.awt.GridBagConstraints.CENTER,
           java.awt.GridBagConstraints.NONE,
           new java.awt.Insets(0, 2, 0, 2),
           0,
           0));
   headerPanel.add(
       new javax.swing.JLabel(middleHeaderText),
       new java.awt.GridBagConstraints(
           4,
           0,
           1,
           1,
           0,
           0,
           java.awt.GridBagConstraints.CENTER,
           java.awt.GridBagConstraints.NONE,
           new java.awt.Insets(0, 2, 0, 2),
           0,
           0));
   headerPanel.add(
       variable,
       new java.awt.GridBagConstraints(
           5,
           0,
           1,
           1,
           0,
           0,
           java.awt.GridBagConstraints.CENTER,
           java.awt.GridBagConstraints.NONE,
           new java.awt.Insets(0, 2, 0, 2),
           0,
           0));
   headerPanel.add(
       endHeader,
       new java.awt.GridBagConstraints(
           6,
           0,
           1,
           1,
           0,
           0,
           java.awt.GridBagConstraints.CENTER,
           java.awt.GridBagConstraints.NONE,
           new java.awt.Insets(0, 2, 0, 2),
           0,
           0));
   headerPanel.add(
       glue,
       new java.awt.GridBagConstraints(
           7,
           0,
           1,
           1,
           1,
           1,
           java.awt.GridBagConstraints.CENTER,
           java.awt.GridBagConstraints.BOTH,
           new java.awt.Insets(0, 0, 0, 0),
           0,
           0));
 }
 protected void restoreDrag() {
   super.restoreDrag();
   this.addDragSourceComponent(endHeader);
 }
  public void getHTML(StringBuffer toWriteTo, int colSpan, boolean useColor, boolean isDisabled) {
    int totalRows = 0;
    String colorString = "";
    String borderColorString = getHTMLColorString(java.awt.Color.lightGray);
    String styleString = "";
    String strikeStart = "";
    String strikeEnd = "";
    if (!isDisabled) {
      isDisabled = isDisabled();
    }
    if (useColor) {
      if (isDisabled) {
        colorString =
            " bgcolor=\""
                + getHTMLColorString(
                    edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getColor(
                        "disabledHTML"))
                + "\"";
      } else {
        colorString = " bgcolor=\"" + getHTMLColorString(getCustomBackgroundColor()) + "\"";
      }
    }
    if (isDisabled) {
      strikeStart =
          "<strike><font color=\""
              + getHTMLColorString(
                  edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getColor(
                      "disabledHTMLText"))
              + "\">";
      strikeEnd = "</font></strike>";
    }
    totalRows = getTotalHTMLRows(m_element);
    if (this
        instanceof
        edu.cmu.cs.stage3.alice.authoringtool.editors.questioneditor.MainCompositeQuestionPanel) {
      totalRows++;
    }
    styleString =
        " style=\"border-left: 1px solid "
            + borderColorString
            + "; border-top: 1px solid "
            + borderColorString
            + "; border-right: 1px solid "
            + borderColorString
            + "\"";
    toWriteTo.append(
        "<td colspan=\"" + colSpan + "\"" + colorString + styleString + ">&nbsp;&nbsp;");

    toWriteTo.append(strikeStart + getHeaderHTML() + strikeEnd);
    if (this instanceof IfElseElementPanel
        || edu.cmu.cs.stage3.alice.authoringtool.editors.compositeeditor.CompositeElementEditor
            .IS_JAVA) {
      styleString = " style=\"border-left: 1px solid " + borderColorString + "\"";
    } else {
      styleString =
          " style=\"border-left: 1px solid "
              + borderColorString
              + "; border-bottom: 1px solid "
              + borderColorString
              + "\"";
    }
    toWriteTo.append(
        "</td>\n</tr>\n<tr>\n<td width=\"20\" rowspan=\""
            + totalRows
            + "\""
            + colorString
            + styleString
            + ">&nbsp;&nbsp;&nbsp;&nbsp;</td>\n");
    for (int i = 0; i < componentElementPanel.getElementComponentCount(); i++) {
      if (i > 0) {
        toWriteTo.append("<tr>\n");
      }
      java.awt.Component currentComponent = componentElementPanel.getComponent(i);
      if (currentComponent instanceof CompositeElementPanel) {
        ((CompositeElementPanel) currentComponent)
            .getHTML(toWriteTo, colSpan - 1, useColor, isDisabled);
      } else {
        String componentColorString = "";
        String componentStrikeStart = "";
        String componentStrikeEnd = "";
        boolean isComponentDisabled =
            isDisabled || ((ComponentElementPanel) currentComponent).isDisabled();
        if (currentComponent instanceof ComponentElementPanel) {
          if (isComponentDisabled) {
            componentColorString =
                " bgcolor=\""
                    + getHTMLColorString(
                        edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getColor(
                            "disabledHTML"))
                    + "\"";
            componentStrikeStart =
                "<strike><font color=\""
                    + getHTMLColorString(
                        edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getColor(
                            "disabledHTMLText"))
                    + "\">";
            componentStrikeEnd = "</font></strike>";
          } else {
            componentColorString =
                " bgcolor=\""
                    + getHTMLColorString(
                        ((ComponentElementPanel) currentComponent).getCustomBackgroundColor())
                    + "\"";
          }
        }
        styleString =
            " style=\"border-bottom: 1px solid "
                + borderColorString
                + "; border-right: 1px solid "
                + borderColorString
                + "; border-left: 1px solid "
                + borderColorString
                + "; border-top: 1px solid "
                + borderColorString
                + "\"";
        toWriteTo.append(
            "<td width=\"100%\" colspan=\""
                + (colSpan - 1)
                + "\""
                + componentColorString
                + styleString
                + ">&nbsp;&nbsp;"
                + componentStrikeStart
                + edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getHTMLStringForComponent(
                    currentComponent)
                + componentStrikeEnd
                + "</td>\n");
      }
    }
    if (componentElementPanel.getElementComponentCount() == 0) {
      if (this instanceof IfElseElementPanel
          || edu.cmu.cs.stage3.alice.authoringtool.editors.compositeeditor.CompositeElementEditor
              .IS_JAVA) {
        styleString = " style=\"border-right: 1 solid " + borderColorString + "\"";
      } else {
        styleString =
            " style=\"border-right: 1 solid "
                + borderColorString
                + "; border-bottom: 1 solid "
                + borderColorString
                + "\"";
      }
      toWriteTo.append(
          "<td width=\"100%\" colspan=\""
              + (colSpan - 1)
              + "\""
              + colorString
              + styleString
              + ">"
              + strikeStart
              + "<i> Do Nothing </i>"
              + strikeEnd
              + "</td>\n</tr>\n");
    }
    if (this
        instanceof
        edu.cmu.cs.stage3.alice.authoringtool.editors.questioneditor.MainCompositeQuestionPanel) {
      edu.cmu.cs.stage3.alice.authoringtool.editors.questioneditor.MainCompositeQuestionPanel
          mainQuestion =
              (edu.cmu.cs.stage3.alice.authoringtool.editors.questioneditor
                      .MainCompositeQuestionPanel)
                  this;
      styleString =
          " style=\"border-bottom: 1 solid "
              + borderColorString
              + "; border-right: 1 solid "
              + borderColorString
              + "; border-left: 1 solid "
              + borderColorString
              + ";\"";
      colorString =
          " bgcolor=\""
              + getHTMLColorString(
                  edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getColor("Return"))
              + "\"";
      toWriteTo.append(
          "<tr>\n<td width=\"100%\" colspan=\""
              + colSpan
              + "\""
              + colorString
              + styleString
              + ">"
              + edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getHTMLStringForComponent(
                  mainQuestion.returnPanel)
              + "</td>\n</tr>\n");
    }
    if (this instanceof IfElseElementPanel) {
      IfElseElementPanel ifElse = (IfElseElementPanel) this;
      if (m_element instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.IfElse) {
        totalRows =
            getTotalRowsToRenderForIfElse(
                m_element,
                ((edu.cmu.cs.stage3.alice.core.question.userdefined.IfElse) m_element)
                    .elseComponents);
      } else if (m_element instanceof edu.cmu.cs.stage3.alice.core.response.IfElseInOrder) {
        totalRows =
            getTotalRowsToRenderForIfElse(
                m_element,
                ((edu.cmu.cs.stage3.alice.core.response.IfElseInOrder) m_element)
                    .elseComponentResponses);
      }
      styleString =
          " style=\"border-left: 1 solid "
              + borderColorString
              + "; border-right: 1 solid "
              + borderColorString
              + "\"";

      toWriteTo.append(
          "<tr>\n<td colspan=\""
              + colSpan
              + "\""
              + colorString
              + styleString
              + ">&nbsp;&nbsp;"
              + strikeStart
              + edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getHTMLStringForComponent(
                  ((IfElseElementPanel) this).elsePanel)
              + strikeEnd
              + "</td>\n");
      if (edu.cmu.cs.stage3.alice.authoringtool.editors.compositeeditor.CompositeElementEditor
          .IS_JAVA) {
        styleString = " style=\"border-left: 1 solid " + borderColorString + "\"";
      } else {
        styleString =
            " style=\"border-left: 1 solid "
                + borderColorString
                + "; border-bottom: 1 solid "
                + borderColorString
                + "\"";
      }
      toWriteTo.append(
          "</tr>\n<tr>\n<td width=\"20\" rowspan=\""
              + totalRows
              + "\""
              + colorString
              + styleString
              + ">&nbsp;</td>\n");
      for (int i = 0; i < ifElse.elseComponentPanel.getElementComponentCount(); i++) {
        if (i > 0) {
          toWriteTo.append("<tr>\n");
        }
        java.awt.Component currentComponent = ifElse.elseComponentPanel.getComponent(i);
        if (currentComponent instanceof CompositeElementPanel) {
          ((CompositeElementPanel) currentComponent)
              .getHTML(toWriteTo, colSpan - 1, useColor, isDisabled);
        } else {
          String componentColorString = "";
          String componentStrikeStart = "";
          String componentStrikeEnd = "";
          boolean isComponentDisabled =
              isDisabled || ((ComponentElementPanel) currentComponent).isDisabled();
          if (currentComponent instanceof ComponentElementPanel) {
            if (isComponentDisabled) {
              componentColorString =
                  " bgcolor=\""
                      + getHTMLColorString(
                          edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getColor(
                              "disabledHTML"))
                      + "\"";
              componentStrikeStart =
                  "<strike><font color=\""
                      + getHTMLColorString(
                          edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.getColor(
                              "disabledHTMLText"))
                      + "\">";
              componentStrikeEnd = "</font></strike>";
            } else {
              componentColorString =
                  " bgcolor=\""
                      + getHTMLColorString(
                          ((ComponentElementPanel) currentComponent).getCustomBackgroundColor())
                      + "\"";
            }
          }
          styleString =
              " style=\"border-bottom: 1 solid "
                  + borderColorString
                  + "; border-right: 1 solid "
                  + borderColorString
                  + "; border-left: 1 solid "
                  + borderColorString
                  + "; border-top: 1 solid "
                  + borderColorString
                  + "\"";
          toWriteTo.append(
              "<td colspan=\""
                  + (colSpan - 1)
                  + "\""
                  + componentColorString
                  + styleString
                  + ">&nbsp;&nbsp;"
                  + componentStrikeStart
                  + edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getHTMLStringForComponent(
                      currentComponent)
                  + componentStrikeEnd
                  + "</td>\n");
        }
        toWriteTo.append("</tr>\n");
      }
      if (ifElse.elseComponentPanel.getElementComponentCount() == 0) {
        if (!edu.cmu.cs.stage3.alice.authoringtool.editors.compositeeditor.CompositeElementEditor
            .IS_JAVA) {
          styleString =
              " style=\"border-right: 1 solid "
                  + borderColorString
                  + "; border-bottom: 1 solid "
                  + borderColorString
                  + "\"";
        } else {
          styleString = " style=\"border-right: 1 solid " + borderColorString + "\"";
        }
        toWriteTo.append(
            "<td colspan=\""
                + (colSpan - 1)
                + "\""
                + colorString
                + styleString
                + ">"
                + strikeStart
                + "<i> Do Nothing </i>"
                + strikeEnd
                + "</td>\n</tr>\n");
      }
    }
    if (edu.cmu.cs.stage3.alice.authoringtool.editors.compositeeditor.CompositeElementEditor
        .IS_JAVA) {
      styleString =
          " style=\"border-left: 1 solid "
              + borderColorString
              + "; border-bottom: 1 solid "
              + borderColorString
              + "; border-right: 1 solid "
              + borderColorString
              + "\"";
      toWriteTo.append(
          "<tr><td colspan=\""
              + colSpan
              + "\""
              + colorString
              + styleString
              + ">"
              + strikeStart
              + "<b>&nbsp;&nbsp;}</b>"
              + strikeEnd
              + "</td></tr>");
    }
    // toWriteTo.append("</tr>\n");
  }