use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class ReportCtl method startDocumentPrint.
/**
* Start Document Print for Type with specified printer.
* @param type document type in ReportEngine
* @param recordId id
* @param parent The window which invoked the printing
* @param windowNo The windows number which invoked the printing
* @param printerName Specified printer name
* @param processInfo Process Info
* @return true if success
*/
public static boolean startDocumentPrint(int type, MPrintFormat customPrintFormat, int recordId, ASyncProcess parent, int windowNo, boolean isDirectPrint, String printerName, ProcessInfo processInfo) {
String trxName;
if (processInfo != null)
trxName = processInfo.getTransactionName();
else
trxName = null;
ReportEngine reportEngine = ReportEngine.get(Env.getCtx(), type, recordId, trxName);
if (reportEngine == null) {
if (Ini.isClient()) {
ADialog.error(0, null, "NoDocPrintFormat");
} else {
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null)
loader = ReportCtl.class.getClassLoader();
Class<?> clazz = loader.loadClass("org.adempiere.webui.window.FDialog");
Method m = clazz.getMethod("error", Integer.TYPE, String.class);
m.invoke(null, 0, "NoDocPrintFormat");
} catch (Exception e) {
throw new AdempiereException(e);
}
}
return false;
}
if (customPrintFormat != null) {
// Use custom print format if available
reportEngine.setPrintFormat(customPrintFormat);
}
if (reportEngine.getPrintFormat() != null) {
MPrintFormat format = reportEngine.getPrintFormat();
// ==============================
if (format.getJasperProcess_ID() > 0) {
ServerReportCtl.runJasperProcess(recordId, reportEngine, isDirectPrint, printerName, processInfo);
} else // Standard Print Format (Non-Jasper)
// ==================================
{
// set generated PDF
if (processInfo != null)
processInfo.setPDFReport(reportEngine.getPDF());
createOutput(reportEngine, !isDirectPrint, printerName);
if (isDirectPrint) {
ReportEngine.printConfirm(type, recordId, trxName);
}
}
}
return true;
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class VPOS method init.
@Override
public void init(int WindowNo, FormFrame frame) {
this.frame = frame.getCFrame();
this.frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.frame.setResizable(true);
//
logger.info("init - SalesRep_ID=" + Env.getAD_User_ID(getCtx()));
setWindowNo(WindowNo);
frame.setJMenuBar(null);
if (!loadPOS()) {
EventQueue.invokeLater(new Runnable() {
public void run() {
CFrame closeFrame = frame.getCFrame();
closeFrame.dispatchEvent(new WindowEvent(closeFrame, WindowEvent.WINDOW_CLOSING));
dispose();
}
});
return;
}
userPinListener = new POSUserPinListener(this);
//Delay 5 seconds by default
userPinTimer = new javax.swing.Timer((getPINEntryTimeout() + 10) * 1000, userPinListener);
if (isPresentElectronicScales()) {
scalesListener = new POSScalesListener(this);
scalesTimer = new javax.swing.Timer(400, scalesListener);
}
isCorrectUserPin = null;
settingKeyboardFocusManager();
if (getM_POS() == null) {
if (this.frame != null)
this.frame.dispose();
return;
}
//
try {
if (!dynInit()) {
dispose();
return;
}
// Add to frame
frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
} catch (AdempierePOSException exception) {
ADialog.error(getWindowNo(), this.frame, exception.getLocalizedMessage());
dispose();
return;
}
logger.config("PosPanel.init - " + mainPanel.getPreferredSize());
if (getAutoLogoutDelay() > 0 && logoutTimer == null) {
logoutTimer = new javax.swing.Timer(1000, new ActionListener() {
PointerInfo pi = null;
long lastMouseMove = System.currentTimeMillis();
long lastKeyboardEvent = System.currentTimeMillis();
public void actionPerformed(ActionEvent actionEvent) {
try {
long now = actionEvent.getWhen();
PointerInfo newPi = MouseInfo.getPointerInfo();
// mouse moved
if (newPi != null && pi != null && !pi.getLocation().equals(newPi.getLocation())) {
lastMouseMove = now;
}
pi = newPi;
if (isVirtualKeyboard())
lastKeyboardEvent = focusManager.getLastWhen();
else
lastKeyboardEvent = 0;
if (getAutoLogoutDelay() * 1000 < now - Math.max(lastKeyboardEvent, lastMouseMove)) {
// new PosLogin(this);
}
} catch (AdempiereException exception) {
ADialog.error(getWindowNo(), getFrame(), exception.getLocalizedMessage());
}
}
});
logoutTimer.start();
}
if (isVirtualKeyboard())
focusManager.start();
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class POSQuantityPanel method actionPerformed.
/**
* Distribute actions
* @param actionEvent event
*/
public void actionPerformed(ActionEvent actionEvent) {
try {
if (actionEvent.getSource().equals(buttonUp)) {
posPanel.moveUp();
return;
} else if (actionEvent.getSource().equals(buttonDown)) {
posPanel.moveDown();
return;
}
if (actionEvent.getSource().equals(buttonMinus)) {
fieldQuantity.minus(1);
} else if (actionEvent.getSource().equals(buttonPlus)) {
fieldQuantity.plus();
} else if (actionEvent.getSource().equals(buttonDelete)) {
if (posPanel.isUserPinValid()) {
posPanel.deleteLine(posPanel.getOrderLineId());
fieldQuantity.setValue(0.0);
fieldPrice.setValue(0.0);
fieldDiscountPercentage.setValue(0.0);
posPanel.refreshPanel();
return;
}
}
if (actionEvent.getSource().equals(buttonScales)) {
posPanel.hideKeyboard();
posPanel.getScalesTimer().restart();
posPanel.showScales();
return;
}
BigDecimal quantity = (BigDecimal) fieldQuantity.getValue();
if (fieldQuantity.hasChanged() && actionEvent.getSource().equals(fieldQuantity) && (actionEvent.getActionCommand().equals("KeyEvent") || actionEvent.getActionCommand().equals("InvocationEvent"))) {
// Verify if it add or set
if (posPanel.isAddQty()) {
posPanel.setQtyAdded(quantity);
} else {
posPanel.setQty(quantity);
}
posPanel.updateLineTable();
posPanel.refreshPanel();
posPanel.changeViewPanel();
posPanel.getMainFocus();
return;
}
if ((actionEvent.getSource().equals(buttonPlus) || actionEvent.getSource().equals(buttonMinus))) {
posPanel.setQty((BigDecimal) fieldQuantity.getValue());
posPanel.setPrice((BigDecimal) fieldPrice.getValue());
BigDecimal discountPercentage = (BigDecimal) fieldDiscountPercentage.getValue();
if (discountPercentage == null)
discountPercentage = Env.ZERO;
posPanel.setDiscountPercentage(discountPercentage);
posPanel.updateLineTable();
posPanel.changeViewPanel();
posPanel.refreshPanel();
return;
}
if (actionEvent.getSource().equals(fieldDiscountPercentage) && actionEvent.getActionCommand().toString().equals("KeyEvent") || actionEvent.getSource().equals(fieldPrice) && actionEvent.getActionCommand().toString().equals("KeyEvent")) {
BigDecimal discountPercentage = (BigDecimal) fieldDiscountPercentage.getValue();
BigDecimal price = (BigDecimal) fieldPrice.getValue();
if (discountPercentage.signum() < 0)
throw new AdempierePOSException("@Discount@ @Error@");
if (price.signum() < 0)
throw new AdempierePOSException("@Price@ @Error@");
if (posPanel.isUserPinValid()) {
if ((posPanel.getQty().compareTo(quantity) != 0 && fieldQuantity.hasChanged() && (actionEvent.getSource().equals(fieldQuantity) || actionEvent.getSource().equals(buttonPlus) || actionEvent.getSource().equals(buttonMinus))) || (posPanel.getPrice().compareTo(price) != 0 && fieldPrice.hasChanged() && actionEvent.getSource().equals(fieldPrice)) || (posPanel.getDiscountPercentage().compareTo(discountPercentage) != 0 && fieldDiscountPercentage.hasChanged() && actionEvent.getSource().equals(fieldDiscountPercentage))) {
posPanel.setQty((BigDecimal) fieldQuantity.getValue());
posPanel.setPrice((BigDecimal) fieldPrice.getValue());
posPanel.setDiscountPercentage((BigDecimal) fieldDiscountPercentage.getValue());
posPanel.updateLineTable();
posPanel.changeViewPanel();
posPanel.refreshPanel();
}
}
return;
}
} catch (AdempiereException exception) {
ADialog.error(posPanel.getWindowNo(), this, exception.getLocalizedMessage());
}
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class POSUserPinListener method actionPerformed.
@Override
public final void actionPerformed(ActionEvent actionEvent) {
if (active) {
try {
if (actionEvent.getSource() == pos.getUserPinTimer()) {
pos.invalidateUserPin();
pos.getUserPinTimer().stop();
return;
}
if (pos.getUserPinTimer().isRunning())
return;
doPerformAction(actionEvent);
} catch (AdempiereException exception) {
ADialog.error(pos.getWindowNo(), pos.getFrame(), exception.getLocalizedMessage());
throw new AdempiereException(exception.getMessage());
}
}
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class MTaxCategory method getDefaultTax.
// MTaxCategory
/**
* getDefaultTax
* Get the default tax id associated with this tax category
*
*/
public MTax getDefaultTax() {
MTax m_tax = new MTax(getCtx(), 0, get_TrxName());
final String whereClause = COLUMNNAME_C_TaxCategory_ID + "=? AND " + COLUMNNAME_IsDefault + "='Y'";
List<MTax> list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName()).setParameters(getC_TaxCategory_ID()).setOnlyActiveRecords(true).list();
if (list.size() == 0) {
// Error - should be at least one default
throw new AdempiereException("NoDefaultTaxRate");
} else if (list.size() == 1) {
m_tax = list.get(0);
} else {
// Error - should only be one default
throw new AdempiereException("TooManyDefaults");
}
return m_tax;
}
Aggregations