Search in sources :

Example 1 with MemoryMonitor

use of jgnash.ui.components.MemoryMonitor in project jgnash by ccavanaugh.

the class MainFrame method buildUI.

private void buildUI() {
    ActionParser actionParser = new ActionParser(this);
    actionParser.preLoadActions("jgnash.ui.actions");
    actionParser.preLoadAction("copy-command", new DefaultEditorKit.CopyAction());
    actionParser.preLoadAction("cut-command", new DefaultEditorKit.CutAction());
    actionParser.preLoadAction("paste-command", new DefaultEditorKit.PasteAction());
    actionParser.preLoadAction("exit-command", new AbstractAction() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            shutDown();
        }
    });
    actionParser.preLoadAction("open-command", new OpenFileAction());
    actionParser.preLoadAction("open-command-tb", new OpenFileAction());
    actionParser.preLoadAction("account-filter-command", new AbstractEnabledAction() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            expandingAccountPanel.showAccountFilterDialog();
        }
    });
    actionParser.preLoadAction("register-filter-command", new AbstractEnabledAction() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            registerTreePanel.showAccountFilterDialog();
        }
    });
    actionParser.preLoadAction("currency-background-update-command", new UpdateExchangeRateAction());
    actionParser.preLoadAction("security-background-update-command", new UpdateSecuritiesAction());
    try (final InputStream stream = MainFrame.class.getResourceAsStream("/jgnash/resource/main-frame-actions.xml")) {
        actionParser.loadFile(stream);
    } catch (final IOException exception) {
        logger.log(Level.SEVERE, exception.getMessage(), exception);
    }
    menuBar = actionParser.createMenuBar("main-menu");
    JToolBar toolBar = actionParser.createToolBar("main-toolbar");
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    viewMenu = (JMenu) actionParser.getJMenuItem("view-menu-command");
    reportMenu = (JMenu) actionParser.getJMenuItem("report-menu-command");
    windowMenu = (JMenu) actionParser.getJMenuItem("window-menu-command");
    Objects.requireNonNull(windowMenu);
    windowMenu.setEnabled(false);
    editAction = actionParser.getAction("edit-menu-command");
    if (EngineFactory.getEngine(EngineFactory.DEFAULT) == null) {
        setOpenState(false);
    }
    setTitle(Main.VERSION);
    mainView = buildMainView();
    backgroundOperationLabel = new JXBusyLabel(new Dimension(18, 18));
    statusField = new JTextField();
    statusField.setEditable(false);
    statusField.setFont(statusField.getFont().deriveFont(statusField.getFont().getSize2D() - 1f));
    infoColor = statusField.getForeground();
    JXStatusBar statusBar = new JXStatusBar();
    statusBar.setResizeHandleEnabled(true);
    statusBar.add(statusField, new JXStatusBar.Constraint(JXStatusBar.Constraint.ResizeBehavior.FILL));
    if (ThemeManager.isLookAndFeelSubstance()) {
        statusBar.add(new SubstanceFontSlider());
    }
    statusBar.add(backgroundOperationLabel);
    statusBar.add(new MemoryMonitor(), new JXStatusBar.Constraint(120));
    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.add(toolBar, BorderLayout.NORTH);
    contentPanel.add(mainView, BorderLayout.CENTER);
    contentPanel.add(statusBar, BorderLayout.SOUTH);
    JPanel rootPanel = new JPanel(new BorderLayout());
    rootPanel.add(menuBar, BorderLayout.NORTH);
    rootPanel.add(contentPanel, BorderLayout.CENTER);
    waitPanel = new WaitMessagePanel();
    busyLayerUI = new BusyLayerUI();
    JLayer<JPanel> rootLayer = new JLayer<>(rootPanel, busyLayerUI);
    getContentPane().add(rootLayer, BorderLayout.CENTER);
    setGlassPane(waitPanel);
}
Also used : JPanel(javax.swing.JPanel) SubstanceFontSlider(jgnash.ui.components.SubstanceFontSlider) JLayer(javax.swing.JLayer) ActionEvent(java.awt.event.ActionEvent) JTextField(javax.swing.JTextField) ActionParser(jgnash.ui.util.builder.ActionParser) BorderLayout(java.awt.BorderLayout) DefaultEditorKit(javax.swing.text.DefaultEditorKit) AbstractAction(javax.swing.AbstractAction) JXBusyLabel(org.jdesktop.swingx.JXBusyLabel) WaitMessagePanel(jgnash.ui.components.WaitMessagePanel) AbstractEnabledAction(jgnash.ui.actions.AbstractEnabledAction) InputStream(java.io.InputStream) IOException(java.io.IOException) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) MemoryMonitor(jgnash.ui.components.MemoryMonitor) JXStatusBar(org.jdesktop.swingx.JXStatusBar)

