Search in sources :

Example 61 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project jgnash by ccavanaugh.

the class AccountRegisterReport method createFilterPanel.

private JPanel createFilterPanel() {
    FormLayout layout = new FormLayout("p, $lcgap, p:g", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.append(filterCheckBox, txtFilter);
    return builder.getPanel();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder)

Example 62 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project jgnash by ccavanaugh.

the class IncomeExpensePieChart method createPanel.

private JPanel createPanel() {
    EnumSet<AccountType> set = EnumSet.of(AccountType.INCOME, AccountType.EXPENSE);
    JButton refreshButton = new JButton(rb.getString("Button.Refresh"));
    startField = new DatePanel();
    endField = new DatePanel();
    showEmptyCheck = new JCheckBox(rb.getString("Label.ShowEmptyAccounts"));
    showPercentCheck = new JCheckBox(rb.getString("Button.ShowPercentValues"));
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    combo = AccountListComboBox.getParentTypeInstance(engine.getRootAccount(), set);
    final LocalDate dStart = DateUtils.getFirstDayOfTheMonth(LocalDate.now()).minusYears(1);
    long start = pref.getLong(START_DATE, DateUtils.asEpochMilli(dStart));
    startField.setDate(DateUtils.asLocalDate(start));
    currentAccount = combo.getSelectedAccount();
    JFreeChart chart = createPieChart(currentAccount);
    chartPanel = new ChartPanel(chart, true, true, true, false, true);
    //                         (chart, properties, save, print, zoom, tooltips)
    FormLayout layout = new FormLayout("p, 4dlu, 70dlu, 8dlu, p, 4dlu, 70dlu, 8dlu, p, 4dlu:g, left:p", "f:d, 3dlu, f:d, 6dlu, f:p:g");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    layout.setRowGroups(new int[][] { { 1, 3 } });
    builder.append(combo, 9);
    builder.append(showEmptyCheck);
    builder.nextLine();
    builder.nextLine();
    builder.append(rb.getString("Label.StartDate"), startField);
    builder.append(rb.getString("Label.EndDate"), endField);
    builder.append(refreshButton);
    builder.append(showPercentCheck);
    builder.nextLine();
    builder.nextLine();
    builder.append(chartPanel, 11);
    JPanel panel = builder.getPanel();
    combo.addActionListener(e -> {
        setCurrentAccount(combo.getSelectedAccount());
        pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate()));
    });
    refreshButton.addActionListener(e -> {
        setCurrentAccount(currentAccount);
        pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate()));
    });
    showEmptyCheck.addActionListener(e -> setCurrentAccount(currentAccount));
    showPercentCheck.addActionListener(e -> ((PiePlot) chartPanel.getChart().getPlot()).setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels));
    ChartMouseListener mouseListener = new ChartMouseListener() {

        @Override
        public void chartMouseClicked(final ChartMouseEvent event) {
            MouseEvent me = event.getTrigger();
            if (me.getID() == MouseEvent.MOUSE_CLICKED && me.getClickCount() == 1) {
                try {
                    ChartEntity entity = event.getEntity();
                    // expand sections if interesting, back out if in nothing
                    if (entity instanceof PieSectionEntity) {
                        Account a = (Account) ((PieSectionEntity) entity).getSectionKey();
                        if (a.getChildCount() > 0) {
                            setCurrentAccount(a);
                        }
                    } else if (entity == null) {
                        Account parent = currentAccount;
                        if (parent == null) {
                            return;
                        }
                        parent = parent.getParent();
                        if (parent == null || parent instanceof RootAccount) {
                            return;
                        }
                        setCurrentAccount(parent);
                    }
                } catch (final Exception e) {
                    Logger.getLogger(IncomeExpensePieChart.class.getName()).log(Level.SEVERE, e.getLocalizedMessage(), e);
                }
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            setChartCursor(chartPanel, event.getEntity(), event.getTrigger().getPoint());
        }
    };
    chartPanel.addChartMouseListener(mouseListener);
    return panel;
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JPanel(javax.swing.JPanel) RootAccount(jgnash.engine.RootAccount) Account(jgnash.engine.Account) ChartPanel(org.jfree.chart.ChartPanel) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) MouseEvent(java.awt.event.MouseEvent) JButton(javax.swing.JButton) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) AccountType(jgnash.engine.AccountType) LocalDate(java.time.LocalDate) JFreeChart(org.jfree.chart.JFreeChart) ChartMouseListener(org.jfree.chart.ChartMouseListener) JCheckBox(javax.swing.JCheckBox) RootAccount(jgnash.engine.RootAccount) DatePanel(jgnash.ui.components.DatePanel) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder) ChartEntity(org.jfree.chart.entity.ChartEntity) Engine(jgnash.engine.Engine) PieSectionEntity(org.jfree.chart.entity.PieSectionEntity)

