99import actions .menu .ActionsMenuBarTitles ;
1010import paintcomponents .java .lazy .ClassPaintComponent ;
1111import ui .PaintPanel ;
12+ import ui .general .InputManager ;
13+ import ui .general .InputManagerDelegate ;
1214import ui .helper .classsearch .ClassSearchFrame ;
1315import ui .helper .classsearch .ClassSearchFrameDelegateInterface ;
14-
1516public 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
0 commit comments