Exemplo n.º 1
0
  private void refreshJList(
      JDBModuleJList jlist,
      DefaultComboBoxModel comboboxmodel,
      LinkedList<JDBListData> linkedlist) {
    comboboxmodel.removeAllElements();

    for (int j = 0; j < linkedlist.size(); j++) {
      comboboxmodel.addElement(linkedlist.get(j));
    }
    ListModel jList1Model = comboboxmodel;

    jlist.setModel(jList1Model);
  }
Exemplo n.º 2
0
  private void populateUnAssignedList() {
    unassignedModel.removeAllElements();

    JDBModule mod = new JDBModule(Common.selectedHostID, Common.sessionID);

    unassignedList = mod.getModulesUnAssignedtoRFMenu();

    if (unassignedList.size() > 0) {
      for (int j = 0; j < unassignedList.size(); j++) {
        unassignedModel.addElement(unassignedList.get(j));
      }
    }

    ListModel jList1Model = unassignedModel;

    jListUnAssigned.setModel(jList1Model);
  }
Exemplo n.º 3
0
  private void populateAssignedList() {
    assignedModel.removeAllElements();

    JDBModule mod = new JDBModule(Common.selectedHostID, Common.sessionID);

    assignedList = mod.getModulesAssignedtoRFMenu();

    if (assignedList.size() > 0) {
      for (int j = 0; j < assignedList.size(); j++) {
        assignedModel.addElement(assignedList.get(j));
      }
      jButtonUp.setEnabled(true);
      jButtonDown.setEnabled(true);
    } else {
      jButtonUp.setEnabled(false);
      jButtonDown.setEnabled(false);
    }

    ListModel jList1Model = assignedModel;

    jListAssigned.setModel(jList1Model);
  }
