Search in sources :

Example 1 with WindowLocation

use of org.jabref.gui.util.WindowLocation 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 2 with WindowLocation

use of org.jabref.gui.util.WindowLocation in project jabref by JabRef.

the class MergeEntriesDialog method init.

/**
     * Sets up the dialog
     *
     * @param selected Selected BibtexEntries
     */
private void init(List<BibEntry> selected) {
    // Check if there are two entries selected
    if (selected.size() != 2) {
        // None selected. Inform the user to select entries first.
        JOptionPane.showMessageDialog(panel.frame(), Localization.lang("You have to choose exactly two entries to merge."), MERGE_ENTRIES, JOptionPane.INFORMATION_MESSAGE);
        this.dispose();
        return;
    }
    // Store the two entries
    BibEntry one = selected.get(0);
    BibEntry two = selected.get(1);
    MergeEntries mergeEntries = new MergeEntries(one, two, panel.getBibDatabaseContext().getMode());
    // Create undo-compound
    NamedCompound ce = new NamedCompound(MERGE_ENTRIES);
    FormLayout layout = new FormLayout("fill:700px:grow", "fill:400px:grow, 4px, p, 5px, p");
    this.setLayout(layout);
    this.add(mergeEntries.getMergeEntryPanel(), cc.xy(1, 1));
    this.add(new JSeparator(), cc.xy(1, 3));
    // Create buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    JButton cancel = new JButton(Localization.lang("Cancel"));
    cancel.setActionCommand("cancel");
    cancel.addActionListener(e -> {
        panel.output(Localization.lang("Canceled merging entries"));
        dispose();
    });
    JButton replaceentries = new JButton(MERGE_ENTRIES);
    replaceentries.setActionCommand("replace");
    replaceentries.addActionListener(e -> {
        BibEntry mergedEntry = mergeEntries.getMergeEntry();
        panel.insertEntry(mergedEntry);
        ce.addEdit(new UndoableInsertEntry(panel.getDatabase(), mergedEntry, panel));
        ce.addEdit(new UndoableRemoveEntry(panel.getDatabase(), one, panel));
        panel.getDatabase().removeEntry(one);
        ce.addEdit(new UndoableRemoveEntry(panel.getDatabase(), two, panel));
        panel.getDatabase().removeEntry(two);
        ce.end();
        panel.getUndoManager().addEdit(ce);
        panel.output(Localization.lang("Merged entries"));
        dispose();
    });
    bb.addButton(new JButton[] { replaceentries, cancel });
    this.add(bb.getPanel(), cc.xy(1, 5));
    // Add some margin around the layout
    layout.appendRow(RowSpec.decode(MARGIN));
    layout.appendColumn(ColumnSpec.decode(MARGIN));
    layout.insertRow(1, RowSpec.decode(MARGIN));
    layout.insertColumn(1, ColumnSpec.decode(MARGIN));
    WindowLocation pw = new WindowLocation(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y, JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y);
    pw.displayWindowAtStoredLocation();
    // Show what we've got
    setVisible(true);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) BibEntry(org.jabref.model.entry.BibEntry) NamedCompound(org.jabref.gui.undo.NamedCompound) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) JButton(javax.swing.JButton) UndoableRemoveEntry(org.jabref.gui.undo.UndoableRemoveEntry) WindowLocation(org.jabref.gui.util.WindowLocation) JSeparator(javax.swing.JSeparator) UndoableInsertEntry(org.jabref.gui.undo.UndoableInsertEntry)

Example 3 with WindowLocation

use of org.jabref.gui.util.WindowLocation in project jabref by JabRef.

the class MergeFetchedEntryDialog method init.

/**
     * Sets up the dialog
     */
private void init() {
    mergeEntries = new MergeEntries(this.originalEntry, this.fetchedEntry, Localization.lang("Original entry"), Localization.lang("Entry from %0", type), panel.getBibDatabaseContext().getMode());
    // Create undo-compound
    ce = new NamedCompound(Localization.lang("Merge entry with %0 information", type));
    FormLayout layout = new FormLayout("fill:700px:grow", "fill:400px:grow, 4px, p, 5px, p");
    this.setLayout(layout);
    this.add(mergeEntries.getMergeEntryPanel(), cc.xy(1, 1));
    this.add(new JSeparator(), cc.xy(1, 3));
    // Create buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    JButton cancel = new JButton(new CancelAction());
    JButton replaceEntry = new JButton(new ReplaceAction());
    bb.addButton(replaceEntry, cancel);
    this.add(bb.getPanel(), cc.xy(1, 5));
    // Add some margin around the layout
    layout.appendRow(RowSpec.decode(MARGIN));
    layout.appendColumn(ColumnSpec.decode(MARGIN));
    layout.insertRow(1, RowSpec.decode(MARGIN));
    layout.insertColumn(1, ColumnSpec.decode(MARGIN));
    WindowLocation pw = new WindowLocation(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y, JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y);
    pw.displayWindowAtStoredLocation();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) NamedCompound(org.jabref.gui.undo.NamedCompound) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) JButton(javax.swing.JButton) WindowLocation(org.jabref.gui.util.WindowLocation) JSeparator(javax.swing.JSeparator)

