示例#1
0
 public boolean calculate() throws SQLException {
   boolean ok = false;
   Object[] results = validacion.checkConsistenciaHI_HR(id_concurso);
   ok = (Boolean) results[0];
   if ((Boolean) results[0]) {
     labEstado.setText("Passed HI-HR test");
   } else {
     labEstado.setText("Failed HI-HR test");
     ArrayList<String[]> al = (ArrayList<String[]>) results[3];
     String[][] data = new String[al.size()][1];
     for (int i = 0; i < al.size(); i++) {
       data[i] = al.get(i);
     }
     String[] columnNames = {"Correlativo", "LitoCodigo", "Codigo Postulante", "Nro Aula"};
     tableHIs = new JTable(new HITableModel(data, columnNames));
     spHI.setViewportView(tableHIs);
     tableHIs.revalidate();
     ArrayList<String> al2 = (ArrayList<String>) results[4];
     data = new String[al2.size()][1];
     for (int i = 0; i < al2.size(); i++) {
       data[i][0] = al2.get(i);
     }
     tableHRs = new JTable(new HITableModel(data, new String[] {"LitoCodigo"}));
     spHR.setViewportView(tableHRs);
     tableHRs.revalidate();
     setVisible(false);
     setVisible(true);
     //                System.err.println(fillDashes("-", guiones));
   }
   labHI.setText(results[1] + "");
   labHR.setText(results[2] + "");
   return ok;
 }
示例#2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString());
   IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString());
   if (e.getSource() == buttonInsert) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       RoomsController.roomsController.save(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "ok");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonUpdate) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       rooms.setRoomID(IDROOM);
       RoomsController.roomsController.update(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "Update to succeed !");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonDelete) {
     try {
       List<CheckIn> temp = CheckInController.checkInController.all();
       for (int i = 0; i < temp.size(); i++) {
         if (IDROOM == temp.get(i).getRoomID()) {
           this.error = 0;
         } else {
           this.error = 0;
           RoomsController.roomsController.delete(IDROOM);
           int c = model.getRowCount();
           for (int ii = c - 1; ii >= 0; ii--) {
             model.removeRow(ii);
             jRoom.revalidate();
           }
           all();
         }
       }
       JOptionPane.showMessageDialog(this, "Delete to succeed !");
     } catch (Exception ex) {
       JOptionPane.showMessageDialog(this, "can't delete row bcause check still !");
     }
   }
   if (e.getSource() == buttonRefresh) {}
 }
示例#3
0
  public void update() {
    infoPanel.update();

    Object[][] history = new Object[account.getHistory().size()][5];
    int i = 0;
    for (Transaction t : account.getHistory()) {
      history[i][0] = t.getType();
      BigDecimal amount;
      BigDecimal balance;
      if (account.getType().isLoan()) {
        amount = (t.getType().isPositive() ? t.getAmount().negate() : t.getAmount());
        balance = t.getBalance().negate();
      } else {
        amount = (t.getType().isPositive() ? t.getAmount() : t.getAmount().negate());
        balance = t.getBalance();
      }
      history[i][1] = FORMATTER.valueToString(amount);
      history[i][2] = FORMATTER.valueToString(balance);
      history[i][3] = t.getTimestamp();
      history[i][4] = t.getFraudStatus();
      i++;
    }
    historyTable.setModel(
        new javax.swing.table.DefaultTableModel(
            history, new String[] {"Type", "Amount", "Balance", "Month", "Flag"}) {
          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        });
    historyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    historyTable.revalidate();
  }
示例#4
0
 /**
  * tests if there should be an empty row appended
  *
  * @param inserting is set: the selected cell will be filled but is not yet
  */
 public void addRow(boolean inserting) {
   int row = replaceTable.getSelectedRow();
   int col = replaceTable.getSelectedColumn();
   if (row + 1 == replaceTable.getRowCount() && col >= 0) {
     boolean[] colSet = new boolean[2];
     colSet[0] = !data.lastElement().firstElement().equals("");
     colSet[1] = !data.lastElement().lastElement().equals("");
     colSet[col] = colSet[col] || inserting;
     if (colSet[0] && colSet[1]) {
       TableCellEditor editor = replaceTable.getCellEditor();
       if (editor != null) {
         row = replaceTable.getEditingRow();
         col = replaceTable.getEditingColumn();
         data.get(row).set(col, editor.getCellEditorValue().toString());
       }
       data.add(new Vector<String>(Arrays.asList(new String[] {"", ""})));
       replaceTable.revalidate();
       CASSubDialog.this.pack();
       Rectangle r = replaceTable.getCellRect(replaceTable.getRowCount() - 1, col, false);
       scrollPane.getViewport().scrollRectToVisible(r);
       if (editor != null) {
         replaceTable.editCellAt(row, col);
       }
     }
   }
 }
