// Implementation of valueChanged
  public void valueChanged(ListSelectionEvent e) {
    if (e.getSource() == table.getSelectionModel()) {
      ListSelectionModel ls = table.getSelectionModel();

      int index = ls.getMinSelectionIndex();
      long id = (long) table.getValueAt(index, 0);

      updateFeesData(id);
    } else {
      ListSelectionModel ls = feestable.getSelectionModel();

      int index = ls.getMinSelectionIndex();

      float feespayed = (float) feestable.getValueAt(index, 1);
      float totalfees = (float) feestable.getValueAt(index, 2);

      feespayedlabel.setText("Fees Payed: " + feespayed);
      totalfeeslabel.setText("Total Fees: " + totalfees);

      if (totalfees - feespayed > 0) {
        feesduelabel.setText("Fees Due: " + (totalfees - feespayed));
      }

      panel_6.revalidate();
    }
  }
Exemplo n.º 2
0
  // This method from http://www.exampledepot.com/egs/javax.swing.table/PackCol.html
  public int packColumn(JTable table, int vColIndex, int margin) {
    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
    TableColumn col = colModel.getColumn(vColIndex);
    int width = 0;

    // Get width of column header
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
      renderer = table.getTableHeader().getDefaultRenderer();
    }
    Component comp =
        renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
    width = comp.getPreferredSize().width;

    // Get maximum width of column data
    for (int r = 0; r < table.getRowCount(); r++) {
      renderer = table.getCellRenderer(r, vColIndex);
      comp =
          renderer.getTableCellRendererComponent(
              table, table.getValueAt(r, vColIndex), false, false, r, vColIndex);
      width = Math.max(width, comp.getPreferredSize().width);
    }

    // Add margin
    width += 2 * margin;

    // Set the width
    col.setPreferredWidth(width);

    return width;
  }
Exemplo n.º 3
0
    /**
     * Create a Transferable to use as the source for a data transfer.
     *
     * @param c The component holding the data to be transfered. This argument is provided to enable
     *     sharing of TransferHandlers by multiple components.
     * @return The representation of the data to be transfered.
     */
    protected Transferable createTransferable(JComponent c) {
      Object[] values = null;
      if (c instanceof JList) {
        values = ((JList) c).getSelectedValues();
      } else if (c instanceof JTable) {
        JTable table = (JTable) c;
        int[] rows = table.getSelectedRows();
        if (rows != null) {
          values = new Object[rows.length];
          for (int i = 0; i < rows.length; i++) {
            values[i] = table.getValueAt(rows[i], 0);
          }
        }
      }
      if (values == null || values.length == 0) {
        return null;
      }

      StringBuffer plainBuf = new StringBuffer();
      StringBuffer htmlBuf = new StringBuffer();

      htmlBuf.append("<html>\n<body>\n<ul>\n");

      for (Object obj : values) {
        String val = ((obj == null) ? "" : obj.toString());
        plainBuf.append(val + "\n");
        htmlBuf.append("  <li>" + val + "\n");
      }

      // remove the last newline
      plainBuf.deleteCharAt(plainBuf.length() - 1);
      htmlBuf.append("</ul>\n</body>\n</html>");

      return new FileTransferable(plainBuf.toString(), htmlBuf.toString(), values);
    }
