|
@@ -18,12 +18,12 @@ import ui.view.*;
|
|
|
|
|
|
public class CategoryController {
|
|
|
|
|
|
- private IdCounter ID;
|
|
|
- private Model M;
|
|
|
+ private iDCounter ID;
|
|
|
+ private Model MODEL;
|
|
|
|
|
|
- public CategoryController(Model model, IdCounter id) {
|
|
|
+ public CategoryController(Model model, iDCounter id) {
|
|
|
this.ID = id;
|
|
|
- this.M = model;
|
|
|
+ this.MODEL = model;
|
|
|
initCategories();
|
|
|
}
|
|
|
|
|
@@ -64,12 +64,12 @@ public class CategoryController {
|
|
|
public void addCategory(Category toAdd) {
|
|
|
int number = 0;
|
|
|
String name = toAdd.getName();
|
|
|
- while (containsInList(M.getCategories(), toAdd)) {
|
|
|
+ while (containsInList(MODEL.getCategories(), toAdd)) {
|
|
|
number++;
|
|
|
toAdd.setName(name + "_" + number);
|
|
|
}
|
|
|
;
|
|
|
- M.getCategories().add(toAdd);
|
|
|
+ MODEL.getCategories().add(toAdd);
|
|
|
notifyCatListeners();
|
|
|
}
|
|
|
|
|
@@ -91,7 +91,7 @@ public class CategoryController {
|
|
|
* @return true if successfull, otherwise false
|
|
|
*/
|
|
|
public boolean deleteCategory(String catName) {
|
|
|
- int position = getPositionInList(M.getCategories(), searchCatNode(catName));
|
|
|
+ int position = getPositionInList(MODEL.getCategories(), searchCatNode(catName));
|
|
|
if (position != -1) {
|
|
|
deleteCategoryAt(position);
|
|
|
return true;
|
|
@@ -104,7 +104,7 @@ public class CategoryController {
|
|
|
* deletes a Category at given position
|
|
|
*/
|
|
|
public void deleteCategoryAt(int idx) {
|
|
|
- M.getCategories().remove(idx);
|
|
|
+ MODEL.getCategories().remove(idx);
|
|
|
notifyCatListeners();
|
|
|
}
|
|
|
|
|
@@ -187,15 +187,15 @@ public class CategoryController {
|
|
|
* @param catLis
|
|
|
*/
|
|
|
public void addCatListener(CategoryListener catLis) {
|
|
|
- M.getCategoryListeners().add(catLis);
|
|
|
+ MODEL.getCategoryListeners().add(catLis);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* notifies all listeners about changes in the Categories
|
|
|
*/
|
|
|
public void notifyCatListeners() {
|
|
|
- for (CategoryListener l : M.getCategoryListeners()) {
|
|
|
- l.onChange(M.getCategories());
|
|
|
+ for (CategoryListener l : MODEL.getCategoryListeners()) {
|
|
|
+ l.onChange(MODEL.getCategories());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -208,7 +208,7 @@ public class CategoryController {
|
|
|
public Category searchCatNode(String name) {
|
|
|
Category query = null;
|
|
|
|
|
|
- for (Category cat : M.getCategories()) {
|
|
|
+ for (Category cat : MODEL.getCategories()) {
|
|
|
if (cat.getName().equals(name)) {
|
|
|
query = cat;
|
|
|
break;
|