From 77d58298d00c11ade8862ca8acb0fdef5a45322e Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期五, 21 三月 2025 17:39:38 +0800
Subject: [PATCH] 修改
---
src/main/java/com/example/client/service/Level3View2Service.java | 109 +++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 91 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/example/client/service/Level3View2Service.java b/src/main/java/com/example/client/service/Level3View2Service.java
index 31d2cfc..dee2b1c 100644
--- a/src/main/java/com/example/client/service/Level3View2Service.java
+++ b/src/main/java/com/example/client/service/Level3View2Service.java
@@ -3,9 +3,7 @@
import com.example.client.dto.ColumnDto;
import com.example.client.dto.JComboBoxItem;
import com.example.client.model.TableButton;
-import com.example.client.utils.CommonTable;
-import com.example.client.utils.GBC;
-import com.example.client.utils.MultiSelectComboBox;
+import com.example.client.utils.*;
import com.example.server.cabin.service.CabinService;
import com.example.server.progressTrack.Dto.TableNodeDto;
import com.example.server.progressTrack.model.DjJdgzNetworkLevel1;
@@ -18,6 +16,7 @@
import javax.swing.*;
import javax.swing.event.TableModelEvent;
+import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.*;
@@ -35,6 +34,8 @@
private SysTeamGroupClassService sysTeamGroupClassService;
@Autowired
private CabinService cabinService;
+ @Autowired
+ private StatisProductService statisProductService;
private JTable table;
private List<TableNodeDto> list;
@@ -42,8 +43,8 @@
private List<ColumnDto> columnDto;
- public JPanel createTable(Integer width, Integer height) {
- JPanel panel = new JPanel();
+ public JPanel createTable(Integer width, Integer height,JFrame frame) {
+ JPanel panel = new JPanel(new BorderLayout());
JPanel topJpanel = new JPanel();
GridBagLayout layout = new GridBagLayout();
@@ -52,7 +53,7 @@
topJpanel.setBackground(Color.WHITE);
JPanel centerJpanel = new JPanel();
- centerJpanel.setPreferredSize(new Dimension(width - 20, height - 100));
+ centerJpanel.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeight(95,frame)));
centerJpanel.setBackground(Color.WHITE);
panel.add(topJpanel, BorderLayout.NORTH);
panel.add(centerJpanel, BorderLayout.CENTER);
@@ -62,7 +63,7 @@
JComboBoxItem[] cabinList = cabinService.getList();
JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList();
String[] typeList = new String[]{
- "鏀硅", "鍔犺", "鎹㈣", "鏀硅繘鎬т慨鐞�",""
+ "","鏀硅", "鍔犺", "鎹㈣", "鏀硅繘鎬т慨鐞�"
};
JLabel JLabel0 = new JLabel("宸ョ▼");
@@ -90,6 +91,17 @@
JTextField sb = new JTextField(16);
JButton query = new JButton("鏌ヨ");
+ List<ColorDescription> colorDescriptions = new ArrayList<>();
+ colorDescriptions.add(new ColorDescription("#3498DB", "杩涜涓�"));
+ colorDescriptions.add(new ColorDescription("#F1C40F", "涓存湡"));
+ colorDescriptions.add(new ColorDescription("#E74C3C", "閫炬湡"));
+ colorDescriptions.add(new ColorDescription("#2ECC71", "姝e父瀹屾垚"));
+ colorDescriptions.add(new ColorDescription("#006400", "瓒呮湡瀹屾垚"));
+
+ // 鍒涘缓涓嬫媺妗�
+ ColorDescriptionComboBox comboBox5 = new ColorDescriptionComboBox(colorDescriptions);
+ JButton btnTjz = new JButton("璁惧杩涘害缁熻鎬昏〃");
+
topJpanel.add(JLabel0, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
topJpanel.add(comboBox, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
topJpanel.add(JLabel1, new GBC(2, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
@@ -103,8 +115,10 @@
topJpanel.add(sb, new GBC(0, 1, 2, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
topJpanel.add(query, new GBC(2, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
+ topJpanel.add(comboBox5, new GBC(3, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
+ topJpanel.add(btnTjz, new GBC(5, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
- list = level3Service.getNodeList(shipList.get(0).getId(), deptList[0].getId(), teamList[0].getId(), cabinList[0].getId(), typeList[0],null);
+ list = level3Service.getNodeList(shipList.get(0).getId(), deptList[0].getId(), teamList[0].getId(), cabinList[0].getId(), typeList[0], null);
columnDto = new ArrayList<>();
//columnDto.add(new ColumnDto("ID", "id", -1, null,false));
@@ -122,6 +136,30 @@
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+ MouseMotionListener mouseMotionListener = new MouseMotionListener() {
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ // 涓嶉渶瑕佸鐞嗛紶鏍囨嫋鍔ㄤ簨浠�
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ Point point = e.getPoint();
+ int row = table.rowAtPoint(point);
+ int column = table.columnAtPoint(point);
+
+ if (row <= list.size() && column > 1) {
+ String hexColor = (String) table.getValueAt(row, column);
+ String tooltip = getTooltipText(hexColor);
+ table.setToolTipText(tooltip);
+ } else {
+ table.setToolTipText(null);
+ }
+ }
+ };
+
+ table.addMouseMotionListener(mouseMotionListener);
+
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent event) {
String content = comboBox.getSelectedItem().toString();
@@ -131,7 +169,7 @@
String type = comboBox4.getSelectedItem().toString();
Long shipId = shipMap.get(content);
- list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type,null);
+ list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, null);
CommonTable.refreshTable(list, columnDto, table);
table.setRowHeight(25);
@@ -145,12 +183,11 @@
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
JComboBoxItem selectedItem = (JComboBoxItem) comboBox1.getSelectedItem();
- if (selectedItem.getId() != null) {
- long selectedId = selectedItem.getId();
+ if (selectedItem != null) {
+ Long selectedId = selectedItem.getId();
JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(selectedId);
comboBox2.setModel(new DefaultComboBoxModel<>(teamList));
- comboBox2.setSelectedIndex(0);
String content = comboBox.getSelectedItem().toString();
JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
@@ -159,7 +196,7 @@
String type = comboBox4.getSelectedItem().toString();
Long shipId = shipMap.get(content);
- list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type,null);
+ list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, null);
CommonTable.refreshTable(list, columnDto, table);
table.setRowHeight(25);
@@ -180,7 +217,7 @@
String type = comboBox4.getSelectedItem().toString();
Long shipId = shipMap.get(content);
- list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type,null);
+ list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, null);
CommonTable.refreshTable(list, columnDto, table);
table.setRowHeight(25);
@@ -198,7 +235,7 @@
String type = comboBox4.getSelectedItem().toString();
Long shipId = shipMap.get(content);
- list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type,null);
+ list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, null);
CommonTable.refreshTable(list, columnDto, table);
table.setRowHeight(25);
@@ -216,7 +253,7 @@
String type = comboBox4.getSelectedItem().toString();
Long shipId = shipMap.get(content);
- list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type,null);
+ list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, null);
CommonTable.refreshTable(list, columnDto, table);
table.setRowHeight(25);
@@ -229,7 +266,7 @@
query.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- list = level3Service.getNodeList(null, null, null, null, null,sb.getText());
+ list = level3Service.getNodeList(null, null, null, null, null, sb.getText());
CommonTable.refreshTable(list, columnDto, table);
table.setRowHeight(25);
@@ -245,19 +282,55 @@
}
comboBox.setSelectedItem(shipList.get(0).getShipNo());
+ btnTjz.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ String content = comboBox.getSelectedItem().toString();
+ Long shipId = shipMap.get(content);
+ statisProductService.createTable(frame,shipId);
+ }
+ });
JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setViewportView(table);
scrollPane.getViewport().setBackground(Color.WHITE);
- scrollPane.setPreferredSize(new Dimension(width - 20, height - 120));
+ scrollPane.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeightWithScroll(95,frame)));
centerJpanel.add(scrollPane);
+ frame.addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ centerJpanel.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeight(95,frame)));
+ scrollPane.setPreferredSize(new Dimension(width - 20,Compute.ComputeHeightWithScroll(95,frame)));
+ centerJpanel.revalidate();
+ centerJpanel.repaint();
+ scrollPane.revalidate();
+ scrollPane.repaint();
+ }
+ });
return panel;
}
+ private static String getTooltipText(String hexColor) {
+ switch (hexColor) {
+ case "#3498DB":
+ return "杩涜涓�";
+ case "#F1C40F":
+ return "涓存湡";
+ case "#E74C3C":
+ return "閫炬湡";
+ case "#2ECC71":
+ return "姝e父瀹屾垚";
+ case "#006400":
+ return "瓒呮湡瀹屾垚";
+ default:
+ return "鏈紑濮�";
+ }
+ }
}
+
--
Gitblit v1.9.1