Exemplo n.º 4
0
    public Component getTableCellEditorComponent(
        JTable table, Object value, boolean isSelected, int row, int column) {

      ((JComboBox) editorComponent).removeAllItems();
      if (options.containTrait(table.getValueAt(row, 0).toString())) {
        if (column == 5) {
          for (Object ob : options.getPartitionTraitsSubstitutionModels()) {
            ((JComboBox) editorComponent).addItem(ob);
          }
        } else if (column == 6) {
          for (Object ob : options.getPartitionTraitsClockModels()) {
            ((JComboBox) editorComponent).addItem(ob);
          }
        }
      } else {
        if (column == 5) {
          for (Object ob : options.getPartitionNonTraitsSubstitutionModels()) {
            ((JComboBox) editorComponent).addItem(ob);
          }
        } else if (column == 6) {
          for (Object ob : options.getPartitionNonTraitsClockModels()) {
            ((JComboBox) editorComponent).addItem(ob);
          }
        }
      }

      //            if (((JComboBox) editorComponent).contains(value)) // todo need validate whether
      // value in the editorComponent

      ((JComboBox) editorComponent).setSelectedItem(value);
      delegate.setValue(value);

      return editorComponent;
    }
 private static void drawSelection(JTable table, int column, Graphics g, final int width) {
   int y = 0;
   final int[] rows = table.getSelectedRows();
   final int height = table.getRowHeight();
   for (int row : rows) {
     final TableCellRenderer renderer = table.getCellRenderer(row, column);
     final Component component =
         renderer.getTableCellRendererComponent(
             table, table.getValueAt(row, column), false, false, row, column);
     g.translate(0, y);
     component.setBounds(0, 0, width, height);
     boolean wasOpaque = false;
     if (component instanceof JComponent) {
       final JComponent j = (JComponent) component;
       if (j.isOpaque()) wasOpaque = true;
       j.setOpaque(false);
     }
     component.paint(g);
     if (wasOpaque) {
       ((JComponent) component).setOpaque(true);
     }
     y += height;
     g.translate(0, -y);
   }
 }
  /** Observer method to update the insuranceCompanyTable */
  public void updateTable() {

    tableData.update(
        model.getInsuranceCompanies(), model.getSortingStrategy()); // Populate the table

    // Check if InsuranceCompany map is empty
    if (model.getInsuranceCompanies().size() > 0) {
      selectRow();
      int selectedCompanyId =
          Integer.valueOf(
              (String)
                  insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0));
      controller.selectInsuranceCompany(selectedCompanyId);
      recordEdited = -1; // Reset the recordEdited field
    } else {
      // If all records are deleted, clear the edit panel
      companyIdTextField.setText("");
      companyNameTextField.setText("");
      urlTextField.setText("");
      generalDescriptionTextField.setText("");
      insuranceTypesTextField.setText("");
      telephoneTextField.setText("");
      percentageTextField.setText("");
    }
  }
Exemplo n.º 7
0
 private void removeSelectedParameters() {
   int[] selRows = parametersTable.getSelectedRows();
   List<Parameter> parametersToRemove = new ArrayList<Parameter>();
   for (int row : selRows) {
     parametersToRemove.add((Parameter) parametersTable.getValueAt(row, 0));
   }
   removeParameters(parametersToRemove);
 }
Exemplo n.º 8
0
  void okButton_actionPerformed(ActionEvent e) {
    int num_rows = filtersTable.getRowCount();
    EditableDefinablePlugin edp = m_data.getPlugin();
    for (int row = 0; row < num_rows; row++) {
      String mimeType = (String) filtersTable.getValueAt(row, 0);
      String mimeTypeValue = (String) filtersTable.getValueAt(row, 1);

      try {
        mimeTypeEditorBuilder.checkValue(edp, mimeType, mimeTypeValue);
      } catch (DynamicallyLoadedComponentException dlce) {
        String logMessage =
            "Failed to set the "
                + mimeTypeEditorBuilder.getValueName()
                + " for MIME type "
                + mimeType
                + " to "
                + mimeTypeValue;
        logger.error(logMessage, dlce);
        if (!EDPInspectorTableModel.handleDynamicallyLoadedComponentException(this, dlce)) {
          return;
        } else {
          logger.debug("User override; allow " + mimeTypeValue);
        }
      }
    }
    mimeTypeEditorBuilder.clear(edp);
    for (int row = 0; row < num_rows; row++) {
      String mimeType = (String) filtersTable.getValueAt(row, 0);
      String mimeTypeValue = (String) filtersTable.getValueAt(row, 1);

      try {
        mimeTypeEditorBuilder.put(edp, mimeType, mimeTypeValue);
      } catch (DynamicallyLoadedComponentException dlce) {
        String logMessage =
            "Internal error; MIME type " + mimeType + " not set to " + mimeTypeValue;
        logger.error(logMessage, dlce);
      } catch (PluginException.InvalidDefinition ex) {
        JOptionPane.showMessageDialog(
            this,
            ex.getMessage(),
            WordUtils.capitalize(mimeTypeEditorBuilder.getValueName()) + " Warning",
            JOptionPane.WARNING_MESSAGE);
      }
    }
    setVisible(false);
  }
  @Override
  public Component getTableCellEditorComponent(
      JTable table, Object value, boolean isSelected, int row, int column) {

    ((JTextField) this.editorComponent)
        .setText("" + ((Field) table.getValueAt(row, column)).getValue());

    return this.editorComponent;
  }
