Skip to content

Commit 2380ca8

Browse files
committed
conlfict resolved
2 parents c1d76d1 + 59cf778 commit 2380ca8

5 files changed

Lines changed: 51 additions & 5 deletions

File tree

src/actions/AddLazyJavaMethodComponentAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ public void performAction() {
4646
String desiaredConstructorIndex = JOptionPane.showInputDialog(
4747
"Please enter the index of the constructor you would like to use: \n\n\n"
4848

49+
4950
+ getMethodsSelectionUI(methods));
5051
//call DialogInputChecker to check input
5152
DialogInputChecker inputChecker = new DialogInputChecker();
5253
if(inputChecker.isValidNumber(desiaredConstructorIndex, 0, methods.length -1)){
5354
AddLazyJavaMethodComponentGlobalAction assiciatedAction
5455
= (AddLazyJavaMethodComponentGlobalAction) ActionName.ADD_LAZY_JAVA_METHOD_ACTION.getAssiciatedAction();
5556
assiciatedAction.setMethodComponent(comp);
56-
assiciatedAction.setMethod(String.class.getMethods()[Integer.parseInt(desiaredConstructorIndex)]);
57+
assiciatedAction.setMethod(comp.getDisplayingClass().getMethods()[Integer.parseInt(desiaredConstructorIndex)]);
5758
GlobalPaintActionExecuter.getSharedInstance().execute(assiciatedAction, panel);
5859
}
5960
}

src/actions/InputDataForDataInputBoxAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ 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){
24+
if (comps.get(0) instanceof DataInputTextfieldPaintComponent) {
2525
return true;
2626
}
2727
return false;

src/actions/global/globalactions/FileOpenAndSaveGlobalActionTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import actions.global.GlobalPaintActionExecuter;
1515
import paintcomponents.java.lazy.ClassPaintComponent;
1616
import ui.PaintPanel;
17+
import java.io.File;
18+
import java.nio.file.Files;
1719

1820
/*
1921
* @author Yidong Luo
@@ -39,7 +41,7 @@ public void test() {
3941
FileSaveAsGlobalAction fileSaveAssociatedAction
4042
= (FileSaveAsGlobalAction) ActionName.FILE_SAVE_AS_GLOBAL_ACTION
4143
.getAssiciatedAction();
42-
fileSaveAssociatedAction.setFilePath("temp.xml");
44+
fileSaveAssociatedAction.setFilePath("JSPFileSaveOpenTest.xml");
4345
fileSaveAssociatedAction.execute(panel);
4446

4547

@@ -54,15 +56,18 @@ public void test() {
5456
FileOpenGlobalAction fileOpenAssociatedAction
5557
= (FileOpenGlobalAction) ActionName.FILE_OPEN_GLOBAL_ACTION
5658
.getAssiciatedAction();
57-
fileOpenAssociatedAction.setFileToOpen("temp.xml");
59+
fileOpenAssociatedAction.setFileToOpen("JSPFileSaveOpenTest.xml");
5860
fileOpenAssociatedAction.execute(panel);
5961

6062
//Components on the panel should be the same as what was saved to be
6163
assertEquals(1, panel.getPaintComponents().size());
6264
assertTrue(panel.getPaintComponents().get(0)
6365
instanceof ClassPaintComponent);
6466

65-
67+
File xml = new File("JSPFileSaveOpenTest.xml");
68+
69+
xml.delete();
70+
6671
}
6772

6873
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package painttools.tools;
2+
3+
public @interface DefaultPaintTool {
4+
5+
}

src/painttools/tools/SelectTool.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
import java.awt.event.MouseEvent;
44
import java.util.ArrayList;
55

6+
7+
import javax.swing.ImageIcon;
8+
9+
import actions.InputDataForDataInputBoxAction;
610
import buttons.ToolButton;
711
import paintcomponents.PaintComponent;
12+
import paintcomponents.data.DataInputTextfieldPaintComponent;
813
import settings.Defaults;
914
import ui.PaintPanel;
1015
import ui.icons.CustomIcons;
@@ -64,10 +69,17 @@ public void mouseClicked(MouseEvent e) {
6469
* @param comp
6570
*/
6671
public void selectComponent(PaintComponent comp) {
72+
6773
comp.select(this);
74+
75+
// update the components listening to select tool
6876
for (SelectionToolListener selectionToolListener : listeners) {
6977
selectionToolListener.selectionChanged();
7078
}
79+
80+
// prompt data input if user double clicked on a selected data box
81+
doubleClickAction(comp);
82+
7183
panel.repaint();
7284
}
7385

@@ -78,6 +90,11 @@ public void selectComponent(PaintComponent comp) {
7890
* @param comp
7991
*/
8092
public void deselectComponent(PaintComponent comp) {
93+
94+
// check if double clicked, if so perform the action on the data box
95+
doubleClickAction(comp);
96+
97+
// then deselect the component
8198
comp.deselect(this);
8299
for (SelectionToolListener selectionToolListener : listeners) {
83100
selectionToolListener.selectionChanged();
@@ -285,4 +302,22 @@ public void removeSelectedComponent(PaintComponent pc){
285302
selectedComponents.remove(pc);
286303
}
287304

305+
306+
/**
307+
* Check if user double clicked a data box and it will prompt user to type
308+
* data if double clicked on a selected or de-selected data box
309+
*
310+
* @param comp
311+
*/
312+
private void doubleClickAction(PaintComponent comp) {
313+
314+
// data input box prompt right after a double click on the box
315+
if (comp instanceof DataInputTextfieldPaintComponent && getLastMouseEvent().getClickCount() == 2
316+
&& !getLastMouseEvent().isConsumed()) {
317+
318+
InputDataForDataInputBoxAction newAction = new InputDataForDataInputBoxAction(panel);
319+
newAction.performAction();
320+
getLastMouseEvent().consume();
321+
}
322+
}
288323
}

0 commit comments

Comments
 (0)