Search in sources :

Example 61 with WindowEvent

use of java.awt.event.WindowEvent in project jdk8u_jdk by JetBrains.

the class ServiceDialog method initPrintDialog.

/**
     * Initialize print dialog.
     */
void initPrintDialog(int x, int y, PrintService[] services, int defaultServiceIndex, DocFlavor flavor, PrintRequestAttributeSet attributes) {
    this.services = services;
    this.defaultServiceIndex = defaultServiceIndex;
    this.asOriginal = attributes;
    this.asCurrent = new HashPrintRequestAttributeSet(attributes);
    this.psCurrent = services[defaultServiceIndex];
    this.docFlavor = flavor;
    SunPageSelection pages = (SunPageSelection) attributes.get(SunPageSelection.class);
    if (pages != null) {
        isAWT = true;
    }
    if (attributes.get(DialogOnTop.class) != null) {
        setAlwaysOnTop(true);
    }
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    tpTabs = new JTabbedPane();
    tpTabs.setBorder(new EmptyBorder(5, 5, 5, 5));
    String gkey = getMsg("tab.general");
    int gmnemonic = getVKMnemonic("tab.general");
    pnlGeneral = new GeneralPanel();
    tpTabs.add(gkey, pnlGeneral);
    tpTabs.setMnemonicAt(0, gmnemonic);
    String pkey = getMsg("tab.pagesetup");
    int pmnemonic = getVKMnemonic("tab.pagesetup");
    pnlPageSetup = new PageSetupPanel();
    tpTabs.add(pkey, pnlPageSetup);
    tpTabs.setMnemonicAt(1, pmnemonic);
    String akey = getMsg("tab.appearance");
    int amnemonic = getVKMnemonic("tab.appearance");
    pnlAppearance = new AppearancePanel();
    tpTabs.add(akey, pnlAppearance);
    tpTabs.setMnemonicAt(2, amnemonic);
    c.add(tpTabs, BorderLayout.CENTER);
    updatePanels();
    JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    btnApprove = createExitButton("button.print", this);
    pnlSouth.add(btnApprove);
    getRootPane().setDefaultButton(btnApprove);
    btnCancel = createExitButton("button.cancel", this);
    handleEscKey(btnCancel);
    pnlSouth.add(btnCancel);
    c.add(pnlSouth, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent event) {
            dispose(CANCEL);
        }
    });
    getAccessibleContext().setAccessibleDescription(getMsg("dialog.printtitle"));
    setResizable(false);
    setLocation(x, y);
    pack();
}
Also used : FlowLayout(java.awt.FlowLayout) WindowAdapter(java.awt.event.WindowAdapter) javax.print(javax.print) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) SunPageSelection(sun.print.SunPageSelection) EmptyBorder(javax.swing.border.EmptyBorder)

Example 62 with WindowEvent

use of java.awt.event.WindowEvent in project jabref by JabRef.

the class DuplicateResolverDialog method init.