Exemplo n.º 10
0
 private static int getRowIndex(JTable table, int columnIndex, Object expectedValue) {
   for (int i = 0; i < table.getRowCount(); i++) {
     Object value = table.getValueAt(i, columnIndex);
     if (value != null && value.equals(expectedValue)) {
       return i;
     }
   }
   return -1;
 }
  private String extractContent(
      DataGridPanel grid, String delimiter, boolean saveHeader, boolean ecloseWithDowbleQuotes) {
    JTable _table = grid.getTable();

    int numcols = _table.getSelectedColumnCount();
    int numrows = _table.getSelectedRowCount();

    if (numcols > 0 && numrows > 0) {
      StringBuffer sbf = new StringBuffer();
      int[] rowsselected = _table.getSelectedRows();
      int[] colsselected = _table.getSelectedColumns();

      if (saveHeader) {
        // put header name list
        for (int j = 0; j < numcols; j++) {
          String text =
              (String)
                  _table
                      .getTableHeader()
                      .getColumnModel()
                      .getColumn(colsselected[j])
                      .getHeaderValue();
          sbf.append(text);
          if (j < numcols - 1) sbf.append(delimiter);
        }
        sbf.append("\n");
      }

      // put content
      for (int i = 0; i < numrows; i++) {
        for (int j = 0; j < numcols; j++) {
          Object value = _table.getValueAt(rowsselected[i], colsselected[j]);
          String _value = "";
          if (value != null) {
            _value = value.toString();
          }
          if (ecloseWithDowbleQuotes) {
            sbf.append("\"").append(_value).append("\"");
          } else {
            sbf.append(_value);
          }

          if (j < numcols - 1) sbf.append(delimiter);
        }
        sbf.append("\n");
      }

      //            StringSelection stsel = new StringSelection(sbf.toString());
      //            Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard();
      //            system.setContents(stsel, stsel);
      return sbf.toString();
    }

    return null;
  }
  // Add fee method
  private void addFees() {
    try {
      float feesadded = Float.parseFloat(addfeestextfield.getText());

      int id = table.getSelectionModel().getMinSelectionIndex();
      long studentid = (long) table.getValueAt(id, 0);

      int index = feestable.getSelectionModel().getMinSelectionIndex();
      String coursename = (String) feestable.getValueAt(index, 0);

      Database db = new Database();
      db.addFees(feesadded, studentid, coursename);

      updateFeesData(studentid);

      addfeestextfield.setText("");
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
    }
  }
Exemplo n.º 13
0
                          // appointment time and what not
 public void mouseClicked(MouseEvent e) {
   int row = Cal.getSelectedRow(); // this will give you the row number
   int col = Cal.getSelectedColumn(); // this will give you the column number
   if (row != -1
       && col != -1
       && Cal.getValueAt(row, col)
           != null) { // this now will only activate when there is an actual date associated with
                      // that day
     input(row, col, currentYear);
   }
 }
Exemplo n.º 14
0
  protected void internalDoubleClick(MouseEvent e) {
    if (!(e.getComponent() instanceof JComponent)) return;
    JComponent inComponent = (JComponent) e.getComponent();

    if (inComponent instanceof JTable) {
      JTable thisTable = (JTable) inComponent;
      int rowPoint = thisTable.rowAtPoint(new Point(e.getX(), e.getY()));
      Searcher whichSearch = (Searcher) thisTable.getValueAt(rowPoint, -1);

      whichSearch.execute();
    }
  }
  private int getColumnCellWidth(JTable table, int colIndex) {
    int width = 0;
    for (int r = 0; r < table.getRowCount(); r++) {
      TableCellRenderer renderer = table.getCellRenderer(r, colIndex);
      Component comp =
          renderer.getTableCellRendererComponent(
              table, table.getValueAt(r, colIndex), false, false, r, colIndex);
      width = Math.max(width, comp.getPreferredSize().width);
    }

    return width;
  }
