use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class Tuple2PositionRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Position) {
label.setBorder(new EtchedBorder(1, Color.lightGray, Color.DARK_GRAY));
label.setText("<html>" + ((Position) value).getName() + "<br />" + ((Position) value).getDescription() + "</html>");
}
return label;
}
use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class CreditMemoAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Calendar release = Calendar.getInstance();
release.setTime(doc.getHistory().getRelease());
Calendar beforeOneYear = Calendar.getInstance();
beforeOneYear.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR) - 1);
if (beforeOneYear.after(release) && JOptionPane.CANCEL_OPTION == JOptionPane.showConfirmDialog(parent, "Der Vorgang ist über ein Jahr alt und die Garantie ist abgelaufen!\nMöchten sie fortfahren?", "Garantie Warnung", JOptionPane.OK_CANCEL_OPTION)) {
return;
}
List<AfterInvoicePosition> creditPositions = new ArrayList<>();
for (Position position : doc.getPositions().values()) {
if (position.getType() != PositionType.COMMENT)
creditPositions.add(new AfterInvoicePosition(position));
}
CreditMemoView view = new CreditMemoView(creditPositions);
OkCancelDialog<CreditMemoView> dialog = new OkCancelDialog<>("Test", view);
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
if (dialog.getCloseType() == CloseType.OK) {
doc.removeAllPositions();
for (Position position : view.getPositions()) {
doc.append(position);
}
doc.setType(DocumentType.CREDIT_MEMO);
doc.setDirective(Directive.BALANCE_REPAYMENT);
Document d = Dl.remote().lookup(RedTapeWorker.class).update(doc, view.getStockLocation(), Dl.local().lookup(Guardian.class).getUsername());
controller.reloadSelectionOnStateChange(d.getDossier());
}
}
use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class DefaultStateTransitionAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// Invoice
if (((RedTapeStateTransition) transition).getHints().contains(RedTapeStateTransition.Hint.CREATES_INVOICE)) {
int confirmInvoice = JOptionPane.showOptionDialog(parent, "Eine Rechnung wird unwiederruflich erstellt. Möchten Sie fortfahren?", "Rechnungserstellung", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
if (confirmInvoice == JOptionPane.CANCEL_OPTION)
return;
}
// Cancel
if (((RedTapeStateTransition) transition).equals(RedTapeStateTransitions.CANCEL)) {
int confirmInvoice = JOptionPane.showOptionDialog(parent, "Der Vorgang wird storniert.\nMöchten Sie fortfahren?", "Abbrechen des Vorganges", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
if (confirmInvoice == JOptionPane.NO_OPTION)
return;
}
if (((RedTapeStateTransition) transition).getHints().contains(RedTapeStateTransition.Hint.ADDS_SETTLEMENT)) {
SettlementViewCask view = new SettlementViewCask();
OkCancelDialog<SettlementViewCask> dialog = new OkCancelDialog<>(parent, "Zahlung hinterlegen", view);
dialog.setVisible(true);
if (dialog.getCloseType() == CloseType.OK) {
for (Document.Settlement settlement : view.getSettlements()) {
cdoc.getDocument().add(settlement);
}
} else {
return;
}
}
if (((RedTapeStateTransition) transition).getHints().contains(RedTapeStateTransition.Hint.UNIT_LEAVES_STOCK)) {
for (Position p : cdoc.getDocument().getPositions(PositionType.PRODUCT_BATCH).values()) {
// TODO not the best but fastest solution for now, this must be changed later
if (StringUtils.isBlank(p.getRefurbishedId())) {
if (JOptionPane.showConfirmDialog(parent, "Der Vorgang enthält Neuware, wurden alle Seriennummern erfasst?", "Bitte verifizieren", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION)
return;
}
}
}
Optional.of(Dl.remote().lookup(RedTapeWorker.class).stateChange(cdoc, transition, Dl.local().lookup(Guardian.class).getUsername())).filter(Ui.failure()::handle).map(Reply::getPayload).map(Document::getDossier).ifPresent(d -> controller.reloadSelectionOnStateChange(d));
}
use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class DocumentUpdateView method changePositionOrderAction.
// </editor-fold>//GEN-END:initComponents
private void changePositionOrderAction(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_changePositionOrderAction
final MultipleSelectionModel<Position> selection = positionsFxList.getSelectionModel();
final int index = selection.getSelectedIndex();
Position selectedItem = selection.getSelectedItem();
if (index < 0)
return;
if (evt.getSource() == moveUpButton) {
// Don't move at the beginning
if (index == 0)
return;
document.moveUp(selectedItem);
Platform.runLater(() -> {
Position removed = positions.remove(index);
positions.add(index - 1, removed);
selection.select(index - 1);
});
} else {
// Don't move at the end
if (index == positions.size() - 1)
return;
document.moveDown(selectedItem);
Platform.runLater(() -> {
Position removed = positions.remove(index);
positions.add(index + 1, removed);
selection.select(index + 1);
});
}
}
use of eu.ggnet.dwoss.redtape.ee.entity.Position in project dwoss by gg-net.
the class DocumentTest method testAppend.
@Test
public void testAppend() {
Document doc = new Document();
assertEquals("Document.posistion.size", 0, doc.getPositions().size());
Position p1 = doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
assertEquals("Document.posistion.size", 1, doc.getPositions().size());
assertEquals(p1, doc.getPosition(p1.getId()));
doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
doc.append(Position.builder().amount(1).type(PositionType.UNIT).build());
assertEquals("Document.posistion.size", 3, doc.getPositions().size());
assertEquals("Postions order", Arrays.asList(1, 2, 3), new ArrayList<>(doc.getPositions().keySet()));
}
Aggregations