private void init(BibEntry one, BibEntry two, DuplicateResolverType type) {
    JButton both;
    JButton second;
    JButton first;
    JButton removeExact = null;
    switch(type) {
        case DUPLICATE_SEARCH:
            first = new JButton(Localization.lang("Keep left"));
            second = new JButton(Localization.lang("Keep right"));
            both = new JButton(Localization.lang("Keep both"));
            me = new MergeEntries(one, two, frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
            break;
        case INSPECTION:
            first = new JButton(Localization.lang("Remove old entry"));
            second = new JButton(Localization.lang("Remove entry from import"));
            both = new JButton(Localization.lang("Keep both"));
            me = new MergeEntries(one, two, Localization.lang("Old entry"), Localization.lang("From import"), frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
            break;
        case DUPLICATE_SEARCH_WITH_EXACT:
            first = new JButton(Localization.lang("Keep left"));
            second = new JButton(Localization.lang("Keep right"));
            both = new JButton(Localization.lang("Keep both"));
            removeExact = new JButton(Localization.lang("Automatically remove exact duplicates"));
            me = new MergeEntries(one, two, frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
            break;
        default:
            first = new JButton(Localization.lang("Import and remove old entry"));
            second = new JButton(Localization.lang("Do not import entry"));
            both = new JButton(Localization.lang("Import and keep old entry"));
            me = new MergeEntries(one, two, Localization.lang("Old entry"), Localization.lang("From import"), frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
            break;
    }
    if (removeExact != null) {
        options.add(removeExact);
    }
    options.add(first);
    options.add(second);
    options.add(both);
    options.add(merge);
    options.add(Box.createHorizontalStrut(5));
    options.add(cancel);
    options.add(helpButton);
    first.addActionListener(e -> buttonPressed(DuplicateResolverResult.KEEP_LEFT));
    second.addActionListener(e -> buttonPressed(DuplicateResolverResult.KEEP_RIGHT));
    both.addActionListener(e -> buttonPressed(DuplicateResolverResult.KEEP_BOTH));
    merge.addActionListener(e -> buttonPressed(DuplicateResolverResult.KEEP_MERGE));
    if (removeExact != null) {
        removeExact.addActionListener(e -> buttonPressed(DuplicateResolverResult.AUTOREMOVE_EXACT));
    }
    cancel.addActionListener(e -> buttonPressed(DuplicateResolverResult.BREAK));
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            buttonPressed(DuplicateResolverResult.BREAK);
        }
    });
    getContentPane().add(me.getMergeEntryPanel());
    getContentPane().add(options, BorderLayout.SOUTH);
    pack();
    WindowLocation pw = new WindowLocation(this, JabRefPreferences.DUPLICATES_POS_X, JabRefPreferences.DUPLICATES_POS_Y, JabRefPreferences.DUPLICATES_SIZE_X, JabRefPreferences.DUPLICATES_SIZE_Y);
    pw.displayWindowAtStoredLocation();
    both.requestFocus();
}
Also used : MergeEntries(org.jabref.gui.mergeentries.MergeEntries) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) WindowLocation(org.jabref.gui.util.WindowLocation)

Example 63 with WindowEvent

use of java.awt.event.WindowEvent in project jabref by JabRef.

the class BibtexKeyPatternDialog method init.

private void init() {
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(bibtexKeyPatternPanel, BorderLayout.CENTER);
    JButton ok = new JButton(Localization.lang("OK"));
    // label of "cancel" is set later as the label is overwritten by assigning an action to the button
    JButton cancel = new JButton();
    JPanel lower = new JPanel();
    lower.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    ButtonBarBuilder bb = new ButtonBarBuilder(lower);
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    getContentPane().add(lower, BorderLayout.SOUTH);
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    getContentPane().setPreferredSize(new Dimension(500, 600));
    pack();
    ok.addActionListener(e -> {
        metaData.setCiteKeyPattern(bibtexKeyPatternPanel.getKeyPatternAsDatabaseBibtexKeyPattern());
        panel.markNonUndoableBaseChanged();
        dispose();
    });
    final JDialog dialog = this;
    Action cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
        }
    };
    cancel.setAction(cancelAction);
    cancel.setText(Localization.lang("Cancel"));
    KeyBinder.bindCloseDialogKeyToCancelAction(this.getRootPane(), cancelAction);
}
Also used : JPanel(javax.swing.JPanel) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) BorderLayout(java.awt.BorderLayout) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) AbstractAction(javax.swing.AbstractAction) JDialog(javax.swing.JDialog)

Example 64 with WindowEvent