Exemplo n.º 16
0
 /**
  * This method is activated on the Keystrokes we are listening to in this implementation. Here it
  * listens for Copy and Paste ActionCommands. Selections comprising non-adjacent cells result in
  * invalid selection and then copy action cannot be performed. Paste is done by aligning the upper
  * left corner of the selection with the 1st element in the current selection of the JTable.
  */
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().compareTo("Copy") == 0) {
     StringBuffer sbf = new StringBuffer();
     // Check to ensure we have selected only a contiguous block of
     // cells
     int numcols = jTable1.getSelectedColumnCount();
     int numrows = jTable1.getSelectedRowCount();
     int[] rowsselected = jTable1.getSelectedRows();
     int[] colsselected = jTable1.getSelectedColumns();
     if (!((numrows - 1 == rowsselected[rowsselected.length - 1] - rowsselected[0]
             && numrows == rowsselected.length)
         && (numcols - 1 == colsselected[colsselected.length - 1] - colsselected[0]
             && numcols == colsselected.length))) {
       JOptionPane.showMessageDialog(
           null, "Invalid Copy Selection", "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE);
       return;
     }
     for (int i = 0; i < numrows; i++) {
       for (int j = 0; j < numcols; j++) {
         sbf.append(jTable1.getValueAt(rowsselected[i], colsselected[j]));
         if (j < numcols - 1) sbf.append("\t");
       }
       sbf.append("\n");
     }
     stsel = new StringSelection(sbf.toString());
     system = Toolkit.getDefaultToolkit().getSystemClipboard();
     system.setContents(stsel, stsel);
   }
   if (e.getActionCommand().compareTo("Paste") == 0) {
     System.out.println("Trying to Paste");
     int startRow = (jTable1.getSelectedRows())[0];
     int startCol = (jTable1.getSelectedColumns())[0];
     try {
       String trstring =
           (String) (system.getContents(this).getTransferData(DataFlavor.stringFlavor));
       System.out.println("String is:" + trstring);
       StringTokenizer st1 = new StringTokenizer(trstring, "\n");
       for (int i = 0; st1.hasMoreTokens(); i++) {
         rowstring = st1.nextToken();
         StringTokenizer st2 = new StringTokenizer(rowstring, "\t");
         for (int j = 0; st2.hasMoreTokens(); j++) {
           value = (String) st2.nextToken();
           if (startRow + i < jTable1.getRowCount() && startCol + j < jTable1.getColumnCount())
             jTable1.setValueAt(value, startRow + i, startCol + j);
           System.out.println(
               "Putting " + value + "at row = " + startRow + i + "column = " + startCol + j);
         }
       }
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
 }
Exemplo n.º 17
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ExcelConfig dlExcel = new ExcelConfig();
   List<Column> columns = new ArrayList<Column>();
   dlExcel.setColumns(new Columns());
   dlExcel.getColumns().setColumns(columns);
   dlExcel.setClazz(clasz);
   dlExcel.setCache(cache.isSelected());
   dlExcel.setSheet(sheet.getText());
   dlExcel.setSheetNum(Integer.parseInt(sheetNum.getText()));
   dlExcel.setStartRow(Integer.parseInt(startRow.getText()));
   // 列
   int rows = table.getRowCount();
   Column column = null;
   for (int i = 0; i < rows; i++) {
     column = new Column();
     column.setName(String.valueOf(table.getValueAt(i, 0)));
     column.setType(String.valueOf(table.getValueAt(i, 1)));
     column.setHeader(String.valueOf(table.getValueAt(i, 2)));
     columns.add(column);
   }
   XmlConfig config = new XmlConfig();
   // filepath
   String xmlPath = filePath.getText();
   String fileName = clasz.substring(clasz.lastIndexOf('.') + 1);
   String fullPath = xmlPath + "/" + fileName + ".xml";
   try {
     config.WriteXml(dlExcel, fullPath);
     if (JOptionPane.showConfirmDialog(
             GenXml.this, "保存完成,是否退出向导?", "成功", JOptionPane.OK_CANCEL_OPTION)
         == JOptionPane.OK_OPTION) {
       System.exit(0);
     }
   } catch (Exception e2) {
     JOptionPane.showMessageDialog(GenXml.this, "保存出错:" + e2.getMessage());
   }
 }
 /**
  * Searches for InsuranceCompanies. Calls the controller and updates the tableData to the
  * searchMap.
  */
 private void searchInsuranceCompany() {
   String query = searchTextField.getText();
   controller.searchInsuranceCompanies(query);
   tableData.update(
       model.getSearchMap(), model.getSortingStrategy()); // Updates tableData and sortingStrategy
   // Enable automatic selection while searching
   if (tableData.getRowCount() > 0) {
     selectRow();
     int selectedCompanyId =
         Integer.valueOf(
             (String)
                 insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0));
     controller.selectInsuranceCompany(selectedCompanyId);
   }
 }
  /** Initial method to populate the insuranceCompaniesTable */
  public void loadTable() {

    Map<Integer, InsuranceCompany> data = model.getInsuranceCompanies();
    tableData = new InsuranceCompanyTableModel(data);
    insuranceCompaniesTable.setModel(tableData);
    insuranceCompaniesTable.getColumnModel().getColumn(0).setMaxWidth(50);
    insuranceCompaniesTable
        .getSelectionModel()
        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // Check if db is empty and proceed with selecting only if the table is populated
    if (insuranceCompaniesTable.getRowCount() > 0) {
      // Set selected company according to selected row on load
      selectRow();
      int selectedCompanyId =
          Integer.valueOf(
              (String)
                  insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0));
    }
  }
  /** Observer method to update the editPanel and it's contents */
  public void updateEditPanel() {

    InsuranceCompany insuranceCompany = model.getCurrentInsuranceCompany();

    if (insuranceCompany != null) { // If no currentInsuranceCompany is set (if the db is empty)
      // Update all text fields
      String id =
          (String) insuranceCompaniesTable.getValueAt(insuranceCompaniesTable.getSelectedRow(), 0);
      companyIdTextField.setText(id);
      companyNameTextField.setText(insuranceCompany.getCompanyName());
      urlTextField.setText(insuranceCompany.getUrl());
      urlTextField.setCaretPosition(0);
      generalDescriptionTextField.setText(insuranceCompany.getGeneralDescription());
      generalDescriptionTextField.setCaretPosition(0);
      insuranceTypesTextField.setText(insuranceCompany.getInsuranceTypes());
      insuranceTypesTextField.setCaretPosition(0);
      telephoneTextField.setText(insuranceCompany.getTelephone());
      percentageTextField.setText(Float.toString(insuranceCompany.getPercentage()));
    }
  }
