Skip to content

Commit

Permalink
Merge pull request #34 from Nikola-Mircic/gui
Browse files Browse the repository at this point in the history
Gui
  • Loading branch information
Nikola-Mircic authored Oct 30, 2024
2 parents 180d3ec + b9bd2bc commit e780843
Show file tree
Hide file tree
Showing 18 changed files with 741 additions and 265 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ user.enc
pass.enc
efakturaplus.iml

/.idea/
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<hr>

### TO-DO list:
- [ ] - Multiple types of plots
- [ ] - Total income/outcome/tax calculation
- [ ] - Improved PDF file display
- [x] Multiple types of plots
- [ ] Total income/outcome/tax calculation
- [ ] Improved PDF file display

49 changes: 18 additions & 31 deletions src/efakturaplus/gui/InvoiceList.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public class InvoiceList extends JPanel {

private static final long serialVersionUID = 1L;

ArrayList<InvoiceListItem> invoices;
ArrayList<Invoice> invoices;

private JPanel invoiceDisplay;
private GridBagLayout layout;

public InvoiceList() {
public InvoiceList(ArrayList<Invoice> invoices) {
this.setLayout(new BorderLayout());

this.invoices = new ArrayList<>();
this.invoices = invoices;

this.layout = new GridBagLayout();
this.invoiceDisplay = new JPanel(this.layout);
Expand All @@ -55,38 +55,22 @@ public InvoiceList() {

printInvoices();
}

public void printInvoices() {
this.invoiceDisplay.removeAll();

public void addInvoice(Invoice invoice) {
InvoiceListItem toRemove = null;
for(InvoiceListItem item : invoices) {
if(item.invoice.id.equals(invoice.id) && invoice.status.ordinal() < item.invoice.status.ordinal())
toRemove = item;
}

if(toRemove != null)
this.invoices.remove(toRemove);

InvoiceListItem item = new InvoiceListItem(invoice);

this.invoices.add(item);

this.invoices.sort(new Comparator<InvoiceListItem>() {

this.invoices.sort(new Comparator<Invoice>() {
@Override
public int compare(InvoiceListItem item1, InvoiceListItem item2) {
return item2.invoice.deliveryDate.compareTo(item1.invoice.deliveryDate);
public int compare(Invoice item1, Invoice item2) {
return item2.deliveryDate.compareTo(item1.deliveryDate);
}
});

printInvoices();
}

public void printInvoices() {
this.invoiceDisplay.removeAll();


int n = this.invoices.size();
GridBagConstraints constr = new GridBagConstraints();


ArrayList<InvoiceListItem> items = new ArrayList<InvoiceListItem>();

if (n == 0) {
ImageIcon loading_gif = new ImageIcon("./icons/loading.gif");
JLabel loading = new JLabel("Loading ...", loading_gif, JLabel.CENTER);
Expand All @@ -99,21 +83,24 @@ public void printInvoices() {
this.invoiceDisplay.add(loading, constr);
}

InvoiceListItem item = null;

for(int i=0; i<n; ++i) {
item = new InvoiceListItem(this.invoices.get(i));

constr.gridx = 0;
constr.gridy = i*45;
constr.anchor = GridBagConstraints.FIRST_LINE_START;
constr.weightx = 1.0;
constr.weighty = 0.0;
constr.fill = GridBagConstraints.HORIZONTAL;

this.invoiceDisplay.add(this.invoices.get(i), constr);
this.invoiceDisplay.add(item, constr);
}

if(n != 0) {
constr.weighty = 1.0;
this.layout.setConstraints(this.invoices.get(n-1), constr);
this.layout.setConstraints(item, constr);
}
}
}
Expand Down
Loading

0 comments on commit e780843

Please sign in to comment.