diff --git a/src/SwingPresenter.java b/src/SwingPresenter.java index 1aa8b62..ccd7512 100644 --- a/src/SwingPresenter.java +++ b/src/SwingPresenter.java @@ -171,9 +171,14 @@ } rowCount++; } - DefaultTableModel tableModel = new DefaultTableModel(tableData, columnsData); + DefaultTableModel tableModel = new DefaultTableModel(tableData, columnsData) { + @Override public boolean isCellEditable(int row, int column) { + return false; + } + }; JTable table = new JTable(tableModel); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table.getTableHeader().setReorderingAllowed(false); ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.addListSelectionListener(new ListSelectionListener() { @Override @@ -338,10 +343,15 @@ } rowCount++; } - DefaultTableModel tableModel = new DefaultTableModel(tableData, columnsData); + DefaultTableModel tableModel = new DefaultTableModel(tableData, columnsData) { + @Override public boolean isCellEditable(int row, int column) { + return false; + } + }; JTable table = new JTable(tableModel); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - ListSelectionModel selectionModel = table.getSelectionModel(); + table.getTableHeader().setReorderingAllowed(false); + ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { diff --git a/src/Widget.java b/src/Widget.java index 6f6067b..154d3db 100644 --- a/src/Widget.java +++ b/src/Widget.java @@ -102,32 +102,70 @@ public void updateDataFromState(String screenId, String widId, int state, String search1, String search2, String search3, String search4, String search5, String search6, String search7, String result, Map> businessCardManagement) { Map> temp_if0; if ((state==0)) { - Map temp_json92 = new HashMap<>(); - temp_json92.put("住所1", search5); - temp_json92.put("住所2", search6); - temp_json92.put("事業内容1", search1); - temp_json92.put("事業内容2", search2); - temp_json92.put("会社概要", search3); - temp_json92.put("担当者", search7); Map> temp_search0 = new HashMap<>(); for (String key: businessCardManagement.keySet()) { - boolean isMatch = true; + boolean doesMatch = true; if (search4 != null && !search4.isEmpty()) { // 会社名を指定 if (!key.contains(search4)) continue; } - for (String qKey: temp_json92.keySet()) { - Map value = businessCardManagement.get(key); - for (String valKey: value.keySet()) { - if (temp_json92.get(qKey) != null && !temp_json92.get(qKey).equals("") && valKey.equals(qKey)) { - if (!((String) value.get(valKey)).contains((String) temp_json92.get(qKey))) { - isMatch = false; + Map 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; + } } - break; + } + } 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 (!isMatch) break; + 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 (isMatch) { + if (doesMatch) { temp_search0.put(key, businessCardManagement.get(key)); } }