Exemplo n.º 4
0
  private void initGUI() {
    try {
      this.setPreferredSize(new java.awt.Dimension(538, 440));
      this.setBounds(0, 0, 526 + Common.LFAdjustWidth, 459 + Common.LFAdjustHeight);
      setVisible(true);

      this.setClosable(true);
      this.setIconifiable(true);
      {
        jDesktopPane1 = new JDesktopPane();
        jDesktopPane1.setBackground(Color.WHITE);
        this.getContentPane().add(jDesktopPane1, BorderLayout.NORTH);
        jDesktopPane1.setPreferredSize(new Dimension(536, 415));
        {
          jScrollPaneAssigned = new JScrollPane();
          jDesktopPane1.add(jScrollPaneAssigned);
          jScrollPaneAssigned.setBounds(10, 25, 220, 340);
          jScrollPaneAssigned.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
          {
            ListModel jListAssignedModel =
                new DefaultComboBoxModel(new String[] {"Item One", "Item Two"});
            jListAssigned = new JDBModuleJList(Common.selectedHostID, Common.sessionID);
            jScrollPaneAssigned.setViewportView(jListAssigned);

            jListAssigned.setBackground(Common.color_list_assigned);
            jListAssigned.setCellRenderer(Common.renderer_list_assigned);
            jListAssigned.setModel(jListAssignedModel);
          }
        }
        {
          jScrollPaneUnAssigned = new JScrollPane();
          jDesktopPane1.add(jScrollPaneUnAssigned);
          jScrollPaneUnAssigned.setBounds(272, 25, 220, 340);
          jScrollPaneUnAssigned.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
          {
            ListModel jListUnAssignedModel =
                new DefaultComboBoxModel(new String[] {"Item One", "Item Two"});
            jListUnAssigned = new JDBModuleJList(Common.selectedHostID, Common.sessionID);
            jScrollPaneUnAssigned.setViewportView(jListUnAssigned);
            jListUnAssigned.setBackground(Common.color_list_unassigned);
            jListUnAssigned.setCellRenderer(Common.renderer_list_unassigned);
            jListUnAssigned.setModel(jListUnAssignedModel);
          }
        }
        {
          jButtonAssign = new JButton4j(Common.icon_arrow_left);
          jDesktopPane1.add(jButtonAssign);
          jButtonAssign.setBounds(238, 133, 25, 25);
          jButtonAssign.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  if (jListUnAssigned.getSelectedIndex() > -1) {
                    for (int j = jListUnAssigned.getMaxSelectionIndex();
                        j >= jListUnAssigned.getMinSelectionIndex();
                        j--) {
                      if (jListUnAssigned.isSelectedIndex(j)) {
                        JDBListData item = (JDBListData) jListUnAssigned.getModel().getElementAt(j);

                        addToList(assignedList, item, false);
                      }
                    }

                    for (int j = jListUnAssigned.getMaxSelectionIndex();
                        j >= jListUnAssigned.getMinSelectionIndex();
                        j--) {
                      if (jListUnAssigned.isSelectedIndex(j)) {
                        Object item = jListUnAssigned.getModel().getElementAt(j);

                        removeFromList(unassignedList, item);
                      }
                    }

                    refreshJList(jListAssigned, assignedModel, assignedList);
                    refreshJList(jListUnAssigned, unassignedModel, unassignedList);

                    setButtonState();
                  }
                }
              });
        }
        {
          jButtonUnAssign = new JButton4j(Common.icon_arrow_right);
          jDesktopPane1.add(jButtonUnAssign);
          jButtonUnAssign.setBounds(238, 168, 25, 25);
          jButtonUnAssign.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  if (jListAssigned.getSelectedIndex() > -1) {
                    for (int j = jListAssigned.getMaxSelectionIndex();
                        j >= jListAssigned.getMinSelectionIndex();
                        j--) {
                      if (jListAssigned.isSelectedIndex(j)) {
                        JDBListData item = (JDBListData) jListAssigned.getModel().getElementAt(j);

                        addToList(unassignedList, item, true);
                      }
                    }

                    for (int j = jListAssigned.getMaxSelectionIndex();
                        j >= jListAssigned.getMinSelectionIndex();
                        j--) {
                      if (jListAssigned.isSelectedIndex(j)) {
                        Object item = jListAssigned.getModel().getElementAt(j);

                        removeFromList(assignedList, item);
                      }
                    }
                    refreshJList(jListUnAssigned, unassignedModel, unassignedList);
                    refreshJList(jListAssigned, assignedModel, assignedList);

                    setButtonState();
                  }
                }
              });
        }
        {
          jButtonUp = new JButton4j(Common.icon_arrow_up);
          jDesktopPane1.add(jButtonUp);
          jButtonUp.setBounds(238, 100, 25, 25);
          jButtonUp.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  int sel = jListAssigned.getSelectedIndex();
                  JDBListData element = ((JDBListData) jListAssigned.getModel().getElementAt(sel));
                  assignedList = JDBModule.moveElementUp(assignedList, element);
                  refreshJList(jListAssigned, assignedModel, assignedList);
                  jListAssigned.setSelectedIndex(assignedList.indexOf(element));
                  jButtonSave.setEnabled(true);
                  jButtonUndo.setEnabled(true);
                }
              });
        }
        {
          jButtonDown = new JButton4j(Common.icon_arrow_down);
          jDesktopPane1.add(jButtonDown);
          jButtonDown.setBounds(238, 205, 25, 25);
          jButtonDown.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  int j = jListAssigned.getSelectedIndex();
                  JDBListData element = ((JDBListData) jListAssigned.getModel().getElementAt(j));
                  assignedList = JDBModule.moveElementDown(assignedList, element);
                  refreshJList(jListAssigned, assignedModel, assignedList);
                  jListAssigned.setSelectedIndex(assignedList.indexOf(element));
                  jButtonSave.setEnabled(true);
                  jButtonUndo.setEnabled(true);
                }
              });
        }
        {
          jButtonClose = new JButton4j(Common.icon_close);
          jDesktopPane1.add(jButtonClose);
          jButtonClose.setText(lang.get("btn_Close"));
          jButtonClose.setBounds(369, 373, 110, 30);
          jButtonClose.setMnemonic(lang.getMnemonicChar());
          jButtonClose.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  dispose();
                }
              });
        }
        {
          jButtonHelp = new JButton4j(Common.icon_help);
          jDesktopPane1.add(jButtonHelp);
          jButtonHelp.setText(lang.get("btn_Help"));
          jButtonHelp.setBounds(258, 373, 110, 30);
          jButtonHelp.setMnemonic(lang.getMnemonicChar());
        }
        {
          jButtonSave = new JButton4j(Common.icon_update);
          jDesktopPane1.add(jButtonSave);
          jButtonSave.setText(lang.get("btn_Save"));
          jButtonSave.setBounds(30, 373, 112, 30);
          jButtonSave.setEnabled(false);
          jButtonSave.setMnemonic(lang.getMnemonicChar());
          jButtonSave.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  JDBRFMenu t = new JDBRFMenu(Common.selectedHostID, Common.sessionID);
                  t.rewriteRFMenu(assignedList);
                  jButtonSave.setEnabled(false);
                  jButtonUndo.setEnabled(false);
                }
              });
        }
        {
          jButtonUndo = new JButton4j(Common.icon_undo);
          jDesktopPane1.add(jButtonUndo);
          jButtonUndo.setText(lang.get("btn_Undo"));
          jButtonUndo.setBounds(145, 373, 112, 30);
          jButtonUndo.setEnabled(false);
          jButtonUndo.setMnemonic(lang.getMnemonicChar());
          jButtonUndo.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  populateAssignedList();
                  populateUnAssignedList();
                  jButtonSave.setEnabled(false);
                  jButtonUndo.setEnabled(false);
                }
              });
        }
        {
          jLabel1 = new JLabel4j_title();
          jDesktopPane1.add(jLabel1);
          jLabel1.setText(lang.get("lbl_Assigned"));
          jLabel1.setBounds(10, 5, 208, 18);
          jLabel1.setFont(Common.font_title);
        }
        {
          jLabel2 = new JLabel4j_title();
          jDesktopPane1.add(jLabel2);
          jLabel2.setText(lang.get("lbl_Unassigned"));
          jLabel2.setBounds(272, 4, 154, 18);
          jLabel2.setFont(Common.font_title);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }