Skip to content

Commit 1c126e4

Browse files
authored
Merge pull request #146 from UCSDOalads/funcGroup
Fixed bug: Class Box is no longer updatable
2 parents ef0ef15 + a300abf commit 1c126e4

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/actions/InputDataForDataInputBoxAction.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ public InputDataForDataInputBoxAction(PaintPanel panel) {
2121
public boolean canPerformAction() {
2222
ArrayList<PaintComponent> comps = panel.getSelectTool().getSelectedComponents();
2323
if(comps.size()!= 1) return false;
24-
if (comps.get(0) instanceof DataInputTextfieldPaintComponent) {
25-
return true;
24+
Object comp = comps.get(0);
25+
if (comp instanceof DataInputTextfieldPaintComponent) {
26+
//Make sure this is not a class box
27+
if( ((DataInputTextfieldPaintComponent) comp).canUpdate()){
28+
return true;
29+
}
2630
}
2731
return false;
2832
}

src/actions/global/globalactions/AddLazyJavaClassGlobalAction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public void setClassToCreate(Class classToCreate) {
2323
@Override
2424
protected void execute(PaintPanel panel) {
2525
ClassPaintComponent comp = new ClassPaintComponent(classToCreate, x, y);
26+
//The class input box shouldn't be updatable.
27+
comp.setCannotUpdate();
2628
panel.addPaintComponent(comp);
2729

2830
if (panel.getSelectTool() != null) {

src/paintcomponents/data/DataInputTextfieldPaintComponent.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public class DataInputTextfieldPaintComponent extends DataTextIOPaintComponent
1616
implements DataFromPointDataProvider{
1717

1818

19+
//Protect the class box from being updated
20+
boolean canUpdate = true;
21+
1922
public DataInputTextfieldPaintComponent(String displayingText, int x,
2023
int y) {
2124
super(displayingText, x, y);
@@ -52,8 +55,19 @@ public DataInputTextfieldPaintComponent(Element rootElement, PaintPanel panel) {
5255
linkPoints(rootElement);
5356
}
5457

58+
/*
59+
* Set this input box to be "in-updatable"
60+
* Now this should only be used by the class input box
61+
*/
62+
public void setCannotUpdate(){
63+
this.canUpdate = false;
64+
}
5565

56-
66+
/*
67+
* Getter for whether it's updatable.
68+
*/
69+
public boolean canUpdate(){
70+
return this.canUpdate;
71+
}
5772

58-
5973
}

0 commit comments

Comments
 (0)