示例#5
0
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals("Add Column")) {
     PopMessage.popMsg("Invalid new column for this window");
     // defaultModel.addColumn("AddColumn");
   }
   if (e.getActionCommand().equals("Add Row")) defaultModel.addRow(new Vector());
   if (e.getActionCommand().equals("Remove Column")) {
     PopMessage.popMsg("Invalid new column for this window");
     //            int columncount = defaultModel.getColumnCount() - 1;
     //            if (columncount >= 0) {
     //                TableColumnModel columnModel = table.getColumnModel();
     //                TableColumn tableColumn = columnModel.getColumn(columncount);
     //                columnModel.removeColumn(tableColumn);
     //                defaultModel.setColumnCount(columncount);
     //            }
   }
   if (e.getActionCommand().equals("Remove Row")) {
     int rowcount = defaultModel.getRowCount() - 1;
     if (rowcount >= 0) {
       defaultModel.removeRow(rowcount);
       defaultModel.setRowCount(rowcount);
     }
   }
   table.revalidate();
 }
示例#6
0
  /** Sets the call stack with the given vector of method names. */
  public void setContents(Vector newMethodNames) {
    methodNames = (Vector) newMethodNames.clone();
    callStackTable.revalidate();

    Rectangle r = callStackTable.getCellRect(newMethodNames.size() - 1, 0, true);
    callStackTable.scrollRectToVisible(r);
    repaint();
  }
  /** Load the gui values from the data object attributes. */
  public void loadFromObject() {
    InterfaceRegistry registry = (InterfaceRegistry) iobject;
    int row = 0;

    for (Iterator i = registry.getGagingSystemIterator(); i.hasNext(); ) {
      gagingSystemTableModel.setValueAt(i.next(), row++, 0);
    }

    gagingSystemTable.revalidate();
  }
  private void setSizeAndDimensions(
      @NotNull JTable table,
      @NotNull JBPopup popup,
      @NotNull RelativePoint popupPosition,
      @NotNull List<UsageNode> data) {
    JComponent content = popup.getContent();
    Window window = SwingUtilities.windowForComponent(content);
    Dimension d = window.getSize();

    int width = calcMaxWidth(table);
    width = (int) Math.max(d.getWidth(), width);
    Dimension headerSize = ((AbstractPopup) popup).getHeaderPreferredSize();
    width = Math.max((int) headerSize.getWidth(), width);
    width = Math.max(myWidth, width);

    if (myWidth == -1) myWidth = width;
    int newWidth = Math.max(width, d.width + width - myWidth);

    myWidth = newWidth;

    int rowsToShow = Math.min(30, data.size());
    Dimension dimension = new Dimension(newWidth, table.getRowHeight() * rowsToShow);
    Rectangle rectangle = fitToScreen(dimension, popupPosition, table);
    dimension = rectangle.getSize();
    Point location = window.getLocation();
    if (!location.equals(rectangle.getLocation())) {
      window.setLocation(rectangle.getLocation());
    }

    if (!data.isEmpty()) {
      TableScrollingUtil.ensureSelectionExists(table);
    }
    table.setSize(dimension);
    // table.setPreferredSize(dimension);
    // table.setMaximumSize(dimension);
    // table.setPreferredScrollableViewportSize(dimension);

    Dimension footerSize = ((AbstractPopup) popup).getFooterPreferredSize();

    int newHeight =
        (int) (dimension.height + headerSize.getHeight() + footerSize.getHeight())
            + 4 /* invisible borders, margins etc*/;
    Dimension newDim = new Dimension(dimension.width, newHeight);
    window.setSize(newDim);
    window.setMinimumSize(newDim);
    window.setMaximumSize(newDim);

    window.validate();
    window.repaint();
    table.revalidate();
    table.repaint();
  }
