コード例 #1
0
 public MyRenderComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
   super();
   this.table = table;
   this.col = col;
   if (value != null) {
     setText(value.toString());
   } else {
     setText("");
   }
   setOpaque(false);
   setFont(UIManager.getFont("TableHeader.font"));
   setForeground(UIManager.getColor("TableHeader.foreground"));
   setHorizontalAlignment(JLabel.CENTER);
   setHorizontalTextPosition(SwingConstants.LEADING);
   setBorder(UIManager.getBorder("TableHeader.cellBorder"));
   if ((JTattooUtilities.getJavaVersion() >= 1.6)
       && (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel)) {
     RowSorter rowSorter = table == null ? null : table.getRowSorter();
     List keyList = rowSorter == null ? null : rowSorter.getSortKeys();
     if ((keyList != null) && (keyList.size() > 0)) {
       RowSorter.SortKey sortKey = (RowSorter.SortKey) keyList.get(0);
       if (sortKey.getColumn() == table.convertColumnIndexToModel(col)) {
         AbstractIconFactory iconFactory =
             ((AbstractLookAndFeel) UIManager.getLookAndFeel()).getIconFactory();
         if (sortKey.getSortOrder().equals(SortOrder.ASCENDING)) {
           setIcon(iconFactory.getUpArrowIcon());
         } else if (sortKey.getSortOrder().equals(SortOrder.DESCENDING)) {
           setIcon(iconFactory.getDownArrowIcon());
         }
       }
     }
   }
   gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getTheme().getRolloverColor());
 }
コード例 #2
0
 private static void testJTable(JTable table, int iterations) {
   for (int i = 0; i < iterations; i++) {
     long time = System.currentTimeMillis();
     table.getRowSorter().toggleSortOrder(0);
     System.err.println(System.currentTimeMillis() - time + " ms");
   }
 }
コード例 #3
0
ファイル: Creator.java プロジェクト: hunter7654/aephyr
 private void updateFilter() {
   DefaultRowSorter<TableModel, Object> sorter =
       (DefaultRowSorter<TableModel, Object>) otherTable.getRowSorter();
   String key = keyFilter.getSelectedItem().toString();
   RowFilter<TableModel, Object> filter = null;
   if (!key.isEmpty()) {
     Object method = keyFilterMethod.getSelectedItem();
     if (method == STARTS_WITH) {
       filter = RowFilter.regexFilter('^' + Pattern.quote(key), UITableModel.KEY_COLUMN_INDEX);
     } else if (method == ENDS_WITH) {
       filter = RowFilter.regexFilter(Pattern.quote(key) + '$', UITableModel.KEY_COLUMN_INDEX);
     } else if (method == CONTAINS) {
       filter = RowFilter.regexFilter(Pattern.quote(key), UITableModel.KEY_COLUMN_INDEX);
     } else {
       filter = RowFilter.regexFilter(key, UITableModel.KEY_COLUMN_INDEX);
     }
   }
   String type = typeFilter.getSelectedItem().toString();
   if (!type.isEmpty()) {
     RowFilter<TableModel, Object> typeFilter =
         RowFilter.regexFilter('^' + type + '$', UITableModel.TYPE_COLUMN_INDEX);
     filter =
         filter == null
             ? typeFilter
             : RowFilter.<TableModel, Object>andFilter(Arrays.asList(filter, typeFilter));
   }
   sorter.setRowFilter(filter);
 }