Example 4 with WindowLocation

use of org.jabref.gui.util.WindowLocation in project jabref by JabRef.

the class JabRefFrame method init.

private void init() {
    tabbedPane = new DragDropPopupPane(tabPopupMenu());
    MyGlassPane glassPane = new MyGlassPane();
    setGlassPane(glassPane);
    setTitle(FRAME_TITLE);
    setIconImages(IconTheme.getLogoSet());
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            if (OS.OS_X) {
                JabRefFrame.this.setVisible(false);
            } else {
                new CloseAction().actionPerformed(null);
            }
        }
    });
    initSidePane();
    initLayout();
    initActions();
    // Show the toolbar if it was visible at last shutdown:
    tlb.setVisible(Globals.prefs.getBoolean(JabRefPreferences.TOOLBAR_VISIBLE));
    setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
    WindowLocation pw = new WindowLocation(this, JabRefPreferences.POS_X, JabRefPreferences.POS_Y, JabRefPreferences.SIZE_X, JabRefPreferences.SIZE_Y);
    pw.displayWindowAtStoredLocation();
    tabbedPane.setBorder(null);
    tabbedPane.setForeground(GUIGlobals.INACTIVE_TABBED_COLOR);
    /*
         * The following state listener makes sure focus is registered with the
         * correct database when the user switches tabs. Without this,
         * cut/paste/copy operations would some times occur in the wrong tab.
         */
    tabbedPane.addChangeListener(e -> {
        markActiveBasePanel();
        BasePanel currentBasePanel = getCurrentBasePanel();
        if (currentBasePanel == null) {
            return;
        }
        Platform.runLater(() -> Globals.stateManager.activeDatabaseProperty().setValue(Optional.of(currentBasePanel.getBibDatabaseContext())));
        if (new SearchPreferences(Globals.prefs).isGlobalSearch()) {
            globalSearchBar.performSearch();
        } else {
            String content = "";
            Optional<SearchQuery> currentSearchQuery = currentBasePanel.getCurrentSearchQuery();
            if (currentSearchQuery.isPresent()) {
                content = currentSearchQuery.get().getQuery();
            }
            globalSearchBar.setSearchTerm(content, true);
        }
        currentBasePanel.getPreviewPanel().updateLayout();
        groupSidePane.getToggleAction().setSelected(sidePaneManager.isComponentVisible(GroupSidePane.class));
        previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled());
        generalFetcher.getToggleAction().setSelected(sidePaneManager.isComponentVisible(GeneralFetcher.class));
        openOfficePanel.getToggleAction().setSelected(sidePaneManager.isComponentVisible(OpenOfficeSidePanel.class));
        Globals.getFocusListener().setFocused(currentBasePanel.getMainTable());
        setWindowTitle();
        editModeAction.initName();
        currentBasePanel.updateSearchManager();
        currentBasePanel.setBackAndForwardEnabledState();
        currentBasePanel.getUndoManager().postUndoRedoEvent();
        currentBasePanel.getMainTable().requestFocus();
    });
    //opened (double-clicked) documents are not displayed.
    if (OS.OS_X) {
        try {
            new MacAdapter().registerMacEvents(this);
        } catch (Exception e) {
            LOGGER.fatal("Could not interface with Mac OS X methods.", e);
        }
    }
    initShowTrackingNotification();
}
Also used : SearchQuery(org.jabref.logic.search.SearchQuery) WindowAdapter(java.awt.event.WindowAdapter) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) SearchPreferences(org.jabref.preferences.SearchPreferences) OpenOfficeSidePanel(org.jabref.gui.openoffice.OpenOfficeSidePanel) WindowEvent(java.awt.event.WindowEvent) GroupSidePane(org.jabref.gui.groups.GroupSidePane) GeneralFetcher(org.jabref.gui.importer.fetcher.GeneralFetcher) WindowLocation(org.jabref.gui.util.WindowLocation) MacAdapter(osx.macadapter.MacAdapter)

