From 02553e48b8959e77fca8a681ec14cd3be01a88a0 Mon Sep 17 00:00:00 2001 From: flanflanagan Date: Sat, 6 Jun 2015 21:44:05 -0500 Subject: [PATCH 1/3] removing a one or more now updates commodites lists --- cyclist/src/edu/utexas/cycic/FormBuilder.java | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/cyclist/src/edu/utexas/cycic/FormBuilder.java b/cyclist/src/edu/utexas/cycic/FormBuilder.java index 37a4f181..4d2f3892 100644 --- a/cyclist/src/edu/utexas/cycic/FormBuilder.java +++ b/cyclist/src/edu/utexas/cycic/FormBuilder.java @@ -136,9 +136,10 @@ public void handle(ActionEvent e){ public Button arrayListRemove(final GridPane grid, final ArrayList dataArray, final int dataArrayNumber, ArrayList facArray){ Button button = new Button(); button.setText("Remove"); - ArrayList tempData = (ArrayList) ((ArrayList) dataArray.get(dataArrayNumber)).get(0); button.setOnAction(new EventHandler(){ public void handle(ActionEvent e) { + commodRemoval((ArrayList) facArray.get(1), (ArrayList) dataArray.get(dataArrayNumber)); + VisFunctions.redrawPane(); dataArray.remove(dataArrayNumber); if(dataArray.size() == 0){ facArray.set(10, false); @@ -152,6 +153,46 @@ public void handle(ActionEvent e) { return button; } + /** + * + * @param facArray + * @param dataArray + */ + public void commodRemoval(ArrayList facArray, ArrayList dataArray){ + System.out.println(facArray); + System.out.println(dataArray); + if(facArray.get(0) instanceof ArrayList){ + for(int i = 0; i < facArray.size(); i++){ + commodRemoval((ArrayList) facArray.get(i), (ArrayList) dataArray.get(i)); + } + } else if(facArray.get(1) instanceof ArrayList){ + for(int i = 0; i < dataArray.size(); i++){ + commodRemoval((ArrayList) facArray.get(1), (ArrayList) dataArray.get(i)); + } + } else { + System.out.println("SOMETHING " + facArray); + System.out.println("SOMETHING " + dataArray); + switch ((String) facArray.get(2).toString().toLowerCase()){ + case "incommodity": + for(int i = 0; i < formNode.cycicCircle.incommods.size(); i++){ + if(dataArray.get(0).toString().equalsIgnoreCase(formNode.cycicCircle.incommods.get(i))){ + formNode.cycicCircle.incommods.remove(i); + break; + } + } + break; + case "outcommodity": + for(int i = 0; i < formNode.cycicCircle.outcommods.size(); i++){ + if(dataArray.get(0).toString().equalsIgnoreCase(formNode.cycicCircle.outcommods.get(i))){ + formNode.cycicCircle.outcommods.remove(i); + break; + } + } + break; + } + } + } + /** * This function builds an input form from the data structures associated * with a facility. From 756817a081b1972fb43d5240554281cc287f3c9f Mon Sep 17 00:00:00 2001 From: flanflanagan Date: Sun, 7 Jun 2015 15:51:46 -0500 Subject: [PATCH 2/3] fixed linking bug --- .../utexas/cycic/FormBuilderFunctions.java | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/cyclist/src/edu/utexas/cycic/FormBuilderFunctions.java b/cyclist/src/edu/utexas/cycic/FormBuilderFunctions.java index 269272d1..83b224e3 100644 --- a/cyclist/src/edu/utexas/cycic/FormBuilderFunctions.java +++ b/cyclist/src/edu/utexas/cycic/FormBuilderFunctions.java @@ -281,11 +281,11 @@ static ComboBox comboBoxInCommod(final facilityNode facNode, ArrayList(){ public void handle(MouseEvent e){ - for(int i =0; i < facNode.cycicCircle.incommods.size(); i++){ + /*for(int i =0; i < facNode.cycicCircle.incommods.size(); i++){ if(facNode.cycicCircle.incommods.get(i) == cb.getValue()){ facNode.cycicCircle.incommods.remove(i); } - } + }*/ cb.getItems().clear(); for(CommodityNode label: DataArrays.CommoditiesList){ @@ -293,7 +293,7 @@ public void handle(MouseEvent e){ } cb.getItems().add("New Commodity"); - if(!defaultValue.get(0).equals("")) { + if(defaultValue.get(0) != null) { cb.setValue((String) defaultValue.get(0)); } } @@ -304,7 +304,15 @@ public void handle(MouseEvent e){ cb.setPromptText("Select a commodity"); cb.valueProperty().addListener(new ChangeListener(){ public void changed(ObservableValue observable, String oldValue, String newValue){ - if (newValue == "New Commodity"){ + if(newValue == null){ + for (int i = 0; i < facNode.cycicCircle.incommods.size(); i++) { + if (facNode.cycicCircle.incommods.get(i) == (String) oldValue){ + String string = facNode.cycicCircle.incommods.remove(i); + System.out.println(string); + break; + } + } + } else if (newValue == "New Commodity"){ Cycic.addNewCommodity(); } else { facNode.cycicCircle.incommods.add(newValue); @@ -314,7 +322,8 @@ public void changed(ObservableValue observable, String oldValu } for (int i = 0; i < facNode.cycicCircle.incommods.size(); i++) { if (facNode.cycicCircle.incommods.get(i) == (String) oldValue){ - facNode.cycicCircle.incommods.remove(i); + String string = facNode.cycicCircle.incommods.remove(i); + System.out.println("SECOND " + string); break; } } @@ -340,18 +349,18 @@ static ComboBox comboBoxOutCommod(final facilityNode facNode, ArrayList< cb.setOnMousePressed(new EventHandler(){ public void handle(MouseEvent e){ - for(int i = 0; i < facNode.cycicCircle.outcommods.size(); i++){ - if(facNode.cycicCircle.outcommods.get(i) == cb.getValue()){ - facNode.cycicCircle.outcommods.remove(i); - } + /*for(int i = 0; i < facNode.cycicCircle.outcommods.size(); i++){ + if(facNode.cycicCircle.outcommods.get(i) == cb.getValue()){ + facNode.cycicCircle.outcommods.remove(i); } + }*/ cb.getItems().clear(); for (CommodityNode label: DataArrays.CommoditiesList){ cb.getItems().add(label.name.getText()); } cb.getItems().add("New Commodity"); - if (defaultValue.get(0) != "") { + if (defaultValue.get(0) != null) { cb.setValue((String) defaultValue.get(0)); } } @@ -362,7 +371,14 @@ public void handle(MouseEvent e){ cb.setPromptText("Select a commodity"); cb.valueProperty().addListener(new ChangeListener(){ public void changed(ObservableValue observable, String oldValue, String newValue){ - if (newValue == "New Commodity"){ + if(newValue == null){ + for (int i = 0; i < facNode.cycicCircle.outcommods.size(); i++) { + if (facNode.cycicCircle.outcommods.get(i) == (String) oldValue){ + facNode.cycicCircle.outcommods.remove(i); + break; + } + } + } else if (newValue == "New Commodity"){ Cycic.addNewCommodity(); } else { facNode.cycicCircle.outcommods.add(newValue); From 3d996778e864af0930a272158d07602f2b13b288 Mon Sep 17 00:00:00 2001 From: flanflanagan Date: Mon, 8 Jun 2015 10:21:33 -0500 Subject: [PATCH 3/3] need to communicate changes to formViews --- cyclist/src/edu/utexas/cycic/Cycic.java | 28 +++++++++++++++++++ .../edu/utexas/cycic/CycicNotifications.java | 1 + cyclist/src/edu/utexas/cycic/FormBuilder.java | 4 --- .../utexas/cycic/FormBuilderFunctions.java | 1 - .../cycic/presenter/CycicPresenter.java | 6 +++- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/cyclist/src/edu/utexas/cycic/Cycic.java b/cyclist/src/edu/utexas/cycic/Cycic.java index 50a89b22..97b0f519 100644 --- a/cyclist/src/edu/utexas/cycic/Cycic.java +++ b/cyclist/src/edu/utexas/cycic/Cycic.java @@ -58,12 +58,14 @@ import edu.utah.sci.cyclist.Cyclist; import edu.utah.sci.cyclist.core.controller.CyclistController; import edu.utah.sci.cyclist.core.event.dnd.DnD; +import edu.utah.sci.cyclist.core.event.notification.CyclistNotification; import edu.utah.sci.cyclist.core.model.CyclusJob; import edu.utah.sci.cyclist.core.model.CyclusJob.Status; import edu.utah.sci.cyclist.core.model.Preferences; import edu.utah.sci.cyclist.core.ui.components.ViewBase; import edu.utah.sci.cyclist.core.util.AwesomeIcon; import edu.utah.sci.cyclist.core.util.GlyphRegistry; +import edu.utexas.cycic.presenter.CycicPresenter; public class Cycic extends ViewBase{ static Logger log = Logger.getLogger(Cycic.class); @@ -552,6 +554,7 @@ public void handle(ActionEvent e){ facility.cycicCircle.outcommods.remove(i); } } + commodListRm(facility.facilityStructure, facility.facilityData, commod); } VisFunctions.redrawPane(); buildCommodPane(); @@ -907,4 +910,29 @@ private void export() { } } + public static void commodListRm(ArrayList facArray, ArrayList dataArray, String commod){ + if(facArray.get(0) instanceof ArrayList){ + for(int i = 0; i < facArray.size(); i++){ + commodListRm((ArrayList) facArray.get(i), (ArrayList) dataArray.get(i), commod); + } + } else if(facArray.get(1) instanceof ArrayList){ + for(int i = 0; i < dataArray.size(); i++){ + commodListRm((ArrayList) facArray.get(1), (ArrayList) dataArray.get(i), commod); + } + } else { + switch ((String) facArray.get(2).toString().toLowerCase()){ + case "incommodity": + if(dataArray.get(0).toString().equalsIgnoreCase(commod)){ + dataArray.set(0, ""); + } + break; + case "outcommodity": + if(dataArray.get(0).toString().equalsIgnoreCase(commod)){ + dataArray.set(0, ""); + } + break; + } + } + } + } diff --git a/cyclist/src/edu/utexas/cycic/CycicNotifications.java b/cyclist/src/edu/utexas/cycic/CycicNotifications.java index b08ed38c..5e274f02 100644 --- a/cyclist/src/edu/utexas/cycic/CycicNotifications.java +++ b/cyclist/src/edu/utexas/cycic/CycicNotifications.java @@ -3,5 +3,6 @@ public class CycicNotifications { public static final String NEW_INSTIT = "new_instit"; + public static final String FORM_REDRAW = "form_redraw"; } diff --git a/cyclist/src/edu/utexas/cycic/FormBuilder.java b/cyclist/src/edu/utexas/cycic/FormBuilder.java index 4d2f3892..885ac659 100644 --- a/cyclist/src/edu/utexas/cycic/FormBuilder.java +++ b/cyclist/src/edu/utexas/cycic/FormBuilder.java @@ -159,8 +159,6 @@ public void handle(ActionEvent e) { * @param dataArray */ public void commodRemoval(ArrayList facArray, ArrayList dataArray){ - System.out.println(facArray); - System.out.println(dataArray); if(facArray.get(0) instanceof ArrayList){ for(int i = 0; i < facArray.size(); i++){ commodRemoval((ArrayList) facArray.get(i), (ArrayList) dataArray.get(i)); @@ -170,8 +168,6 @@ public void commodRemoval(ArrayList facArray, ArrayList dataArra commodRemoval((ArrayList) facArray.get(1), (ArrayList) dataArray.get(i)); } } else { - System.out.println("SOMETHING " + facArray); - System.out.println("SOMETHING " + dataArray); switch ((String) facArray.get(2).toString().toLowerCase()){ case "incommodity": for(int i = 0; i < formNode.cycicCircle.incommods.size(); i++){ diff --git a/cyclist/src/edu/utexas/cycic/FormBuilderFunctions.java b/cyclist/src/edu/utexas/cycic/FormBuilderFunctions.java index 83b224e3..8aea37ba 100644 --- a/cyclist/src/edu/utexas/cycic/FormBuilderFunctions.java +++ b/cyclist/src/edu/utexas/cycic/FormBuilderFunctions.java @@ -323,7 +323,6 @@ public void changed(ObservableValue observable, String oldValu for (int i = 0; i < facNode.cycicCircle.incommods.size(); i++) { if (facNode.cycicCircle.incommods.get(i) == (String) oldValue){ String string = facNode.cycicCircle.incommods.remove(i); - System.out.println("SECOND " + string); break; } } diff --git a/cyclist/src/edu/utexas/cycic/presenter/CycicPresenter.java b/cyclist/src/edu/utexas/cycic/presenter/CycicPresenter.java index 548d679e..2ee12ee4 100644 --- a/cyclist/src/edu/utexas/cycic/presenter/CycicPresenter.java +++ b/cyclist/src/edu/utexas/cycic/presenter/CycicPresenter.java @@ -5,14 +5,17 @@ import edu.utah.sci.cyclist.core.event.notification.EventBus; import edu.utah.sci.cyclist.core.presenter.ViewPresenter; import edu.utah.sci.cyclist.core.presenter.CyclistViewPresenter; +import edu.utah.sci.cyclist.core.event.notification.CyclistNotification; import edu.utah.sci.cyclist.core.event.notification.CyclistNotifications; import edu.utah.sci.cyclist.core.event.notification.CyclistViewNotification; +import edu.utah.sci.cyclist.core.event.notification.SimpleNotification; import edu.utah.sci.cyclist.core.ui.View; import edu.utah.sci.cyclist.core.model.Table; +import edu.utexas.cycic.CycicNotifications; public class CycicPresenter extends ViewPresenter { - + /** * CycicPresenter * Constructor @@ -40,5 +43,6 @@ public void call() { public void onViewSelected(View view) { super.onViewSelected(view); } + } \ No newline at end of file