Search in sources :

Example 1 with OverlayPanel

use of org.jabref.gui.util.component.OverlayPanel in project jabref by JabRef.

the class BasicAction method initRawPanel.

// Panel with text import functionality
private void initRawPanel() {
    rawPanel.setLayout(new BorderLayout());
    // Textarea
    textPane.setEditable(false);
    document = textPane.getStyledDocument();
    addStylesToDocument();
    try {
        document.insertString(0, "", document.getStyle("regular"));
    } catch (BadLocationException ex) {
        LOGGER.warn("Problem setting style", ex);
    }
    OverlayPanel testPanel = new OverlayPanel(textPane, Localization.lang("paste text here"));
    testPanel.setPreferredSize(new Dimension(450, 255));
    testPanel.setMaximumSize(new Dimension(450, Integer.MAX_VALUE));
    // Setup fields (required to be done before setting up popup menu)
    fieldList = new JList<>(getAllFields());
    fieldList.setCellRenderer(new SimpleCellRenderer(fieldList.getFont()));
    ListSelectionModel listSelectionModel = fieldList.getSelectionModel();
    listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listSelectionModel.addListSelectionListener(new FieldListSelectionHandler());
    fieldList.addMouseListener(new FieldListMouseListener());
    // After the call to getAllFields
    initPopupMenuAndToolbar();
    //Add listener to components that can bring up popup menus.
    MouseListener popupListener = new PopupListener(inputMenu);
    textPane.addMouseListener(popupListener);
    testPanel.addMouseListener(popupListener);
    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(toolBar, BorderLayout.NORTH);
    leftPanel.add(testPanel, BorderLayout.CENTER);
    JPanel inputPanel = setUpFieldListPanel();
    // parse with FreeCite button
    parseWithFreeCiteButton.addActionListener(event -> {
        if (parseWithFreeCiteAndAddEntries()) {
            okPressed = false;
            dispose();
        }
    });
    rawPanel.add(leftPanel, BorderLayout.CENTER);
    rawPanel.add(inputPanel, BorderLayout.EAST);
    JLabel desc = new JLabel("<html><h3>" + Localization.lang("Plain text import") + "</h3><p>" + Localization.lang("This is a simple copy and paste dialog. First load or paste some text into " + "the text input area.<br>After that, you can mark text and assign it to a BibTeX field.") + "</p></html>");
    desc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    rawPanel.add(desc, BorderLayout.SOUTH);
}
Also used : JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) OverlayPanel(org.jabref.gui.util.component.OverlayPanel) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 MouseListener (java.awt.event.MouseListener)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 ListSelectionModel (javax.swing.ListSelectionModel)1 BadLocationException (javax.swing.text.BadLocationException)1 OverlayPanel (org.jabref.gui.util.component.OverlayPanel)1