Search in sources :

Example 1 with MacAdapter

use of osx.macadapter.MacAdapter 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)

Aggregations

WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 GroupSidePane (org.jabref.gui.groups.GroupSidePane)1 GeneralFetcher (org.jabref.gui.importer.fetcher.GeneralFetcher)1 OpenOfficeSidePanel (org.jabref.gui.openoffice.OpenOfficeSidePanel)1 WindowLocation (org.jabref.gui.util.WindowLocation)1 SearchQuery (org.jabref.logic.search.SearchQuery)1 SearchPreferences (org.jabref.preferences.SearchPreferences)1 MacAdapter (osx.macadapter.MacAdapter)1