Exemplo n.º 21
0
 public void actionPerformed(final ActionEvent e) {
   if (e.getSource() instanceof JButton) {
     final JButton button = (JButton) e.getSource();
     if (button.getText().equals("Save")) {
       AccountManager.getAccounts().clear();
       String[] data = new String[4];
       for (int i = 0; i < table.getRowCount(); i++) {
         for (int x = 0; x < table.getColumnCount(); x++) {
           data[x] = (String) table.getValueAt(i, x);
         }
         AccountManager.getAccounts().add(new Account(data[0], data[1], data[2], data[3]));
       }
       AccountManager.saveAccounts();
       dispose();
     } else if (button.getToolTipText().equals("Add")) {
       final String str =
           JOptionPane.showInputDialog(
               getParent(),
               "Enter the account username:"******"New Account",
               JOptionPane.QUESTION_MESSAGE);
       if (str == null || str.isEmpty()) {
         return;
       }
       final int row = table.getRowCount();
       ((DefaultTableModel) table.getModel()).addRow(new Object[] {str, null, null, null});
       ((DefaultTableModel) table.getModel()).fireTableRowsInserted(row, row);
     } else if (button.getToolTipText().equals("Remove")) {
       final int row = table.getSelectedRow();
       final String user = (String) table.getModel().getValueAt(table.getSelectedRow(), 0);
       if (user != null) {
         for (int i = 0; i < AccountManager.getAccounts().size(); i++) {
           if (AccountManager.getAccounts().get(i).getUsername().equals(user)) {
             AccountManager.getAccounts().remove(i);
           }
         }
         ((DefaultTableModel) table.getModel()).fireTableRowsDeleted(row, row);
       }
     }
   }
 }
 public ArrayList<Team> getValuesInTable() {
   teamList.clear();
   int rowNum = table.getRowCount();
   for (int i = 0; i < rowNum; i++) {
     String teamName = String.valueOf(table.getValueAt(i, 0));
     int teamPoints = Integer.parseInt(String.valueOf(table.getValueAt(i, 1)));
     int teamGD = Integer.parseInt(String.valueOf(table.getValueAt(i, 2)));
     int wins = Integer.parseInt(String.valueOf(table.getValueAt(i, 2)));
     int loses = Integer.parseInt(String.valueOf(table.getValueAt(i, 2)));
     int draws = Integer.parseInt(String.valueOf(table.getValueAt(i, 2)));
     int gamesPlayed = Integer.parseInt(String.valueOf(table.getValueAt(i, 3)));
     Team team = new Team(teamName, teamPoints, teamGD, wins, draws, loses, gamesPlayed);
     teamList.add(i, team);
   }
   return teamList;
 }
  // Add course method
  public void addCourse() {
    try {
      Database db = new Database();

      String coursename = (String) coursecombobox.getSelectedItem();
      if (coursecombobox.getSelectedIndex() == 0) {
        throw new Exception("No course selected");
      }

      float fees = db.getCoursefees(coursename);
      float totalfees = fees + (ims.main.Settings.getInstallment() * (int) spinner.getValue());

      long id = (long) table.getValueAt((int) table.getSelectionModel().getMinSelectionIndex(), 0);

      db.addCourseToCurrentStudent(id, totalfees, (int) spinner.getValue(), coursename);

      updateFeesData(id);
      courseReset();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
    }
  }
