Skip to content

Commit 1ad6c9c

Browse files
committed
Merge branch 'develop' into improveLineSelectionbyTanSu
Improved the algorithm of determining the distance between given point and line.
2 parents 416e99c + 8fc6d47 commit 1ad6c9c

7 files changed

Lines changed: 63 additions & 9 deletions

File tree

src/actions/AddLazyJavaMethodComponentAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public void performAction() {
4545

4646
String desiaredConstructorIndex = JOptionPane.showInputDialog(
4747
"Please enter the index of the constructor you would like to use: \n\n\n"
48+
4849
+ getMethodsSelectionUI(methods));
4950
//call DialogInputChecker to check input
5051
DialogInputChecker inputChecker = new DialogInputChecker();
@@ -55,7 +56,6 @@ public void performAction() {
5556
assiciatedAction.setMethod(String.class.getMethods()[Integer.parseInt(desiaredConstructorIndex)]);
5657
GlobalPaintActionExecuter.getSharedInstance().execute(assiciatedAction, panel);
5758
}
58-
5959
}
6060

6161
public String getMethodsSelectionUI(Method[] methods) {

src/actions/global/globalactions/AddLazyJavaClassGlobalAction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ protected void execute(PaintPanel panel) {
2525
ClassPaintComponent comp = new ClassPaintComponent(classToCreate, x, y);
2626
panel.addPaintComponent(comp);
2727

28+
if (panel.getSelectTool() != null) {
29+
panel.getSelectTool().clearSelection();
30+
panel.getSelectTool().selectComponent(comp);
31+
}
32+
2833
// add action to undo redo manager
2934
UndoRedoableInterface undoRedoBlock = new UndoRedoableInterface() {
3035

src/actions/global/globalactions/ConstructDataLineSegmentGlobalAction.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/paintcomponents/data/DataToPoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public DataToPoint(int x, int y, Type expectedType) {
5353
public Object fetchData() throws NoConnectingLineSegmentException, NoSuchElementException, DataFromPointNoDataProviderException, DataFromPointProviderCannotProvideDataException{
5454
if(this.lineSegment == null) throw new NoConnectingLineSegmentException();
5555

56-
Object returnVal = lineSegment.getFromPoint().getData();
56+
Object returnVal = lineSegment.getFromPoint().getData().toString();
5757
if(returnVal == null) throw new NoSuchElementException();
5858
return returnVal;
5959

src/painttools/toolbar/ToolBar.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public ToolBar(PaintPanel panel) {
4444
selectTool = new SelectTool(panel);
4545
addTool(new DotTool());
4646
addTool(selectTool);
47+
addTool(new LineTool());
4748

4849

49-
addTool(new AddClassTool(panel));
50-
addTool(new AddInputBoxTool(panel));
51-
addTool(new AddOutputBoxTool(panel));
50+
addComponentTool(new AddClassTool(panel));
51+
addComponentTool(new AddInputBoxTool(panel));
52+
addComponentTool(new AddOutputBoxTool(panel));
5253

53-
addTool(new LineTool());
5454

5555
addSeprator();
5656

@@ -80,6 +80,29 @@ public void actionPerformed(ActionEvent e) {
8080
add(button);
8181
}
8282

83+
/**
84+
* Adds a component tool to the toolbar. This method will add specific tool to the
85+
* tool bar, and an action listener associated with it
86+
*
87+
* @param tool
88+
*/
89+
private void addComponentTool(PaintTool tool) {
90+
ToolButton button = tool.getButton();
91+
buttons.add(button);
92+
button.addActionListener(new ActionListener() {
93+
94+
@Override
95+
public void actionPerformed(ActionEvent e) {
96+
setButtonSelection(e);
97+
select(tool);
98+
99+
buttons.get(1).doClick();
100+
}
101+
});
102+
addSeprator();
103+
add(button);
104+
}
105+
83106
/**
84107
* Adds a ToolBarListener to this toolbar
85108
* @param listener

src/typesystem/HaskellType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ public boolean canBeAssignedFrom(Type type) {
1212
return false;
1313
}
1414

15+
@Override
16+
public Class getCurClass() {
17+
// TODO Auto-generated method stub
18+
return null;
19+
}
20+
1521
}

src/typesystem/Type.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
public abstract class Type {
44

55
public abstract boolean canBeAssignedFrom(Type type);
6+
public abstract Class getCurClass();
67
}

0 commit comments

Comments
 (0)