示例#9
0
 private void addButtonActionPerfomed(ActionEvent evt) {
   try {
     WorkCard.getWork().addCard(Integer.parseInt(tficon.getText()), tfcolor.getText());
     if (searchFrame.getSearchRequest() != null) {
       Search search = new CardSearch();
       model.setArrayOfCards(
           (ArrayList<Card>) search.regularSearch(searchFrame.getSearchRequest()));
     }
   } catch (NotFoundException ex) {
     log.debug(ex.getMessage());
   }
   tficon.setText("");
   tfcolor.setText("");
   jTable1.revalidate();
   jTable1.repaint();
 }
示例#10
0
  private void deleteButtonActionPerfomed(ActionEvent evt) {
    try {
      if ((jTable1.getSelectedRow() >= 0)
          && (jTable1.getSelectedRow() < WorkCard.getWork().getOfCountCards())) {
        WorkCard.getWork()
            .deleteCard(
                WorkCard.getWork().getArrOfCards().get(jTable1.getSelectedRow()).getIcon(),
                WorkCard.getWork().getArrOfCards().get(jTable1.getSelectedRow()).getColor());
        if (searchFrame.getSearchRequest() != null) {
          Search search = new CardSearch();
          model.setArrayOfCards(
              (ArrayList<Card>) search.regularSearch(searchFrame.getSearchRequest()));
        }
      }
    } catch (NotFoundException e) {
      log.debug(e.getMessage());
    }

    jTable1.revalidate();
    jTable1.repaint();
  }
  private void okButtonActionPerfomed(ActionEvent evt) {
    searchRequest = tfsearch.getText();
    try {
      Search search = new UserSearch();
      if (isRegular) {
        model.setArrayOfUsers((ArrayList<User>) search.searchByRegexp(searchRequest));
      } else {
        model.setArrayOfUsers((ArrayList<User>) search.searchBySubstring(searchRequest));
      }
      // memberList.setTable(table);
      table.revalidate();
      table.repaint();

      this.setVisible(false); // TODO мб this.dispose(); ?

    } catch (NotFoundException e) {
      jMessage.setText("Nothing found.");
    }
    //   finally {
    //     this.setVisible(false);
    // }
  }
示例#12
0
 private void clearButtonActionPerformed(ActionEvent evt) {
   model.setArrayOfCards(WorkCard.getWork().getArrOfCards());
   searchFrame.setSearchRequest(null);
   jTable1.revalidate();
   jTable1.repaint();
 }
 /**
  * Called when the system table model has changed.
  *
  * @param event The table model event.
  */
 public void tableChanged(TableModelEvent event) {
   gagingSystemTable.revalidate();
 }
 /** Called when revalidate is required. */
 public void revalidateChange() {
   segmentTable.revalidate();
   repaint();
 }
 /** Sets the start address. */
 public void setStartAddress(int index) {
   startAddress = index;
   segmentTable.revalidate();
 }
示例#16
0
 /** Resets the contents of this CallStackComponent. */
 public void reset() {
   methodNames.removeAllElements();
   callStackTable.revalidate();
   callStackTable.clearSelection();
 }