Exemplo n.º 24
0
    public void tableChanged(TableModelEvent evt) {
      int row, col;
      String key, val;

      if (evt.getType() == TableModelEvent.UPDATE) {
        row = evt.getFirstRow();
        col = evt.getColumn();
        if (col == 0) { // set()
          key = (String) table_model.getValueAt(row, col);
          val = (String) table_model.getValueAt(row, col + 1);
          if (key != null && val != null) {
            tree.put(selected_node, key, val);
          }
        } else { // add()
          key = (String) table_model.getValueAt(row, col - 1);
          val = (String) table.getValueAt(row, col);
          if (key != null && val != null) {
            tree.put(selected_node, key, val);
          }
        }
      }
    }
Exemplo n.º 25
0
  // For editing current student
  public StudentEditingDlg(
      Frame frame, String title, final JTable table, final int rowIndex, final int whichClass) {
    super(frame, title, true);
    this.setSize(200, 400);
    this.setIconImage(new ImageIcon(getClass().getResource("tigerpaw.jpg")).getImage());

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(
        dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);

    JPanel northpanel = new JPanel();
    northpanel.setLayout(new GridLayout(4, 1));
    JPanel southpanel = new JPanel(); // create new Panel instances
    JPanel first = new JPanel();
    JPanel second = new JPanel();
    JPanel third = new JPanel();
    JPanel fourth = new JPanel();

    JLabel firstname =
        new JLabel(
            "First Name",
            JLabel.TRAILING); // create label and textfield for first name, and add it to the 1st
    // panel
    first.add(firstname, BorderLayout.NORTH);
    firstnameField = new JTextField((String) table.getValueAt(rowIndex, 1), 15);
    firstname.setLabelFor(firstnameField);
    first.add(firstnameField);

    JLabel lastname =
        new JLabel(
            "Last Name",
            JLabel.TRAILING); // create label and textfield for last name address, and add it to the
    // 2nd panel
    second.add(lastname);
    lastnameField = new JTextField((String) table.getValueAt(rowIndex, 0), 15);
    lastname.setLabelFor(lastnameField);
    second.add(lastnameField);

    JLabel username =
        new JLabel(
            "Username",
            JLabel
                .TRAILING); // create label and textfield for username, and add it to the 2nd panel
    third.add(username);
    usernameField = new JTextField((String) table.getValueAt(rowIndex, 2), 15);
    username.setLabelFor(usernameField);
    third.add(usernameField);

    JLabel cuid =
        new JLabel(
            "CUID",
            JLabel.TRAILING); // create label and textfield for cuid, and add it to the 3rd panel
    fourth.add(cuid);
    cuidField = new JTextField((String) table.getValueAt(rowIndex, 3), 15);
    cuid.setLabelFor(cuidField);
    fourth.add(cuidField);

    final JButton saveButton = new JButton("Save"); // create save Button
    saveButton.addMouseListener(
        new MouseAdapter() { // create actionListener for when it is pressed
          public void mouseClicked(MouseEvent arg0) {
            Student s =
                new Student(
                    firstnameField.getText(),
                    lastnameField.getText(),
                    usernameField.getText(),
                    cuidField.getText());
            ClassDataStore.getInstance().getClasses().get(whichClass).setStudent(rowIndex, s);
            ((DefaultTableModel) table.getModel()).fireTableDataChanged();
            dispose();
          }
        });
    southpanel.add(saveButton, BorderLayout.WEST);

    final JButton cancelButton = new JButton("Cancel"); // create cancel Button
    cancelButton.addMouseListener(
        new MouseAdapter() { // create actionListener for when it is pressed
          public void mouseClicked(MouseEvent arg0) {
            dispose();
          }
        });
    southpanel.add(cancelButton, BorderLayout.CENTER);

    northpanel.add(first); // add all panels to JFrame
    northpanel.add(second);
    northpanel.add(third);
    northpanel.add(fourth);

    add(northpanel);
    add(southpanel, BorderLayout.SOUTH);

    // Set colors
    Color orange = new Color(234, 106, 32);
    Color purple = new Color(82, 45, 128);
    Color white = new Color(255, 255, 255);

    firstname.setForeground(white);
    lastname.setForeground(white);
    username.setForeground(white);
    cuid.setForeground(white);

    first.setBackground(orange);
    second.setBackground(orange);
    third.setBackground(orange);
    fourth.setBackground(orange);
    northpanel.setBackground(orange);
    southpanel.setBackground(orange);
    saveButton.setBackground(purple);
    saveButton.setForeground(white);
    cancelButton.setBackground(purple);
    cancelButton.setForeground(white);
  }
