Search in sources :

Example 1 with DatePanel

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

the class AmortizeDialog method initComponents.

private void initComponents() {
    dateField = new DatePanel();
    interestField = new JFloatField(0, 3, 2);
    loanAmountField = new JFloatField();
    loanTermField = new JIntegerField();
    payPeriodsField = new JIntegerField();
    intPeriodsField = new JIntegerField();
    feesField = new JFloatField();
    interestAccButton = new JButton(rb.getString("Word.None"));
    bankAccButton = new JButton(rb.getString("Word.None"));
    feesAccButton = new JButton(rb.getString("Word.None"));
    payeeField = new JTextFieldEx();
    memoField = new JTextFieldEx();
    useDaysButton = new JCheckBox(rb.getString("Button.UseDailyRate"));
    daysField = new JFloatField();
    cancelButton = new JButton(rb.getString("Button.Cancel"));
    okButton = new JButton(rb.getString("Button.Ok"));
}
Also used : JIntegerField(jgnash.ui.components.JIntegerField) JCheckBox(javax.swing.JCheckBox) JFloatField(jgnash.ui.components.JFloatField) DatePanel(jgnash.ui.components.DatePanel) JButton(javax.swing.JButton) JTextFieldEx(jgnash.ui.components.JTextFieldEx)

Example 2 with DatePanel

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

the class DateChkNumberDialog method initComponents.

private void initComponents() {
    datePanel = new DatePanel();
    numberCombo = new TransactionNumberComboBox(account);
    okButton = new JButton(rb.getString("Button.Ok"));
    cancelButton = new JButton(rb.getString("Button.Cancel"));
    okButton.addActionListener(this);
    cancelButton.addActionListener(this);
    getRootPane().setDefaultButton(okButton);
}
Also used : DatePanel(jgnash.ui.components.DatePanel) JButton(javax.swing.JButton) TransactionNumberComboBox(jgnash.ui.components.TransactionNumberComboBox)

Example 3 with DatePanel

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

the class MonthBalanceCSV method getOptions.

private void getOptions() {
    final DatePanel startField = new DatePanel();
    final DatePanel endField = new DatePanel();
    ButtonGroup group = new ButtonGroup();
    JRadioButton vButton = new JRadioButton(rb.getString("Button.Vertical"));
    JRadioButton hButton = new JRadioButton(rb.getString("Button.Horizontal"));
    group.add(vButton);
    group.add(hButton);
    vButton.setSelected(true);
    FormLayout layout = new FormLayout("right:p, 4dlu, p:g", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.rowGroupingEnabled(true);
    builder.append(rb.getString("Label.StartDate"), startField);
    builder.append(rb.getString("Label.EndDate"), endField);
    builder.append(rb.getString("Label.Layout"), vButton);
    builder.append("", hButton);
    builder.nextLine();
    builder.appendUnrelatedComponentsGapRow();
    builder.nextLine();
    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) {
        startDate = startField.getLocalDate();
        endDate = endField.getLocalDate();
    }
    vertical = vButton.isSelected();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) DatePanel(jgnash.ui.components.DatePanel) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder)

Example 4 with DatePanel

use of jgnash.ui.components.DatePanel 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 5 with DatePanel

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

the class CurrencyExchangeDialog method initComponents.

private void initComponents() {
    baseCurrencyCombo = new CurrencyComboBox();
    exchangeCurrencyCombo = new CurrencyComboBox();
    dateField = new DatePanel();
    baseCurrencyCombo.addActionListener(this);
    exchangeCurrencyCombo.addActionListener(this);
    model = new HistoryModel();
    table = new HistoryTable();
    table.setModel(model);
    table.setPreferredScrollableViewportSize(new java.awt.Dimension(150, 150));
    table.setCellSelectionEnabled(false);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setRowSorter(new TableRowSorter<>(model));
    table.setFillsViewportHeight(true);
    table.getSelectionModel().addListSelectionListener(this);
    closeButton = new JButton(rb.getString("Button.Close"));
    deleteButton = new JButton(rb.getString("Button.Delete"));
    clearButton = new JButton(rb.getString("Button.Clear"));
    addButton = new JButton(rb.getString("Button.Add"));
    updateButton = new JButton(rb.getString("Button.UpdateOnline"));
    updateButton.setIcon(IconUtils.getIcon("/jgnash/resource/applications-internet.png"));
    progressBar = new JProgressBar();
    stopButton = new JButton(rb.getString("Button.Stop"));
    stopButton.setIcon(IconUtils.getIcon("/jgnash/resource/process-stop.png"));
    stopButton.setEnabled(false);
    addButton.addActionListener(this);
    clearButton.addActionListener(this);
    closeButton.addActionListener(this);
    deleteButton.addActionListener(this);
    updateButton.addActionListener(this);
    stopButton.addActionListener(this);
    EventQueue.invokeLater(CurrencyExchangeDialog.this::updateModel);
}
Also used : DatePanel(jgnash.ui.components.DatePanel) CurrencyComboBox(jgnash.ui.components.CurrencyComboBox) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar)

Aggregations

DatePanel (jgnash.ui.components.DatePanel)12 FormLayout (com.jgoodies.forms.layout.FormLayout)8 JButton (javax.swing.JButton)6 CellConstraints (com.jgoodies.forms.layout.CellConstraints)5 JLabel (javax.swing.JLabel)5 JRadioButton (javax.swing.JRadioButton)5 JCheckBox (javax.swing.JCheckBox)4 JPanel (javax.swing.JPanel)4 JSpinner (javax.swing.JSpinner)4 SpinnerNumberModel (javax.swing.SpinnerNumberModel)4 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)3 ChartPanel (org.jfree.chart.ChartPanel)3 JFreeChart (org.jfree.chart.JFreeChart)3 LocalDate (java.time.LocalDate)2 Account (jgnash.engine.Account)2 JFloatField (jgnash.ui.components.JFloatField)2 JIntegerField (jgnash.ui.components.JIntegerField)2 Dimension (java.awt.Dimension)1 TextField (java.awt.TextField)1 MouseEvent (java.awt.event.MouseEvent)1