private void init(String title) {
    diag = new JDialog(frame, title, false);

    preview = new PreviewPanel(null, new MetaData(), Globals.prefs.get("preview1"));

    sortedEntries =
        new SortedList<BibtexEntry>(entries, new EntryComparator(false, true, "author"));
    model = new EventTableModel<BibtexEntry>(sortedEntries, new EntryTableFormat());
    entryTable = new JTable(model);
    GeneralRenderer renderer = new GeneralRenderer(Color.white);
    entryTable.setDefaultRenderer(JLabel.class, renderer);
    entryTable.setDefaultRenderer(String.class, renderer);
    setWidths();
    TableComparatorChooser<BibtexEntry> tableSorter =
        new TableComparatorChooser<BibtexEntry>(
            entryTable, sortedEntries, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD);
    setupComparatorChooser(tableSorter);
    JScrollPane sp = new JScrollPane(entryTable);

    EventSelectionModel<BibtexEntry> selectionModel =
        new EventSelectionModel<BibtexEntry>(sortedEntries);
    entryTable.setSelectionModel(selectionModel);
    selectionModel.getSelected().addListEventListener(new EntrySelectionListener());
    entryTable.addMouseListener(new TableClickListener());

    contentPane.setTopComponent(sp);
    contentPane.setBottomComponent(preview);

    // Key bindings:
    AbstractAction closeAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            diag.dispose();
          }
        };
    ActionMap am = contentPane.getActionMap();
    InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.prefs.getKey("Close dialog"), "close");
    am.put("close", closeAction);

    diag.addWindowListener(
        new WindowAdapter() {
          public void windowOpened(WindowEvent e) {
            contentPane.setDividerLocation(0.5f);
          }

          public void windowClosing(WindowEvent event) {
            Globals.prefs.putInt("searchDialogWidth", diag.getSize().width);
            Globals.prefs.putInt("searchDialogHeight", diag.getSize().height);
          }
        });

    diag.getContentPane().add(contentPane, BorderLayout.CENTER);
    // Remember and default to last size:
    diag.setSize(
        new Dimension(
            Globals.prefs.getInt("searchDialogWidth"), Globals.prefs.getInt("searchDialogHeight")));
    diag.setLocationRelativeTo(frame);
  }
Ejemplo n.º 2
0
 private JComponent buildGridPanel() {
   final String[] props = {
     "clave",
     "factura.numero",
     "factura.fecha",
     "factura.tipo",
     "factura.total",
     "factura.pagos",
     "factura.devolucionesCred",
     "factura.saldo",
     "factura.descuentoPactado",
     "factura.cargo",
     "importe"
   };
   final String[] cols = {
     "Cliente",
     "Factura",
     "Fecha",
     "T",
     "Total",
     "Pagos",
     "Devoluciones",
     "Saldo",
     "Desc",
     "Cargo",
     "Importe"
   };
   final TableFormat<NotasDeCreditoDet> tf =
       GlazedLists.tableFormat(NotasDeCreditoDet.class, props, cols);
   final SortedList<NotasDeCreditoDet> sortedList =
       new SortedList<NotasDeCreditoDet>(model.getPartidas(), null);
   final EventTableModel<NotasDeCreditoDet> tm =
       new EventTableModel<NotasDeCreditoDet>(sortedList, tf);
   final EventSelectionModel<NotasDeCreditoDet> selectionModel =
       new EventSelectionModel<NotasDeCreditoDet>(sortedList);
   selectionModel.setSelectionMode(ListSelection.SINGLE_SELECTION);
   final Action deleteAction =
       new AbstractAction() {
         public void actionPerformed(ActionEvent e) {
           if (!selectionModel.getSelected().isEmpty()) {
             selectionModel.getSelected().remove(0);
             if (sortedList.isEmpty()) getOKAction().setEnabled(false);
           }
         }
       };
   grid = ComponentUtils.getStandardTable();
   grid.setModel(tm);
   grid.packAll();
   grid.setSelectionModel(selectionModel);
   ComponentUtils.addDeleteAction(grid, deleteAction);
   JScrollPane sp = new JScrollPane(grid);
   return sp;
 }
Ejemplo n.º 3
0
 /**
  * Metodo para construir el grid. Subclaseses recomendable que ejecuten super.buildGrid antes de
  * iniciar una personalizacion de este metodo
  *
  * @return
  */
 protected JXTable buildGrid() {
   final EventTableModel<T> tm = new EventTableModel<T>(sortedSource, getTableFormat());
   selectionModel = new EventSelectionModel(sortedSource);
   selectionModel.setSelectionMode(getSelectionMode());
   final JXTable grid = ComponentUtils.getStandardTable();
   grid.setModel(tm);
   grid.setSelectionModel(selectionModel);
   final Action select =
       new AbstractAction() {
         public void actionPerformed(ActionEvent e) {
           doSelect();
         }
       };
   ComponentUtils.addEnterAction(grid, select);
   grid.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 2) doSelect();
         }
       });
   // new TableComparatorChooser(grid,sortedSource,true);
   TableComparatorChooser.install(
       grid, sortedSource, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE);
   grid.packAll();
   return grid;
 }
Ejemplo n.º 4
0
 public List<T> getSelectedList() {
   if (!selectionModel.getSelected().isEmpty()) {
     return selectionModel.getSelected();
   }
   return new ArrayList<T>();
 }
Ejemplo n.º 5
0
 /** Regresa el primer bean seleccinado por el usuario */
 public T getSelected() {
   if (!selectionModel.getSelected().isEmpty()) {
     return selectionModel.getSelected().get(0);
   }
   return null;
 }
Ejemplo n.º 6
0
 public void doSelect() {
   List dat = new ArrayList();
   dat.addAll(selectionModel.getSelected());
   onSelection(dat);
 }
Ejemplo n.º 7
0
  private void init(String title) {
    diag = new JDialog(frame, title, false);

    int activePreview = Globals.prefs.getInt(JabRefPreferences.ACTIVE_PREVIEW);
    preview =
        new PreviewPanel(
            null,
            new MetaData(),
            activePreview == 0
                ? Globals.prefs.get(JabRefPreferences.PREVIEW_0)
                : Globals.prefs.get(JabRefPreferences.PREVIEW_1));

    sortedEntries =
        new SortedList<BibtexEntry>(entries, new EntryComparator(false, true, "author"));
    model = new EventTableModel<BibtexEntry>(sortedEntries, new EntryTableFormat());
    entryTable = new JTable(model);
    GeneralRenderer renderer = new GeneralRenderer(Color.white);
    entryTable.setDefaultRenderer(JLabel.class, renderer);
    entryTable.setDefaultRenderer(String.class, renderer);
    setWidths();
    TableComparatorChooser<BibtexEntry> tableSorter =
        TableComparatorChooser.install(
            entryTable, sortedEntries, AbstractTableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD);
    setupComparatorChooser(tableSorter);
    JScrollPane sp = new JScrollPane(entryTable);

    final EventSelectionModel<BibtexEntry> selectionModel =
        new EventSelectionModel<BibtexEntry>(sortedEntries);
    entryTable.setSelectionModel(selectionModel);
    selectionModel.getSelected().addListEventListener(new EntrySelectionListener());
    entryTable.addMouseListener(new TableClickListener());

    contentPane.setTopComponent(sp);
    contentPane.setBottomComponent(preview);

    // Key bindings:
    AbstractAction closeAction =
        new AbstractAction() {

          @Override
          public void actionPerformed(ActionEvent e) {
            diag.dispose();
          }
        };
    ActionMap am = contentPane.getActionMap();
    InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.prefs.getKey("Close dialog"), "close");
    am.put("close", closeAction);

    entryTable
        .getActionMap()
        .put(
            "copy",
            new AbstractAction() {

              @Override
              public void actionPerformed(ActionEvent e) {
                if (!selectionModel.getSelected().isEmpty()) {
                  BibtexEntry[] bes =
                      selectionModel
                          .getSelected()
                          .toArray(new BibtexEntry[selectionModel.getSelected().size()]);
                  TransferableBibtexEntry trbe = new TransferableBibtexEntry(bes);
                  // ! look at ClipBoardManager
                  Toolkit.getDefaultToolkit()
                      .getSystemClipboard()
                      .setContents(trbe, frame.basePanel());
                  frame.output(
                      Localization.lang("Copied")
                          + ' '
                          + (bes.length > 1
                              ? bes.length + " " + Localization.lang("entries")
                              : "1 " + Localization.lang("entry") + '.'));
                }
              }
            });

    diag.addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowOpened(WindowEvent e) {
            contentPane.setDividerLocation(0.5f);
          }

          @Override
          public void windowClosing(WindowEvent event) {
            Globals.prefs.putInt(JabRefPreferences.SEARCH_DIALOG_WIDTH, diag.getSize().width);
            Globals.prefs.putInt(JabRefPreferences.SEARCH_DIALOG_HEIGHT, diag.getSize().height);
          }
        });

    diag.getContentPane().add(contentPane, BorderLayout.CENTER);
    // Remember and default to last size:
    diag.setSize(
        new Dimension(
            Globals.prefs.getInt(JabRefPreferences.SEARCH_DIALOG_WIDTH),
            Globals.prefs.getInt(JabRefPreferences.SEARCH_DIALOG_HEIGHT)));
    diag.setLocationRelativeTo(frame);
  }
Ejemplo n.º 8
0
 public void view() {
   if (selectionModel.getSelected().isEmpty()) return;
   Venta v = ((Pago) selectionModel.getSelected().get(0)).getVenta();
   ConsultaUtils.mostrarVenta(v);
 }