コード例 #4
0
ファイル: Creator.java プロジェクト: hunter7654/aephyr
 private static JTable createUITable(
     boolean keyColumnResizable, int typeWidth, Type type, List<String> lst, Actions editAction) {
   String[] keys = lst.toArray(new String[lst.size()]);
   Arrays.sort(keys);
   TableModel mdl = type == null ? new UITableModel(keys) : new UITypeTableModel(keys, type, true);
   JTable table = new UITable(mdl, null);
   table.putClientProperty("JTable.autoStartsEdit", Boolean.FALSE);
   table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   table.setRowHeight(25);
   TableColumnModel columns = table.getColumnModel();
   int keyWidth = TABLE_WIDTH - typeWidth - VALUE_WIDTH - DEFAULT_WIDTH;
   columns.getColumn(UITableModel.KEY_COLUMN_INDEX).setMinWidth(keyWidth);
   columns.getColumn(UITableModel.KEY_COLUMN_INDEX).setPreferredWidth(keyWidth);
   columns.getColumn(UITableModel.KEY_COLUMN_INDEX).setResizable(keyColumnResizable);
   Creator.setWidth(columns.getColumn(UITableModel.TYPE_COLUMN_INDEX), typeWidth);
   TableColumn column = columns.getColumn(UITableModel.VALUE_COLUMN_INDEX);
   Creator.setWidth(column, VALUE_WIDTH);
   column.setCellRenderer(new UIDefaultsRenderer());
   column.setCellEditor(new UIDefaultsEditor());
   Creator.setWidth(columns.getColumn(UITableModel.DEFAULT_COLUMN_INDEX), DEFAULT_WIDTH);
   table.setAutoCreateRowSorter(true);
   DefaultRowSorter<?, ?> sorter = (DefaultRowSorter<?, ?>) table.getRowSorter();
   sorter.setSortable(UITableModel.VALUE_COLUMN_INDEX, false);
   table
       .getInputMap(JComponent.WHEN_FOCUSED)
       .put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTEXT_MENU, 0), editAction);
   table.getActionMap().put(editAction, editAction);
   return table;
 }
コード例 #5
0
ファイル: Creator.java プロジェクト: hunter7654/aephyr
 public void actionPerformed(ActionEvent e) {
   Object value = getValue(NAME);
   if (value == MNEMONIC) {
     JComponent c = (JComponent) e.getSource();
     c.requestFocusInWindow();
     value = getValue(MNEMONIC);
     if (value != null) {
       JComboBox combo = (JComboBox) c;
       combo.setSelectedItem(value);
     }
   } else if (value == EDIT) {
     JTable table = (JTable) e.getSource();
     int row = table.getSelectionModel().getLeadSelectionIndex();
     if (row < 0 || row >= table.getRowCount()) return;
     int col = UITableModel.VALUE_COLUMN_INDEX;
     table.editCellAt(row, table.convertColumnIndexToView(col));
   } else if (value == SORT) {
     value = getValue(SORT);
     JTable table = (JTable) e.getSource();
     for (int col = table.getColumnCount(); --col >= 0; ) {
       if (value.equals(table.getColumnName(col))) {
         table.getRowSorter().toggleSortOrder(table.convertColumnIndexToModel(col));
         break;
       }
     }
   } else if (value == CLOSE) {
     SwingUtilities.getWindowAncestor((Component) e.getSource()).dispose();
   }
 }
コード例 #6
0
 @SuppressWarnings("unchecked")
 @Override
 public int loop() {
   synchronized (lock) {
     try {
       if (!ui.isVisible()) handler.stopMod(getName());
       World world = minecraft.getWorld();
       JTable list = ui.getList();
       DefaultTableModel model = (DefaultTableModel) list.getModel();
       TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) list.getRowSorter();
       if (world != null) {
         Player currentPlayer = minecraft.getPlayer();
         int playerX = (int) java.lang.Math.round(currentPlayer.getX());
         int playerY = (int) java.lang.Math.round(currentPlayer.getY());
         int playerZ = (int) java.lang.Math.round(currentPlayer.getZ());
         ArrayList<Block> blocks = new ArrayList<Block>();
         for (int x = playerX - radius; x < playerX + radius; x++)
           for (int y = playerY - radius; y < playerY + radius; y++)
             for (int z = playerZ - radius; z < playerZ + radius; z++)
               if (world.getBlockIDAt(x, y, z) == blockID) blocks.add(new Block(x, y, z));
         label:
         for (int row = 0; row < model.getRowCount(); row++) {
           int x = (Integer) model.getValueAt(row, 1);
           int y = (Integer) model.getValueAt(row, 2);
           int z = (Integer) model.getValueAt(row, 3);
           for (Block block : blocks) {
             if (x == block.getX() && y == block.getY() && z == block.getZ()) {
               model.setValueAt(getDistanceTo(x, y, z, currentPlayer), row, 0);
               continue label;
             }
           }
           model.removeRow(row);
         }
         label:
         for (Block block : blocks) {
           for (int row = 0; row < model.getRowCount(); row++) {
             int x = (Integer) model.getValueAt(row, 1);
             int y = (Integer) model.getValueAt(row, 2);
             int z = (Integer) model.getValueAt(row, 3);
             if (x == block.getX() && y == block.getY() && z == block.getZ()) continue label;
           }
           model.addRow(
               new Object[] {
                 getDistanceTo(block.getX(), block.getY(), block.getZ(), minecraft.getPlayer()),
                 block.getX(),
                 block.getY(),
                 block.getZ()
               });
         }
         sorter.sort();
         list.repaint();
       } else {
         for (int i = model.getRowCount() - 1; i >= 0; i--) model.removeRow(i);
       }
     } catch (Exception exception) {
     }
   }
   return 500;
 }
