use of org.jabref.gui.renderer.GeneralRenderer in project jabref by JabRef.
the class SearchResultFrame method init.
private void init(String title) {
searchResultFrame = new JFrame();
searchResultFrame.setTitle(title);
searchResultFrame.setIconImages(IconTheme.getLogoSet());
preview = new PreviewPanel(null, null);
sortedEntries = new SortedList<>(entries, new EntryComparator(false, true, FieldName.AUTHOR));
model = (DefaultEventTableModel<BibEntry>) GlazedListsSwing.eventTableModelWithThreadProxyList(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<BibEntry> tableSorter = TableComparatorChooser.install(entryTable, sortedEntries, AbstractTableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD);
setupComparatorChooser(tableSorter);
JScrollPane sp = new JScrollPane(entryTable);
final DefaultEventSelectionModel<BibEntry> selectionModel = (DefaultEventSelectionModel<BibEntry>) GlazedListsSwing.eventSelectionModelWithThreadProxyList(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) {
dispose();
}
};
ActionMap actionMap = contentPane.getActionMap();
InputMap inputMap = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DATABASE), "close");
actionMap.put("close", closeAction);
actionMap = entryTable.getActionMap();
inputMap = entryTable.getInputMap();
//Override 'selectNextColumnCell' and 'selectPreviousColumnCell' to move rows instead of cells on TAB
actionMap.put("selectNextColumnCell", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
selectNextEntry();
}
});
actionMap.put("selectPreviousColumnCell", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
selectPreviousEntry();
}
});
actionMap.put("selectNextRow", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
selectNextEntry();
}
});
actionMap.put("selectPreviousRow", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
selectPreviousEntry();
}
});
String selectFirst = "selectFirst";
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.SELECT_FIRST_ENTRY), selectFirst);
actionMap.put(selectFirst, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent event) {
selectFirstEntry();
}
});
String selectLast = "selectLast";
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.SELECT_LAST_ENTRY), selectLast);
actionMap.put(selectLast, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent event) {
selectLastEntry();
}
});
actionMap.put("copy", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (!selectionModel.getSelected().isEmpty()) {
List<BibEntry> bes = selectionModel.getSelected();
TransferableBibtexEntry trbe = new TransferableBibtexEntry(bes);
// ! look at ClipBoardManager
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(trbe, frame.getCurrentBasePanel());
frame.output(Localization.lang("Copied") + ' ' + (bes.size() > 1 ? bes.size() + " " + Localization.lang("entries") : "1 " + Localization.lang("entry") + '.'));
}
}
});
// override standard enter-action; enter opens the selected entry
entryTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
actionMap.put("Enter", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
BibEntry entry = sortedEntries.get(entryTable.getSelectedRow());
selectEntryInBasePanel(entry);
}
});
searchResultFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
contentPane.setDividerLocation(0.5f);
}
@Override
public void windowClosing(WindowEvent event) {
dispose();
}
});
searchResultFrame.getContentPane().add(contentPane, BorderLayout.CENTER);
// Remember and default to last size:
SearchPreferences searchPreferences = new SearchPreferences(Globals.prefs);
searchResultFrame.setSize(searchPreferences.getSeachDialogWidth(), searchPreferences.getSeachDialogHeight());
searchResultFrame.setLocation(searchPreferences.getSearchDialogPosX(), searchPreferences.getSearchDialogPosY());
searchResultFrame.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
new SearchPreferences(Globals.prefs).setSearchDialogWidth(searchResultFrame.getSize().width).setSearchDialogHeight(searchResultFrame.getSize().height);
}
@Override
public void componentMoved(ComponentEvent e) {
new SearchPreferences(Globals.prefs).setSearchDialogPosX(searchResultFrame.getLocation().x).setSearchDialogPosY(searchResultFrame.getLocation().y);
}
});
}
use of org.jabref.gui.renderer.GeneralRenderer in project jabref by JabRef.
the class MainTable method updateRenderers.
public static void updateRenderers() {
MainTable.defRenderer = new GeneralRenderer(Globals.prefs.getColor(JabRefPreferences.TABLE_BACKGROUND), Globals.prefs.getColor(JabRefPreferences.TABLE_TEXT));
Color sel = MainTable.defRenderer.getTableCellRendererComponent(new JTable(), "", true, false, 0, 0).getBackground();
MainTable.reqRenderer = new GeneralRenderer(Globals.prefs.getColor(JabRefPreferences.TABLE_REQ_FIELD_BACKGROUND), Globals.prefs.getColor(JabRefPreferences.TABLE_TEXT));
MainTable.optRenderer = new GeneralRenderer(Globals.prefs.getColor(JabRefPreferences.TABLE_OPT_FIELD_BACKGROUND), Globals.prefs.getColor(JabRefPreferences.TABLE_TEXT));
MainTable.resolvedRenderer = new GeneralRenderer(Globals.prefs.getColor(JabRefPreferences.TABLE_RESOLVED_FIELD_BACKGROUND), Globals.prefs.getColor(JabRefPreferences.TABLE_TEXT));
MainTable.incRenderer = new IncompleteRenderer();
MainTable.compRenderer = new CompleteRenderer(Globals.prefs.getColor(JabRefPreferences.TABLE_BACKGROUND));
MainTable.grayedOutNumberRenderer = new CompleteRenderer(Globals.prefs.getColor(JabRefPreferences.GRAYED_OUT_BACKGROUND));
MainTable.veryGrayedOutNumberRenderer = new CompleteRenderer(Globals.prefs.getColor(JabRefPreferences.VERY_GRAYED_OUT_BACKGROUND));
MainTable.grayedOutRenderer = new GeneralRenderer(Globals.prefs.getColor(JabRefPreferences.GRAYED_OUT_BACKGROUND), Globals.prefs.getColor(JabRefPreferences.GRAYED_OUT_TEXT), MainTable.mixColors(Globals.prefs.getColor(JabRefPreferences.GRAYED_OUT_BACKGROUND), sel));
MainTable.veryGrayedOutRenderer = new GeneralRenderer(Globals.prefs.getColor(JabRefPreferences.VERY_GRAYED_OUT_BACKGROUND), Globals.prefs.getColor(JabRefPreferences.VERY_GRAYED_OUT_TEXT), MainTable.mixColors(Globals.prefs.getColor(JabRefPreferences.VERY_GRAYED_OUT_BACKGROUND), sel));
MainTable.markedRenderers = new ArrayList<>(EntryMarker.MARK_COLOR_LEVELS);
MainTable.markedNumberRenderers = new ArrayList<>(EntryMarker.MARK_COLOR_LEVELS);
for (int i = 0; i < EntryMarker.MARK_COLOR_LEVELS; i++) {
Color c = Globals.prefs.getColor(JabRefPreferences.MARKED_ENTRY_BACKGROUND + i);
MainTable.markedRenderers.add(new GeneralRenderer(c, Globals.prefs.getColor(JabRefPreferences.TABLE_TEXT), MainTable.mixColors(Globals.prefs.getColor(JabRefPreferences.MARKED_ENTRY_BACKGROUND + i), sel)));
MainTable.markedNumberRenderers.add(new CompleteRenderer(c));
}
}
Aggregations