@@ -38,18 +38,37 @@ public DataLineSegment getLineSeg() {
3838
3939 @ Override
4040 protected void execute (PaintPanel panel ) {
41-
42- if (!toPoint .getExpectedType ().canBeAssignedFrom (fromPoint .getExpectedType ())) {
41+ //Diagnostic
42+ //System.out.println(fromPoint.getExpectedType().getCurClass().getName());
43+ //System.out.println(toPoint.getExpectedType().getCurClass().getName());
44+ /*if (!toPoint.getExpectedType().canBeAssignedFrom(fromPoint.getExpectedType())) {
45+
4346 int result = JOptionPane.showConfirmDialog(panel,
4447 "The source type is " + fromPoint.getExpectedType() + ", the destination type is "
4548 + toPoint.getExpectedType() + ". Do you want to proceed and create the connection anyway?",
4649
4750 "Type Mismatch", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
4851 if (result == JOptionPane.NO_OPTION) {
4952 return;
50- }
53+ }*/
54+ //Below method was deprecated
55+ try {fromPoint .setExpectedType (toPoint .getExpectedType ());}
56+
57+ catch (ClassCastException e ){
58+ if (!toPoint .getExpectedType ().canBeAssignedFrom (fromPoint .getExpectedType ())) {
59+
60+ int result = JOptionPane .showConfirmDialog (panel ,
61+ "The source type is " + fromPoint .getExpectedType () + ", the destination type is "
62+ + toPoint .getExpectedType () + ". Do you want to proceed and create the connection anyway?" ,
63+
64+ "Type Mismatch" , JOptionPane .YES_NO_OPTION , JOptionPane .WARNING_MESSAGE );
65+ if (result == JOptionPane .NO_OPTION ) {
66+ return ;
67+ }
5168
5269 }
70+
71+ }
5372
5473 DataLineSegment seg = new DataLineSegment (fromPoint , toPoint );
5574 panel .addPaintComponent (seg );
0 commit comments