use of java.awt.event.WindowEvent 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);
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) GeneralRenderer(org.jabref.gui.renderer.GeneralRenderer) WindowAdapter(java.awt.event.WindowAdapter) PreviewPanel(org.jabref.gui.PreviewPanel) JFrame(javax.swing.JFrame) SortedList(ca.odell.glazedlists.SortedList) List(java.util.List) BasicEventList(ca.odell.glazedlists.BasicEventList) EventList(ca.odell.glazedlists.EventList) AbstractAction(javax.swing.AbstractAction) ComponentAdapter(java.awt.event.ComponentAdapter) JScrollPane(javax.swing.JScrollPane) BibEntry(org.jabref.model.entry.BibEntry) ActionMap(javax.swing.ActionMap) TransferableBibtexEntry(org.jabref.gui.TransferableBibtexEntry) DefaultEventSelectionModel(ca.odell.glazedlists.swing.DefaultEventSelectionModel) SearchPreferences(org.jabref.preferences.SearchPreferences) EntryComparator(org.jabref.logic.bibtex.comparator.EntryComparator) JTable(javax.swing.JTable) WindowEvent(java.awt.event.WindowEvent) InputMap(javax.swing.InputMap) ComponentEvent(java.awt.event.ComponentEvent)

Example 65 with WindowEvent

use of java.awt.event.WindowEvent in project jabref by JabRef.

the class MergeSharedEntryDialog method showMergeDialog.

public void showMergeDialog() {
    mergeDialog.setMinimumSize(new Dimension(600, 600));
    StringBuilder message = new StringBuilder();
    message.append("<html>");
    message.append("<b>");
    message.append(Localization.lang("Update could not be performed due to existing change conflicts."));
    message.append("</b>");
    message.append("<br/><br/>");
    message.append(Localization.lang("You are not working on the newest version of BibEntry."));
    message.append("<br/><br/>");
    message.append(Localization.lang("Shared version: %0", String.valueOf(sharedBibEntry.getSharedBibEntryData().getVersion())));
    message.append("<br/>");
    message.append(Localization.lang("Local version: %0", String.valueOf(localBibEntry.getSharedBibEntryData().getVersion())));
    message.append("<br/><br/>");
    message.append(Localization.lang("Please merge the shared entry with yours and press \"Merge entries\" to resolve this problem."));
    message.append("<br/>");
    JLabel mergeInnformation = new JLabel(message.toString());
    mergeInnformation.setBorder(new EmptyBorder(9, 9, 9, 9));
    mergeDialog.add(mergeInnformation, BorderLayout.NORTH);
    mergeDialog.add(mergeEntries.getMergeEntryPanel(), BorderLayout.CENTER);
    JButton mergeButton = new JButton(Localization.lang("Merge entries"));
    mergeButton.addActionListener(e -> mergeEntries());
    JButton cancelButton = new JButton(Localization.lang("Cancel"));
    cancelButton.addActionListener(e -> showConfirmationDialog());
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(mergeButton, BorderLayout.WEST);
    buttonPanel.add(cancelButton, BorderLayout.EAST);
    mergeDialog.add(buttonPanel, BorderLayout.SOUTH);
    mergeDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    mergeDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            showConfirmationDialog();
        }
    });
    mergeDialog.setLocationRelativeTo(jabRefFrame);
    mergeDialog.pack();
    mergeDialog.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

WindowEvent (java.awt.event.WindowEvent)201 WindowAdapter (java.awt.event.WindowAdapter)140 JPanel (javax.swing.JPanel)44 JButton (javax.swing.JButton)40 JFrame (javax.swing.JFrame)40 BorderLayout (java.awt.BorderLayout)36 ActionEvent (java.awt.event.ActionEvent)34 Dimension (java.awt.Dimension)32 JLabel (javax.swing.JLabel)30 JScrollPane (javax.swing.JScrollPane)26 ActionListener (java.awt.event.ActionListener)25 GridBagConstraints (java.awt.GridBagConstraints)19 GridBagLayout (java.awt.GridBagLayout)19 FlowLayout (java.awt.FlowLayout)18 Frame (java.awt.Frame)15 Insets (java.awt.Insets)15 JDialog (javax.swing.JDialog)13 JTextArea (javax.swing.JTextArea)13 Container (java.awt.Container)12 WindowListener (java.awt.event.WindowListener)10