Example 2 with MemoryMonitor

use of jgnash.ui.components.MemoryMonitor in project jgnash by ccavanaugh.

the class ConsoleDialog method show.

public static void show() {
    if (dialog == null) {
        // only one visible window
        init();
        ResourceBundle rb = ResourceUtils.getBundle();
        JButton copyButton = new JButton(rb.getString("Button.CopyToClip"));
        copyButton.addActionListener(e -> {
            if (console != null) {
                console.selectAll();
                console.copy();
            }
        });
        JButton gcButton = new JButton(rb.getString("Button.ForceGC"));
        gcButton.addActionListener(e -> System.gc());
        JButton heapButton = new JButton(rb.getString("Button.CreateHeapDump"));
        heapButton.addActionListener(e -> {
            if (console != null) {
                dumpHeap();
            }
        });
        dialog = new JDialog(UIApplication.getFrame(), Dialog.ModalityType.MODELESS);
        dialog.setTitle(rb.getString("Title.Console"));
        dialog.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent evt) {
                /* force the shut down to the end of the event thread.
                     * Lets other listeners do their job */
                EventQueue.invokeLater(() -> {
                    synchronized (consoleLock) {
                        ConsoleDialog.close();
                    }
                });
            }
        });
        synchronized (consoleLock) {
            console = new JTextArea();
            console.setEditable(false);
            // set a mono spaced font to preserve spacing
            console.setFont(new Font("Monospaced", Font.PLAIN, console.getFont().getSize()));
        }
        JPanel panel = new JPanel();
        panel.setBorder(Borders.DIALOG);
        panel.setLayout(new BorderLayout());
        panel.add(new MemoryMonitor(), BorderLayout.NORTH);
        panel.add(new JScrollPane(console), BorderLayout.CENTER);
        JPanel buttonPanel = StaticUIMethods.buildRightAlignedBar(heapButton, gcButton, copyButton);
        buttonPanel.setBorder(new EmptyBorder(10, 0, 10, 0));
        panel.add(buttonPanel, BorderLayout.SOUTH);
        dialog.getContentPane().add(panel, BorderLayout.CENTER);
        dialog.pack();
        // Minimum size
        dialog.setMinimumSize(dialog.getSize());
        dialog.setFocusableWindowState(false);
        dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        DialogUtils.addBoundsListener(dialog);
        dialog.setVisible(true);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) Font(java.awt.Font) MemoryMonitor(jgnash.ui.components.MemoryMonitor) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) ResourceBundle(java.util.ResourceBundle) EmptyBorder(javax.swing.border.EmptyBorder) JDialog(javax.swing.JDialog)

Aggregations

BorderLayout (java.awt.BorderLayout)2 JPanel (javax.swing.JPanel)2 MemoryMonitor (jgnash.ui.components.MemoryMonitor)2 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 ActionEvent (java.awt.event.ActionEvent)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ResourceBundle (java.util.ResourceBundle)1 AbstractAction (javax.swing.AbstractAction)1 JButton (javax.swing.JButton)1 JDialog (javax.swing.JDialog)1 JLayer (javax.swing.JLayer)1 JScrollPane (javax.swing.JScrollPane)1 JTextArea (javax.swing.JTextArea)1 JTextField (javax.swing.JTextField)1 JToolBar (javax.swing.JToolBar)1 EmptyBorder (javax.swing.border.EmptyBorder)1