public static void main(final String[] args) { Adempiere.startupEnvironment(false); Ini.setAdempiereHome("."); Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, true); doIt(); }
boolean isPrintPreview() { if (_printPreview != null) { return _printPreview; } return Ini.isPropertyBool(Ini.P_PRINTPREVIEW); }
public Boolean savePreferences(Map<String, String> ctx) { CContext cContext = getContext(); MUser user = MUser.get(cContext); MUserPreference preference = user.getPreference(); String printerName = ctx.get("PrinterName"); if (printerName != null && printerName.trim().equalsIgnoreCase("")) { cContext.setPrinterName(printerName); preference.setPrinterName(printerName); } String autoCommit = ctx.get("AutoCommit"); if (autoCommit != null) { cContext.setAutoCommit(autoCommit.trim().equalsIgnoreCase("Y")); preference.setIsAutoCommit(autoCommit.trim().equalsIgnoreCase("Y")); } String showAdvanced = ctx.get("#ShowAdvanced"); if (showAdvanced != null) { cContext.setContext("#ShowAdvanced", showAdvanced); preference.setIsShowAdvanced(showAdvanced.trim().equalsIgnoreCase("Y")); } String showAccounting = ctx.get("#ShowAcct"); if (showAccounting != null) { cContext.setContext("#ShowAcct", showAccounting); preference.setIsShowAcct(showAccounting.trim().equalsIgnoreCase("Y")); } String showTranslation = ctx.get("#ShowTrl"); if (showTranslation != null) { cContext.setContext("#ShowTrl", showTranslation); preference.setIsShowTrl(showTranslation.trim().equalsIgnoreCase("Y")); } String uiTheme = ctx.get("#UITheme"); if (uiTheme != null && !uiTheme.trim().equalsIgnoreCase("")) { cContext.setContext("#UITheme", uiTheme); preference.setUITheme(uiTheme); } String printPreview = ctx.get("#PrintPreview"); if (printPreview != null) { cContext.setPrintPreview(printPreview.equalsIgnoreCase("Y")); Ini.setProperty(Ini.P_PRINTPREVIEW, printPreview.equalsIgnoreCase("Y")); Ini.saveProperties(Ini.isClient()); } String date = ctx.get("#Date"); cContext.setContext("#Date", date); return preference.save(); }
/** * Constructor * * @param Title Title * @param AD_Process_ID AD_Process_ID * @param Table_ID AD_Table_ID * @param Record_ID Record_ID */ public ProcessInfo(String Title, int AD_Process_ID, int Table_ID, int Record_ID) { setTitle(Title); setAD_Process_ID(AD_Process_ID); setTable_ID(Table_ID); setRecord_ID(Record_ID); if (Ini.isPropertyBool(Ini.P_PRINTPREVIEW)) m_printPreview = true; else m_printPreview = false; } // ProcessInfo
/** * Static Init * * @throws Exception */ private void jbInit() throws Exception { Charset[] charsets = Ini.getAvailableCharsets(); for (int i = 0; i < charsets.length; i++) fCharset.appendItem(charsets[i].displayName(), charsets[i]); bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile")); bFile.setTooltiptext(Msg.getMsg(Env.getCtx(), "FileImportFileInfo")); bFile.addEventListener(Events.ON_CLICK, this); fCharset.setMold("select"); fCharset.setRows(0); fCharset.setTooltiptext(Msg.getMsg(Env.getCtx(), "Charset", false)); info.setValue(" "); labelFormat.setValue(Msg.translate(Env.getCtx(), "AD_ImpFormat_ID")); pickFormat.setMold("select"); pickFormat.setRows(0); bNext.setTooltiptext(Msg.getMsg(Env.getCtx(), "Next")); bNext.setLabel(">"); bNext.addEventListener(Events.ON_CLICK, this); record.setValue("------"); bPrevious.setTooltiptext(Msg.getMsg(Env.getCtx(), "Previous")); bPrevious.setLabel("<"); bPrevious.addEventListener(Events.ON_CLICK, this); northPanel.appendChild(bFile); northPanel.appendChild(fCharset); northPanel.appendChild(info); northPanel.appendChild(labelFormat); northPanel.appendChild(pickFormat); northPanel.appendChild(bPrevious); northPanel.appendChild(record); northPanel.appendChild(bNext); rawData.setWidth("100%"); rawData.setCols(80); rawData.setRows(MAX_SHOWN_LINES); rawData.setHeight("40%"); previewPanel.setWidth("100%"); previewPanel.setHeight("58%"); previewPanel.setStyle("overflow: auto"); centerPanel.setWidth("100%"); // Elaine 2008/11/07 - fix text area is not expanded in IE7 centerPanel.setHeight("100%"); centerPanel.appendChild(rawData); centerPanel.appendChild(new Separator()); centerPanel.appendChild(previewPanel); confirmPanel.addActionListener(Events.ON_CLICK, this); }
private String getDefaultPrinterNameFromIni(final String propName) { log.debug("Looking for " + propName + " in ini file"); String printerName = Ini.getProperty(propName); if (!Check.isEmpty(printerName)) { log.debug("Found printerName: " + printerName); return printerName; } log.debug("Looking for machine's printers"); final PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); if (services == null || services.length == 0) { // [email protected]: so what? we don't need a printer to generate PDFs // log.warn("No default printer found on this machine"); return ""; } printerName = services[0].getName(); Ini.setProperty(propName, printerName); log.debug("Found printerName: " + printerName); return printerName; }
/** * Create DataSource * * @param connection connection * @return data dource */ @Override public DataSource getDataSource(CConnection connection) { if (m_ds != null) return m_ds; try { System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog"); // System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "ALL"); ComboPooledDataSource cpds = new ComboPooledDataSource(); cpds.setDataSourceName("AdempiereDS"); cpds.setDriverClass(DRIVER); // loads the jdbc driver cpds.setJdbcUrl(getConnectionURL(connection)); cpds.setUser(connection.getDbUid()); cpds.setPassword(connection.getDbPwd()); cpds.setPreferredTestQuery(DEFAULT_CONN_TEST_SQL); cpds.setIdleConnectionTestPeriod(1200); cpds.setAcquireRetryAttempts(2); // cpds.setTestConnectionOnCheckin(true); // cpds.setTestConnectionOnCheckout(true); // cpds.setCheckoutTimeout(60); if (Ini.isClient()) { cpds.setInitialPoolSize(1); cpds.setMinPoolSize(1); cpds.setMaxPoolSize(15); cpds.setMaxIdleTimeExcessConnections(1200); cpds.setMaxIdleTime(900); m_maxbusyconnections = 10; } else { cpds.setInitialPoolSize(10); cpds.setMinPoolSize(5); cpds.setMaxPoolSize(150); cpds.setMaxIdleTimeExcessConnections(1200); cpds.setMaxIdleTime(1200); m_maxbusyconnections = 120; } // the following sometimes kill active connection! // cpds.setUnreturnedConnectionTimeout(1200); // cpds.setDebugUnreturnedConnectionStackTraces(true); m_ds = cpds; } catch (Exception ex) { m_ds = null; // log might cause infinite loop since it will try to acquire database connection again // log.log(Level.SEVERE, "Could not initialise C3P0 Datasource", ex); System.err.println("Could not initialise C3P0 Datasource: " + ex.getLocalizedMessage()); } return m_ds; } // getDataSource
private boolean isDirectPrint(final I_AD_Printer printer) { Boolean isDirectPrint = null; if (printer != null && printer.getIsDirectPrint() != null) { isDirectPrint = X_AD_Printer.ISDIRECTPRINT_Yes.equals(printer.getIsDirectPrint()); if (LogManager.isLevelFine()) { log.debug("IsDirectPrint for: " + isDirectPrint + " (From: " + printer + ")"); } } if (isDirectPrint == null) { isDirectPrint = !Ini.isPropertyBool(Ini.P_PRINTPREVIEW); if (LogManager.isLevelFine()) { log.debug("IsDirectPrint: " + isDirectPrint + " (From: ini)"); } } return isDirectPrint; }
public static void main(String[] args) { Adempiere.startup(true); Ini.setProperty(Ini.P_UID, "SuperUser"); Ini.setProperty(Ini.P_PWD, "System"); Ini.setProperty(Ini.P_ROLE, "GardenWorld Admin"); Ini.setProperty(Ini.P_CLIENT, "GardenWorld"); Ini.setProperty(Ini.P_ORG, "HQ"); Ini.setProperty(Ini.P_WAREHOUSE, "HQ Warehouse"); Ini.setProperty(Ini.P_LANGUAGE, "English"); // Ini.setProperty(Ini.P_PRINTER,"MyPrinter"); Login login = new Login(Env.getCtx()); login.batchLogin(); ForecastEngine engine = ForecastEngine.get(); }
/** Dynamic Init */ private void dynInit() { // Load Formats pickFormat.appendItem(s_none, s_none); String sql = MRole.getDefault() .addAccessSQL( "SELECT Name FROM AD_ImpFormat", "AD_ImpFormat", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); try { PreparedStatement pstmt = DB.prepareStatement(sql, null); ResultSet rs = pstmt.executeQuery(); while (rs.next()) pickFormat.appendItem(rs.getString(1), rs.getString(1)); rs.close(); pstmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); } pickFormat.setSelectedIndex(0); pickFormat.addEventListener(Events.ON_SELECT, this); Charset charset = Ini.getCharset(); for (int i = 0; i < fCharset.getItemCount(); i++) { ListItem listitem = fCharset.getItemAtIndex(i); Charset compare = (Charset) listitem.getValue(); if (charset == compare) { fCharset.setSelectedIndex(i); break; } } fCharset.addEventListener(Events.ON_SELECT, this); confirmPanel.setEnabled("Ok", false); } // dynInit
public static void main(final String[] args) { // // Start ADempiere AdempiereToolsHelper.getInstance().startupMinimal(); LogManager.setLevel(Level.DEBUG); Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, false); // metas: don't log migration scripts final TableAndColumnInfoRepository repository = new TableAndColumnInfoRepository(); // // Get AD_Reference_ID parameter if (args.length < 1) { throw new AdempiereException("Provide AD_Reference_ID parameter"); } final String adReferenceIdStr = args[0]; Check.assumeNotEmpty(adReferenceIdStr, "Valid AD_Reference_ID parameter: {}", adReferenceIdStr); final int adReferenceId = Integer.parseInt(adReferenceIdStr.trim()); // // Get the AD_Reference list info final ListInfo listInfo = repository.getListInfo(adReferenceId).orNull(); if (listInfo == null) { throw new AdempiereException("No list info found for AD_Reference_ID=" + adReferenceId); } // // Generate the Java code final String javacode = ADRefListGenerator.newInstance() .setColumnName("MyColumnName") .setListInfo(listInfo) .generateConstants(); // // Output the result System.out.println("Generated Java code:"); System.out.println( "--------------------------------------------------------------------------------------------"); System.out.println(javacode); System.out.println( "--------------------------------------------------------------------------------------------"); }
/** * Invoke the form VCreateFromPackage * * @param ctx context * @param WindowNo window no * @param mTab tab * @param mField field * @param value value * @return null or error message */ public String createFrom( final Properties ctx, final int WindowNo, final GridTab mTab, final GridField mField, final Object value) { final I_C_Invoice invoice = InterfaceWrapperHelper.create(mTab, I_C_Invoice.class); if (invoice.getC_Invoice_ID() <= 0) { return ""; } final I_C_DocType dt = invoice.getC_DocTypeTarget(); if (!Constants.DOCBASETYPE_AEInvoice.equals(dt.getDocBaseType()) || !CommissionConstants.COMMISSON_INVOICE_DOCSUBTYPE_CORRECTION.equals( dt.getDocSubType())) { // nothing to do final IDocumentPA docPA = Services.get(IDocumentPA.class); final I_C_DocType dtCorr = docPA.retrieve( ctx, invoice.getAD_Org_ID(), Constants.DOCBASETYPE_AEInvoice, CommissionConstants.COMMISSON_INVOICE_DOCSUBTYPE_CORRECTION, true, null); if (dtCorr != null) { final String msg = Msg.getMsg( ctx, MSG_INVOICECORR_CREATEFROM_WRONG_DOCTYPE_1P, new Object[] {dtCorr.getName()}); return msg; } else { throw new AdempiereException( "Missing C_DocType with DocBaseType='" + Constants.DOCBASETYPE_AEInvoice + "' and DocSubType='" + CommissionConstants.COMMISSON_INVOICE_DOCSUBTYPE_CORRECTION + "'"); } } final String swingclassname = "de.metas.commission.form.VCreateCorrections"; final String zkclassname = "not.yet.implemented"; final String classname; if (Ini.isClient()) { classname = swingclassname; } else { classname = zkclassname; return ""; } ICreateFrom cf = null; Class cl; try { if (Ini.isClient()) { cl = Class.forName(classname); } else { cl = Thread.currentThread().getContextClassLoader().loadClass(classname); } } catch (final ClassNotFoundException e) { log.error(e.getLocalizedMessage(), e); return e.getLocalizedMessage(); } if (cl != null) { try { java.lang.reflect.Constructor<? extends ICreateFrom> ctor = cl.getConstructor(I_C_Invoice.class, int.class); cf = ctor.newInstance(invoice, WindowNo); } catch (Throwable e) { log.error(e.getLocalizedMessage(), e); return e.getLocalizedMessage(); } } if (cf != null) { if (cf.isInitOK()) { cf.showWindow(); cf.closeWindow(); mTab.dataRefresh(); } else cf.closeWindow(); } return ""; } // createShippingPackages
/** * Execute Process Instance and Lock UI. Calls lockUI and unlockUI if parent is a ASyncProcess * * <pre> * - Get Process Information * - Call Class * - Submit SQL Procedure * - Run SQL Procedure * </pre> */ public void run() { log.fine("AD_PInstance_ID=" + m_pi.getAD_PInstance_ID() + ", Record_ID=" + m_pi.getRecord_ID()); // Lock // lock(); // try {System.out.println(">> sleeping ..");sleep(20000);System.out.println(".. sleeping <<");} // catch (Exception e) {} // Get Process Information: Name, Procedure Name, ClassName, IsReport, IsDirectPrint String ProcedureName = ""; int AD_ReportView_ID = 0; int AD_Workflow_ID = 0; boolean IsReport = false; boolean IsDirectPrint = false; // String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END CASE," + " p.IsServerProcess " + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " + "WHERE p.IsActive='Y'" + " AND i.AD_PInstance_ID=?"; if (!Env.isBaseLanguage(m_wscctx, "AD_Process")) sql = "SELECT t.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport, p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END CASE," + " p.IsServerProcess " + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " + " INNER JOIN AD_Process_Trl t ON (p.AD_Process_ID=t.AD_Process_ID" + " AND t.AD_Language='" + Env.getAD_Language(m_wscctx) + "') " + "WHERE p.IsActive='Y'" + " AND i.AD_PInstance_ID=?"; // try { PreparedStatement pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, null); pstmt.setInt(1, m_pi.getAD_PInstance_ID()); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { m_pi.setTitle(rs.getString(1)); if (m_waiting != null) m_waiting.setTitle(m_pi.getTitle()); ProcedureName = rs.getString(2); m_pi.setClassName(rs.getString(3)); m_pi.setAD_Process_ID(rs.getInt(4)); // Report if ("Y".equals(rs.getString(5))) { IsReport = true; if ("Y".equals(rs.getString(6)) && !Ini.isPropertyBool(Ini.P_PRINTPREVIEW)) IsDirectPrint = true; } AD_ReportView_ID = rs.getInt(7); AD_Workflow_ID = rs.getInt(8); // int estimate = rs.getInt(9); if (estimate != 0) { m_pi.setEstSeconds(estimate + 1); // admin overhead if (m_waiting != null) m_waiting.setTimerEstimate(m_pi.getEstSeconds()); } m_IsServerProcess = "Y".equals(rs.getString(10)); } else log.log(Level.SEVERE, "No AD_PInstance_ID=" + m_pi.getAD_PInstance_ID()); rs.close(); pstmt.close(); } catch (SQLException e) { m_pi.setSummary( Msg.getMsg(m_wscctx, "ProcessNoProcedure") + " " + e.getLocalizedMessage(), true); // unlock(); log.log(Level.SEVERE, "run", e); return; } // No PL/SQL Procedure if (ProcedureName == null) ProcedureName = ""; /** ******************************************************************** Workflow */ if (AD_Workflow_ID > 0) { startWorkflow(AD_Workflow_ID); // unlock(); return; } /** ******************************************************************** Start Optional Class */ if (m_pi.getClassName() != null) { // Run Class if (!startProcess()) { // unlock(); return; } // No Optional SQL procedure ... done if (!IsReport && ProcedureName.length() == 0) { // unlock (); return; } // No Optional Report ... done if (IsReport && AD_ReportView_ID == 0) { // unlock (); return; } } // If not a report, we need a prodedure name if (!IsReport && ProcedureName.length() == 0) { m_pi.setSummary(Msg.getMsg(m_wscctx, "ProcessNoProcedure"), true); // unlock(); return; } /** ******************************************************************** Report submission */ if (IsReport) { // Optional Pre-Report Process if (ProcedureName.length() > 0) { if (!startDBProcess(ProcedureName)) { // unlock(); return; } } // Pre-Report // Start Report ----------------------------------------------- boolean ok = ReportCtl.start(m_pi, IsDirectPrint); m_pi.setSummary("Report", !ok); // unlock (); } /** ******************************************************************** Process submission */ else { if (!startDBProcess(ProcedureName)) { // unlock(); return; } // Success - getResult ProcessInfoUtil.setSummaryFromDB(m_pi); // unlock(); } // *** Process submission *** // log.fine(Log.l3_Util, "ProcessCtl.run - done"); } // run