示例#17
0
  private ClientWindow(String name) {
    setTitle("ClientWindow");
    setContentPane(WindowPanel);
    pack();

    clientFacade = ClientFacade.getClientFacadeByClientName(name);
    NameLabel.setText(clientFacade.getClientName());

    productItemMap = clientFacade.getProductList();
    FormOrderPanel.setVisible(false);

    tableModel = new ProductsTableModel();
    ProductsTable.setModel(tableModel);

    root = new DefaultMutableTreeNode("ClientOrders");

    generateOrdersTree();

    OrdersTree.setModel(new DefaultTreeModel(root));
    OrdersTree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
              TreePath pathSelected = OrdersTree.getSelectionPath();
              if (OrdersTree.isPathSelected(pathSelected)
                  && OrdersTree.getModel().isLeaf(pathSelected.getLastPathComponent())) {
                ManagerPopupMenu managerPopupMenu = new ManagerPopupMenu();
                managerPopupMenu.getJPopupMenu().show(e.getComponent(), e.getX(), e.getY());
              }
            }
          }
        });
    OrdersTree.setShowsRootHandles(true);
    OrdersTree.setRootVisible(true);

    OrdersTree.getSelectionModel()
        .addTreeSelectionListener(
            e -> {
              DefaultMutableTreeNode selectedNode =
                  (DefaultMutableTreeNode) OrdersTree.getLastSelectedPathComponent();
              if (selectedNode.isLeaf()) {
                if (!((String) selectedNode.getUserObject()).equals("ClientOrders")) {
                  List<ProductRow> productRowList =
                      clientFacade.getProductRowsByOrder(
                          clientFacade.getValidDate((String) selectedNode.getUserObject()));
                  productRowList
                      .stream()
                      .forEach(
                          productRow ->
                              ClientWindow.this.tableModel.addRow(
                                  productRow.getId(),
                                  productRow.getType(),
                                  productRow.getPrice(),
                                  productRow.getNumber()));

                  ProductsTable.revalidate();
                }
              }
            });

    Font font = new Font("Verdana", Font.PLAIN, 12);
    jMenuBar = new JMenuBar();
    jMenu = new JMenu("Actions");

    JMenuItem jCreateProviderOrderItem = new JMenuItem("Создать заказ");
    jCreateProviderOrderItem.setFont(font);
    jCreateProviderOrderItem.addActionListener(e -> openClientOrderForm());
    jMenu.add(jCreateProviderOrderItem);

    jMenu.addSeparator();

    JMenuItem jCloseItem = new JMenuItem("Закрыть");
    jCloseItem.setFont(font);
    jCloseItem.addActionListener(e -> close());
    jMenu.add(jCloseItem);

    jMenuBar.add(jMenu);
    MenuPanel.add(jMenuBar);

    OrderOkButton.addActionListener(e -> createClientOrder());
    OrderCancelButton.addActionListener(e -> closeClientOrderForm());
    TypeComboBox.addItemListener(e -> setPriceByType());
    AddProductButton.addActionListener(
        e -> {
          if (productItemList == null) {
            productItemList = new HashMap<String, ProductItem>();
          }
          productItemList.put(
              TypeComboBox.getSelectedItem().toString(),
              new ProductItem(
                  TypeComboBox.getSelectedItem().toString(),
                  PriceTextField.getText(),
                  AmountTextField.getText()));
        });

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);

    BurgerButton.addActionListener(e -> FastFoodTextArea.append(clientFacade.getBurger()));

    RunServerButton.addActionListener(e -> InfoTextArea.append(clientFacade.runServer()));

    StopServerButton.addActionListener(e -> InfoTextArea.append(clientFacade.stopServer()));
  }