Example 5 with WindowLocation

use of org.jabref.gui.util.WindowLocation in project jabref by JabRef.

the class StyleSelectDialog method init.

private void init() {
    setupPopupMenu();
    addButton.addActionListener(actionEvent -> {
        AddFileDialog addDialog = new AddFileDialog();
        addDialog.setDirectoryPath(preferences.getCurrentStyle());
        addDialog.setVisible(true);
        addDialog.getFileName().ifPresent(fileName -> {
            if (loader.addStyleIfValid(fileName)) {
                preferences.setCurrentStyle(fileName);
            }
        });
        updateStyles();
    });
    addButton.setToolTipText(Localization.lang("Add style file"));
    removeButton.addActionListener(removeAction);
    removeButton.setToolTipText(Localization.lang("Remove style"));
    // Create a preview panel for previewing styles
    // Must be done before creating the table to avoid NPEs
    preview = new PreviewPanel(null, null);
    // Use the test entry from the Preview settings tab in Preferences:
    preview.setEntry(prevEntry);
    setupTable();
    updateStyles();
    // Build dialog
    diag = new JDialog(frame, Localization.lang("Select style"), true);
    FormBuilder builder = FormBuilder.create();
    builder.layout(new FormLayout("fill:pref:grow, 4dlu, left:pref, 4dlu, left:pref", "pref, 4dlu, 100dlu:grow, 4dlu, pref, 4dlu, fill:100dlu"));
    builder.add(Localization.lang("Select one of the available styles or add a style file from disk.")).xyw(1, 1, 5);
    builder.add(new JScrollPane(table)).xyw(1, 3, 5);
    builder.add(addButton).xy(3, 5);
    builder.add(removeButton).xy(5, 5);
    builder.add(preview).xyw(1, 7, 5);
    builder.padding("5dlu, 5dlu, 5dlu, 5dlu");
    diag.add(builder.getPanel(), BorderLayout.CENTER);
    AbstractAction okListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) {
                JOptionPane.showMessageDialog(diag, Localization.lang("You must select a valid style file."), Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE);
                return;
            }
            okPressed = true;
            storeSettings();
            diag.dispose();
        }
    };
    ok.addActionListener(okListener);
    Action cancelListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            diag.dispose();
        }
    };
    cancel.addActionListener(cancelListener);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.add(bb.getPanel(), BorderLayout.SOUTH);
    ActionMap am = bb.getPanel().getActionMap();
    InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelListener);
    im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk");
    am.put("enterOk", okListener);
    diag.pack();
    WindowLocation pw = new WindowLocation(diag, JabRefPreferences.STYLES_POS_X, JabRefPreferences.STYLES_POS_Y, JabRefPreferences.STYLES_SIZE_X, JabRefPreferences.STYLES_SIZE_Y);
    pw.displayWindowAtStoredLocation();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JScrollPane(javax.swing.JScrollPane) FormBuilder(com.jgoodies.forms.builder.FormBuilder) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) PreviewPanel(org.jabref.gui.PreviewPanel) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) InputMap(javax.swing.InputMap) WindowLocation(org.jabref.gui.util.WindowLocation) AbstractAction(javax.swing.AbstractAction) JDialog(javax.swing.JDialog)

Aggregations

WindowLocation (org.jabref.gui.util.WindowLocation)6 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)4 FormLayout (com.jgoodies.forms.layout.FormLayout)4 JButton (javax.swing.JButton)3 FormBuilder (com.jgoodies.forms.builder.FormBuilder)2 ActionEvent (java.awt.event.ActionEvent)2 WindowAdapter (java.awt.event.WindowAdapter)2 WindowEvent (java.awt.event.WindowEvent)2 AbstractAction (javax.swing.AbstractAction)2 Action (javax.swing.Action)2 ActionMap (javax.swing.ActionMap)2 InputMap (javax.swing.InputMap)2 JDialog (javax.swing.JDialog)2 JScrollPane (javax.swing.JScrollPane)2 JSeparator (javax.swing.JSeparator)2 NamedCompound (org.jabref.gui.undo.NamedCompound)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 PreviewPanel (org.jabref.gui.PreviewPanel)1 GroupSidePane (org.jabref.gui.groups.GroupSidePane)1