Math2mat
|
00001 00015 package m2m.frontend.dynamicview.figure; 00016 00017 import m2m.backend.structure.Multiplexer; 00018 import m2m.frontend.dynamicview.model.*; 00019 00020 import org.eclipse.draw2d.ActionEvent; 00021 import org.eclipse.draw2d.ActionListener; 00022 import org.eclipse.draw2d.CheckBox; 00023 import org.eclipse.draw2d.ColorConstants; 00024 import org.eclipse.draw2d.Figure; 00025 import org.eclipse.draw2d.Label; 00026 import org.eclipse.draw2d.ToolbarLayout; 00027 import org.eclipse.draw2d.XYLayout; 00028 import org.eclipse.draw2d.geometry.Rectangle; 00029 00030 00031 00032 public class IfPropertyFigure extends Figure implements ActionListener 00033 { 00037 private GraphicIf graphicIf; 00041 private XYLayout layout; 00045 private Label labelName = new Label(); 00049 private Label labelCondition = new Label(); 00053 private CheckBox checkBoxMonitor = new CheckBox("Monitor mode"); 00054 00055 00059 public IfPropertyFigure() 00060 { 00061 /* Set the type of layout */ 00062 layout = new XYLayout(); 00063 setLayoutManager(layout); 00064 00065 /* Initialisation of the labelName */ 00066 labelName.setForegroundColor(ColorConstants.black); 00067 add(labelName, ToolbarLayout.VERTICAL); 00068 setConstraint(labelName, new Rectangle(0, 0, -1, -1)); 00069 labelName.setText("Unknown"); 00070 00071 /* Initialisation of the labelCondition */ 00072 labelCondition.setForegroundColor(ColorConstants.black); 00073 add(labelCondition, ToolbarLayout.VERTICAL); 00074 setConstraint(labelCondition, new Rectangle(0, 30, -1, -1)); 00075 labelCondition.setText("Unknown"); 00076 00077 /* Initialisation of the checkBoxAutoRoute */ 00078 add(checkBoxMonitor); 00079 setConstraint(checkBoxMonitor, new Rectangle(0, 45, -1, -1)); 00080 checkBoxMonitor.addActionListener(this); 00081 00082 /* Initialisation of the figure */ 00083 setOpaque(true); 00084 setBackgroundColor(ColorConstants.menuBackground); 00085 setForegroundColor(ColorConstants.menuForeground); 00086 } 00087 00088 00093 public void setProperty(GraphicIf graphicIf) 00094 { 00095 this.graphicIf = graphicIf; 00096 00097 if(!(graphicIf.getElement() instanceof Multiplexer)) 00098 checkBoxMonitor.setEnabled(false); 00099 else 00100 checkBoxMonitor.setEnabled(true); 00101 00102 /* Initialize the state of the checkBox */ 00103 checkBoxMonitor.setSelected(graphicIf.getMonitor()); 00104 00105 /* Get and show the name of name and condition nodes of the GraphicIf */ 00106 labelName.setText("Name : " + graphicIf.getName()); 00107 labelCondition.setText("Condition : " + graphicIf.getCondition()); 00108 } 00109 00110 00115 @Override 00116 public void actionPerformed(ActionEvent arg) 00117 { 00118 /* Enable/Disable the monitoring of the condition signal */ 00119 graphicIf.setMonitor(checkBoxMonitor.isSelected()); 00120 } 00121 }