Skip to content

Commit 48df4f3

Browse files
author
Xiangyi Gong
committed
Merge branch 'develop' into XYGBranch
2 parents 265c190 + 4f41aec commit 48df4f3

53 files changed

Lines changed: 2115 additions & 277 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/actions/AddAnnotationAction.java

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,48 @@
55
import javax.swing.JOptionPane;
66

77
import actions.menu.ActionsMenuBarTitles;
8+
import actions.singleinstanceoperations.SingleInstanceOperation;
89
import paintcomponents.PaintComponent;
910
import paintcomponents.annotations.TextAnnotation;
1011
import paintcomponents.data.DataTextPaintComponent;
1112
import ui.PaintPanel;
1213

13-
public class AddAnnotationAction extends PaintAction{
14-
14+
/**
15+
* add the annotation to a component
16+
*
17+
* @author muchi
18+
*
19+
*/
20+
public class AddAnnotationAction extends SingleInstanceOperation<PaintComponent>{
21+
22+
/**
23+
* ctor
24+
* @param panel the panel
25+
*/
1526
public AddAnnotationAction(PaintPanel panel) {
1627
super(panel);
1728
}
1829

30+
/**
31+
* @return the location of the button
32+
*/
1933
@Override
20-
public boolean canPerformAction() {
21-
//get selected components
22-
ArrayList<PaintComponent> items = panel.getSelectTool().getSelectedComponents();
23-
24-
if(items.size() != 1){
25-
return false;
26-
}
27-
if(!(items.get(0) instanceof DataTextPaintComponent)){
28-
return false;
29-
}
30-
return true;
34+
public String locationString() {
35+
return ActionsMenuBarTitles.Data().Annotations().Add().toString();
3136
}
3237

3338
@Override
34-
public void performAction() {
35-
ArrayList<PaintComponent> items = panel.getSelectTool().getSelectedComponents();
39+
protected void performActionOnInstance(PaintComponent instance) {
40+
// TODO Auto-generated method stub
3641
String annotations = JOptionPane
3742
.showInputDialog("Please specify the annotation of the component");
38-
new TextAnnotation(items.get(0), annotations);
43+
new TextAnnotation(instance, annotations);
3944

40-
panel.repaint();
4145
}
4246

4347
@Override
44-
public String locationString() {
45-
return ActionsMenuBarTitles.Data().Annotations().Add().toString();
48+
protected Class<PaintComponent> getGenericClassType() {
49+
return PaintComponent.class;
4650
}
4751

4852

src/actions/AddDataDisplayBoxAction.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ public void redoAction() {
3636
panel.addPaintComponent(comp);
3737
panel.repaint();
3838
}
39+
40+
@Override
41+
protected String commandName() {
42+
return "add data displayBox";
43+
}
44+
45+
@Override
46+
protected String commandDescription() {
47+
return "add a string display";
48+
}
49+
50+
3951
});
4052
panel.repaint();
4153
}

src/actions/AddDataInputBoxAction.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ public void redoAction() {
3838
panel.repaint();
3939

4040
}
41+
42+
@Override
43+
protected String commandName() {
44+
return "add data inputBox";
45+
}
46+
47+
@Override
48+
protected String commandDescription() {
49+
// TODO Auto-generated method stub
50+
return "add a string input";
51+
}
4152
});
4253
panel.repaint();
4354
}

src/actions/AddInstanceOperationAction.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ public void performAction() {
4646
cons[desiaredConstructorIndex], panel.getWidth() / 2,
4747
panel.getHeight() / 2);
4848
panel.addPaintComponent(consComp);
49-
// add action to undo redo manager
50-
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
51-
52-
@Override
53-
public void undoAction() {
54-
consComp.remove(panel);
55-
panel.repaint();
56-
}
57-
58-
@Override
59-
public void redoAction() {
60-
panel.addPaintComponent(consComp);
61-
panel.repaint();
62-
}
63-
});
49+
// // add action to undo redo manager
50+
// SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
51+
//
52+
// @Override
53+
// public void undoAction() {
54+
// consComp.remove(panel);
55+
// panel.repaint();
56+
// }
57+
//
58+
// @Override
59+
// public void redoAction() {
60+
// panel.addPaintComponent(consComp);
61+
// panel.repaint();
62+
// }
63+
// });
6464
panel.repaint();
6565
}
6666

src/actions/AddInteractiveConstructorAction.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ public void performAction() {
4444
panel.getHeight() / 2);
4545
panel.addPaintComponent(consComp);
4646
// add action to undo redo manager
47-
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
48-
49-
@Override
50-
public void undoAction() {
51-
consComp.remove(panel);
52-
panel.repaint();
53-
}
54-
55-
@Override
56-
public void redoAction() {
57-
panel.addPaintComponent(consComp);
58-
panel.repaint();
59-
}
60-
});
47+
// SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
48+
//
49+
// @Override
50+
// public void undoAction() {
51+
// consComp.remove(panel);
52+
// panel.repaint();
53+
// }
54+
//
55+
// @Override
56+
// public void redoAction() {
57+
// panel.addPaintComponent(consComp);
58+
// panel.repaint();
59+
// }
60+
// });
6161
panel.repaint();
6262
}
6363