コード例 #7
0
 public synchronized void enableDynamicSort(boolean enabled) {
   // enable or disable the dynamic sort. When dynamic sort is ON we always need that the model,
   // each times it
   // receives an update, asks the view for a complete refresh, so to enable the SortsOnUpdates we
   // have also to
   // enable the complete refresh on each update
   ((StockTable) table.getModel()).enableCompleteRefresh(enabled);
   ((TableRowSorter<?>) table.getRowSorter()).setSortsOnUpdates(enabled);
 }
コード例 #8
0
ファイル: EditorPane.java プロジェクト: hencjo/jOOQ
 public void setFilter(JTable table, String filter) {
   if (filter != null && filter.length() == 0) {
     this.filter = null;
     ((TableRowSorter<?>) table.getRowSorter()).setRowFilter(null);
     return;
   }
   this.filter = filter;
   ((TableRowSorter<?>) table.getRowSorter())
       .setRowFilter(
           new RowFilter<Object, Object>() {
             @Override
             public boolean include(
                 javax.swing.RowFilter.Entry<? extends Object, ? extends Object> entry) {
               String lcFilter = EditorPane.this.filter.toLowerCase();
               for (int i = entry.getValueCount() - 1; i >= 0; i--) {
                 if (entry.getStringValue(i).toLowerCase().contains(lcFilter)) {
                   return true;
                 }
               }
               return false;
             }
           });
 }
コード例 #9
0
 // This method is used to filter table by column
 protected void update_filter() {
   txt_search_word.setText("");
   Object selected = cmb_search_catagory.getSelectedItem();
   TableRowSorter<?> sorter = (TableRowSorter<?>) tbl_service_details.getRowSorter();
   String text = "(?i)" + txt_search_text.getText();
   if ("Nothing".equals(selected)) {
     sorter.setRowFilter(null);
   } else {
     int col = -1;
     if ("Customer Name".equals(selected)) {
       col = 1;
     } else if ("Vehicle Number".equals(selected)) {
       col = 3;
     }
     sorter.setRowFilter(RowFilter.regexFilter(text, col));
   }
 }
コード例 #10
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   JLabel c =
       (JLabel)
           super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   if (table.getRowSorter().convertRowIndexToModel(row) == currentActor.getDefaultAttack()) {
     MiscUtil.setLabelBold(c);
   }
   // Check parsing: at some point may want to create 'ParsingComponent' which has label and
   // textfield versions
   AttackTableModel.columns col = AttackTableModel.columns.valueOf(table.getColumnName(column));
   if (col == columns.Damage
       && !ParsingFieldParserFactory.DamageParser().parseIsValid(c.getText()))
     c.setForeground(Color.red);
   else c.setForeground(Color.black);
   return c;
 }
コード例 #11
0
 private void openSWF() {
   if (foundIs == null) {
     return;
   }
   int index = tableRes.getRowSorter().convertRowIndexToModel(tableRes.getSelectedRow());
   if (index > -1) {
     SwfInMemory swf = foundIs.get(index);
     ReReadableInputStream str = swf.is;
     try {
       str.seek(0);
     } catch (IOException ex) {
       Logger.getLogger(LoadFromMemoryFrame.class.getName()).log(Level.SEVERE, null, ex);
       return;
     }
     str.mark(Integer.MAX_VALUE);
     SWFSourceInfo sourceInfo =
         new SWFSourceInfo(str, null, swf.process + " [" + (index + 1) + "]");
     Main.openFile(sourceInfo);
   }
 }
