use of eu.ggnet.dwoss.redtapext.ui.cao.jasper.DocumentPrintAction in project dwoss by gg-net.
the class RedTapeController method fillToolBar.
/**
* Fills the toolbar as well as organizing the popupmenus.
* <p/>
*/
public void fillToolBar() {
view.actionBar.removeAll();
view.actionBar.setLayout(new FlowLayout(FlowLayout.LEADING, 3, 3));
view.actionBar.add(new JButton(new AbstractAction("Kunden bearbeiten") {
@Override
public void actionPerformed(ActionEvent e) {
openUpdateCustomer(model.getPurchaseCustomer().getId());
view.customerDetailArea.setText(Dl.remote().lookup(CustomerService.class).asHtmlHighDetailed(model.getPurchaseCustomer().getId()));
}
}));
// build customer dependant actions.
if (getViewOnlyCustomerIds().contains(model.getPurchaseCustomer().getId())) {
// Don't allow anything here.
} else if (model.getPurchaseCustomer().getFlags().contains(CustomerFlag.SYSTEM_CUSTOMER)) {
view.actionBar.add(new JButton(new DossierCreateAction(parent(), false, RedTapeController.this, model.getPurchaseCustomer().getId())));
} else {
view.actionBar.add(new JButton(new DossierCreateAction(parent(), false, RedTapeController.this, model.getPurchaseCustomer().getId())));
view.actionBar.add(new JButton(new DossierCreateAction(parent(), true, RedTapeController.this, model.getPurchaseCustomer().getId())));
}
JToolBar.Separator sep = new JToolBar.Separator();
sep.setAlignmentX(JComponent.CENTER_ALIGNMENT);
view.actionBar.add(sep);
if (model.getSelectedDocument() != null && !getViewOnlyCustomerIds().contains(model.getPurchaseCustomer().getId())) {
Document selDocument = model.getSelectedDocument();
DossierUpdateAction action = new DossierUpdateAction(parent(), this, model.getPurchaseCustomer().getId(), model.getSelectedDocument());
view.actionBar.add(new JButton(action));
// Deactivate Button if a Update isn't possible or allowed.
if (!isSelectedDocumentEditable()) {
action.setEnabled(false);
}
if (selDocument.getType().equals(DocumentType.CREDIT_MEMO)) {
Dl.local().lookup(Guardian.class).add(action, CREATE_ANNULATION_INVOICE);
accessDependentActions.add(action);
}
view.setDocumentPopupActions(action, new AbstractAction("Details") {
@Override
public void actionPerformed(ActionEvent e) {
openDocumentViewer(model.getSelectedDocument());
}
});
view.actionBar.add(new JButton(new DocumentPrintAction(selDocument, DocumentViewType.DEFAULT, this, model.getPurchaseCustomer().getId())));
if (selDocument.getType() == DocumentType.ORDER)
view.actionBar.add(new JButton(new DocumentPrintAction(selDocument, DocumentViewType.RESERVATION, this, model.getPurchaseCustomer().getId())));
if (!EnumSet.of(DocumentType.ANNULATION_INVOICE, DocumentType.COMPLAINT, DocumentType.CREDIT_MEMO).contains(selDocument.getType())) {
view.actionBar.add(new DocumentPrintAction(selDocument, DocumentViewType.SHIPPING, this, model.getPurchaseCustomer().getId()));
}
}
for (Component component : view.actionBar.getComponents()) {
if (component instanceof JButton) {
((JButton) component).setBorder(new BevelBorder(SoftBevelBorder.LOWERED, Color.lightGray, Color.DARK_GRAY, Color.DARK_GRAY, Color.lightGray));
}
}
view.actionBar.revalidate();
view.actionBar.repaint();
}
Aggregations