Example 63 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project jgnash by ccavanaugh.

the class PortfolioReport method getReportController.

/**
     * Creates a report control panel.  May return null if a panel is not used
     * The ReportController is responsible for dynamic report options with the exception
     * of page format options
     *
     * @return control panel
     */
@Override
public JPanel getReportController() {
    FormLayout layout = new FormLayout("p, $lcgap, p:g, 8dlu, p", "f:d, $lgap, f:d");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.border(Borders.DIALOG);
    builder.append(rb.getString("Label.Account"), accountCombo);
    builder.append(refreshButton);
    builder.nextLine();
    builder.nextLine();
    builder.append(buildOptionPanel(), 5);
    layout.addGroupedRow(1);
    layout.addGroupedRow(3);
    return builder.getPanel();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder)

Example 64 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project jgnash by ccavanaugh.

the class ProfitLossTXT method getDates.

private LocalDate[] getDates() {
    final LocalDate start = LocalDate.now().minusYears(1);
    final JDateField startField = new JDateField();
    final JDateField endField = new JDateField();
    startField.setValue(start);
    final FormLayout layout = new FormLayout("right:p, 4dlu, p:g", "");
    final DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.rowGroupingEnabled(true);
    builder.append(rb.getString("Label.StartDate"), startField);
    builder.append(rb.getString("Label.EndDate"), endField);
    builder.nextLine();
    builder.appendUnrelatedComponentsGapRow();
    builder.nextLine();
    final JPanel panel = builder.getPanel();
    int option = JOptionPane.showConfirmDialog(null, new Object[] { panel }, rb.getString("Message.StartEndDate"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (option == JOptionPane.OK_OPTION) {
        return new LocalDate[] { startField.localDateValue(), endField.localDateValue() };
    }
    return null;
}
Also used : JDateField(jgnash.ui.components.JDateField) FormLayout(com.jgoodies.forms.layout.FormLayout) JPanel(javax.swing.JPanel) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder) LocalDate(java.time.LocalDate)

Example 65 with FormLayout

use of com.jgoodies.forms.layout.FormLayout in project jgnash by ccavanaugh.

the class CurrenciesPanel method buildCenterPanel.

private JPanel buildCenterPanel() {
    FormLayout layout = new FormLayout("p:g", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.append(addButton);
    builder.append(removeButton);
    return builder.getPanel();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder)

Aggregations

FormLayout (com.jgoodies.forms.layout.FormLayout)318 CellConstraints (com.jgoodies.forms.layout.CellConstraints)136 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)128 JPanel (javax.swing.JPanel)109 JScrollPane (javax.swing.JScrollPane)76 PanelBuilder (com.jgoodies.forms.builder.PanelBuilder)63 JLabel (javax.swing.JLabel)55 JButton (javax.swing.JButton)41 BorderLayout (java.awt.BorderLayout)32 FormBuilder (com.jgoodies.forms.builder.FormBuilder)19 JTextField (javax.swing.JTextField)19 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)18 JCheckBox (javax.swing.JCheckBox)18 Dimension (java.awt.Dimension)12 ActionEvent (java.awt.event.ActionEvent)12 DatePanel (jgnash.ui.components.DatePanel)11 TextAdapter (org.apache.cayenne.modeler.util.TextAdapter)11 JRadioButton (javax.swing.JRadioButton)10 ActionListener (java.awt.event.ActionListener)9 AbstractAction (javax.swing.AbstractAction)9