Component comp = super.boxComponent(designer);
JPanel compPanel = new ProxyPanel(new BorderLayout(0,0));
final int where = getChildDesigners().size();
final SwitchActivity switchActivity = (SwitchActivity)getActivity();
Condition[] conditions = switchActivity.getConditions();
String conditionDescription;// = "condition" + where;
if(conditions!=null && conditions.length>where){
conditionDescription = conditions[where].toString();
switchActivity.setExtendedAttribute("conditionDescriptions_" + where, conditionDescription);
}else{
conditionDescription = "condition" + where;
}
final JPanel conditionLabelPanel = new ProxyPanel(new BorderLayout());
final JLabel conditionLabel = new JLabel(conditionDescription);
conditionLabelPanel.add("Center", conditionLabel);
conditionLabel.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent arg0) {
conditionLabelPanel.removeAll();
final JTextField labelEditor = new JTextField();
labelEditor.setText(conditionLabel.getText());
conditionLabelPanel.add("Center", labelEditor);
final ActionListener onEditDone = new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
Condition theCondition = null;
int where = switchActivity.getChildActivities().indexOf(designer.getActivity());
Condition[] conditions = switchActivity.getConditions();
if(conditions!=null && conditions.length > where){
theCondition = conditions[where];
}
String conditionDescription = labelEditor.getText();
if(theCondition!=null){
if(conditionDescription==null || conditionDescription.trim().length()==0){
conditionDescription = theCondition.toString();
}else{
theCondition.getDescription().setText(conditionDescription);
}
}
conditionLabel.setText(conditionDescription);
conditionLabelPanel.removeAll();
conditionLabelPanel.add("Center", conditionLabel);
conditionLabelPanel.revalidate();
switchActivity.setExtendedAttribute("conditionDescriptions_" + where, conditionDescription);
}
};
labelEditor.addFocusListener(new FocusListener(){
public void focusGained(FocusEvent arg0) {
}
public void focusLost(FocusEvent arg0) {
onEditDone.actionPerformed(null);
}
});
labelEditor.addActionListener(onEditDone);
conditionLabelPanel.revalidate();
}
});
switchActivity.addProperyChangeListener(
new PropertyChangeListener(){
public void propertyChange(PropertyChangeEvent pce){
if(pce.getPropertyName().equals("conditions")){
try{
int where = switchActivity.getChildActivities().indexOf(designer.getActivity());
Condition[] conditions = (Condition[])pce.getNewValue();
conditionLabel.setText(conditions[where].toString());
}catch(Exception e){
}
}