@Override public void wakeUp() { startListening(); if (componentElementPanel != null) { componentElementPanel.wakeUp(); } }
@Override public void goToSleep() { stopListening(); if (componentElementPanel != null) { componentElementPanel.goToSleep(); } }
@Override public void release() { super.release(); if (componentElementPanel != null) { componentElementPanel.release(); } edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.releaseGUI(this); }
@Override public void clean() { goToSleep(); if (componentElementPanel != null) { if (containingPanel != null) { containingPanel.remove(componentElementPanel); } componentElementPanel.release(); componentElementPanel = null; } }
protected void variableInit() { Object isExpandedValue = m_element.data.get(IS_EXPANDED_KEY); backgroundColor = getCustomBackgroundColor(); if (isExpandedValue instanceof Boolean) { isExpanded = ((Boolean) isExpandedValue).booleanValue(); } setTransferable( new edu.cmu.cs.stage3.alice.authoringtool.datatransfer.ElementReferenceTransferable( m_element)); if (m_element instanceof edu.cmu.cs.stage3.alice.core.response.CompositeResponse) { edu.cmu.cs.stage3.alice.core.response.CompositeResponse proxy = (edu.cmu.cs.stage3.alice.core.response.CompositeResponse) m_element; m_components = proxy.componentResponses; m_isCommentedOut = proxy.isCommentedOut; componentElementPanel = new edu.cmu.cs.stage3.alice.authoringtool.editors.responseeditor .CompositeComponentResponsePanel(); componentElementPanel.set(m_components, this, authoringTool); componentElementPanel.setBackground(backgroundColor); addDragSourceComponent(componentElementPanel); componentElementPanel.addMouseListener(elementMouseListener); } else if (m_element instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.Composite) { edu.cmu.cs.stage3.alice.core.question.userdefined.Composite proxy = (edu.cmu.cs.stage3.alice.core.question.userdefined.Composite) m_element; m_components = proxy.components; m_isCommentedOut = proxy.isCommentedOut; componentElementPanel = new edu.cmu.cs.stage3.alice.authoringtool.editors.questioneditor .CompositeComponentQuestionPanel(); componentElementPanel.set(m_components, this, authoringTool); componentElementPanel.setBackground(backgroundColor); addDragSourceComponent(componentElementPanel); componentElementPanel.addMouseListener(elementMouseListener); } }
@Override public void setBackground(java.awt.Color color) { super.setBackground(color); backgroundColor = color; if (containingPanel != null) { containingPanel.setBackground(backgroundColor); } if (headerLabel != null) { headerLabel.setBackground(backgroundColor); } if (headerPanel != null) { headerPanel.setBackground(backgroundColor); } if (componentElementPanel != null) { componentElementPanel.setBackground(backgroundColor); } }
protected void removeAllListening() { removeDragSourceComponent(componentElementPanel); componentElementPanel.removeMouseListener(elementMouseListener); grip.setDropTarget(null); removeDragSourceComponent(glue); glue.removeMouseListener(elementMouseListener); removeMouseListener(elementMouseListener); grip.removeMouseListener(elementMouseListener); expandButton.removeActionListener(actionListener); setTransferable(null); if (headerLabel != null) { headerLabel.removeMouseListener(elementMouseListener); removeDragSourceComponent(headerLabel); } if (containingPanel != null) { containingPanel.removeMouseListener(elementMouseListener); removeDragSourceComponent(containingPanel); } if (headerPanel != null) { headerPanel.removeMouseListener(elementMouseListener); removeDragSourceComponent(headerPanel); } }
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 + "> "); 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 + "> </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 + "> " + 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 + "> " + 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 + "> </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 + "> " + 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> }</b>" + strikeEnd + "</td></tr>"); } // toWriteTo.append("</tr>\n"); }
public void addResponsePanel(javax.swing.JComponent toAdd, int position) { componentElementPanel.addElementPanel(toAdd, position); }