Exemplo n.º 1
0
 @Override
 public void loadData() {
   tuser.setListData(model.getListUser().toArray());
   checklistmanager.getSelectionModel().removeSelectionInterval(0, model.getListUser().size() - 1);
   ArrayList userSelectCopy = new ArrayList(model.getListUserSelect());
   for (int i = 0; i < model.getListUser().size(); i++) {
     if (userSelectCopy.contains(model.getListUser().get(i))) {
       checklistmanager.getSelectionModel().addSelectionInterval(i, i);
     }
   }
 }
Exemplo n.º 2
0
  public void load() {
    luser =
        new JXLabel(i18n.Language.getLabel(model.getEntity().getModelEntity().getIdLng()) + ":");
    tuser = new JList();
    tuser.setEnabled(false);
    checklistmanager = new CheckListManager(tuser);
    checklistmanager
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              @Override
              public void valueChanged(ListSelectionEvent e) {

                if (!checklistmanager.getSelectionModel().isSelectionEmpty()) {
                  ArrayList<String> a = new ArrayList<>();
                  for (int i = checklistmanager.getSelectionModel().getMinSelectionIndex();
                      i <= checklistmanager.getSelectionModel().getMaxSelectionIndex();
                      i++) {
                    if (checklistmanager.getSelectionModel().isSelectedIndex(i)) {
                      a.add(model.getListUser().get(i));
                    }
                  }
                  model.setListUserSelect(a);
                }
              }
            });

    suser = new JScrollPane(tuser);
    pButton.addButton(pButton.bSelect, "selectAll");
    pButton.addButton(pButton.bUnselect, "unselectAll");
    pButton.bSelect.addActionListener(this);
    pButton.bUnselect.addActionListener(this);

    gbc = new GridBagConstraints();
    int y = 0;
    gbc.gridx = 0;
    gbc.gridy = y;
    gbc.gridwidth = 1;
    gbc.weightx = 0.1;
    gbc.anchor = java.awt.GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new java.awt.Insets(spaceTop + 10, spaceLeft + 10, spaceBottom, spaceRight);
    this.add(luser, gbc);

    gbc.gridx = 1;
    gbc.gridy = y;
    gbc.gridheight = 2;
    gbc.weightx = 0.9;
    gbc.insets = new java.awt.Insets(spaceTop + 10, spaceLeft, spaceBottom, spaceRight);
    this.add(suser, gbc);

    y += 2;
    gbc.gridx = 1;
    gbc.gridy = y;
    gbc.gridheight = 1;
    gbc.weightx = 1;
    gbc.insets = new java.awt.Insets(spaceTop, spaceLeft, spaceBottom, spaceRight);
    this.add(pButton, gbc);
  }
Exemplo n.º 3
0
 @Override
 public void actionPerformed(ActionEvent e) {
   String act = e.getActionCommand();
   if (act.equals("selectAll")) {
     if (model.getListUser() != null && checklistmanager != null) {
       checklistmanager
           .getSelectionModel()
           .setSelectionInterval(0, model.getListUser().size() - 1);
     }
   } else if (act.equals("unselectAll")) {
     if (model.getListUser() != null && checklistmanager != null) {
       checklistmanager
           .getSelectionModel()
           .removeSelectionInterval(0, model.getListUser().size() - 1);
     }
   }
 }
Exemplo n.º 4
0
 @Override
 public void update(Observable o, Object arg) {
   tuser.setListData(model.getListUser().toArray());
   checklistmanager.getSelectionModel().setSelectionInterval(0, model.getListUser().size() - 1);
 }