-
Notifications
You must be signed in to change notification settings - Fork 3
Kent branch Add more functionality on right click popup menu #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kent0318
wants to merge
5
commits into
develop_smarttool
Choose a base branch
from
KentBranch
base: develop_smarttool
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
85bc914
Add SelectToolInterface
kent0318 1210d9a
Add Remove to Popup Menu
kent0318 3eeb837
Merge branch 'develop' of https://github.com/UCSDOalads/JavaSketchPad…
kent0318 fe4f9b0
Add more functionality in right-click popup menu
kent0318 8460d5c
Merge branch 'develop' of https://github.com/UCSDOalads/JavaSketchPad…
kent0318 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,32 @@ | ||
package actions.add; | ||
|
||
import java.lang.reflect.Constructor; | ||
|
||
import actions.menu.ActionsMenuBarTitles; | ||
import actions.menu.ActionsPopupMenuTitles; | ||
import paintcomponents.java.lazy.ClassConstructorPaintComponent; | ||
import ui.PaintPanel; | ||
|
||
public class AddConstructor extends AddOperation<ClassConstructorPaintComponent> { | ||
|
||
private Constructor constructor; | ||
|
||
public AddConstructor(PaintPanel panel, Constructor constructor) { | ||
super(panel); | ||
// TODO Auto-generated constructor stub | ||
this.constructor = constructor; | ||
} | ||
|
||
@Override | ||
protected ClassConstructorPaintComponent getPaintComponentToAdd() { | ||
// TODO Auto-generated method stub | ||
return new ClassConstructorPaintComponent(constructor, 0, 0); | ||
} | ||
|
||
@Override | ||
public String locationString() { | ||
// TODO Auto-generated method stub | ||
return ActionsPopupMenuTitles.Constructor().append(constructor.toString()).toString(); | ||
} | ||
|
||
} |
This file contains hidden or 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,30 @@ | ||
package actions.add; | ||
|
||
import actions.menu.ActionsPopupMenuTitles; | ||
import paintcomponents.PaintComponent; | ||
import paintcomponents.java.lazy.FieldsPaintComponent; | ||
import ui.PaintPanel; | ||
|
||
public class AddFields extends AddOperation{ | ||
|
||
private Class displayingClass; | ||
|
||
public AddFields(PaintPanel panel, Class displayingClass) { | ||
super(panel); | ||
// TODO Auto-generated constructor stub | ||
this.displayingClass = displayingClass; | ||
} | ||
|
||
@Override | ||
protected PaintComponent getPaintComponentToAdd() { | ||
// TODO Auto-generated method stub | ||
return new FieldsPaintComponent(displayingClass, 0, 0); | ||
} | ||
|
||
@Override | ||
public String locationString() { | ||
// TODO Auto-generated method stub | ||
return ActionsPopupMenuTitles.Fields().toString(); | ||
} | ||
|
||
} |
This file contains hidden or 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,32 @@ | ||
package actions.add; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import actions.menu.ActionsPopupMenuTitles; | ||
import paintcomponents.java.lazy.ClassConstructorPaintComponent; | ||
import paintcomponents.java.lazy.MethodPaintComponent; | ||
import ui.PaintPanel; | ||
|
||
public class AddMethod extends AddOperation<MethodPaintComponent> { | ||
|
||
private Method method; | ||
|
||
public AddMethod(PaintPanel panel, Method method) { | ||
super(panel); | ||
// TODO Auto-generated constructor stub | ||
this.method = method; | ||
} | ||
|
||
@Override | ||
protected MethodPaintComponent getPaintComponentToAdd() { | ||
// TODO Auto-generated method stub | ||
return new MethodPaintComponent(method, 0, 0); | ||
} | ||
|
||
@Override | ||
public String locationString() { | ||
// TODO Auto-generated method stub | ||
return ActionsPopupMenuTitles.Method().append(method.toString()).toString(); | ||
} | ||
|
||
} |
This file contains hidden or 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,37 @@ | ||
package actions.add; | ||
|
||
import paintcomponents.PaintComponent; | ||
import paintcomponents.java.lazy.ClassConstructorPaintComponent; | ||
import ui.PaintPanel; | ||
import actions.PaintAction; | ||
|
||
/** | ||
* Subcalss should override getPaintComponentToAdd to provide an adder should the action be performed | ||
* @author cs12waft | ||
* | ||
* @param <T> | ||
*/ | ||
public abstract class AddOperation<T extends PaintComponent> extends PaintAction { | ||
|
||
public AddOperation(PaintPanel panel) { | ||
super(panel); | ||
} | ||
|
||
@Override | ||
public boolean canPerformAction() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void performAction() { | ||
PaintComponent consComp = getPaintComponentToAdd(); | ||
consComp.translate(panel.getWidth() / 2, panel.getHeight() / 2); | ||
panel.addPaintComponent(consComp); | ||
panel.repaint(); | ||
} | ||
|
||
protected abstract T getPaintComponentToAdd(); | ||
|
||
|
||
|
||
} |
This file contains hidden or 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,32 @@ | ||
package actions.menu; | ||
|
||
public class ActionsPopupMenuTitles { | ||
public String pending; | ||
|
||
public ActionsPopupMenuTitles(String string) { | ||
pending = string; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return pending; | ||
} | ||
|
||
public static ActionsPopupMenuTitles Remove(){ | ||
return new ActionsPopupMenuTitles("Remove"); | ||
} | ||
public static ActionsPopupMenuTitles Constructor(){ | ||
return new ActionsPopupMenuTitles("Constructor"); | ||
} | ||
public static ActionsPopupMenuTitles Method(){ | ||
return new ActionsPopupMenuTitles("Method"); | ||
} | ||
public static ActionsPopupMenuTitles Fields(){ | ||
return new ActionsPopupMenuTitles("Fields"); | ||
} | ||
public ActionsPopupMenuTitles append(String str) { | ||
pending += "/" + str; | ||
return this; | ||
} | ||
|
||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach (using instanceof) is dangerous, Please Comment on these two lines on the reason for selection.
Instanceof makes code unmaintanable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make a comment on the approach taken,
Include the following line: