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); } }
private void setVariable() { if (m_each.get() != null && m_list.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(); } }
public void objectArrayPropertyChanged( edu.cmu.cs.stage3.alice.core.event.ObjectArrayPropertyEvent objectArrayPropertyEvent) { stopListening(); startListening(); if (isTopOccurrance(m_element.getParent(), m_list.get())) { m_each .getElementValue() .name .set( "item_from_" + ((edu.cmu.cs.stage3.alice.core.Element) m_list.get()).name.getStringValue()); setAllNames(m_components, 2); } }
protected void updateName() { edu.cmu.cs.stage3.alice.core.Variable v = ((edu.cmu.cs.stage3.alice.core.Variable) m_each.getValue()); v.name.set(makeVariableName(((edu.cmu.cs.stage3.alice.core.Element) m_list.get()))); headerPanel.remove(variable); variable = edu.cmu.cs.stage3.alice.authoringtool.util.GUIFactory.getVariableDnDPanel( (edu.cmu.cs.stage3.alice.core.Variable) m_each.get()); 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)); }
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); }
protected void setVariableName() { edu.cmu.cs.stage3.alice.core.Element l = (edu.cmu.cs.stage3.alice.core.Element) m_list.get(); String newName = makeVariableName(l); ((edu.cmu.cs.stage3.alice.core.Element) m_each.get()).name.set(newName); }
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)); }