11package actions ;
22
3+ import java .awt .Dimension ;
4+
35import javax .swing .JOptionPane ;
46
57import actions .edit .undoredo .SharedUndoRedoActionManager ;
68import actions .edit .undoredo .UndoRedoableInterface ;
79import actions .menu .ActionsMenuBarTitles ;
8- import actions .menu .PaintActionMenuItem ;
910import paintcomponents .java .lazy .ClassPaintComponent ;
1011import ui .PaintPanel ;
12+ import ui .helper .classsearch .ClassSearchFrame ;
13+ import ui .helper .classsearch .ClassSearchFrameDelegateInterface ;
1114
1215public class AddLazyJavaClassAction extends PaintAction {
1316
@@ -19,37 +22,51 @@ public AddLazyJavaClassAction(PaintPanel panel) {
1922 public boolean canPerformAction () {
2023 return true ;
2124 }
22-
25+
2326 @ Override
2427 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 () {
28+
29+ ClassSearchFrame classSearchFrame = new ClassSearchFrame ();
30+ classSearchFrame .setDelegate (new ClassSearchFrameDelegateInterface () {
31+
32+ @ Override
33+ public void didSelectClass (String classname ) {
3434
35- @ Override
36- public void undoAction () {
37- comp .remove (panel );
38- panel .repaint ();
39- }
40-
41- @ Override
42- public void redoAction () {
35+ try {
36+ Class classObj = Class .forName (classname );
37+ ClassPaintComponent comp = new ClassPaintComponent (classObj ,
38+ panel .getWidth () / 2 , panel .getHeight () / 2 );
4339 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+ });
4455 panel .repaint ();
56+ } catch (ClassNotFoundException e ) {
57+ e .printStackTrace ();
58+ JOptionPane .showMessageDialog (panel ,
59+ classname + " :: Class Not Found" );
4560 }
46- });
47- panel .repaint ();
48- } catch (ClassNotFoundException e ) {
49- e .printStackTrace ();
50- JOptionPane .showMessageDialog (panel ,
51- className + " :: Class Not Found" );
52- }
61+ }
62+ });
63+
64+
65+ classSearchFrame .setVisible (true );
66+ classSearchFrame .setSize (new Dimension (300 , 200 ));
67+
68+
69+
5370
5471 }
5572
0 commit comments