import java.util.*;
public class Widget {
private String type;
private String text;
private boolean visible;
private int x;
private int y;
private int width;
private int height;
private int state;
private Map<String, Map<String, Object>> data;
private List<String> columns;
private String primaryKeyName;
private Widget1 widget;
private CurScreen curScreen;
private ScreenTemplates screenTemplates;
private SwingPresenter presenter;
public Widget(String type, String text, boolean visible, int x, int y, int width, int height, int state, Map<String, Map<String, Object>> data, List<String> columns, String primaryKeyName, ScreenTemplates screenTemplates, SwingPresenter presenter) {
this.type = type;
this.text = text;
this.visible = visible;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.state = state;
this.data = data;
this.columns = columns;
this.primaryKeyName = primaryKeyName;
this.screenTemplates = screenTemplates;
this.presenter = presenter;
}
public Map<String, Object> getValue() {
Map temp_nil3 = new HashMap<>();
temp_nil3.put("type",this.getType());
temp_nil3.put("text",this.getText());
temp_nil3.put("visible",this.getVisible());
temp_nil3.put("x",this.getX());
temp_nil3.put("y",this.getY());
temp_nil3.put("width",this.getWidth());
temp_nil3.put("height",this.getHeight());
temp_nil3.put("state",this.getState());
if (this.getType().equals("table")) {
temp_nil3.put("data",this.getData());
temp_nil3.put("columns",this.getColumns());
temp_nil3.put("primaryKeyName",this.getPrimaryKeyName());
}
return temp_nil3;
}
public String getType() {
return this.type;
}
public String getText() {
return this.text;
}
public boolean getVisible() {
return this.visible;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public int getState() {
return this.state;
}
public Map<String, Map<String, Object>> getData() {
return this.data;
}
public List<String> getColumns() {
return this.columns;
}
public String getPrimaryKeyName() {
return this.primaryKeyName;
}
public void changeX(String wid, int x) {
this.x = x;
this.presenter.setX(wid, x);
}
public void changeY(String wid, int y) {
this.y = y;
this.presenter.setY(wid, y);
}
public void changeVisible(String wid, boolean visible) {
this.visible = visible;
this.presenter.setVisible(wid, visible);
}
public void changeText(String text) {
this.text = text;
}
// public void updateFromWidget(String self, String scId, String wid, Map<String, Object> widget, String curScreen) {
// this.value = widget;
// }
public void updateDataFromState(String screenId, String widId, int state, String search1, String search2, String search3, String search4, String search5, String search7, String result, Map<String, Map<String, Object>> businessCardManagement) {
Map<String, Map<String, Object>> temp_if0;
if ((state==0)) {
Map<String, Map<String, Object>> temp_search0 = new HashMap<>();
for (String key: businessCardManagement.keySet()) {
boolean doesMatch = true;
if (search4 != null && !search4.isEmpty()) { // 会社名を指定
if (!key.contains(search4)) continue;
}
Map<String, Object> value = businessCardManagement.get(key);
Object address1 = value.get("住所1");
Object address2 = value.get("住所2");
Object businessDescription1 = value.get("事業内容1");
Object businessDescription2 = value.get("事業内容2");
Object companyOverview = value.get("会社概要");
Object contactPerson1 = value.get("担当者1");
Object contactPerson2 = value.get("担当者2");
Object contactPerson3 = value.get("担当者3");
Object contactPerson4 = value.get("担当者4");
if (search5 != null && !search5.isEmpty()) {
if ((address1 == null || !((String) address1).contains(search5))
&& (address2 == null || !((String) address2).contains(search5))) { // 住所1にも住所2にも含まれない
doesMatch = false;
}
}
if (doesMatch) {
if (search1 != null && !search1.isEmpty()) { // 事業内容1
doesMatch = false;
if ((businessDescription1 != null && ((String) businessDescription1).contains(search1))
|| (businessDescription2 != null && ((String) businessDescription2).contains(search1))) { // 事業内容1か事業内容2に含まれる
doesMatch = true;
} else {
if (search2 != null && !search2.isEmpty()) { // 事業内容2
if ((businessDescription1 != null && ((String) businessDescription1).contains(search2))
|| (businessDescription2 != null && ((String) businessDescription2).contains(search2))) { // 事業内容1か事業内容2に含まれる
doesMatch = true;
}
}
}
} else {
if (search2 != null && !search2.isEmpty()) { // 事業内容2
doesMatch = false;
if ((businessDescription1 != null && ((String) businessDescription1).contains(search2))
|| (businessDescription2 != null && ((String) businessDescription2).contains(search2))) { // 事業内容1か事業内容2に含まれる
doesMatch = true;
}
}
}
if (doesMatch) {
if (search3 != null && !search3.isEmpty()) { // 会社概要
if (companyOverview == null || !((String) companyOverview).contains(search3)) { // 会社概要に含まれない
doesMatch = false;
}
}
if (doesMatch) {
if (search7 != null && !search7.isEmpty()) { // 担当者
if ((contactPerson1 == null || !((String) contactPerson1).contains(search7))
&& (contactPerson2 == null || !((String) contactPerson2).contains(search7))
&& (contactPerson3 == null || !((String) contactPerson3).contains(search7))
&& (contactPerson4 == null || !((String) contactPerson4).contains(search7))) { // 担当者1にも担当者2にも担当者3にも担当者4にも含まれない
doesMatch = false;
}
}
}
}
}
if (doesMatch) {
temp_search0.put(key, businessCardManagement.get(key));
}
}
temp_if0 = temp_search0;
} else {
temp_if0 = this.data;
}
this.data = temp_if0;
this.presenter.setTable(screenId, widId, temp_if0);
}
public void textEvent(String wid, String nextText) {
this.text = nextText;
this.widget = screenTemplates.getScreenTemplate(curScreen.getValue()).getWidgets1().getWidget1(wid);
this.widget.updateTextFromText(wid, wid, wid, this.text, curScreen.getValue());
}
public void mouseEvent(String wid, int nextState) {
this.state = nextState;
this.widget = screenTemplates.getScreenTemplate(curScreen.getValue()).getWidgets1().getWidget1(wid);
this.widget.updateStateFromState(wid, wid, wid, this.state, curScreen.getValue());
}
public void setCurScreen(CurScreen curScreen) {
this.curScreen = curScreen;
}
}