⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apanel.java

📁 Java写的ERP系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
				query.addRestriction(link, MQuery.EQUAL,
					Env.getContext(m_ctx, m_curWindowNo, link),
					infoName, infoDisplay);
		}

//		try
		{
			new AReport (m_curTab.getAD_Table_ID(), (JComponent)source, query);
		}
//		catch (Exception e)
		{
//			ADialog.error(m_curWindowNo, this, e.getMessage());
		}
	}	//	cmd_report

	/**
	 *	Print specific Report - or start default Report
	 *  @param source event source
	 */
	private void cmd_print(Object source)
	{
		//	Get process defined for this tab
		int AD_Process_ID = m_curTab.getAD_Process_ID();
		Log.trace(Log.l1_User, "APanel.cmd_print - " + AD_Process_ID);

		//	No report defined
		if (AD_Process_ID == 0)
		{
			cmd_report(source);
			return;
		}

		cmd_save(false);
		//
		int recordID = m_curTab.getCurrentKeyID();
		ProcessInfo pi = new ProcessInfo (getTitle(), AD_Process_ID, recordID);

		ProcessCtl.process(this, m_curWindowNo, pi); //  calls lockUI, unlockUI
	}   //  cmd_print

	/**
	 *	Find - Set Query
	 */
	private void cmd_find()
	{
		if (m_curTab == null)
			return;
		cmd_save(false);
		//
		Find find = new Find(Env.getFrame(this), m_curWindowNo, m_curTab);
		MQuery query = find.getQuery();
		find = null;
		//	Confirmed query
		if (query != null)
		{
			m_onlyCurrentRows = false;      	//  search history too
			m_curTab.setQuery(query);
			m_curGC.query(m_onlyCurrentRows, m_onlyCurrentDays);   //  autoSize
		}
		aFind.setPressed(m_curTab.isQueryActive());
	}	//	cmd_find

	/**
	 *	Attachment
	 */
	private void cmd_attachment()
	{
		Log.trace(Log.l1_User, "APanel.cmd_attachment");
		int record_ID = m_curTab.getCurrentKeyID();
		if (record_ID == -1)	//	No Key
		{
			aAttachment.setEnabled(false);
			return;
		}

		Attachment va = new Attachment (Env.getFrame(this), m_curWindowNo,
			m_curTab.getAD_AttachmentID(), m_curTab.getAD_Table_ID(), record_ID);
		va.setVisible(true);
		//
		m_curTab.loadAttachments();						//	reload
		aAttachment.setPressed(m_curTab.hasAttachment());
	}	//	attachment

	/**
	 *	Toggle History
	 */
	private void cmd_history()
	{
		Log.trace(Log.l1_User, "APanel.cmd_history");
		if (m_mWorkbench.getMWindow(getWindowIndex()).isTransaction())
		{
			if (m_curTab.needSave(true, true) && !cmd_save(false))
				return;

			Point pt = new Point (0, aHistory.getButton().getBounds().height);
			SwingUtilities.convertPointToScreen(pt, aHistory.getButton());
			VOnlyCurrentDays ocd = new VOnlyCurrentDays(Env.getFrame(this), pt);
			m_onlyCurrentDays = ocd.getCurrentDays();
			if (m_onlyCurrentDays == -1)	//	all
			{
				m_onlyCurrentRows = false;
				m_onlyCurrentDays = 1;
			}
			else
				m_onlyCurrentRows = true;
			Log.trace(Log.l4_Data, "APanel.cmd_history OnlyCurrent=" + m_onlyCurrentRows + ", Days=" + m_onlyCurrentDays);
			m_curGC.query(m_onlyCurrentRows, m_onlyCurrentDays);   //  autoSize
		}
	}	//	cmd_history

	/**
	 *	Help
	 */
	private void cmd_help()
	{
		Log.trace(Log.l1_User, "CWindow.cmd_help");
		Help hlp = new Help (Env.getFrame(this), this.getTitle(), m_mWorkbench.getMWindow(getWindowIndex()));
		hlp.show();
	}	//	cmd_help

	/**
	 *  Close this screen - after save
	 *  @param exit ask if user wants to exit application
	 */
	private void cmd_end (boolean exit)
	{
		boolean exitSystem = false;
		cmd_save(false);
		if (m_curAPanelTab != null)
		{
			m_curAPanelTab.unregisterPanel();
			m_curAPanelTab = null;
		}

		if (exit && ADialog.ask(m_curWindowNo, this, "ExitApplication?"))
			exitSystem = true;

		Env.getFrame(this).dispose();		//	calls this dispose

		if (exitSystem)
			AEnv.exit(0);
	}   //  cmd_end

	/*************************************************************************/

	/**
	 *	Start Button Process
	 *  @param vButton button
	 */
	private void actionButton (VButton vButton)
	{
		Log.trace(Log.l1_User, "APanel.actionButton", vButton.toString());

		boolean startWOasking = false;
		String col = vButton.getColumnName();

		//  Zoom
		if (col.equals("Record_ID"))
		{
			int AD_Table_ID = Env.getContextAsInt (m_ctx, m_curWindowNo, "AD_Table_ID");
			int Record_ID = Env.getContextAsInt (m_ctx, m_curWindowNo, "Record_ID");
			String IsSOTrx = Env.getContext(m_ctx, m_curWindowNo, "IsSOTrx");
			//
			String TableName = null;
			int AD_Window_ID = 0;
			String sql = "SELECT TableName, AD_Window_ID FROM AD_Table WHERE AD_Table_ID=?";
			try
			{
				PreparedStatement pstmt = DB.prepareStatement(sql);
				pstmt.setInt(1, AD_Table_ID);
				ResultSet rs = pstmt.executeQuery();
				if (rs.next())
				{
					TableName = rs.getString(1);
					AD_Window_ID = rs.getInt(2);
				}
				rs.close();
				pstmt.close();
			}
			catch (SQLException e)
			{
				Log.error ("GridController.startProcess-Zoom", e);
			}
			//  Nothing to Zoom to
			if (TableName == null || AD_Window_ID == 0)
				return;

			AWindow frame = new AWindow();
			if (!frame.initWindow(AD_Window_ID, MQuery.getEqualQuery(TableName + "_ID", Record_ID), IsSOTrx.equals("Y")))
				return;
			AEnv.showCenterScreen(frame);
			frame = null;
			return;
		}   //  Zoom

		//  save first	---------------
		if (m_curTab.needSave(true, false))
			if (!cmd_save(true))
				return;
		//
		int record_ID = m_curTab.getCurrentKeyID();
		if (record_ID == -1 && m_curTab.getKeyColumnName().endsWith("_ID"))
		{
			ADialog.error(m_curWindowNo, this, "SaveErrorRowNotFound");
			return;
		}

		//	Pop up Payment Rules
		if (col.equals("PaymentRule"))
		{
			VPayment vp = new VPayment(m_curWindowNo, m_curTab, vButton);
			if (vp.isInitOK())		//	may not be allowed
				vp.show();
			vp.dispose();
		}	//	PaymentRule

		//	Pop up Document Action
		else if (col.equals("DocAction"))
		{
			VDocAction vda = new VDocAction(m_curWindowNo, m_curTab, vButton);
			//	Something to select from?
			if (vda.getNumberOfOptions() == 0)
			{
				vda.dispose ();
				return;
			}
			else
			{
				vda.show();
				if (!vda.getStartProcess())
					return;
				startWOasking = true;
				vda.dispose();
			}
		}	//	DocAction

		//  Pop up Create From
		else if (col.equals("CreateFrom"))
		{
			//  m_curWindowNo
			VCreateFrom vcf = VCreateFrom.create (m_curTab);
			if (vcf != null)
			{
				if (vcf.isInitOK())
				{
					vcf.show();
					vcf.dispose();
					m_curTab.dataRefresh();
				}
				else
					vcf.dispose();
				return;
			}
			//	else may start process
		}	//	CreateFrom

		//  Posting -----
		else if (col.equals("Posted"))
		{
			//  Check Doc Status
			String processed = Env.getContext(m_ctx, m_curWindowNo, "Processed");
			if (!processed.equals("Y"))
			{
				ADialog.error(m_curWindowNo, this, "PostDocNotComplete");
				return;
			}

			//  Check Post Status
			Object ps = m_curTab.getValue("Posted");
			if (ps != null && ps.equals("Y"))
			{
				new org.compiere.acct.AcctViewer (Env.getContextAsInt (m_ctx, m_curWindowNo, "AD_Client_ID"),
					m_curTab.getAD_Table_ID(), m_curTab.getCurrentKeyID());
			}
			else
			{
				if (ADialog.ask(m_curWindowNo, this, "PostImmediate?"))
				{
					AEnv.postImmediate (m_curWindowNo, Env.getContextAsInt (m_ctx, m_curWindowNo, "AD_Client_ID"),
						m_curTab.getAD_Table_ID(), m_curTab.getCurrentKeyID(), true);
					m_curTab.dataRefresh();
				}
			}
			return;
		}   //  Posted

		/**
		 *  Start Process ----
		 */

		Log.trace(Log.l3_Util, "APanel.actionButton", "Process_ID=" + vButton.getProcess_ID());
		if (vButton.getProcess_ID() == 0)
			return;
		//	Save item changed
		if (m_curTab.needSave(true, false))
			if (!cmd_save(true))
				return;

		//	Ask user to start process, if Description and Help is not empty
		if (!startWOasking && !(vButton.getDescription().equals("") && vButton.getHelp().equals("")))
			if (!ADialog.ask(m_curWindowNo, this, "StartProcess?", vButton.getDescription()
				+ "\n" + vButton.getHelp()))
				return;
		//
		String title = vButton.getDescription();
		if (title == null || title.length() == 0)
			title = vButton.getName();
		ProcessInfo pi = new ProcessInfo (title, vButton.getProcess_ID(), record_ID);

		ProcessCtl.process(this, m_curWindowNo, pi); //  calls lockUI, unlockUI
	}	//	actionButton

	/*************************************************************************/

	/**
	 *  Lock User Interface.
	 *  Called from the Worker before processing
	 *  @param pi process info
	 */
	public void lockUI (ProcessInfo pi)
	{
	//	Log.trace(Log.l5_DData, "APanel.lockUI");
		setBusy(true);
	}   //  lockUI

	/**
	 *  Unlock User Interface.
	 *  Called from the Worker when processing is done
	 *  @param pi of execute ASync call
	 */
	public void unlockUI (ProcessInfo pi)
	{
	//	Log.trace(Log.l5_DData, "APanel.unlockUI");
		setBusy(false);
		//  Process Result
		if (pi != null)
		{
			//	Refresh data
			m_curTab.dataRefresh();
			m_curGC.dynamicDisplay(0);
			//	Update Status Line
			setStatusLine(pi.Summary, pi.Error);
			//	Get Log Info
			pi.setProcessLog ();
			if (pi.LogInfo.length() > 0)
				ADialog.info(m_curWindowNo, this, Env.getHeader(m_ctx, m_curWindowNo),
					pi.Title, pi.LogInfo);	//	 clear text
		}
	}   //  unlockUI

	/**
	 *  Is the UI locked (Internal method)
	 *  @return true, if UI is locked
	 */
	public boolean isUILocked()
	{
		return m_isLocked;
	}   //  isLoacked

	/**
	 *  Method to be executed async.
	 *  Called from the ASyncProcess worker
	 *  @param pi process info
	 */
	public void executeASync (ProcessInfo pi)
	{
		Log.trace(Log.l3_Util, "APanel.executeASync");
	}   //  executeASync

	/**
	 *  String representation
	 *  @return String representation
	 */
	public String toString()
	{
		String s = "APanel[curWindowNo=" + m_curWindowNo;
		if (m_mWorkbench != null)
			s += ",WB=" + m_mWorkbench.toString();
		s += "]";
		return s;
	}   //  toString



}	//	APanel

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -