SWINGSEVEN

package gui;
import java.awt.BorderLayout;
import java.awt.Checkbox;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.JTree;
import javax.swing.border.EmptyBorder;
import javax.swing.table.JTableHeader;
import javax.swing.tree.DefaultMutableTreeNode;

import dao.StaffMes;

import util.OperateXml;
public class OperateFrame extends JFrame { 
 private JTable jtable;
 private JLabel sourceName;
 private MineContent content;
 private String[][] date;
 private JButton jb1;
 private JButton jb2;
 private JLabel jlb;
 private pagination pg;
 private JTree tree;
 private JCheckBox[] cb;
 private Set ischeck;
 //选择框集合
 private String pathName = "gg.xml";
 private JPopupMenu popupMenu;
    private int dangqian = 1;
    int zongyeshu = 0; 
 String[][] jieguoji;
 public OperateFrame(MineContent content) {
  this();
  this.content = content;
 }
 public OperateFrame() {
  init();
 }
 private void init() {
  setSize(900, 600);
  setLocation(200, 200);
  setResizable(false);
  setContentPane(createContentPane());
 }
 private JPanel createContentPane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  pane.setBorder(new EmptyBorder(20, 20, 20, 20));
  sourceName = new JLabel("进入系统",JLabel.CENTER);
  pane.add(BorderLayout.NORTH,sourceName);
  pane.add(BorderLayout.CENTER, createMinePane());
  return pane;
 }
 private JPanel createMinePane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  pane.add(BorderLayout.NORTH, createTopPane());
  pane.add(BorderLayout.CENTER, createCenterPane());
  return pane;
 }
 
 //树
 private JPanel createCenterPane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  //TODO 彭河江
  final OperateXml operateXml = OperateXml.getOperXmlGinglton();
  ArrayList<ArrayList<String>> lists = operateXml.xml2List(pathName);
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("中软国际科技服务有限公司");
  for (ArrayList<String> arrayList : lists) {
   DefaultMutableTreeNode deptNode = new DefaultMutableTreeNode(arrayList.get(0));
   root.add(deptNode);
   for (int i = 1; i < arrayList.size(); i++) {
    deptNode.add(new DefaultMutableTreeNode(arrayList.get(i)));
   }
  }
  tree = new JTree(root);
  //TODO  彭河江
  popupMenu = new JPopupMenu();
  //右键插入
  JMenuItem insert = new JMenuItem("增加"); 
  insert.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
    content.insert(OperateFrame.this,operateXml,pathName);
    tree.updateUI();
   }   
  });
  JMenuItem update = new JMenuItem("更新");
  //右键跟新
  update.addActionListener(new ActionListener()
  {
   public void actionPerformed(ActionEvent e)
   {
    content.update(OperateFrame.this,operateXml,pathName);
    tree.updateUI();
   }     
  });
  JMenuItem delete = new JMenuItem("删除");
  //右键删除
  delete.addActionListener(new ActionListener()
  {

   public void actionPerformed(ActionEvent e)
   {
    content.delete(OperateFrame.this,operateXml,pathName);
    tree.updateUI();
   }
  });
  JMenuItem find = new JMenuItem("查找");
  //右键查找
  find.addActionListener(new ActionListener()
  {

   public void actionPerformed(ActionEvent e)
   {
    content.find(OperateFrame.this);
   }
   
  });   
  popupMenu.add(insert);
  popupMenu.addSeparator();
  popupMenu.add(update);
  popupMenu.addSeparator();
  popupMenu.add(delete);
  popupMenu.addSeparator();
  popupMenu.add(find);
  tree.addMouseListener(new MouseAdapter()
  {
   public void mousePressed(MouseEvent e)
   {
    if(e.getButton() == MouseEvent.BUTTON3)
    {
     content.mouse(OperateFrame.this, e);
    }
    
   }
  });
  tree.setShowsRootHandles(true);
  pane.add(BorderLayout.WEST, tree);
  pane.add(BorderLayout.CENTER, createRightPane());
  return pane;
 }
 private JPanel createRightPane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  pane.add(BorderLayout.CENTER, createNorthPane());
  pane.add(BorderLayout.SOUTH, createSouthPane());
  return pane;
 }
 //Jtable 表格
 private JPanel createNorthRightPane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  String[] ss = { "工号", "姓名", "性别", "身份证", "备注" };
        jtable = new JTable(new String[10][5], ss);
        jtable.addMouseListener(new MouseAdapter(){
         public void mousePressed(MouseEvent e){   
       content.mousechecked(OperateFrame.this,e);    
   }
        });
        jtable.setEnabled(false);
  jtable.setRowHeight(40);
  JTableHeader head = jtable.getTableHeader();
  pane.add(BorderLayout.NORTH, head);
  pane.add(BorderLayout.CENTER, jtable);
  return pane;
 }
 //把所有的传过来的二维数组都在这个类中得到String[][] str 
 private JPanel createSouthPane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  jb1= new JButton("上一页");
  jb2 = new JButton("下一页");
  JButton jb3 = new JButton("提交");
        pg = new pagination();
  jlb = new JLabel("1/1");
  pane.setLayout(new FlowLayout());
  pane.add(jlb); 
  pane.add(jb1);
  //上一页
  jb1.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent ae) {   
    
     //每次点击都触发获的二维数组,这个以jieguoji代替,后面的同上
    // jieguoji = singleString.getinstance().getstr()
    //在其他获得二维数组的事件中new singleString()并且要实现setstr(。。)方法
    
    
       jieguoji = SingleString.getInstance().getStr();
       if(dangqian>1){
        dangqian--; 
        pg.fenYe(jieguoji, dangqian, jtable, jlb);
       }
      
   }  
  });  
  pane.add(jb2);
  //下一页
  jb2.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent ae) {
              
    jieguoji = SingleString.getInstance().getStr();
    zongyeshu = pg.getcount(jieguoji);
      if(dangqian<zongyeshu){
       checkNextAndPre();
       dangqian++;
       pg.fenYe(jieguoji, dangqian, jtable, jlb);
     
      }
      if(dangqian==zongyeshu){
       pg.fenYe(jieguoji, dangqian, jtable, jlb);
      }
   }
   
  });  
  pane.add(jb3);
  //提交
  jb3.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent ae) {
      content.jb3(OperateFrame.this);
   }
   
  });
  return pane;
 }
 //上一页下一页时checkbox的变化
 
 
 protected void checkNextAndPre() {
     int[] arr = new int[30];
     for(int i= 0 ;i<cb.length;i++){
      if(cb[i].isSelected()){
       arr[i] = 1;
       cb[i].setSelected(false);
      }
     }
     for(int j=0;j<cb.length;j++){
      System.out.println(arr[j]);
     }
    //     else{
//     if(ischeck.contains((dangqian-1)*10+0)){
//      ischeck.remove((dangqian-1)*10+0);
//     }
//    }
   //System.out.println(ischeck);
 }
 private JPanel createNorthPane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  pane.add(BorderLayout.WEST, createNorthLeftPane());
  pane.add(BorderLayout.CENTER, createNorthRightPane());
  return pane;
 }
 
 private JPanel createNorthLeftPane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  cb = new JCheckBox[10];
  
  pane.setLayout(new GridLayout(cb.length, 1));
  for (int i = 0; i < cb.length; i++) {
   cb[i] = new JCheckBox();
   pane.add(cb[i]);
   cb[i].addItemListener(new ItemListener(){

    @Override
    public void itemStateChanged(ItemEvent ie) {
       content.checkBox(OperateFrame.this,ie);
    }
    
   });
  }
  return pane;
 }
 private JPanel createTopPane() {
  JPanel pane = new JPanel(new BorderLayout(0, 8));
  JMenuBar jmb = new JMenuBar();//菜单栏
  String[] s1 = { "修改密码", "导入", "导出员工", "导出所选",
    "添加员工", "帮助", "退出" };
  JMenu[] jm = new JMenu[s1.length];//菜单
  String[][] s2 = {{"修改","取消"},{"导入","取消"},
    {"导出全部员工","取消"},{"导出所选员工","取消"},
    {"添加","取消"},{"帮助","取消"},{"退出","取消"}};
  for (int i = 0; i < s1.length; i++) {
   jm[i] = new JMenu(s1[i]);
   jmb.add(jm[i]);
   for(int j = 0;j<s2[i].length;j++){
    if("".equals(s2[i][j])){
        //将新分隔符追加到菜单的末尾
        jm[i].addSeparator();
       }else{
        JMenuItem jmi=new JMenuItem(s2[i][j]);
        jm[i].add(jmi);
        jmi.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent ae) {
            content.jmi(ae,OperateFrame.this);
         }
         
        });
       }
   }
  }
  pane.add(BorderLayout.CENTER, jmb);
  return pane;
 } 
 public String getEveryValue(int i, int j) {
  System.out.println(jtable.getValueAt(i, j));
  return jtable.getValueAt(i, j).toString();
 }
 public String[][] getDate(){
  return date;
 }
 public String[][] setDate(String[][] str){
  return str;
 }
 public void showView() {
  setVisible(true);
 }
 public void updateView(){
  //跟新登录信息
  String str = "欢迎"+content.getLoginEmp().getName()+
      "进入系统";
  sourceName.setText(str);
  //跟新表格信息
  StaffMes sm = new StaffMes();
  String[][] ss = sm.getAllWorker();
  SingleString.getInstance().setStr(ss);
  pg.fenYe(ss,1,jtable,jlb); 
 }
    public JTree getJtree(){
     return tree;
    }
    //导入xls时跟新数据
    public void updateLView(){
     String[][] str= content.getRushdate();
     SingleString.getInstance().setStr(str);
     pg.fenYe(str,1,jtable,jlb);
    }
    public JPopupMenu getJpopupMenu(){
     return popupMenu;
    }
    public JTable getJtabel(){
     return jtable;
    }
    public JCheckBox[] getCheckBox(){
     return cb;
    }
    public JLabel getjJlabel(){
     return jlb;
    }
    public void deleteDangqian(){
     dangqian=1;
    }
    public int getDangqian(){
     return dangqian;
    }
}