src/actions/AddInteractiveJavaMethodComponentAction.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ public void performAction() {
5252
panel.getHeight() / 2);
5353
panel.addPaintComponent(methodComp);
5454
// add action to undo redo manager
55-
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
56-
57-
@Override
58-
public void undoAction() {
59-
methodComp.remove(panel);
60-
panel.repaint();
61-
}
62-
63-
@Override
64-
public void redoAction() {
65-
panel.addPaintComponent(methodComp);
66-
panel.repaint();
67-
}
68-
});
55+
// SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
56+
//
57+
// @Override
58+
// public void undoAction() {
59+
// methodComp.remove(panel);
60+
// panel.repaint();
61+
// }
62+
//
63+
// @Override
64+
// public void redoAction() {
65+
// panel.addPaintComponent(methodComp);
66+
// panel.repaint();
67+
// }
68+
// });
6969
panel.repaint();
7070
}
7171
public String getMethodsSelectionUI(Method[] methods) {

src/actions/AddLazyJavaClassAction.java

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import actions.menu.ActionsMenuBarTitles;
1010
import paintcomponents.java.lazy.ClassPaintComponent;
1111
import ui.PaintPanel;
12+
import ui.general.InputManager;
13+
import ui.general.InputManagerDelegate;
1214
import ui.helper.classsearch.ClassSearchFrame;
1315
import ui.helper.classsearch.ClassSearchFrameDelegateInterface;
14-
1516
public class AddLazyJavaClassAction extends PaintAction {
1617

1718
public AddLazyJavaClassAction(PaintPanel panel) {
@@ -25,49 +26,43 @@ public boolean canPerformAction() {
2526

2627
@Override
2728
public void performAction() {
28-
29-
ClassSearchFrame classSearchFrame = new ClassSearchFrame();
30-
classSearchFrame.setDelegate(new ClassSearchFrameDelegateInterface() {
29+
InputManager im = new InputManager();
30+
im.askForClass(panel,new InputManagerDelegate<Class>() {
3131

3232
@Override
33-
public void didSelectClass(String classname) {
34-
35-
try {
36-
Class classObj = Class.forName(classname);
37-
ClassPaintComponent comp = new ClassPaintComponent(classObj,
38-
panel.getWidth() / 2, panel.getHeight() / 2);
39-
panel.addPaintComponent(comp);
40-
// add action to undo redo manager
41-
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
42-
43-
@Override
44-
public void undoAction() {
45-
comp.remove(panel);
46-
panel.repaint();
47-
}
48-
49-
@Override
50-
public void redoAction() {
51-
panel.addPaintComponent(comp);
52-
panel.repaint();
53-
}
54-
});
55-
panel.repaint();
56-
} catch (ClassNotFoundException e) {
57-
e.printStackTrace();
58-
JOptionPane.showMessageDialog(panel,
59-
classname + " :: Class Not Found");
60-
}
61-
}
62-
});
63-
64-
65-
classSearchFrame.setVisible(true);
66-
classSearchFrame.setSize(new Dimension(300, 200));
67-
68-
69-
33+
public void didFinishInput(Class input) {
34+
ClassPaintComponent comp = new ClassPaintComponent(input,
35+
panel.getWidth() / 2, panel.getHeight() / 2);
36+
panel.addPaintComponent(comp);
37+
// add action to undo redo manager
38+
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
39+
40+
@Override
41+
public void undoAction() {
42+
comp.remove(panel);
43+
panel.repaint();
44+
}
45+
46+
@Override
47+
public void redoAction() {
48+
panel.addPaintComponent(comp);
49+
panel.repaint();
50+
}
7051

52+
@Override
53+
protected String commandName() {
54+
return "add lazy javaClass";
55+
}
56+
57+
@Override
58+
protected String commandDescription() {
59+
return "add a java class component";
60+
}
61+
});
62+
panel.repaint();
63+
}
64+
} );
65+
7166
}
7267

7368
@Override

src/actions/AddLazyJavaConstructorAction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ public void redoAction() {
5757
panel.addPaintComponent(consComp);
5858
panel.repaint();
5959
}
60+
61+
@Override
62+
protected String commandName() {
63+
return "add lazy javaConstructor";
64+
}
65+
66+
@Override
67+
protected String commandDescription() {
68+
return "add a lazily evaludated java constructor";
69+
}
6070
});
6171
panel.repaint();
6272
}

src/actions/AddLazyJavaFieldsComponentAction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public void redoAction() {
4848
panel.addPaintComponent(fieldsComp);
4949

5050
}
51+
52+
@Override
53+
protected String commandName() {
54+
return "add lazy javaFieldsComponent";
55+
}
56+
57+
@Override
58+
protected String commandDescription() {
59+
return "add a java fields component";
60+
}
5161
});
5262
panel.repaint();
5363
}

src/actions/AddLazyJavaMethodComponentAction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ public void redoAction() {
6060
panel.addPaintComponent(methodComp);
6161
panel.repaint();
6262
}
63+
64+
@Override
65+
protected String commandName() {
66+
return "add lazy javaMethodComponent";
67+
}
68+
69+
@Override
70+
protected String commandDescription() {
71+
return "add a lazily evaluated java method component";
72+
}
6373
});
6474
panel.repaint();
6575
}

0 commit comments

Comments
 (0)