コード例 #12
0
ファイル: SQLReadSingleLogic.java プロジェクト: epinhao/Tesis
  public static void main(String[] args) throws IOException {

    Sql reader = new Sql();
    final String emisora = "BIMBO";
    final String serie = "";
    final Calendar day = new GregorianCalendar(2010, 10, 17);
    ArrayList<Orden> ordenes = reader.readIniciales(emisora, serie, day);
    reader.read(ordenes, emisora, serie, day);

    String datetext =
        day.get(Calendar.YEAR) + "" + (day.get(Calendar.MONTH) + 1) + "" + day.get(Calendar.DATE);

    FileWriter fw = new FileWriter("ordenes" + emisora + datetext + ".txt");
    final BufferedWriter bw = new BufferedWriter(fw);

    FileWriter fw2 = new FileWriter("ordenes2" + emisora + datetext + ".txt");
    final BufferedWriter bw2 = new BufferedWriter(fw2);

    FileWriter fwc = new FileWriter("compra" + emisora + datetext + ".txt");
    final BufferedWriter bwc = new BufferedWriter(fwc);

    FileWriter fwv = new FileWriter("venta" + emisora + datetext + ".txt");
    final BufferedWriter bwv = new BufferedWriter(fwv);

    FileWriter fwd = new FileWriter("distancia" + emisora + datetext + ".txt");
    final BufferedWriter bwd = new BufferedWriter(fwd);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final DefaultTableModel modelVenta =
        new DefaultTableModel() {
          @Override
          public Class getColumnClass(int column) {
            if (column == 1) {
              return BigDecimal.class;
            }
            return Object.class;
          }
        };
    final DefaultTableModel modelCompra =
        new DefaultTableModel() {
          @Override
          public Class getColumnClass(int column) {
            if (column == 1) {
              return BigDecimal.class;
            }
            return Object.class;
          }
        };
    final DefaultTableModel modelExec = new DefaultTableModel();
    final DefaultTableModel modelExec2 = new DefaultTableModel();
    final DefaultTableModel modelOrdenes = new DefaultTableModel();

    final JTable tableVenta = new JTable(modelVenta);
    tableVenta.setAutoCreateRowSorter(true);
    final JTable tableCompra = new JTable(modelCompra);
    tableCompra.setAutoCreateRowSorter(true);
    final JTable tableExec = new JTable(modelExec);
    final JTable tableExec2 = new JTable(modelExec2);
    final JTable tableOrdenes = new JTable(modelOrdenes);

    JScrollPane scrollPaneVenta = new JScrollPane(tableVenta);
    JScrollPane scrollPaneCompra = new JScrollPane(tableCompra);
    JScrollPane scrollPaneExec = new JScrollPane(tableExec);
    JScrollPane scrollPaneExec2 = new JScrollPane(tableExec2);
    JScrollPane scrollPaneOrdenes = new JScrollPane(tableOrdenes);
    scrollPaneVenta.setBounds(0, 0, 400, 250);
    scrollPaneCompra.setBounds(0, 250, 400, 250);
    scrollPaneExec.setBounds(400, 0, 400, 250);
    scrollPaneExec2.setBounds(400, 250, 400, 250);
    scrollPaneOrdenes.setBounds(0, 500, 800, 200);
    frame.setLayout(null);
    frame.add(scrollPaneVenta);
    frame.add(scrollPaneCompra);
    frame.add(scrollPaneExec);
    frame.add(scrollPaneExec2);
    frame.add(scrollPaneOrdenes);
    frame.setSize(806, 792);
    frame.setVisible(true);
    frame.setResizable(false);
    ArrayList<SortKey> sortKeysv = new ArrayList<RowSorter.SortKey>();
    sortKeysv.add(new RowSorter.SortKey(1, SortOrder.DESCENDING));
    sortKeysv.add(new RowSorter.SortKey(3, SortOrder.DESCENDING));
    modelVenta.addColumn("");
    modelVenta.addColumn("Precio");
    modelVenta.addColumn("Volumen");
    modelVenta.addColumn("Folio");
    tableVenta.getRowSorter().setSortKeys(sortKeysv);
    ArrayList<SortKey> sortKeysc = new ArrayList<RowSorter.SortKey>();
    sortKeysc.add(new RowSorter.SortKey(1, SortOrder.DESCENDING));
    sortKeysc.add(new RowSorter.SortKey(3, SortOrder.ASCENDING));
    modelCompra.addColumn("");
    modelCompra.addColumn("Precio");
    modelCompra.addColumn("Volumen");
    modelCompra.addColumn("Folio");
    tableCompra.getRowSorter().setSortKeys(sortKeysc);
    modelExec.addColumn("Hora");
    modelExec.addColumn("Precio");
    modelExec.addColumn("Volumen");
    modelExec2.addColumn("Hora");
    modelExec2.addColumn("Precio");
    modelExec2.addColumn("Volumen");
    modelOrdenes.addColumn("Tipo");
    modelOrdenes.addColumn("Precio");
    modelOrdenes.addColumn("Volumen");
    modelOrdenes.addColumn("Hora");
    modelOrdenes.addColumn("Folio");
    modelOrdenes.addColumn("Folio Ant.");
    modelOrdenes.addColumn("Casa de Bolsa");
    Object[] columns = {
      "Tipo", "Precio", "Volumen", "Hora", "Folio", "Folio Ant.", "Casa de Bolsa", "Orden"
    };
    Vector<Object> columnNames = convertToVector(columns);
    Vector<Object> data = new Vector<Object>(6000);
    for (int i = 0; i < ordenes.size(); i++) {
      Vector<Object> row = convertToVector(ordenes.get(i).toRow());
      data.add(row);
    }
    modelOrdenes.setDataVector(data, columnNames);
    DateRenderer2 render = new DateRenderer2();
    tableOrdenes.getColumnModel().getColumn(3).setCellRenderer(render);
    tableExec.getColumnModel().getColumn(0).setCellRenderer(render);
    tableExec2.getColumnModel().getColumn(0).setCellRenderer(render);
    JButton buttonNext = new JButton("Siguiente");
    buttonNext.setBounds(30, 716, 100, 30);
    frame.add(buttonNext);
    buttonNext.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            if (modelOrdenes.getRowCount() > 0)
              action(
                  day,
                  modelCompra,
                  modelVenta,
                  modelOrdenes,
                  modelExec,
                  modelExec2,
                  tableCompra,
                  tableVenta,
                  tableExec,
                  tableExec2,
                  bw,
                  bw2,
                  bwc,
                  bwv,
                  bwd);
          }
        });

    JButton buttonDeleteCompra = new JButton("Cancelar Compra");
    buttonDeleteCompra.setBounds(150, 716, 200, 30);
    frame.add(buttonDeleteCompra);
    buttonDeleteCompra.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            int d = tableCompra.getSelectedRow();
            try {
              modelCompra.removeRow(tableCompra.convertRowIndexToModel(d));
            } catch (Exception ex) {
              System.out.println("Cannot delete row: " + ex);
            }
          }
        });

    JButton buttonDeleteVenta = new JButton("Cancelar Venta");
    buttonDeleteVenta.setBounds(370, 716, 200, 30);
    frame.add(buttonDeleteVenta);
    buttonDeleteVenta.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            int d = tableVenta.getSelectedRow();
            try {
              modelVenta.removeRow(tableVenta.convertRowIndexToModel(d));
            } catch (Exception ex) {
              System.out.println("Cannot delete row: " + ex);
            }
          }
        });
    JButton buttonPlay = new JButton("Play");
    buttonPlay.setBounds(600, 716, 100, 30);
    frame.add(buttonPlay);
    buttonPlay.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            int i = 0;
            // while(tableOrdenes.getRowCount() > 0 && i < 100) {
            while (tableOrdenes.getRowCount() > 0) {
              Date cal = (Date) modelOrdenes.getValueAt(0, 3);
              action(
                  day,
                  modelCompra,
                  modelVenta,
                  modelOrdenes,
                  modelExec,
                  modelExec2,
                  tableCompra,
                  tableVenta,
                  tableExec,
                  tableExec2,
                  bw,
                  bw2,
                  bwc,
                  bwv,
                  bwd);
              // modelCompra.getValueAt(0, 1)

              i++;
            }
            if (tableOrdenes.getRowCount() <= 0)
              try {
                bw.close();
                bw2.close();
                bwc.close();
                bwv.close();
                bwd.close();
              } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
          }
        });
  }