Exemplo n.º 26
0
  public Element createXML() {
    if (agents.getSelectedIndex() + 1 < agents.getModel().getSize()) {
      Element e = (Element) AgentComboBoxModel.getAgents().get(agents.getSelectedIndex());
      Vector settings = new Vector();
      // Eigenschaften ab 7 werden als Settings fürs Tool ausgelesen (EXIF-Tags) :)
      // ist keines gesetzt, so wird der Vector wieder auf null gesetzt :)
      boolean atLeastOneSettingDefined = false;
      Iterator itVals = ctm.getValues().iterator();
      int tempCount = 0;
      for (Object o : ctm.getKeys()) {
        String tempKey = (String) o;
        String tempVal = (String) itVals.next();
        if (tempVal.length() > 0
            && tempCount > 5) { // Wenn Wert da und wenns keiner der ersten 6 std werte is
          settings.add(tempKey + "=" + tempVal);
          atLeastOneSettingDefined = true;
        }
        tempCount++;
      }
      if (!atLeastOneSettingDefined) settings = null;
      String time = null;
      if (datatable.getValueAt(0, 1).toString().length() > 0)
        time = datatable.getValueAt(0, 1).toString();

      String tool = null;
      int count = 0;
      for (Object o1 : ctm.getKeys()) {
        String s = (String) o1;
        if (s.equals("Make")) {
          if (tool == null) tool = new String();
          tool = ctm.getValues().get(count) + " " + tool;
        }
        if (s.equals("Model")) {
          if (tool == null) tool = new String();
          tool = tool + ctm.getValues().get(count);
        }
        count++;
      }
      Mpeg7CreationInformation m7ci = new Mpeg7CreationInformation(e, tool, settings, time);
      // Getting data ....
      String bits = null, fformat = null, fsize = null, ih = null, iw = null;
      if (datatable.getValueAt(1, 1).toString().length() > 0)
        fformat = datatable.getValueAt(1, 1).toString();
      if (datatable.getValueAt(2, 1).toString().length() > 0)
        fsize = datatable.getValueAt(2, 1).toString();
      if (datatable.getValueAt(4, 1).toString().length() > 0)
        ih = datatable.getValueAt(4, 1).toString();
      if (datatable.getValueAt(3, 1).toString().length() > 0)
        iw = datatable.getValueAt(3, 1).toString();
      if (datatable.getValueAt(5, 1).toString().length() > 0)
        bits = datatable.getValueAt(5, 1).toString();
      Mpeg7MediaFormat m7mf = new Mpeg7MediaFormat(bits, fformat, fsize, ih, iw);
      Element mediaFormat = m7mf.createDocument();
      Element ret = new Element("return", mediaFormat.getNamespace()).addContent(mediaFormat);
      ret.addContent(m7ci.createDocument().detach());
      return ret;
    } else {
      return null;
    }
  }