内容概要:本文深入剖析了一个全开源淘客系统的实现细节,涵盖了多个关键技术点。首先介绍了用Go语言重构的淘宝联盟API网关,展示了商品搜索接口的核心代码,强调了参数签名、HTTP请求处理以及数据转换的重要性。接着讨论了数据库设计,特别是佣金结算表的结构,突出了JSON类型的使用和乐观锁机制的应用。前端方面,展示了基于Vue.js的佣金日历组件,体现了数据驱动UI和事件冒泡处理的设计理念。部署环节则分享了一些实用技巧,如手动更新淘宝API的SSL证书链。此外,还探讨了PHP实现的订单同步服务、SDK封装、热更新通道等特性,以及系统的技术售后支持措施。最后,文章总结了该系统的优点,如清晰的MVC分层结构、灵活的分佣规则设计、完善的部署方案和技术售后支持。 适合人群:对淘客系统开发感兴趣的开发者,尤其是希望深入了解系统架构设计、前后端开发、数据库设计和部署优化的技术人员。 使用场景及目标:适用于想要搭建或改进淘客系统的团队和个人开发者。目标是帮助读者理解淘客系统的各个组成部分及其工作原理,从而能够快速上手并进行二次开发。 其他说明:文中提供了大量实际代码片段和配置示例,便于读者理解和实践。同时,作者还分享了许多实用的经验和技巧,有助于提高开发效率和系统稳定性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值