コード例 #13
0
ファイル: Ssys3.java プロジェクト: scyptnex/computing
  public void makeGUI() {
    frm = new JFrame();
    c = frm.getContentPane();

    btnImport = new JButton("Import");
    btnImport.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureImport();
          }
        });
    btnMove = new JButton("Move");
    btnMove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureMove();
          }
        });
    btnDelete = new JButton("Delete");
    btnDelete.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureDelete();
          }
        });
    btnAnalyse = new JButton("Analyse");
    btnAnalyse.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            secureAnalysis();
          }
        });

    tblItems = new JTable(store);
    tblItems.setRowSorter(tableSorter);
    tblItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblItems.setFillsViewportHeight(true);
    tblItems.getRowSorter().toggleSortOrder(Storage.COL_DATE);
    tblItems.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
              tblItems.setRowSelectionInterval(
                  e.getY() / tblItems.getRowHeight(), e.getY() / tblItems.getRowHeight());
            }
            if (e.getClickCount() > 1 || e.getButton() == MouseEvent.BUTTON3) {
              int idx = tblItems.convertRowIndexToModel(tblItems.getSelectedRow());
              secureExport(idx);
            }
          }

          public void mouseEntered(MouseEvent arg0) {}

          public void mouseExited(MouseEvent arg0) {}

          public void mousePressed(MouseEvent arg0) {}

          public void mouseReleased(MouseEvent arg0) {}
        });

    txaStatus = new JTextArea(TXA_HEIGHT, TXA_WIDTH);
    txaStatus.setEditable(false);
    txaStatus.setBorder(BorderFactory.createTitledBorder("Status"));
    txaSearch = new JTextArea(4, TXA_WIDTH);
    txaSearch.setBorder(BorderFactory.createTitledBorder("Search"));
    txaSearch.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent arg0) {}

          public void keyReleased(KeyEvent arg0) {
            filterBase(txaSearch.getText());
            // EXPORT settings here, as in mass export (export everything)
            if (allowExport && txaSearch.getText().equalsIgnoreCase(CMD_EXPORT)) {
              // txaSearch.setText("");
              if (JOptionPane.showConfirmDialog(
                      frm,
                      "Do you really want to export the whole secure base?",
                      "Confirm Export",
                      JOptionPane.OK_CANCEL_OPTION)
                  == JOptionPane.OK_OPTION) {
                totalExport();
              }
            }
            // LOST X IMPORT asin look through the store for files not listed
            if (txaSearch.getText().equalsIgnoreCase(CMD_STOCKTAKE)) {
              for (int i = 0; i < storeLocs.size(); i++) {
                if (store.stockTake(i)) needsSave = true;
              }
            }
          }

          public void keyTyped(KeyEvent arg0) {}
        });

    JPanel pnlTop = new JPanel(new GridLayout(1, 4));
    JPanel pnlEast = new JPanel(new BorderLayout());
    JPanel pnlCenterEast = new JPanel(new BorderLayout());
    JScrollPane jspItems = new JScrollPane(tblItems);

    pnlTop.add(btnImport);
    pnlTop.add(btnMove);
    pnlTop.add(btnDelete);
    pnlTop.add(btnAnalyse);
    pnlCenterEast.add(txaStatus, BorderLayout.CENTER);
    pnlCenterEast.add(txaSearch, BorderLayout.NORTH);
    // pnlEast.add(pswPass, BorderLayout.NORTH);
    pnlEast.add(pnlCenterEast, BorderLayout.CENTER);
    c.setLayout(new BorderLayout());
    c.add(pnlTop, BorderLayout.NORTH);
    c.add(pnlEast, BorderLayout.EAST);
    c.add(jspItems, BorderLayout.CENTER);
    frm.setContentPane(c);
  }
