Skip to content

Commit 2b612f7

Browse files
author
Ultimate Pea
authored
Merge pull request #13 from UCSDOalads/develop
Merge Develop Release v0.2.1
2 parents ddb951f + f92065d commit 2b612f7

33 files changed

+1243
-321
lines changed

src/actions/AddDataDisplayBoxAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package actions;
22

3-
import paintcomponents.DataDisplayPaintComponent;
3+
import actions.menu.ActionsMenuBarTitles;
4+
import paintcomponents.data.DataDisplayPaintComponent;
45
import ui.PaintPanel;
56

67
public class AddDataDisplayBoxAction extends PaintAction {
@@ -23,7 +24,7 @@ public void performAction() {
2324

2425
@Override
2526
public String locationString() {
26-
return "Add/Data Display";
27+
return ActionsMenuBarTitles.Data().Display_Box().Add().toString();
2728
}
2829

2930
}

src/actions/AddDataInputBoxAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package actions;
22

3-
import paintcomponents.DataInputTextfieldPaintComponent;
3+
import actions.menu.ActionsMenuBarTitles;
4+
import paintcomponents.data.DataInputTextfieldPaintComponent;
45
import ui.PaintPanel;
56

67
public class AddDataInputBoxAction extends PaintAction {
@@ -24,7 +25,7 @@ public void performAction() {
2425

2526
@Override
2627
public String locationString() {
27-
return "Add/Data Input Box...";
28+
return ActionsMenuBarTitles.Data().Input_Box().Add().toString();
2829
}
2930

3031
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package actions;
2+
3+
import javax.swing.JOptionPane;
4+
5+
import actions.menu.ActionsMenuBarTitles;
6+
import actions.menu.PaintActionMenuItem;
7+
import paintcomponents.java.lazy.ClassPaintComponent;
8+
import ui.PaintPanel;
9+
10+
public class AddLazyJavaClassAction extends PaintAction {
11+
12+
public AddLazyJavaClassAction(PaintPanel panel) {
13+
super(panel);
14+
}
15+
16+
@Override
17+
public boolean canPerformAction() {
18+
return true;
19+
}
20+
21+
@Override
22+
public void performAction() {
23+
String className = JOptionPane
24+
.showInputDialog("Please specify the name of the Java Class");
25+
try {
26+
Class classObj = Class.forName(className);
27+
panel.addPaintComponent(new ClassPaintComponent(classObj,
28+
panel.getWidth() / 2, panel.getHeight() / 2));
29+
panel.repaint();
30+
} catch (ClassNotFoundException e) {
31+
e.printStackTrace();
32+
JOptionPane.showMessageDialog(panel,
33+
className + " :: Class Not Found");
34+
}
35+
36+
}
37+
38+
@Override
39+
public String locationString() {
40+
return ActionsMenuBarTitles.Lazy().Add().Java_Class().toString();
41+
}
42+
43+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package actions;
2+
3+
import java.lang.reflect.Constructor;
4+
5+
import javax.swing.JOptionPane;
6+
7+
import actions.menu.ActionsMenuBarTitles;
8+
import paintcomponents.java.lazy.ClassConstructorPaintComponent;
9+
import paintcomponents.java.lazy.ClassPaintComponent;
10+
import ui.PaintPanel;
11+
12+
public class AddLazyJavaConstructorAction extends PaintAction {
13+
14+
public AddLazyJavaConstructorAction(PaintPanel panel) {
15+
super(panel);
16+
}
17+
18+
@Override
19+
public boolean canPerformAction() {
20+
if (panel.getSelectTool().getSelectedComponents().size() != 1) {
21+
return false;
22+
}
23+
if (panel.getSelectTool().getSelectedComponents()
24+
.get(0) instanceof ClassPaintComponent) {
25+
return true;
26+
}
27+
return false;
28+
}
29+
30+
@Override
31+
public void performAction() {
32+
ClassPaintComponent comp = (ClassPaintComponent) panel.getSelectTool()
33+
.getSelectedComponents().get(0);
34+
Constructor[] cons = comp.getDisplayingClass().getConstructors();
35+
36+
int desiaredConstructorIndex = Integer
37+
.parseInt(JOptionPane.showInputDialog(
38+
"Please enter the index of the constructor you would like to use: \n\n\n"
39+
+ getConstructorsSelectionUI(cons)));
40+
ClassConstructorPaintComponent consComp = new ClassConstructorPaintComponent(
41+
cons[desiaredConstructorIndex], panel.getWidth() / 2,
42+
panel.getHeight() / 2);
43+
panel.addPaintComponent(consComp);
44+
panel.repaint();
45+
46+
}
47+
48+
public String getConstructorsSelectionUI(Constructor[] cons) {
49+
StringBuilder builder = new StringBuilder();
50+
for (int i = 0; i < cons.length; i++) {
51+
Constructor constructor = cons[i];
52+
builder.append(i + " : " + constructor.toString() + "\n");
53+
}
54+
return builder.toString();
55+
56+
}
57+
58+
@Override
59+
public String locationString() {
60+
return ActionsMenuBarTitles.Lazy().Add().Java_Constructor().toString();
61+
}
62+
63+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package actions;
2+
3+
import actions.menu.ActionsMenuBarTitles;
4+
import paintcomponents.java.lazy.ClassPaintComponent;
5+
import paintcomponents.java.lazy.FieldsPaintComponent;
6+
import ui.PaintPanel;
7+
8+
public class AddLazyJavaFieldsComponentAction extends PaintAction {
9+
10+
public AddLazyJavaFieldsComponentAction(PaintPanel panel) {
11+
super(panel);
12+
}
13+
//TODO
14+
//NOTE: I am copying from Constructor and Methods, consider refinement
15+
@Override
16+
public boolean canPerformAction() {
17+
if (panel.getSelectTool().getSelectedComponents().size() != 1) {
18+
return false;
19+
}
20+
if (panel.getSelectTool().getSelectedComponents()
21+
.get(0) instanceof ClassPaintComponent) {
22+
return true;
23+
}
24+
return false;
25+
}
26+
@Override
27+
public void performAction() {
28+
ClassPaintComponent comp = (ClassPaintComponent) panel.getSelectTool()
29+
.getSelectedComponents().get(0);
30+
31+
FieldsPaintComponent fieldsComp =
32+
new FieldsPaintComponent(comp.getDisplayingClass(),
33+
panel.getWidth() / 2,
34+
panel.getHeight() / 2);
35+
panel.addPaintComponent(fieldsComp);
36+
panel.repaint();
37+
}
38+
39+
@Override
40+
public String locationString() {
41+
return ActionsMenuBarTitles.Lazy().Add().Java_Fields().toString();
42+
}
43+
44+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package actions;
2+
3+
import java.lang.reflect.Method;
4+
5+
import javax.swing.JOptionPane;
6+
7+
import actions.menu.ActionsMenuBarTitles;
8+
import paintcomponents.java.lazy.ClassConstructorPaintComponent;
9+
import paintcomponents.java.lazy.ClassPaintComponent;
10+
import paintcomponents.java.lazy.MethodPaintComponent;
11+
import ui.PaintPanel;
12+
13+
public class AddLazyJavaMethodComponentAction extends PaintAction {
14+
15+
public AddLazyJavaMethodComponentAction(PaintPanel panel) {
16+
super(panel);
17+
}
18+
19+
//TODO
20+
//NOTE: I am copying from Constructor, consider refinement
21+
@Override
22+
public boolean canPerformAction() {
23+
if (panel.getSelectTool().getSelectedComponents().size() != 1) {
24+
return false;
25+
}
26+
if (panel.getSelectTool().getSelectedComponents()
27+
.get(0) instanceof ClassPaintComponent) {
28+
return true;
29+
}
30+
return false;
31+
}
32+
33+
@Override
34+
public void performAction() {
35+
ClassPaintComponent comp = (ClassPaintComponent) panel.getSelectTool()
36+
.getSelectedComponents().get(0);
37+
Method[] methods = comp.getDisplayingClass().getMethods();
38+
39+
int desiaredConstructorIndex = Integer
40+
.parseInt(JOptionPane.showInputDialog(
41+
"Please enter the index of the constructor you would like to use: \n\n\n"
42+
+ getMethodsSelectionUI(methods)));
43+
MethodPaintComponent methodComp = new MethodPaintComponent(
44+
methods[desiaredConstructorIndex], panel.getWidth() / 2,
45+
panel.getHeight() / 2);
46+
panel.addPaintComponent(methodComp);
47+
panel.repaint();
48+
}
49+
public String getMethodsSelectionUI(Method[] methods) {
50+
StringBuilder builder = new StringBuilder();
51+
for (int i = 0; i < methods.length; i++) {
52+
Method constructor = methods[i];
53+
builder.append(i + " : " + constructor.toString() + "\n");
54+
}
55+
return builder.toString();
56+
57+
}
58+
@Override
59+
public String locationString() {
60+
return ActionsMenuBarTitles.Lazy().Add().Java_Method().toString();
61+
}
62+
63+
}

src/actions/AddTextBoxAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import javax.swing.JOptionPane;
44

5+
import actions.menu.ActionsMenuBarTitles;
56
import paintcomponents.TextPaintComponent;
67
import ui.PaintPanel;
78

@@ -25,7 +26,7 @@ public void performAction() {
2526

2627
@Override
2728
public String locationString() {
28-
return "Add/Text Box...";
29+
return ActionsMenuBarTitles.Developer("Add/Text Box...").toString();
2930
}
3031

3132
}

src/actions/ConstructDataLineSegmentAction.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import java.util.ArrayList;
44

5-
import paintcomponents.DataFromPoint;
6-
import paintcomponents.DataLineSegment;
7-
import paintcomponents.DataToPoint;
5+
import actions.menu.ActionsMenuBarTitles;
86
import paintcomponents.PaintComponent;
7+
import paintcomponents.data.DataFromPoint;
8+
import paintcomponents.data.DataLineSegment;
9+
import paintcomponents.data.DataToPoint;
910
import ui.PaintPanel;
1011

1112
public class ConstructDataLineSegmentAction extends ConstructLineSegmentAction {
@@ -22,9 +23,9 @@ public boolean canPerformAction() {
2223
//assume ConstructLineSegment is doing correctly, there is two corrently selected points
2324
ArrayList<PaintComponent> comps = this.panel.getSelectTool().getSelectedComponents();
2425
//TODO IMPORTANT Generic Argument is erased, may cause unexpected behavior when types dont match in the future
25-
if(comps.get(0) instanceof DataFromPoint<?> && comps.get(1) instanceof DataToPoint<?>){
26+
if(comps.get(0) instanceof DataFromPoint && comps.get(1) instanceof DataToPoint){
2627
//allow connection only when no segment has no existing connections to the data
27-
if(((DataToPoint<?>)comps.get(1)).getLineSegment() == null){
28+
if(((DataToPoint)comps.get(1)).getLineSegment() == null){
2829
return true;
2930
}
3031
}
@@ -35,15 +36,14 @@ public boolean canPerformAction() {
3536
public void performAction() {
3637

3738
ArrayList<PaintComponent> comps = this.panel.getSelectTool().getSelectedComponents();
38-
@SuppressWarnings("rawtypes")
39-
DataLineSegment<?> seg = new DataLineSegment((DataFromPoint<?>)comps.get(0), (DataToPoint<?>)comps.get(1));
39+
DataLineSegment seg = new DataLineSegment((DataFromPoint)comps.get(0), (DataToPoint)comps.get(1));
4040
addLineSegment(seg);
4141
}
4242

4343
@Override
4444
public String locationString() {
4545
// TODO Auto-generated method stub
46-
return "Data/Construct/Line Segment";
46+
return ActionsMenuBarTitles.Data().Construct().Line_Segment().toString();
4747
}
4848

4949
}

src/actions/ConstructLineSegmentAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.awt.Component;
44
import java.util.ArrayList;
55

6+
import actions.menu.ActionsMenuBarTitles;
67
import paintcomponents.LineSegment;
78
import paintcomponents.PaintComponent;
89
import paintcomponents.SimplePoint;
@@ -82,7 +83,7 @@ protected void addLineSegment(LineSegment lineSegment) {
8283

8384
@Override
8485
public String locationString() {
85-
return "Construct/Line Segment";
86+
return ActionsMenuBarTitles.Developer("Construct/Line Segment").toString();
8687
}
8788

8889
}

src/actions/InputDataForDataInputBoxAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
import javax.swing.JOptionPane;
66

7-
import paintcomponents.DataInputTextfieldPaintComponent;
7+
import actions.menu.ActionsMenuBarTitles;
88
import paintcomponents.PaintComponent;
9+
import paintcomponents.data.DataInputTextfieldPaintComponent;
910
import ui.PaintPanel;
1011

1112
public class InputDataForDataInputBoxAction extends PaintAction {
@@ -34,7 +35,7 @@ public void performAction() {
3435

3536
@Override
3637
public String locationString() {
37-
return "Input/Input into Data Panel";
38+
return ActionsMenuBarTitles.Data().Input_Box().Update().toString();
3839
}
3940

4041
}

0 commit comments

Comments
 (0)