示例#18
0
 private void scrollToRow(int row) {
   java.awt.Rectangle rect = selectedExpressions.getCellRect(row, 1, false);
   selectedExpressions.scrollRectToVisible(rect);
   selectedExpressions.revalidate();
 }
  public ImportCustomizationDialog(final JabRefFrame frame) {
    super(frame, Localization.lang("Manage custom imports"), false);

    ImportTableModel tableModel = new ImportTableModel();
    customImporterTable = new JTable(tableModel);
    TableColumnModel cm = customImporterTable.getColumnModel();
    cm.getColumn(0).setPreferredWidth(COL_0_WIDTH);
    cm.getColumn(1).setPreferredWidth(COL_1_WIDTH);
    cm.getColumn(2).setPreferredWidth(COL_2_WIDTH);
    cm.getColumn(3).setPreferredWidth(COL_3_WIDTH);
    JScrollPane sp =
        new JScrollPane(
            customImporterTable,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    customImporterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    customImporterTable.setPreferredScrollableViewportSize(getSize());
    if (customImporterTable.getRowCount() > 0) {
      customImporterTable.setRowSelectionInterval(0, 0);
    }

    JButton addFromFolderButton = new JButton(Localization.lang("Add from folder"));
    addFromFolderButton.addActionListener(
        e -> {
          FileDialog dialog = new FileDialog(frame).withExtension(FileExtensions.CLASS);
          dialog.setDefaultExtension(FileExtensions.CLASS);
          Optional<Path> selectedFile = dialog.showDialogAndGetSelectedFile();

          if (selectedFile.isPresent() && (selectedFile.get().getParent() != null)) {
            String chosenFileStr = selectedFile.get().toString();

            try {
              String basePath = selectedFile.get().getParent().toString();
              String className = pathToClass(basePath, new File(chosenFileStr));
              CustomImporter importer = new CustomImporter(basePath, className);

              addOrReplaceImporter(importer);
              customImporterTable.revalidate();
              customImporterTable.repaint();
            } catch (Exception exc) {
              JOptionPane.showMessageDialog(
                  frame, Localization.lang("Could not instantiate %0", chosenFileStr));
            } catch (NoClassDefFoundError exc) {
              JOptionPane.showMessageDialog(
                  frame,
                  Localization.lang(
                      "Could not instantiate %0. Have you chosen the correct package path?",
                      chosenFileStr));
            }
          }
        });
    addFromFolderButton.setToolTipText(
        Localization.lang("Add a (compiled) custom Importer class from a class path.")
            + "\n"
            + Localization.lang("The path need not be on the classpath of JabRef."));

    JButton addFromJarButton = new JButton(Localization.lang("Add from JAR"));
    addFromJarButton.addActionListener(
        e -> {
          FileDialog dialog =
              new FileDialog(frame)
                  .withExtensions(EnumSet.of(FileExtensions.ZIP, FileExtensions.JAR));
          dialog.setDefaultExtension(FileExtensions.JAR);
          Optional<Path> jarZipFile = dialog.showDialogAndGetSelectedFile();

          if (jarZipFile.isPresent()) {
            try (ZipFile zipFile = new ZipFile(jarZipFile.get().toFile(), ZipFile.OPEN_READ)) {
              ZipFileChooser zipFileChooser = new ZipFileChooser(this, zipFile);
              zipFileChooser.setVisible(true);
              customImporterTable.revalidate();
              customImporterTable.repaint(10);
            } catch (IOException exc) {
              LOGGER.info("Could not open ZIP-archive.", exc);
              JOptionPane.showMessageDialog(
                  frame,
                  Localization.lang("Could not open %0", jarZipFile.get().toString())
                      + "\n"
                      + Localization.lang("Have you chosen the correct package path?"));
            } catch (NoClassDefFoundError exc) {
              LOGGER.info("Could not instantiate ZIP-archive reader.", exc);
              JOptionPane.showMessageDialog(
                  frame,
                  Localization.lang("Could not instantiate %0", jarZipFile.get().toString())
                      + "\n"
                      + Localization.lang("Have you chosen the correct package path?"));
            }
          }
        });
    addFromJarButton.setToolTipText(
        Localization.lang("Add a (compiled) custom Importer class from a ZIP-archive.")
            + "\n"
            + Localization.lang("The ZIP-archive need not be on the classpath of JabRef."));

    JButton showDescButton = new JButton(Localization.lang("Show description"));
    showDescButton.addActionListener(
        e -> {
          int row = customImporterTable.getSelectedRow();
          if (row == -1) {
            JOptionPane.showMessageDialog(frame, Localization.lang("Please select an importer."));
          } else {
            CustomImporter importer =
                ((ImportTableModel) customImporterTable.getModel()).getImporter(row);
            JOptionPane.showMessageDialog(frame, importer.getDescription());
          }
        });

    JButton removeButton = new JButton(Localization.lang("Remove"));
    removeButton.addActionListener(
        e -> {
          int row = customImporterTable.getSelectedRow();
          if (row == -1) {
            JOptionPane.showMessageDialog(frame, Localization.lang("Please select an importer."));
          } else {
            customImporterTable.removeRowSelectionInterval(row, row);
            Globals.prefs.customImports.remove(
                ((ImportTableModel) customImporterTable.getModel()).getImporter(row));
            Globals.IMPORT_FORMAT_READER.resetImportFormats(
                Globals.prefs.getImportFormatPreferences(), Globals.prefs.getXMPPreferences());
            customImporterTable.revalidate();
            customImporterTable.repaint();
          }
        });

    Action closeAction =
        new AbstractAction() {

          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        };

    JButton closeButton = new JButton(Localization.lang("Close"));
    closeButton.addActionListener(closeAction);

    JButton helpButton = new HelpAction(HelpFile.CUSTOM_IMPORTS).getHelpButton();

    // Key bindings:
    JPanel mainPanel = new JPanel();
    ActionMap am = mainPanel.getActionMap();
    InputMap im = mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", closeAction);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(sp, BorderLayout.CENTER);
    JPanel buttons = new JPanel();
    ButtonBarBuilder bb = new ButtonBarBuilder(buttons);
    buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    bb.addGlue();
    bb.addButton(addFromFolderButton);
    bb.addButton(addFromJarButton);
    bb.addButton(showDescButton);
    bb.addButton(removeButton);
    bb.addButton(closeButton);
    bb.addUnrelatedGap();
    bb.addButton(helpButton);
    bb.addGlue();

    getContentPane().add(mainPanel, BorderLayout.CENTER);
    getContentPane().add(buttons, BorderLayout.SOUTH);
    this.setSize(getSize());
    pack();
    this.setLocationRelativeTo(frame);
    customImporterTable.requestFocus();
  }