コード例 #14
0
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    // Whether we are printing the result or not
    boolean isPaintingForPrint = false;

    // Title icon
    Icon sortIcon = null;
    if (table != null) {
      JTableHeader header = table.getTableHeader();
      if (header != null) {
        Color fgColor = null;
        Color bgColor = null;
        if (hasFocus) {
          fgColor = UIManager.getColor("TableHeader.focusCellForeground");
          bgColor = UIManager.getColor("TableHeader.focusCellBackground");
        }
        if (fgColor == null) {
          fgColor = header.getForeground();
        }
        if (bgColor == null) {
          bgColor = header.getBackground();
        }
        setForeground(fgColor);
        setBackground(bgColor);

        setFont(header.getFont());

        isPaintingForPrint = header.isPaintingForPrint();
      }

      if (!isPaintingForPrint && table.getRowSorter() != null) {
        if (!horizontalTextPositionSet) {
          // There is a row sorter, and the developer hasn't
          // set a text position, change to leading.
          setHorizontalTextPosition(JLabel.LEADING);
        }
        List<? extends RowSorter.SortKey> sortKeys = table.getRowSorter().getSortKeys();
        if (sortKeys.size() > 0
            && sortKeys.get(0).getColumn() == table.convertColumnIndexToModel(column)) {
          switch (sortKeys.get(0).getSortOrder()) {
            case ASCENDING:
              sortIcon = UIManager.getIcon("Table.ascendingSortIcon");
              break;
            case DESCENDING:
              sortIcon = UIManager.getIcon("Table.descendingSortIcon");
              break;
            case UNSORTED:
              sortIcon = UIManager.getIcon("Table.naturalSortIcon");
              break;
          }
        }
      }
    }
    setIcon(sortIcon);

    // Title text
    setText(value == null ? "" : value.toString());

    // Title margin
    setMargin(WebTableStyle.headerMargin);

    return this;
  }
