Search in sources :

Example 1 with MainTable

use of org.jabref.gui.maintable.MainTable in project jabref by JabRef.

the class SidePaneManager method hide.

public synchronized <T extends SidePaneComponent> void hide(Class<T> sidePaneComponent) {
    SidePaneComponent component = components.get(sidePaneComponent);
    if (component == null) {
        LOGGER.warn("Side pane component '" + sidePaneComponent + "' unknown.");
    } else {
        hideComponent(component);
        if (frame.getCurrentBasePanel() != null) {
            MainTable mainTable = frame.getCurrentBasePanel().getMainTable();
            mainTable.setSelected(mainTable.getSelectedRow());
            mainTable.requestFocus();
        }
    }
}
Also used : MainTable(org.jabref.gui.maintable.MainTable)

Example 2 with MainTable

use of org.jabref.gui.maintable.MainTable in project jabref by JabRef.

the class BasePanel method createMainTable.

private void createMainTable() {
    bibDatabaseContext.getDatabase().registerListener(tableModel.getListSynchronizer());
    bibDatabaseContext.getDatabase().registerListener(SpecialFieldDatabaseChangeListener.getInstance());
    tableFormat = new MainTableFormat(bibDatabaseContext.getDatabase());
    tableFormat.updateTableFormat();
    mainTable = new MainTable(tableFormat, tableModel, frame, this);
    selectionListener = new MainTableSelectionListener(this, mainTable);
    mainTable.updateFont();
    mainTable.addSelectionListener(selectionListener);
    mainTable.addMouseListener(selectionListener);
    mainTable.addKeyListener(selectionListener);
    mainTable.addFocusListener(selectionListener);
    // Add the listener that binds selection to state manager (TODO: should be replaced by proper JavaFX binding as soon as table is implemented in JavaFX)
    mainTable.addSelectionListener(listEvent -> Platform.runLater(() -> Globals.stateManager.setSelectedEntries(mainTable.getSelectedEntries())));
    String clearSearch = "clearSearch";
    mainTable.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.CLEAR_SEARCH), clearSearch);
    mainTable.getActionMap().put(clearSearch, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // need to close these here, b/c this action overshadows the responsible actions when the main table is selected
            switch(mode) {
                case SHOWING_NOTHING:
                    frame.getGlobalSearchBar().endSearch();
                    break;
                case SHOWING_PREVIEW:
                    getPreviewPanel().close();
                    break;
                case SHOWING_EDITOR:
                case WILL_SHOW_EDITOR:
                    getCurrentEditor().close();
                    break;
                default:
                    LOGGER.warn("unknown BasePanelMode: '" + mode + "', doing nothing");
                    break;
            }
        }
    });
    mainTable.getActionMap().put(Actions.CUT, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.CUT);
            } catch (Throwable ex) {
                LOGGER.warn("Could not cut", ex);
            }
        }
    });
    mainTable.getActionMap().put(Actions.COPY, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.COPY);
            } catch (Throwable ex) {
                LOGGER.warn("Could not copy", ex);
            }
        }
    });
    mainTable.getActionMap().put(Actions.PASTE, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.PASTE);
            } catch (Throwable ex) {
                LOGGER.warn("Could not paste", ex);
            }
        }
    });
    mainTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            final int keyCode = e.getKeyCode();
            if (e.isControlDown()) {
                switch(keyCode) {
                    case KeyEvent.VK_PAGE_DOWN:
                        frame.nextTab.actionPerformed(null);
                        e.consume();
                        break;
                    case KeyEvent.VK_PAGE_UP:
                        frame.prevTab.actionPerformed(null);
                        e.consume();
                        break;
                    default:
                        break;
                }
            } else if (keyCode == KeyEvent.VK_ENTER) {
                e.consume();
                try {
                    runCommand(Actions.EDIT);
                } catch (Throwable ex) {
                    LOGGER.warn("Could not run action based on key press", ex);
                }
            }
        }
    });
}
Also used : KeyEvent(java.awt.event.KeyEvent) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) MainTableFormat(org.jabref.gui.maintable.MainTableFormat) MainTableSelectionListener(org.jabref.gui.maintable.MainTableSelectionListener) MainTable(org.jabref.gui.maintable.MainTable) AbstractAction(javax.swing.AbstractAction)

Example 3 with MainTable

use of org.jabref.gui.maintable.MainTable in project jabref by JabRef.

the class GlobalSearchBar method endSearch.

public void endSearch() {
    BasePanel currentBasePanel = frame.getCurrentBasePanel();
    if (currentBasePanel != null) {
        clearSearch(currentBasePanel);
        MainTable mainTable = frame.getCurrentBasePanel().getMainTable();
        Globals.getFocusListener().setFocused(mainTable);
        mainTable.requestFocus();
        SwingUtilities.invokeLater(() -> mainTable.ensureVisible(mainTable.getSelectedRow()));
    }
}
Also used : BasePanel(org.jabref.gui.BasePanel) MainTable(org.jabref.gui.maintable.MainTable)

Aggregations

MainTable (org.jabref.gui.maintable.MainTable)3 ActionEvent (java.awt.event.ActionEvent)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 AbstractAction (javax.swing.AbstractAction)1 BasePanel (org.jabref.gui.BasePanel)1 MainTableFormat (org.jabref.gui.maintable.MainTableFormat)1 MainTableSelectionListener (org.jabref.gui.maintable.MainTableSelectionListener)1