private void selFolder() {
   // selects a single folder, then makes table uneditable other than launch, sel res folder and
   // cancel, gui table different, just shows folder
   final JFileChooser fc = new JFileChooser(currentPath);
   fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   int result = fc.showOpenDialog(FrontEnd.this);
   dir = fc.getSelectedFile();
   switch (result) {
     case JFileChooser.APPROVE_OPTION:
       dirImp = dir.toString();
       dtm.getDataVector().removeAllElements();
       dtm.fireTableDataChanged();
       curRow = 0;
       addRow();
       dtm.setValueAt(
           "You have chosen the folder '" + dirImp.substring(67) + "' and all of its subfolders.",
           0,
           0);
       dtm.setValueAt(dirImp.substring(67), 0, 1);
       if (table.getRowCount() > 0) {
         openF.setEnabled(false);
         openFo.setEnabled(false);
         selFo.setEnabled(false);
         canF.setEnabled(true);
       }
       selFoFl = 1;
     case JFileChooser.CANCEL_OPTION:
       break;
   }
 }
Example #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;
  }
 private void addRow() {
   if (table.getSelectedRow() != -1) {
     // inserts row below the selected one else bottom
     int numRow = table.getRowCount();
     dtm.insertRow(numRow + 1, ",".split(","));
   } else {
     dtm.addRow(",".split(","));
   }
 }
Example #4
0
 /** 增加 */
 private void processAddEvent() {
   Frame frame = JActiveDComDM.MainApplication.MainWindow;
   JManageCTimeDialog ctimeDlg;
   ctimeDlg = new JManageCTimeDialog(frame, "添加时间方案", true);
   ctimeDlg.setSize(480, 310);
   ctimeDlg.setMinimumSize(480, 310);
   ctimeDlg.CenterWindow();
   ctimeDlg.setVisible(true);
   if (ctimeDlg.OPTION == ctimeDlg.OPTION_OK) {
     int index = timeTable.getRowCount();
     timeTable.getModel().setValueAt(ctimeDlg.getCTimeObject(), index, 0);
     timeTable.updateUI();
   }
 }
  /*
   *  Calculate the width based on the widest cell renderer for the
   *  given column.
   */
  private int getColumnDataWidth(int column) {
    if (!isColumnDataIncluded) return 0;

    int preferredWidth = 0;
    int maxWidth = table.getColumnModel().getColumn(column).getMaxWidth();

    for (int row = 0; row < table.getRowCount(); row++) {
      preferredWidth = Math.max(preferredWidth, getCellDataWidth(row, column));

      //  We've exceeded the maximum width, no need to check other rows

      if (preferredWidth >= maxWidth) break;
    }

    return preferredWidth;
  }
Example #6
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);
  }
 private void openFile() {
   // opens a single file chooser (can select multiple), does not traverse folders.
   this.copyList = new ArrayList();
   final JFileChooser fc = new JFileChooser(currentPath);
   fc.setMultiSelectionEnabled(true);
   fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
   FileNameExtensionFilter filterhtml = new FileNameExtensionFilter("HTML File (.html)", "html");
   fc.addChoosableFileFilter(filterhtml);
   fc.setFileFilter(filterhtml);
   int result = fc.showOpenDialog(FrontEnd.this);
   dir = fc.getCurrentDirectory();
   dirImp = dir.toString();
   switch (result) {
     case JFileChooser.APPROVE_OPTION:
       for (File file1 : fc.getSelectedFiles()) {
         fileImp = file1.toString();
         boolean exists = false;
         for (int i = 0; i < table.getRowCount(); i++) {
           dir = fc.getCurrentDirectory();
           dirImp = dir.toString();
           String copyC = dtm.getValueAt(i, 0).toString();
           if (duplC.isSelected()) {
             if (fileImp.endsWith(copyC)) {
               exists = true;
               break;
             }
           }
         }
         if (!exists) {
           addRow();
           dtm.setValueAt(fileImp.substring(67), curRow, 0);
           dtm.setValueAt(dirImp.substring(67), curRow, 1);
           curRow++;
           if (headC == 1) {
             if (fileImp.substring(67).endsWith(dirImp.substring(67) + ".html")) {
               curRow--;
               dtm.removeRow(curRow);
             }
           }
         }
       }
     case JFileChooser.CANCEL_OPTION:
       break;
   }
 }
 private void openFolder() {
   // opens all htmls in a folder other than the one with same name as folder
   final JFileChooser fc = new JFileChooser(currentPath);
   fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   int result = fc.showOpenDialog(FrontEnd.this);
   file = fc.getSelectedFiles();
   dir = fc.getSelectedFile();
   switch (result) {
     case JFileChooser.APPROVE_OPTION:
       dirImp = dir.toString();
       File[] filesInDirectory = dir.listFiles();
       for (File file1 : filesInDirectory) {
         String fileS = file1.toString();
         fileS.substring(fileS.lastIndexOf('.') + 1);
         if (fileS.contains("html")) {
           fileImp = file1.toString();
           boolean exists = false;
           for (int i = 0; i < table.getRowCount(); i++) {
             String copyC = dtm.getValueAt(i, 0).toString();
             if (duplC.isSelected()) {
               if (fileImp.contains(copyC)) {
                 exists = true;
                 break;
               }
             }
           }
           if (!exists) {
             addRow();
             dtm.setValueAt(fileImp.substring(67), curRow, 0);
             dtm.setValueAt(dirImp.substring(67), curRow, 1);
             curRow++;
             if (headC == 1) {
               if (fileImp.substring(67).endsWith(dirImp.substring(67) + ".html")) {
                 curRow--;
                 dtm.removeRow(curRow);
               }
             }
           }
         }
       }
     case JFileChooser.CANCEL_OPTION:
       break;
   }
 }
  /** 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));
    }
  }
Example #10
0
  @Override
  public void actionPerformed(ActionEvent axnEve) {
    Object obj = axnEve.getSource();

    if (obj == selectAllCB) {
      Boolean state;
      if (selectAllCB.isSelected()) {
        state = true;
        deleteBut.setVisible(true);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(true);
        }
      } else {
        state = false;
        deleteBut.setVisible(false);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(false);
        }
      }
      for (int i = 0; i < table.getRowCount(); i++) {
        table.setValueAt(state, i, 0);
      }
    } else if (obj == refreshBut || obj == backBut) {
      setContent(Home.titlePan.getTitle());
      backBut.setVisible(false);
    } else if (obj == deleteBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "DELETE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.deleteMessages(selectedMessages, Home.titlePan.getTitle());
          setContent(Home.titlePan.getTitle());
        }
      }
    } else if (obj == restoreBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "RESTORE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.restoreMessages(selectedMessages);
          setContent(Home.titlePan.getTitle());
        }
      }
    }
  }
 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 {
   }
 }
 /*
  *  Delegate method to main table
  */
 @Override
 public int getRowCount() {
   return main.getRowCount();
 }
Example #13
-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;
 }