コード例 #15
0
  @Override
  public void actionPerformed(ActionEvent e) {
    switch (e.getActionCommand()) {
      case ACTION_SELECT_PROCESS:
        selectProcess();
        break;
      case ACTION_OPEN_SWF:
        openSWF();
        break;
      case ACTION_REFRESH_PROCESS_LIST:
        refreshList();
        break;
      case ACTION_SAVE:
        if (foundIs == null) {
          return;
        }
        int[] selected = tableRes.getSelectedRows();
        if (selected.length > 0) {
          JFileChooser fc = new JFileChooser();
          fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
          if (selected.length > 1) {
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
          } else {
            fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), "movie.swf"));
            fc.setFileFilter(
                new FileFilter() {
                  @Override
                  public boolean accept(File f) {
                    return (f.getName().endsWith(".swf")) || (f.isDirectory());
                  }

                  @Override
                  public String getDescription() {
                    return AppStrings.translate("filter.swf");
                  }
                });
          }
          fc.setAcceptAllFileFilterUsed(false);
          JFrame f = new JFrame();
          View.setWindowIcon(f);
          if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
            File file = Helper.fixDialogFile(fc.getSelectedFile());
            try {
              if (selected.length == 1) {
                SwfInMemory swf =
                    foundIs.get(tableRes.getRowSorter().convertRowIndexToModel(selected[0]));
                ReReadableInputStream bis = swf.is;
                bis.seek(0);
                Helper.saveStream(bis, file);
              } else {
                for (int sel : selected) {
                  SwfInMemory swf =
                      foundIs.get(tableRes.getRowSorter().convertRowIndexToModel(sel));
                  ReReadableInputStream bis = swf.is;
                  bis.seek(0);
                  Helper.saveStream(bis, new File(file, "movie" + sel + ".swf"));
                }
              }
              Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath());
            } catch (IOException ex) {
              View.showMessageDialog(null, translate("error.file.write"));
            }
          }
        }
        break;
    }
  }