/** * Show WHO * * @param e event */ void mouseClicked(MouseEvent e) { if (m_dse == null || m_dse.CreatedBy == null || !MRole.getDefault().isShowPreference()) return; // String title = Msg.getMsg(Env.getCtx(), "Who") + m_text; RecordInfo info = new RecordInfo(Env.getFrame(this), title, m_dse); AEnv.showCenterScreen(info); } // addStatusComponent
/** * Help System * * @param frame Parent * @param title Window * @param url URL to display */ public Help(Frame frame, String title, URL url) { super(frame, title, false); try { jbInit(); info.setPage(url); } catch (Exception ex) { log.log(Level.SEVERE, "", ex); } AEnv.positionCenterWindow(frame, this); } // Help
/** * Help System for Window Help * * @param frame Parent * @param title Title * @param mWindow Window Model */ public Help(Frame frame, String title, GridWindow mWindow) { super(frame, title, false); try { jbInit(); loadInfo(mWindow); } catch (Exception ex) { log.log(Level.SEVERE, "", ex); } AEnv.positionCenterWindow(frame, this); } // Help
/** * Help System * * @param frame Parent * @param title Window * @param helpHtml Helptext */ public Help(Frame frame, String title, String helpHtml) { super(frame, title, false); try { jbInit(); info.setContentType("text/html"); info.setEditable(false); info.setBackground(CompierePLAF.getFieldBackground_Inactive()); info.setText(helpHtml); } catch (Exception ex) { log.log(Level.SEVERE, "Help", ex); } AEnv.positionCenterWindow(frame, this); } // Help
/** * Constructor de la clase ... * * @param frame * @param WindowNo * @param AD_Attachment_ID * @param AD_Table_ID * @param Record_ID * @param trxName */ public Attachment( Frame frame, int WindowNo, int AD_Attachment_ID, int AD_Table_ID, int Record_ID, String trxName) { super(frame, Msg.getMsg(Env.getCtx(), "Attachment"), true); // needs to be modal otherwise APanel does not recongize change. log.config( "Attachment - ID=" + AD_Attachment_ID + ", Table=" + AD_Table_ID + ", Record=" + Record_ID); // m_WindowNo = WindowNo; // try { jbInit(); } catch (Exception ex) { log.log(Level.SEVERE, "Attachment", ex); } // Create Model if (AD_Attachment_ID == 0) { m_attachment = new MAttachment(Env.getCtx(), AD_Table_ID, Record_ID, trxName); } else { m_attachment = new MAttachment(Env.getCtx(), AD_Attachment_ID, trxName); } loadAttachments(); // try { AEnv.showCenterWindow(frame, this); } catch (Exception e) { } text.requestFocus(); } // Attachment
/** * Constructor de la clase ... * * @param frame * @param WindowNo * @param AD_Attachment_ID * @param AD_Table_ID * @param Record_ID * @param trxName */ public BinaryAttachment( Frame frame, int WindowNo, int D_File_Archive_ID, int D_File_ID, String trxName, MTab mTab) { super(frame, "BinaryAttachment", true); // needs to be modal otherwise APanel does not recongize change. d_file_archive_id = D_File_Archive_ID; d_file_id = D_File_ID; // m_WindowNo = WindowNo; // try { jbInit(); } catch (Exception ex) { log.log(Level.SEVERE, "BinaryAttachment", ex); } // Create Model log.fine("En el constructor de BinaryAttachment,d_file_archive_id=" + mTab.getRecord_ID()); // if( AD_Attachment_ID == 0 ) { // m_attachment = new M_D_File_Archive( Env.getCtx(),AD_Table_ID,Record_ID,trxName ); // } else { m_attachment = new M_D_File_Archive(Env.getCtx(), mTab.getRecord_ID(), trxName); // } loadAttachments(); // try { AEnv.showCenterWindow(frame, this); } catch (Exception e) { } text.requestFocus(); } // Attachment
/** * Dialog Windows * * @author Jorg Janke * @version $Id: ADialogDialog.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ */ public final class ADialogDialog extends CDialog implements ActionListener { /** */ private static final long serialVersionUID = 5670261006862936363L; // Services private final IMsgBL msgBL = Services.get(IMsgBL.class); /** * Create Dialog Window for Frame and show it. * * @param frame * @param title * @param message * @param messageType */ public ADialogDialog( final Frame frame, final String title, final String message, final int messageType) { this(frame, title); setMessage(message, messageType); showCenterScreen(); } // ADialogDialog public ADialogDialog(final Frame frame, final String title) { super( frame, title, frame != null // modal ); init(); } /** * Create Dialog Window for Dialog and show it. * * @param dialog * @param title * @param message * @param messageType */ public ADialogDialog(Dialog dialog, String title, String message, int messageType) { this(dialog, title); setMessage(message, messageType); showCenterScreen(); } // ADialogDialog public ADialogDialog(Dialog dialog, String title) { super( dialog, title, dialog != null // modal ); init(); } public void showCenterScreen() { AEnv.showCenterWindow(getOwner(), this); } /** Common Init */ private void init() { assertUIOutOfTransaction(); try { jbInit(); setInitialAnswer(A_OK); // backward compatibility: OK is the default } catch (Exception ex) { log.log(Level.SEVERE, "Dialog init failed: " + ex.getMessage(), ex); } } // common /** Asserts dialog is opened out of transaction. */ public static final void assertUIOutOfTransaction() { final ITrxManager trxManager = Services.get(ITrxManager.class); final String trxName = trxManager.getThreadInheritedTrxName(OnTrxMissingPolicy.ReturnTrxNone); if (!trxManager.isNull(trxName)) { final AdempiereException ex = new AdempiereException( "Opening a dialog while running in a trasaction it's always a bad idea" + " because the database will be kept locked until the user will answer."); // NOTE: this issue is so critical that it's better to throw exception instead to just advice if (Services.get(IDeveloperModeBL.class).isEnabled()) { throw ex; } else { // In case we run in production, we won't fail because that would be a show stopper, but we // will log the exception. log.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } } /** * Sets message and messageType to be displayed. * * @param message * @param messageType */ public void setMessage(final String message, final int messageType) { try { setInfoMessage(message); setInfoIcon(messageType); } catch (Exception ex) { log.log( Level.SEVERE, "Error while setting the message=" + message + ", messageType=" + messageType, ex); } } /** * Window Events - requestFocus * * @param e */ @Override protected void processWindowEvent(final WindowEvent e) { super.processWindowEvent(e); // // When window is opened, focus on initial answer button if (e.getID() == WindowEvent.WINDOW_OPENED) { focusInitialAnswerButton(); } } // processWindowEvent /** Answer OK (0) */ public static int A_OK = 0; /** Answer Cancel (1) */ public static int A_CANCEL = 1; /** Answer Close (-1) - Default */ public static int A_CLOSE = -1; /** Answer */ private int m_returnCode = A_CLOSE; /** Logger */ private static final CLogger log = CLogger.getCLogger(ADialogDialog.class); private int _initialAnswer = -100; // will be initialized on construction time static Icon i_inform = Images.getImageIcon2("Inform32"); static Icon i_warn = Images.getImageIcon2("Warn32"); static Icon i_question = Images.getImageIcon2("Question32"); static Icon i_error = Images.getImageIcon2("Error32"); private JMenuBar menuBar = new JMenuBar(); private JMenu mFile = AEnv.getMenu("File"); private CMenuItem mEMail = new CMenuItem(); private CMenuItem mEnd = new CMenuItem(); private CMenuItem mPreference = new CMenuItem(); private ConfirmPanel confirmPanel = ConfirmPanel.builder().withCancelButton(true).build(); private CPanel westPanel = new CPanel(); private CLabel iconLabel = new CLabel(); private GridBagLayout westLayout = new GridBagLayout(); private CTextPane info = new CTextPane(); private GridBagLayout infoLayout = new GridBagLayout(); private CPanel infoPanel = new CPanel(); /** * Static Constructor * * @throws Exception */ private void jbInit() throws Exception { this.setJMenuBar(menuBar); confirmPanel.setActionListener( this); // set it first just to know buttons are working in case something failed // mEMail.setIcon(Images.getImageIcon2("EMailSupport16")); mEMail.setText(msgBL.getMsg(Env.getCtx(), "EMailSupport")); mEMail.addActionListener(this); mPreference.setIcon(Images.getImageIcon2("Preference16")); mPreference.setText(msgBL.getMsg(Env.getCtx(), "Preference")); mPreference.addActionListener(this); mEnd.setIcon(Images.getImageIcon2("End16")); mEnd.setText(msgBL.getMsg(Env.getCtx(), "End")); mEnd.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.ALT_MASK)); mEnd.addActionListener(this); // westPanel.setLayout(westLayout); westPanel.setName("westPanel"); westPanel.setRequestFocusEnabled(false); infoPanel.setLayout(infoLayout); infoPanel.setName("infoPanel"); infoPanel.setRequestFocusEnabled(false); this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); this.getContentPane().add(westPanel, BorderLayout.WEST); westPanel.add( iconLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); this.getContentPane().add(infoPanel, BorderLayout.CENTER); infoPanel.add( info, new GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); // menuBar.add(mFile); mFile.add(mEMail); if (Env.getUserRolePermissions().isShowPreference()) mFile.add(mPreference); mFile.addSeparator(); mFile.add(mEnd); } // jbinit /** * Convert to HTML and Calculate Size * * @param message message */ private void setInfoMessage(final String message) { final StringBuilder sb = new StringBuilder(message.length() + 20); sb.append("<b>"); String html = Util.maskHTML(message); char[] chars = html.toCharArray(); boolean first = true; int paras = 0; for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (c == '\n') { if (first) { sb.append("</b>"); first = false; } if (paras > 1) sb.append("<br>"); else sb.append("<p>"); paras++; } else sb.append(c); } info.setText(sb.toString()); Dimension size = info.getPreferredSize(); size.width = 450; size.height = (Math.max(paras, message.length() / 60) + 1) * 30; size.height = Math.min(size.height, 600); info.setPreferredSize(size); info.setRequestFocusEnabled(false); info.setReadWrite(false); info.setOpaque(false); info.setBorder(null); // info.setCaretPosition(0); } // calculateSize /** * ************************************************************************ Set Info * * @param messageType */ private void setInfoIcon(int messageType) { final CButton cancelButton = confirmPanel.getCancelButton(); cancelButton.setVisible(false); cancelButton.setEnabled(false); // switch (messageType) { case JOptionPane.ERROR_MESSAGE: iconLabel.setIcon(i_error); break; case JOptionPane.INFORMATION_MESSAGE: iconLabel.setIcon(i_inform); break; case JOptionPane.QUESTION_MESSAGE: cancelButton.setVisible(true); cancelButton.setEnabled(true); iconLabel.setIcon(i_question); break; case JOptionPane.WARNING_MESSAGE: iconLabel.setIcon(i_warn); break; case JOptionPane.PLAIN_MESSAGE: default: break; } // switch } // setInfo /** * ************************************************************************ ActionListener * * @param e */ @Override public void actionPerformed(ActionEvent e) { // log.finest( "ADialogDialog.actionPerformed - " + e); if (e.getActionCommand().equals(ConfirmPanel.A_OK)) { m_returnCode = A_OK; dispose(); } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL) || e.getSource() == mEnd) { m_returnCode = A_CANCEL; dispose(); } else if (e.getSource() == mEMail) { String title = getTitle(); String text = info.getText(); dispose(); // otherwise locking ADialog.createSupportEMail(this, title, text); } else if (e.getSource() == mPreference) { if (Env.getUserRolePermissions().isShowPreference()) { final Preference p = new Preference(null, 0); p.setVisible(true); } } } /** * Get Return Code * * @return return code ({@link #A_OK}, {@link #A_CANCEL}, {@link #A_CLOSE}) */ public int getReturnCode() { return m_returnCode; } // getReturnCode /** * Sets initial answer (i.e. button that will be preselected by default). * * <p>Please note that this is not the default answer that will be returned by {@link * #getReturnCode()} if user does nothing (i.e. closes the window). It is just the preselectated * button. * * @param initialAnswer {@link #A_OK}, {@link #A_CANCEL}. */ public void setInitialAnswer(final int initialAnswer) { // If the inial answer did not actual changed, do nothing if (this._initialAnswer == initialAnswer) { return; } // // Configure buttons accelerator (KeyStroke) and RootPane's default button final JRootPane rootPane = getRootPane(); final CButton okButton = confirmPanel.getOKButton(); final AppsAction okAction = (AppsAction) okButton.getAction(); final CButton cancelButton = confirmPanel.getCancelButton(); final AppsAction cancelAction = (AppsAction) cancelButton.getAction(); if (initialAnswer == A_OK) { okAction.setDefaultAccelerator(); cancelAction.setDefaultAccelerator(); rootPane.setDefaultButton(okButton); } else if (initialAnswer == A_CANCEL) { // NOTE: we need to set the OK's Accelerator keystroke to null because in most of the cases it // is "Enter" // and we want to prevent user for hiting ENTER by mistake okAction.setAccelerator(null); cancelAction.setDefaultAccelerator(); rootPane.setDefaultButton(cancelButton); } else { throw new IllegalArgumentException("Unknown inital answer: " + initialAnswer); } // // Finally, set the new inial answer this._initialAnswer = initialAnswer; } public int getInitialAnswer() { return this._initialAnswer; } /** Request focus on inital answer (see {@link #getInialAnswer()}) button. */ private void focusInitialAnswerButton() { final CButton defaultButton; if (_initialAnswer == A_OK) { defaultButton = confirmPanel.getOKButton(); } else if (_initialAnswer == A_CANCEL) { defaultButton = confirmPanel.getCancelButton(); } else { return; } defaultButton.requestFocusInWindow(); } } // ADialogDialog
public void showCenterScreen() { AEnv.showCenterWindow(getOwner(), this); }
/** Process Button Pressed - Process Matching */ private void cmd_newProduct() { // Selecciono el departamento int depart = 0; String SQL = "Select XX_VMR_DEPARTMENT_ID " + "from XX_VMR_VENDORPRODREF " + "where XX_VMR_VENDORPRODREF_ID=" + LineRefProv.getXX_VMR_VendorProdRef_ID(); try { PreparedStatement pstmt = DB.prepareStatement(SQL, null); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { depart = rs.getInt("XX_VMR_DEPARTMENT_ID"); } rs.close(); pstmt.close(); } catch (Exception a) { log.log(Level.SEVERE, SQL, a); } MVMRVendorProdRef vendorProdRef = new MVMRVendorProdRef(Env.getCtx(), LineRefProv.getXX_VMR_VendorProdRef_ID(), null); if (vendorProdRef.getXX_VMR_ProductClass_ID() > 0 && vendorProdRef.getXX_VMR_TypeLabel_ID() > 0) { MOrder order = new MOrder(Env.getCtx(), LineRefProv.getC_Order_ID(), null); // Selecciono el departamento X_XX_VMR_Department dept = new X_XX_VMR_Department(Env.getCtx(), vendorProdRef.getXX_VMR_Department_ID(), null); int category = dept.getXX_VMR_Category_ID(); // Selecciono la línea X_XX_VMR_Line line = new X_XX_VMR_Line(Env.getCtx(), vendorProdRef.getXX_VMR_Line_ID(), null); int typeInventory = line.getXX_VMR_TypeInventory_ID(); MProduct newProduct = new MProduct( Env.getCtx(), vendorProdRef.getXX_VMR_Department_ID(), vendorProdRef.getXX_VMR_Line_ID(), vendorProdRef.getXX_VMR_Section_ID(), vendorProdRef.get_ID(), vendorProdRef.getC_TaxCategory_ID(), vendorProdRef.getXX_VME_ConceptValue_ID(), typeInventory, null); // Se buscará si por la referencia para producto ya existe para asignarle el Tipo de // Exhibición String sql = "select * from M_Product where XX_VMR_DEPARTMENT_ID = " + vendorProdRef.getXX_VMR_Department_ID() + " and " + "XX_VMR_LINE_ID = " + vendorProdRef.getXX_VMR_Line_ID() + " and XX_VMR_SECTION_ID = " + vendorProdRef.getXX_VMR_Section_ID() + " and " + "XX_VMR_VendorProdRef_id = " + vendorProdRef.getXX_VMR_VendorProdRef_ID() + " order by M_Product_ID desc"; PreparedStatement pstmt = DB.prepareStatement(sql, null); ResultSet rs = null; try { rs = pstmt.executeQuery(); if (rs.next()) newProduct.setXX_VMR_TypeExhibition_ID(rs.getInt("XX_VMR_TypeExhibition_ID")); } catch (SQLException e) { e.printStackTrace(); } finally { DB.closeResultSet(rs); DB.closeStatement(pstmt); } if (vendorProdRef.getXX_VMR_Section_ID() > 0) { X_XX_VMR_Section section = new X_XX_VMR_Section(Env.getCtx(), vendorProdRef.getXX_VMR_Section_ID(), null); newProduct.setName(section.getName()); } else { newProduct.setName(vendorProdRef.getName()); } newProduct.setXX_VMR_Category_ID(category); newProduct.setXX_VMR_LongCharacteristic_ID(vendorProdRef.getXX_VMR_LongCharacteristic_ID()); newProduct.setXX_VMR_Brand_ID(vendorProdRef.getXX_VMR_Brand_ID()); newProduct.setXX_VMR_UnitConversion_ID(vendorProdRef.getXX_VMR_UnitConversion_ID()); newProduct.setXX_PiecesBySale_ID(vendorProdRef.getXX_PiecesBySale_ID()); newProduct.setXX_VMR_UnitPurchase_ID(vendorProdRef.getXX_VMR_UnitPurchase_ID()); newProduct.setXX_SaleUnit_ID(vendorProdRef.getXX_SaleUnit_ID()); newProduct.setC_Country_ID(order.getC_Country_ID()); newProduct.setIsActive(true); newProduct.setC_BPartner_ID(vendorProdRef.getC_BPartner_ID()); newProduct.setXX_VMR_TypeLabel_ID(vendorProdRef.getXX_VMR_TypeLabel_ID()); newProduct.setXX_VMR_ProductClass_ID(vendorProdRef.getXX_VMR_ProductClass_ID()); newProduct.setM_AttributeSet_ID(Env.getCtx().getContextAsInt("#XX_L_P_ATTRIBUTESETST_ID")); newProduct.setProductType(X_Ref_M_Product_ProductType.ITEM.getValue()); newProduct.save(); } else { // Creo variables de sesion para atraparlas en la ventana producto Env.getCtx().setContext("#Depart_Aux", depart); Env.getCtx().setContext("#Section_Aux", LineRefProv.getXX_VMR_Section_ID()); Env.getCtx().setContext("#Line_Aux", LineRefProv.getXX_VMR_Line_ID()); Env.getCtx().setContext("#VendorRef_Aux", LineRefProv.getXX_VMR_VendorProdRef_ID()); Env.getCtx().setContext("#FromProcess_Aux", "Y"); AWindow window_product = new AWindow(); Query query = Query.getNoRecordQuery("M_Product", true); window_product.initWindow(140, query); AEnv.showCenterScreen(window_product); // Obtenemos el GridController para setear la variable m_changed=true JRootPane jRootPane = ((JRootPane) window_product.getComponent(0)); JLayeredPane jLayeredPane = (JLayeredPane) jRootPane.getComponent(1); JPanel jPanel = (JPanel) jLayeredPane.getComponent(0); APanel aPanel = (APanel) jPanel.getComponent(0); VTabbedPane vTabbedPane = (VTabbedPane) aPanel.getComponent(0); GridController gridController = (GridController) vTabbedPane.getComponent(0); GridTable mTable = gridController.getMTab().getTableModel(); mTable.setChanged(true); MProduct.loadLineRefProv(LineRefProv, Env.getCtx()); // Borro las variables de sesion creadas Env.getCtx().remove("#Depart_Aux"); Env.getCtx().remove("#FromProcess_Aux"); Env.getCtx().remove("#Line_Aux"); Env.getCtx().remove("#Section_Aux"); Env.getCtx().remove("#VendorRef_Aux"); } } // cmd_newProduct