Exemplo n.º 27
0
 private void doLaunch() throws IOException {
   // kicks off the launch after confirm and check if not null, two possibilities. Select Folder
   // sets flag and does folder. All others just makes a list.
   int reply =
       JOptionPane.showConfirmDialog(
           null, "Are you sure you want to launch?", "Launch?", JOptionPane.YES_NO_OPTION);
   if (reply == JOptionPane.YES_OPTION) {
     int numRow = table.getRowCount();
     if (numRow < 1) {
       JOptionPane.showMessageDialog(frame, "You need to select tests to launch.");
       return;
     }
     if (selFoFl == 0) {
       try (BufferedWriter bw =
           new BufferedWriter(
               new FileWriter(
                   "C:\\Projects\\testSeleniumFramework\\framework\\runSelectedTests.bat"))) {
         if (numRow < 2) {
           pullS = table.getValueAt(0, 0).toString();
         }
         if (numRow > 1) {
           for (int i = 0; i < numRow; i++) {
             Object o = table.getValueAt(i, 0);
             pullS += ",";
             pullS += o.toString();
           }
         }
         if (pullS.contains("null,")) {
           pullS = pullS.substring(5);
         }
         if (pullS.startsWith(",")) {
           pullS = pullS.substring(1);
         }
         // String lineC ="";
         if (flagF == 1) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + pullS
                   + "\"";
         }
         if (flagF == 2) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + pullS
                   + " Y\"";
         }
         if (flagF == 3) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + pullS
                   + " ONLYFAIL\"";
         }
         bw.write(
             "Echo \"Launching tests..."
                 + "\r\ncd C:\\Projects\\testSeleniumFramework\r\n"
                 + lineC
                 + "\r\n");
       }
       pullS = "";
       Process p =
           Runtime.getRuntime()
               .exec(
                   "cmd /c start C:\\Projects\\testSeleniumFramework\\framework\\runSelectedTests.bat");
     }
     if (selFoFl == 1) {
       try (BufferedWriter bw =
           new BufferedWriter(
               new FileWriter(
                   "C:\\Projects\\testSeleniumFramework\\framework\\runSelectedTests.bat"))) {
         // String lineC = "";
         if (flagF == 1) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + dtm.getValueAt(0, 1).toString()
                   + "\\\"";
         }
         if (flagF == 2) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + dtm.getValueAt(0, 1).toString()
                   + "\\ Y\"";
         }
         if (flagF == 3) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + dtm.getValueAt(0, 1).toString()
                   + "\\ ONLYFAIL\"";
         }
         bw.write(
             "Echo \"Launching tests..."
                 + "\r\ncd C:\\Projects\\testSeleniumFramework\r\n"
                 + lineC
                 + "\r\n");
       }
       pullS = "";
       Process p =
           Runtime.getRuntime()
               .exec(
                   "cmd /c start C:\\Projects\\testSeleniumFramework\\framework\\runSelectedTests.bat");
     }
   } else {
   }
 }
Exemplo n.º 28
0
 public String table_selected(int i) {
   int row = info_table.getSelectedRow();
   return info_table.getValueAt(row, i).toString();
 }
Exemplo n.º 29
-8
 public ArrayList getSelectedMessages() {
   ArrayList list = new ArrayList();
   for (int i = 0; i < table.getRowCount(); i++) {
     if (((Boolean) table.getValueAt(i, 0)) == true) {
       list.add(msgID[i]);
     }
   }
   return list;
 }