-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from UCSDOalads/devBranchByUltimatePea
Merge Java Class IOs from devBranchByUltimatePea
- Loading branch information
Showing
31 changed files
with
1,164 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package actions; | ||
|
||
import javax.swing.JOptionPane; | ||
|
||
import actions.menu.ActionsMenuBarTitles; | ||
import actions.menu.PaintActionMenuItem; | ||
import paintcomponents.java.lazy.ClassPaintComponent; | ||
import ui.PaintPanel; | ||
|
||
public class AddLazyJavaClassAction extends PaintAction { | ||
|
||
public AddLazyJavaClassAction(PaintPanel panel) { | ||
super(panel); | ||
} | ||
|
||
@Override | ||
public boolean canPerformAction() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void performAction() { | ||
String className = JOptionPane | ||
.showInputDialog("Please specify the name of the Java Class"); | ||
try { | ||
Class classObj = Class.forName(className); | ||
panel.addPaintComponent(new ClassPaintComponent(classObj, | ||
panel.getWidth() / 2, panel.getHeight() / 2)); | ||
panel.repaint(); | ||
} catch (ClassNotFoundException e) { | ||
e.printStackTrace(); | ||
JOptionPane.showMessageDialog(panel, | ||
className + " :: Class Not Found"); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public String locationString() { | ||
return ActionsMenuBarTitles.Lazy().Add().Java_Class().toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package actions; | ||
|
||
import java.lang.reflect.Constructor; | ||
|
||
import javax.swing.JOptionPane; | ||
|
||
import actions.menu.ActionsMenuBarTitles; | ||
import paintcomponents.java.lazy.ClassConstructorPaintComponent; | ||
import paintcomponents.java.lazy.ClassPaintComponent; | ||
import ui.PaintPanel; | ||
|
||
public class AddLazyJavaConstructorAction extends PaintAction { | ||
|
||
public AddLazyJavaConstructorAction(PaintPanel panel) { | ||
super(panel); | ||
} | ||
|
||
@Override | ||
public boolean canPerformAction() { | ||
if (panel.getSelectTool().getSelectedComponents().size() != 1) { | ||
return false; | ||
} | ||
if (panel.getSelectTool().getSelectedComponents() | ||
.get(0) instanceof ClassPaintComponent) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void performAction() { | ||
ClassPaintComponent comp = (ClassPaintComponent) panel.getSelectTool() | ||
.getSelectedComponents().get(0); | ||
Constructor[] cons = comp.getDisplayingClass().getConstructors(); | ||
|
||
int desiaredConstructorIndex = Integer | ||
.parseInt(JOptionPane.showInputDialog( | ||
"Please enter the index of the constructor you would like to use: \n\n\n" | ||
+ getConstructorsSelectionUI(cons))); | ||
ClassConstructorPaintComponent consComp = new ClassConstructorPaintComponent( | ||
cons[desiaredConstructorIndex], panel.getWidth() / 2, | ||
panel.getHeight() / 2); | ||
panel.addPaintComponent(consComp); | ||
panel.repaint(); | ||
|
||
} | ||
|
||
public String getConstructorsSelectionUI(Constructor[] cons) { | ||
StringBuilder builder = new StringBuilder(); | ||
for (int i = 0; i < cons.length; i++) { | ||
Constructor constructor = cons[i]; | ||
builder.append(i + " : " + constructor.toString() + "\n"); | ||
} | ||
return builder.toString(); | ||
|
||
} | ||
|
||
@Override | ||
public String locationString() { | ||
return ActionsMenuBarTitles.Lazy().Add().Java_Constructor().toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package actions; | ||
|
||
import actions.menu.ActionsMenuBarTitles; | ||
import paintcomponents.java.lazy.ClassPaintComponent; | ||
import paintcomponents.java.lazy.FieldsPaintComponent; | ||
import ui.PaintPanel; | ||
|
||
public class AddLazyJavaFieldsComponentAction extends PaintAction { | ||
|
||
public AddLazyJavaFieldsComponentAction(PaintPanel panel) { | ||
super(panel); | ||
} | ||
//TODO | ||
//NOTE: I am copying from Constructor and Methods, consider refinement | ||
@Override | ||
public boolean canPerformAction() { | ||
if (panel.getSelectTool().getSelectedComponents().size() != 1) { | ||
return false; | ||
} | ||
if (panel.getSelectTool().getSelectedComponents() | ||
.get(0) instanceof ClassPaintComponent) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
@Override | ||
public void performAction() { | ||
ClassPaintComponent comp = (ClassPaintComponent) panel.getSelectTool() | ||
.getSelectedComponents().get(0); | ||
|
||
FieldsPaintComponent fieldsComp = | ||
new FieldsPaintComponent(comp.getDisplayingClass(), | ||
panel.getWidth() / 2, | ||
panel.getHeight() / 2); | ||
panel.addPaintComponent(fieldsComp); | ||
panel.repaint(); | ||
} | ||
|
||
@Override | ||
public String locationString() { | ||
return ActionsMenuBarTitles.Lazy().Add().Java_Fields().toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package actions; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import javax.swing.JOptionPane; | ||
|
||
import actions.menu.ActionsMenuBarTitles; | ||
import paintcomponents.java.lazy.ClassConstructorPaintComponent; | ||
import paintcomponents.java.lazy.ClassPaintComponent; | ||
import paintcomponents.java.lazy.MethodPaintComponent; | ||
import ui.PaintPanel; | ||
|
||
public class AddLazyJavaMethodComponentAction extends PaintAction { | ||
|
||
public AddLazyJavaMethodComponentAction(PaintPanel panel) { | ||
super(panel); | ||
} | ||
|
||
//TODO | ||
//NOTE: I am copying from Constructor, consider refinement | ||
@Override | ||
public boolean canPerformAction() { | ||
if (panel.getSelectTool().getSelectedComponents().size() != 1) { | ||
return false; | ||
} | ||
if (panel.getSelectTool().getSelectedComponents() | ||
.get(0) instanceof ClassPaintComponent) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void performAction() { | ||
ClassPaintComponent comp = (ClassPaintComponent) panel.getSelectTool() | ||
.getSelectedComponents().get(0); | ||
Method[] methods = comp.getDisplayingClass().getMethods(); | ||
|
||
int desiaredConstructorIndex = Integer | ||
.parseInt(JOptionPane.showInputDialog( | ||
"Please enter the index of the constructor you would like to use: \n\n\n" | ||
+ getMethodsSelectionUI(methods))); | ||
MethodPaintComponent methodComp = new MethodPaintComponent( | ||
methods[desiaredConstructorIndex], panel.getWidth() / 2, | ||
panel.getHeight() / 2); | ||
panel.addPaintComponent(methodComp); | ||
panel.repaint(); | ||
} | ||
public String getMethodsSelectionUI(Method[] methods) { | ||
StringBuilder builder = new StringBuilder(); | ||
for (int i = 0; i < methods.length; i++) { | ||
Method constructor = methods[i]; | ||
builder.append(i + " : " + constructor.toString() + "\n"); | ||
} | ||
return builder.toString(); | ||
|
||
} | ||
@Override | ||
public String locationString() { | ||
return ActionsMenuBarTitles.Lazy().Add().Java_Method().toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.