Skip to content

Commit e953fa9

Browse files
committed
Merge branch 'develop' into MYCBranch
2 parents b6260d1 + 82e7903 commit e953fa9

3 files changed

Lines changed: 48 additions & 32 deletions

File tree

src/actions/AddLazyJavaClassAction.java

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package actions;
22

3+
import java.awt.Dimension;
4+
35
import javax.swing.JOptionPane;
46

57
import actions.edit.undoredo.SharedUndoRedoActionManager;
@@ -8,6 +10,8 @@
810
import actions.menu.PaintActionMenuItem;
911
import paintcomponents.java.lazy.ClassPaintComponent;
1012
import ui.PaintPanel;
13+
import ui.helper.ClassSearchFrame;
14+
import ui.helper.ClassSearchFrameDelegateInterface;
1115

1216
public class AddLazyJavaClassAction extends PaintAction {
1317

@@ -19,37 +23,51 @@ public AddLazyJavaClassAction(PaintPanel panel) {
1923
public boolean canPerformAction() {
2024
return true;
2125
}
22-
26+
2327
@Override
2428
public void performAction() {
25-
String className = JOptionPane
26-
.showInputDialog("Please specify the name of the Java Class");
27-
try {
28-
Class classObj = Class.forName(className);
29-
ClassPaintComponent comp = new ClassPaintComponent(classObj,
30-
panel.getWidth() / 2, panel.getHeight() / 2);
31-
panel.addPaintComponent(comp);
32-
// add action to undo redo manager
33-
SharedUndoRedoActionManager.getSharedInstance().pushUndoableAction(new UndoRedoableInterface() {
29+
30+
ClassSearchFrame classSearchFrame = new ClassSearchFrame();
31+
classSearchFrame.setDelegate(new ClassSearchFrameDelegateInterface() {
32+
33+
@Override
34+
public void didSelectClass(String classname) {
3435

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

5472
}
5573

src/ui/helper/ClassSearchFrame.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public void run() {
101101
synchronized (searchingTextField) {
102102
searchText = searchingTextField.getText();
103103
}
104-
System.out.println("Searching for " + searchText);
105104
// start Search
106105
ArrayList<String> classesForName = searchUtil
107106
.classesForName(searchText);
@@ -142,11 +141,10 @@ public void actionPerformed(ActionEvent e) {
142141

143142
// User cancel the class search
144143
if (e.getSource() == btnCancel) {
145-
System.exit(0);
144+
setVisible(false);
145+
dispose();
146146
} else if (e.getSource() == btnConfirm) {
147147

148-
System.out.println("btnConfirm pressed");
149-
150148
// return the selected (or the first if no selected) class if the
151149
// table is not empty
152150
if (resultsTable.getRowCount() != 0) {
@@ -161,7 +159,8 @@ public void actionPerformed(ActionEvent e) {
161159

162160
}
163161

164-
System.exit(0);
162+
setVisible(false);
163+
dispose();
165164
}
166165
}
167166

src/ui/helper/ClassSearchFrameTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public void run() {
2121

2222
@Override
2323
public void didSelectClass(String classname) {
24-
// TODO Auto-generated method stub
25-
24+
System.out.println(classname);
2625
}
2726
});
2827

0 commit comments

Comments
 (0)