Adempiere 3.1.2
This commit is contained in:
parent
ee46d9e792
commit
8a0bf1e3c7
|
@ -171,7 +171,6 @@ public class AArchive implements ActionListener
|
|||
else // all Reports
|
||||
av.query(true, m_AD_Table_ID, 0);
|
||||
//
|
||||
AEnv.addToWindowManager(ff);
|
||||
ff.pack();
|
||||
AEnv.showCenterScreen(ff);
|
||||
ff = null;
|
||||
|
|
|
@ -257,8 +257,7 @@ public final class AEnv
|
|||
if (iconName == null)
|
||||
iconName = actionName;
|
||||
String text = Msg.getMsg(Env.getCtx(), actionName);
|
||||
ImageIcon icon = Env.getImageIcon2(iconName + "16");
|
||||
CMenuItem mi = new CMenuItem(text, icon);
|
||||
CMenuItem mi = new CMenuItem(text, Env.getImageIcon(iconName + "16.gif"));
|
||||
mi.setActionCommand(actionName);
|
||||
if (ks != null)
|
||||
mi.setAccelerator(ks);
|
||||
|
@ -298,11 +297,6 @@ public final class AEnv
|
|||
if (ADialog.ask(WindowNo, c, "ExitApplication?"))
|
||||
Env.exitEnv(0);
|
||||
}
|
||||
else if (actionCommand.equals("Logout"))
|
||||
{
|
||||
AMenu aMenu = (AMenu)Env.getWindow(WindowNo);
|
||||
aMenu.logout();
|
||||
}
|
||||
|
||||
// View Menu ------------------------
|
||||
else if (actionCommand.equals("InfoProduct"))
|
||||
|
@ -379,9 +373,8 @@ public final class AEnv
|
|||
}
|
||||
else if (actionCommand.equals("Preference"))
|
||||
{
|
||||
if (role.isShowPreference()) {
|
||||
if (role.isShowPreference())
|
||||
AEnv.showCenterScreen(new Preference (Env.getFrame(c), WindowNo));
|
||||
}
|
||||
}
|
||||
|
||||
// Help Menu ------------------------
|
||||
|
@ -485,7 +478,6 @@ public final class AEnv
|
|||
AWindow frame = new AWindow();
|
||||
if (!frame.initWindow(AD_Window_ID, MQuery.getEqualQuery(TableName + "_ID", Record_ID)))
|
||||
return;
|
||||
addToWindowManager(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
frame = null;
|
||||
} // zoom
|
||||
|
@ -536,23 +528,11 @@ public final class AEnv
|
|||
AWindow frame = new AWindow();
|
||||
if (!frame.initWindow(AD_Window_ID, query))
|
||||
return;
|
||||
addToWindowManager(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
frame = null;
|
||||
} // zoom
|
||||
|
||||
/**
|
||||
* Track open frame in window manager
|
||||
* @param frame
|
||||
*/
|
||||
public static void addToWindowManager(CFrame frame)
|
||||
{
|
||||
JFrame top = Env.getWindow(0);
|
||||
if (top instanceof AMenu)
|
||||
{
|
||||
((AMenu)top).getWindowManager().add(frame);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit System
|
||||
* @param status System exit status (usually 0 for no error)
|
||||
|
@ -572,26 +552,6 @@ public final class AEnv
|
|||
Env.exitEnv(status);
|
||||
} // exit
|
||||
|
||||
public static void logout()
|
||||
{
|
||||
if (s_server != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
s_server.remove();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
Env.logout();
|
||||
|
||||
Splash.getSplash().setVisible(true);
|
||||
|
||||
//reload
|
||||
new AMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Workflow Process view enabled.
|
||||
* @return true if enabled
|
||||
|
@ -648,14 +608,7 @@ public final class AEnv
|
|||
AWindow frame = new AWindow();
|
||||
if (!frame.initWindow(s_workflow_Window_ID, query))
|
||||
return;
|
||||
addToWindowManager(frame);
|
||||
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) ) {
|
||||
frame.pack();
|
||||
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
frame.setVisible(true);
|
||||
frame.toFront();
|
||||
} else
|
||||
AEnv.showCenterScreen(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
frame = null;
|
||||
} // startWorkflowProcess
|
||||
|
||||
|
@ -908,33 +861,5 @@ public final class AEnv
|
|||
}
|
||||
}
|
||||
} // cacheReset
|
||||
|
||||
/**
|
||||
* Update all windows after look and feel changes.
|
||||
* @since 2006-11-27
|
||||
*/
|
||||
public static void updateUI()
|
||||
{
|
||||
Set<Window> updated = Env.updateUI();
|
||||
JFrame top = Env.getWindow(0);
|
||||
if (top instanceof AMenu)
|
||||
{
|
||||
CFrame[] frames = ((AMenu)top).getWindowManager().getWindows();
|
||||
for (CFrame f : frames)
|
||||
{
|
||||
if (updated.contains(f)) continue;
|
||||
SwingUtilities.updateComponentTreeUI(f);
|
||||
f.validate();
|
||||
RepaintManager mgr = RepaintManager.currentManager(f);
|
||||
Component childs[] = f.getComponents();
|
||||
for (Component c : childs) {
|
||||
if (c instanceof JComponent)
|
||||
mgr.markCompletelyDirty((JComponent)c);
|
||||
}
|
||||
f.repaint();
|
||||
updated.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // AEnv
|
||||
} // AEnv
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -3,16 +3,16 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
|
@ -20,325 +20,287 @@ import java.awt.Frame;
|
|||
import java.awt.event.*;
|
||||
import java.sql.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
import org.compiere.apps.form.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Start Menu Item & UpdateProgress Bar
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: AMenuStartItem.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class AMenuStartItem extends Thread implements ActionListener
|
||||
{
|
||||
/**
|
||||
* Start Menu Item
|
||||
*
|
||||
* @param ID ID
|
||||
* @param isMenu false if Workflow
|
||||
* @param name Name
|
||||
* @param menu Menu
|
||||
*/
|
||||
public AMenuStartItem (int ID, boolean isMenu, String name, AMenu menu)
|
||||
{
|
||||
m_ID = ID;
|
||||
m_isMenu = isMenu;
|
||||
m_name = name;
|
||||
m_menu = menu;
|
||||
if (menu != null)
|
||||
m_increment = (menu.progressBar.getMaximum()-menu.progressBar.getMinimum()) / 5;
|
||||
} // UpdateProgress
|
||||
|
||||
/** The ID */
|
||||
private int m_ID = 0;
|
||||
private boolean m_isMenu = false;
|
||||
private String m_name;
|
||||
private AMenu m_menu;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(AMenuStartItem.class);
|
||||
|
||||
// Reset Progress Bar
|
||||
private Runnable m_resetPB = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
m_value = 0;
|
||||
if (m_menu != null)
|
||||
m_menu.progressBar.setValue(0);
|
||||
}
|
||||
};
|
||||
// Progress Bar tick
|
||||
private Runnable m_tickPB = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (m_menu == null)
|
||||
return;
|
||||
// 100/5 => 20 ticks - every .5 sec => 10 seconds loadtime
|
||||
final int tick = 5;
|
||||
if (m_menu.progressBar.getValue() < (m_menu.progressBar.getMaximum() - tick))
|
||||
m_menu.progressBar.setValue(m_menu.progressBar.getValue() + tick);
|
||||
}
|
||||
};
|
||||
// Progress Bar max state
|
||||
private Runnable m_updatePB = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (m_menu == null)
|
||||
return;
|
||||
m_value += m_increment;
|
||||
if (m_menu.progressBar.getValue() > m_value) // max value
|
||||
m_menu.progressBar.setValue(m_value);
|
||||
}
|
||||
};
|
||||
private int m_value = 0;
|
||||
private int m_increment = 20;
|
||||
private javax.swing.Timer m_timer = new javax.swing.Timer(500, this); // every 1/2 second
|
||||
|
||||
|
||||
/**
|
||||
* Start Menu Item
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
if (m_menu != null)
|
||||
m_menu.setBusy (true);
|
||||
SwingUtilities.invokeLater(m_resetPB);
|
||||
m_timer.start();
|
||||
SwingUtilities.invokeLater(m_updatePB);
|
||||
try
|
||||
{
|
||||
String sql = "SELECT * FROM AD_Menu WHERE AD_Menu_ID=?";
|
||||
if (!m_isMenu)
|
||||
sql = "SELECT * FROM AD_WF_Node WHERE AD_WF_Node_ID=?";
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
|
||||
SwingUtilities.invokeLater(m_updatePB);
|
||||
if (rs.next()) // should only be one
|
||||
{
|
||||
String Action = rs.getString("Action");
|
||||
String IsSOTrx = "Y";
|
||||
if (m_isMenu)
|
||||
IsSOTrx = rs.getString("IsSOTrx");
|
||||
int cmd;
|
||||
if (Action.equals("W")) // Window
|
||||
{
|
||||
cmd = rs.getInt("AD_Window_ID");
|
||||
startWindow(0, cmd);
|
||||
}
|
||||
else if (Action.equals("P") || Action.equals("R")) // Process & Report
|
||||
{
|
||||
cmd = rs.getInt("AD_Process_ID");
|
||||
startProcess(cmd, IsSOTrx);
|
||||
}
|
||||
else if (Action.equals("B")) // Workbench
|
||||
{
|
||||
cmd = rs.getInt("AD_Workbench_ID");
|
||||
startWindow (cmd, 0);
|
||||
}
|
||||
else if (Action.equals("F")) // WorkFlow
|
||||
{
|
||||
if (m_isMenu)
|
||||
cmd = rs.getInt("AD_Workflow_ID");
|
||||
else
|
||||
cmd = rs.getInt("Workflow_ID");
|
||||
if (m_menu != null)
|
||||
m_menu.startWorkFlow(cmd);
|
||||
}
|
||||
else if (Action.equals("T")) // Task
|
||||
{
|
||||
cmd = rs.getInt("AD_Task_ID");
|
||||
startTask(cmd);
|
||||
}
|
||||
else if (Action.equals("X")) // Form
|
||||
{
|
||||
cmd = rs.getInt("AD_Form_ID");
|
||||
startForm(cmd);
|
||||
}
|
||||
else
|
||||
log.log(Level.SEVERE, "No valid Action in ID=" + m_ID);
|
||||
} // for all records
|
||||
|
||||
SwingUtilities.invokeLater(m_updatePB);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "ID=" + m_ID, e);
|
||||
ADialog.error(0, null, "Error", Msg.parseTranslation(Env.getCtx(), e.getMessage()));
|
||||
}
|
||||
|
||||
try {Thread.sleep(1000);} // 1 sec
|
||||
catch (InterruptedException ie) {}
|
||||
|
||||
// ready for next
|
||||
m_timer.stop();
|
||||
SwingUtilities.invokeLater(m_resetPB);
|
||||
if (m_menu != null)
|
||||
{
|
||||
m_menu.updateInfo();
|
||||
m_menu.setBusy(false);
|
||||
}
|
||||
} // run
|
||||
|
||||
|
||||
/**
|
||||
* Actlion Listener for Timer
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
SwingUtilities.invokeLater(m_tickPB);
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Start Window
|
||||
*
|
||||
* @param AD_Workbench_ID workbench
|
||||
* @param AD_Window_ID window
|
||||
import javax.swing.*;
|
||||
import org.compiere.apps.form.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Start Menu Item & UpdateProgress Bar
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: AMenuStartItem.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class AMenuStartItem extends Thread implements ActionListener
|
||||
{
|
||||
/**
|
||||
* Start Menu Item
|
||||
*
|
||||
* @param ID ID
|
||||
* @param isMenu false if Workflow
|
||||
* @param name Name
|
||||
* @param menu Menu
|
||||
*/
|
||||
public AMenuStartItem (int ID, boolean isMenu, String name, AMenu menu)
|
||||
{
|
||||
m_ID = ID;
|
||||
m_isMenu = isMenu;
|
||||
m_name = name;
|
||||
m_menu = menu;
|
||||
if (menu != null)
|
||||
m_increment = (menu.progressBar.getMaximum()-menu.progressBar.getMinimum()) / 5;
|
||||
} // UpdateProgress
|
||||
|
||||
/** The ID */
|
||||
private int m_ID = 0;
|
||||
private boolean m_isMenu = false;
|
||||
private String m_name;
|
||||
private AMenu m_menu;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(AMenuStartItem.class);
|
||||
|
||||
// Reset Progress Bar
|
||||
private Runnable m_resetPB = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
m_value = 0;
|
||||
if (m_menu != null)
|
||||
m_menu.progressBar.setValue(0);
|
||||
}
|
||||
};
|
||||
// Progress Bar tick
|
||||
private Runnable m_tickPB = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (m_menu == null)
|
||||
return;
|
||||
// 100/5 => 20 ticks - every .5 sec => 10 seconds loadtime
|
||||
final int tick = 5;
|
||||
if (m_menu.progressBar.getValue() < (m_menu.progressBar.getMaximum() - tick))
|
||||
m_menu.progressBar.setValue(m_menu.progressBar.getValue() + tick);
|
||||
}
|
||||
};
|
||||
// Progress Bar max state
|
||||
private Runnable m_updatePB = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (m_menu == null)
|
||||
return;
|
||||
m_value += m_increment;
|
||||
if (m_menu.progressBar.getValue() > m_value) // max value
|
||||
m_menu.progressBar.setValue(m_value);
|
||||
}
|
||||
};
|
||||
private int m_value = 0;
|
||||
private int m_increment = 20;
|
||||
private javax.swing.Timer m_timer = new javax.swing.Timer(500, this); // every 1/2 second
|
||||
|
||||
|
||||
/**
|
||||
* Start Menu Item
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
if (m_menu != null)
|
||||
m_menu.setBusy (true);
|
||||
SwingUtilities.invokeLater(m_resetPB);
|
||||
m_timer.start();
|
||||
SwingUtilities.invokeLater(m_updatePB);
|
||||
try
|
||||
{
|
||||
String sql = "SELECT * FROM AD_Menu WHERE AD_Menu_ID=?";
|
||||
if (!m_isMenu)
|
||||
sql = "SELECT * FROM AD_WF_Node WHERE AD_WF_Node_ID=?";
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
|
||||
SwingUtilities.invokeLater(m_updatePB);
|
||||
if (rs.next()) // should only be one
|
||||
{
|
||||
String Action = rs.getString("Action");
|
||||
String IsSOTrx = "Y";
|
||||
if (m_isMenu)
|
||||
IsSOTrx = rs.getString("IsSOTrx");
|
||||
int cmd;
|
||||
if (Action.equals("W")) // Window
|
||||
{
|
||||
cmd = rs.getInt("AD_Window_ID");
|
||||
startWindow(0, cmd);
|
||||
}
|
||||
else if (Action.equals("P") || Action.equals("R")) // Process & Report
|
||||
{
|
||||
cmd = rs.getInt("AD_Process_ID");
|
||||
startProcess(cmd, IsSOTrx);
|
||||
}
|
||||
else if (Action.equals("B")) // Workbench
|
||||
{
|
||||
cmd = rs.getInt("AD_Workbench_ID");
|
||||
startWindow (cmd, 0);
|
||||
}
|
||||
else if (Action.equals("F")) // WorkFlow
|
||||
{
|
||||
if (m_isMenu)
|
||||
cmd = rs.getInt("AD_Workflow_ID");
|
||||
else
|
||||
cmd = rs.getInt("Workflow_ID");
|
||||
if (m_menu != null)
|
||||
m_menu.startWorkFlow(cmd);
|
||||
}
|
||||
else if (Action.equals("T")) // Task
|
||||
{
|
||||
cmd = rs.getInt("AD_Task_ID");
|
||||
startTask(cmd);
|
||||
}
|
||||
else if (Action.equals("X")) // Form
|
||||
{
|
||||
cmd = rs.getInt("AD_Form_ID");
|
||||
startForm(cmd);
|
||||
}
|
||||
else
|
||||
log.log(Level.SEVERE, "No valid Action in ID=" + m_ID);
|
||||
} // for all records
|
||||
|
||||
SwingUtilities.invokeLater(m_updatePB);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "ID=" + m_ID, e);
|
||||
ADialog.error(0, null, "Error", Msg.parseTranslation(Env.getCtx(), e.getMessage()));
|
||||
}
|
||||
|
||||
try {Thread.sleep(1000);} // 1 sec
|
||||
catch (InterruptedException ie) {}
|
||||
|
||||
// ready for next
|
||||
m_timer.stop();
|
||||
SwingUtilities.invokeLater(m_resetPB);
|
||||
if (m_menu != null)
|
||||
{
|
||||
m_menu.updateInfo();
|
||||
m_menu.setBusy(false);
|
||||
}
|
||||
} // run
|
||||
|
||||
|
||||
/**
|
||||
* Actlion Listener for Timer
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
SwingUtilities.invokeLater(m_tickPB);
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Start Window
|
||||
*
|
||||
* @param AD_Workbench_ID workbench
|
||||
* @param AD_Window_ID window
|
||||
*/
|
||||
private void startWindow(int AD_Workbench_ID, int AD_Window_ID)
|
||||
{
|
||||
AWindow frame = (AWindow)Env.showWindow(AD_Window_ID);
|
||||
if (frame != null) {
|
||||
m_menu.getWindowManager().add(frame);
|
||||
if (Env.showWindow(AD_Window_ID))
|
||||
return;
|
||||
}
|
||||
|
||||
if (Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW)) {
|
||||
frame = m_menu.getWindowManager().find(AD_Window_ID);
|
||||
if ( frame != null ) {
|
||||
frame.toFront();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(m_updatePB); // 1
|
||||
frame = new AWindow();
|
||||
AWindow frame = new AWindow();
|
||||
boolean OK = false;
|
||||
if (AD_Workbench_ID != 0)
|
||||
OK = frame.initWorkbench(AD_Workbench_ID);
|
||||
else
|
||||
OK = frame.initWindow(AD_Window_ID, null); // No Query Value
|
||||
if (!OK)
|
||||
return;
|
||||
else
|
||||
OK = frame.initWindow(AD_Window_ID, null); // No Query Value
|
||||
if (!OK)
|
||||
return;
|
||||
|
||||
SwingUtilities.invokeLater(m_updatePB); // 2
|
||||
frame.pack();
|
||||
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) )
|
||||
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
|
||||
|
||||
// Center the window
|
||||
SwingUtilities.invokeLater(m_updatePB); // 3
|
||||
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) ) {
|
||||
frame.setVisible(true);
|
||||
frame.toFront();
|
||||
} else
|
||||
AEnv.showCenterScreen(frame);
|
||||
|
||||
m_menu.getWindowManager().add(frame);
|
||||
|
||||
AEnv.showCenterScreen(frame);
|
||||
// if (wfPanel.isVisible())
|
||||
// m_WF_Window = frame; // maintain one reference
|
||||
frame = null;
|
||||
} // startWindow
|
||||
|
||||
/**
|
||||
* Start Process.
|
||||
* Start/show Process Dialog which calls ProcessCtl
|
||||
* @param AD_Process_ID process
|
||||
* @param IsSOTrx is SO trx
|
||||
*/
|
||||
private void startProcess (int AD_Process_ID, String IsSOTrx)
|
||||
{
|
||||
SwingUtilities.invokeLater(m_updatePB); // 1
|
||||
boolean isSO = false;
|
||||
if (IsSOTrx != null && IsSOTrx.equals("Y"))
|
||||
isSO = true;
|
||||
m_timer.stop();
|
||||
ProcessDialog pd = new ProcessDialog (AD_Process_ID, isSO);
|
||||
} // startWindow
|
||||
|
||||
/**
|
||||
* Start Process.
|
||||
* Start/show Process Dialog which calls ProcessCtl
|
||||
* @param AD_Process_ID process
|
||||
* @param IsSOTrx is SO trx
|
||||
*/
|
||||
private void startProcess (int AD_Process_ID, String IsSOTrx)
|
||||
{
|
||||
SwingUtilities.invokeLater(m_updatePB); // 1
|
||||
boolean isSO = false;
|
||||
if (IsSOTrx != null && IsSOTrx.equals("Y"))
|
||||
isSO = true;
|
||||
m_timer.stop();
|
||||
ProcessDialog pd = new ProcessDialog (AD_Process_ID, isSO);
|
||||
if (!pd.init())
|
||||
return;
|
||||
m_timer.start();
|
||||
m_menu.getWindowManager().add(pd);
|
||||
|
||||
SwingUtilities.invokeLater(m_updatePB); // 2
|
||||
pd.getContentPane().invalidate();
|
||||
pd.getContentPane().validate();
|
||||
pd.pack();
|
||||
// Center the window
|
||||
SwingUtilities.invokeLater(m_updatePB); // 3
|
||||
AEnv.showCenterScreen(pd);
|
||||
} // startProcess
|
||||
|
||||
/**
|
||||
* Start OS Task
|
||||
* @param AD_Task_ID task
|
||||
*/
|
||||
private void startTask (int AD_Task_ID)
|
||||
{
|
||||
SwingUtilities.invokeLater(m_updatePB); // 1
|
||||
// Get Command
|
||||
MTask task = null;
|
||||
String sql = "SELECT * FROM AD_Task WHERE AD_Task_ID=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, AD_Task_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
task = new MTask (Env.getCtx(), rs, null);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (task == null)
|
||||
AEnv.showCenterScreen(pd);
|
||||
} // startProcess
|
||||
|
||||
/**
|
||||
* Start OS Task
|
||||
* @param AD_Task_ID task
|
||||
*/
|
||||
private void startTask (int AD_Task_ID)
|
||||
{
|
||||
SwingUtilities.invokeLater(m_updatePB); // 1
|
||||
// Get Command
|
||||
MTask task = null;
|
||||
String sql = "SELECT * FROM AD_Task WHERE AD_Task_ID=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, AD_Task_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
task = new MTask (Env.getCtx(), rs, null);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (task == null)
|
||||
return;
|
||||
|
||||
SwingUtilities.invokeLater(m_updatePB); // 2
|
||||
m_menu.getWindowManager().add(new ATask(m_name, task));
|
||||
new ATask(m_name, task);
|
||||
// ATask.start(m_name, task);
|
||||
} // startTask
|
||||
|
||||
/**
|
||||
* Start Form
|
||||
* @param AD_Form_ID form
|
||||
/**
|
||||
* Start Form
|
||||
* @param AD_Form_ID form
|
||||
*/
|
||||
private void startForm (int AD_Form_ID)
|
||||
{
|
||||
FormFrame ff = null;
|
||||
if (Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW)) {
|
||||
ff = m_menu.getWindowManager().findForm(AD_Form_ID);
|
||||
if ( ff != null ) {
|
||||
ff.toFront();
|
||||
return;
|
||||
}
|
||||
}
|
||||
ff = new FormFrame();
|
||||
m_menu.getWindowManager().add(ff);
|
||||
FormFrame ff = new FormFrame();
|
||||
SwingUtilities.invokeLater(m_updatePB); // 1
|
||||
ff.openForm(AD_Form_ID);
|
||||
SwingUtilities.invokeLater(m_updatePB); // 2
|
||||
|
||||
ff.pack();
|
||||
// Center the window
|
||||
SwingUtilities.invokeLater(m_updatePB); // 3
|
||||
if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) ) {
|
||||
ff.pack();
|
||||
ff.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
ff.setVisible(true);
|
||||
ff.toFront();
|
||||
} else
|
||||
AEnv.showCenterScreen(ff);
|
||||
AEnv.showCenterScreen(ff);
|
||||
} // startForm
|
||||
|
||||
} // StartItem
|
||||
} // StartItem
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -184,7 +184,6 @@ public class ARequest implements ActionListener
|
|||
AWindow frame = new AWindow();
|
||||
if (!frame.initWindow(AD_Window_ID, query))
|
||||
return;
|
||||
AEnv.addToWindowManager(frame);
|
||||
// New - set Table/Record
|
||||
if (e.getSource() == m_new)
|
||||
{
|
||||
|
|
|
@ -3,41 +3,41 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.db.*;
|
||||
|
||||
/**
|
||||
* Main Application Window.
|
||||
* - Constructs, initializes and positions JFrame
|
||||
* - Gets content, menu, title from APanel
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: AWindow.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class AWindow extends CFrame
|
||||
{
|
||||
/**
|
||||
* Standard Constructor - requires initWindow
|
||||
*/
|
||||
public AWindow ()
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.db.*;
|
||||
|
||||
/**
|
||||
* Main Application Window.
|
||||
* - Constructs, initializes and positions JFrame
|
||||
* - Gets content, menu, title from APanel
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: AWindow.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class AWindow extends CFrame
|
||||
{
|
||||
/**
|
||||
* Standard Constructor - requires initWindow
|
||||
*/
|
||||
public AWindow ()
|
||||
{
|
||||
super();
|
||||
// Set UI Components
|
||||
|
@ -45,148 +45,147 @@ public class AWindow extends CFrame
|
|||
this.getContentPane().add(m_APanel, BorderLayout.CENTER);
|
||||
this.setGlassPane(m_glassPane);
|
||||
} // AWindow
|
||||
|
||||
|
||||
/** The GlassPane */
|
||||
private AGlassPane m_glassPane = new AGlassPane();
|
||||
/** Application Window */
|
||||
private APanel m_APanel = new APanel(this);
|
||||
|
||||
private APanel m_APanel = new APanel();
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(AWindow.class);
|
||||
|
||||
/**
|
||||
* Dynamic Initialization Workbench
|
||||
* @param AD_Workbench_ID workbench
|
||||
* @return true if loaded OK
|
||||
*/
|
||||
protected boolean initWorkbench (int AD_Workbench_ID)
|
||||
{
|
||||
this.setName("AWindow_WB_" + AD_Workbench_ID);
|
||||
boolean loadedOK = m_APanel.initPanel (AD_Workbench_ID, 0, null);
|
||||
//
|
||||
commonInit();
|
||||
return loadedOK;
|
||||
} // initWorkbench
|
||||
|
||||
/**
|
||||
* Dynamic Initialization Single Window
|
||||
* @param AD_Window_ID window
|
||||
* @param query query
|
||||
* @return true if loaded OK
|
||||
*/
|
||||
public boolean initWindow (int AD_Window_ID, MQuery query)
|
||||
{
|
||||
this.setName("AWindow_" + AD_Window_ID);
|
||||
setAD_Window_ID(AD_Window_ID);
|
||||
//
|
||||
boolean loadedOK = m_APanel.initPanel (0, AD_Window_ID, query);
|
||||
commonInit();
|
||||
return loadedOK;
|
||||
} // initWindow
|
||||
|
||||
/**
|
||||
* Common Init.
|
||||
* After APanel loaded
|
||||
*/
|
||||
private void commonInit()
|
||||
{
|
||||
this.setJMenuBar(m_APanel.getMenuBar());
|
||||
this.setTitle(m_APanel.getTitle());
|
||||
//
|
||||
Image image = m_APanel.getImage();
|
||||
if (image != null)
|
||||
setIconImage(image);
|
||||
} // commonInit
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Set Window Busy
|
||||
* @param busy busy
|
||||
*/
|
||||
public void setBusy (boolean busy)
|
||||
{
|
||||
if (busy == m_glassPane.isVisible()
|
||||
|| CConnection.get().isTerminalServer())
|
||||
return;
|
||||
log.config(getName() + " - " + busy);
|
||||
m_glassPane.setMessage(null);
|
||||
m_glassPane.setVisible(busy);
|
||||
if (busy)
|
||||
m_glassPane.requestFocus();
|
||||
} // setBusy
|
||||
|
||||
/**
|
||||
* Set Busy Message
|
||||
* @param AD_Message message
|
||||
*/
|
||||
public void setBusyMessage (String AD_Message)
|
||||
{
|
||||
m_glassPane.setMessage(AD_Message);
|
||||
} // setBusyMessage
|
||||
|
||||
/**
|
||||
* Set and start Busy Counter
|
||||
* @param time in seconds
|
||||
*/
|
||||
public void setBusyTimer (int time)
|
||||
{
|
||||
m_glassPane.setBusyTimer (time);
|
||||
} // setBusyTimer
|
||||
|
||||
/**
|
||||
* Window Events
|
||||
* @param e event
|
||||
*/
|
||||
protected void processWindowEvent(WindowEvent e)
|
||||
{
|
||||
super.processWindowEvent(e);
|
||||
// System.out.println(">> Apps WE_" + e.getID() // + " Frames=" + getFrames().length
|
||||
// + " " + e);
|
||||
} // processWindowEvent
|
||||
|
||||
/**
|
||||
* Get Application Panel
|
||||
* @return application panel
|
||||
*/
|
||||
protected APanel getAPanel()
|
||||
{
|
||||
return m_APanel;
|
||||
} // getAPanel
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
if (Env.hideWindow(this))
|
||||
return;
|
||||
log.info(toString());
|
||||
if (m_APanel != null)
|
||||
m_APanel.dispose();
|
||||
m_APanel = null;
|
||||
this.removeAll();
|
||||
super.dispose();
|
||||
// System.gc();
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Get Window No of Panel
|
||||
* @return window no
|
||||
*/
|
||||
public int getWindowNo()
|
||||
{
|
||||
if (m_APanel != null)
|
||||
return m_APanel.getWindowNo();
|
||||
return 0;
|
||||
} // getWindowNo
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return Name
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
/**
|
||||
* Dynamic Initialization Workbench
|
||||
* @param AD_Workbench_ID workbench
|
||||
* @return true if loaded OK
|
||||
*/
|
||||
protected boolean initWorkbench (int AD_Workbench_ID)
|
||||
{
|
||||
this.setName("AWindow_WB_" + AD_Workbench_ID);
|
||||
boolean loadedOK = m_APanel.initPanel (AD_Workbench_ID, 0, null);
|
||||
//
|
||||
commonInit();
|
||||
return loadedOK;
|
||||
} // initWorkbench
|
||||
|
||||
/**
|
||||
* Dynamic Initialization Single Window
|
||||
* @param AD_Window_ID window
|
||||
* @param query query
|
||||
* @return true if loaded OK
|
||||
*/
|
||||
public boolean initWindow (int AD_Window_ID, MQuery query)
|
||||
{
|
||||
this.setName("AWindow_" + AD_Window_ID);
|
||||
setAD_Window_ID(AD_Window_ID);
|
||||
//
|
||||
boolean loadedOK = m_APanel.initPanel (0, AD_Window_ID, query);
|
||||
commonInit();
|
||||
return loadedOK;
|
||||
} // initWindow
|
||||
|
||||
/**
|
||||
* Common Init.
|
||||
* After APanel loaded
|
||||
*/
|
||||
private void commonInit()
|
||||
{
|
||||
this.setJMenuBar(m_APanel.getMenuBar());
|
||||
this.setTitle(m_APanel.getTitle());
|
||||
//
|
||||
Image image = m_APanel.getImage();
|
||||
if (image != null)
|
||||
setIconImage(image);
|
||||
} // commonInit
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Set Window Busy
|
||||
* @param busy busy
|
||||
*/
|
||||
public void setBusy (boolean busy)
|
||||
{
|
||||
if (busy == m_glassPane.isVisible()
|
||||
|| CConnection.get().isTerminalServer())
|
||||
return;
|
||||
log.config(getName() + " - " + busy);
|
||||
m_glassPane.setMessage(null);
|
||||
m_glassPane.setVisible(busy);
|
||||
if (busy)
|
||||
m_glassPane.requestFocus();
|
||||
} // setBusy
|
||||
|
||||
/**
|
||||
* Set Busy Message
|
||||
* @param AD_Message message
|
||||
*/
|
||||
public void setBusyMessage (String AD_Message)
|
||||
{
|
||||
m_glassPane.setMessage(AD_Message);
|
||||
} // setBusyMessage
|
||||
|
||||
/**
|
||||
* Set and start Busy Counter
|
||||
* @param time in seconds
|
||||
*/
|
||||
public void setBusyTimer (int time)
|
||||
{
|
||||
m_glassPane.setBusyTimer (time);
|
||||
} // setBusyTimer
|
||||
|
||||
/**
|
||||
* Window Events
|
||||
* @param e event
|
||||
*/
|
||||
protected void processWindowEvent(WindowEvent e)
|
||||
{
|
||||
super.processWindowEvent(e);
|
||||
// System.out.println(">> Apps WE_" + e.getID() // + " Frames=" + getFrames().length
|
||||
// + " " + e);
|
||||
} // processWindowEvent
|
||||
|
||||
/**
|
||||
* Get Application Panel
|
||||
* @return application panel
|
||||
*/
|
||||
protected APanel getAPanel()
|
||||
{
|
||||
return m_APanel;
|
||||
} // getAPanel
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
if (Env.hideWindow(this))
|
||||
return;
|
||||
log.info(toString());
|
||||
if (m_APanel != null)
|
||||
m_APanel.dispose();
|
||||
m_APanel = null;
|
||||
this.removeAll();
|
||||
super.dispose();
|
||||
// System.gc();
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Get Window No of Panel
|
||||
* @return window no
|
||||
*/
|
||||
public int getWindowNo()
|
||||
{
|
||||
if (m_APanel != null)
|
||||
return m_APanel.getWindowNo();
|
||||
return 0;
|
||||
} // getWindowNo
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
* @return Name
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return getName() + "_" + getWindowNo();
|
||||
} // toString
|
||||
|
||||
} // AWindow
|
||||
} // AWindow
|
||||
|
|
|
@ -190,7 +190,6 @@ public class AZoomAcross implements ActionListener
|
|||
AWindow frame = new AWindow();
|
||||
if (!frame.initWindow(AD_Window_ID, m_query))
|
||||
return;
|
||||
AEnv.addToWindowManager(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
frame = null;
|
||||
} // launchZoom
|
||||
|
|
|
@ -3,291 +3,291 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Application Action.
|
||||
* Creates Action with MenuItem and Button
|
||||
* The ActionCommand is translated for display
|
||||
* If translated text contains &, the next character is the Mnemonic
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: AppsAction.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public final class AppsAction extends AbstractAction
|
||||
{
|
||||
/**
|
||||
* Application Action
|
||||
*
|
||||
* @param action base action command - used as AD_Message for Text and Icon name
|
||||
* @param accelerator optional keystroke for accelerator
|
||||
* @param toggle is toggle action (maintains state)
|
||||
*/
|
||||
public AppsAction (String action, KeyStroke accelerator, boolean toggle)
|
||||
{
|
||||
this (action, accelerator, null, toggle);
|
||||
}
|
||||
/**
|
||||
* Application Action
|
||||
*
|
||||
* @param action base action command - used as AD_Message for Text and Icon name
|
||||
* @param accelerator optional keystroke for accelerator
|
||||
* @param text text, if null defered from action
|
||||
*/
|
||||
public AppsAction (String action, KeyStroke accelerator, String text)
|
||||
{
|
||||
this (action, accelerator, text, false);
|
||||
} // AppsAction
|
||||
|
||||
/**
|
||||
* Application Action
|
||||
*
|
||||
* @param action base action command - used as AD_Message for Text and Icon name
|
||||
* @param accelerator optional keystroke for accelerator
|
||||
* @param toolTipText text, if null defered from action
|
||||
* @param toggle is toggle action (maintains state)
|
||||
*/
|
||||
public AppsAction (String action, KeyStroke accelerator, String toolTipText, boolean toggle)
|
||||
{
|
||||
super();
|
||||
m_action = action;
|
||||
m_accelerator = accelerator;
|
||||
m_toggle = toggle;
|
||||
|
||||
// Data
|
||||
if (toolTipText == null)
|
||||
toolTipText = Msg.getMsg(Env.getCtx(), action);
|
||||
int pos = toolTipText.indexOf("&");
|
||||
if (pos != -1 && toolTipText.length() > pos) // We have a nemonic - creates ALT-_
|
||||
{
|
||||
Character ch = new Character(toolTipText.toUpperCase().charAt(pos+1));
|
||||
if (ch != ' ')
|
||||
{
|
||||
toolTipText = toolTipText.substring(0, pos) + toolTipText.substring(pos+1);
|
||||
putValue(Action.MNEMONIC_KEY, new Integer(ch.hashCode()));
|
||||
}
|
||||
}
|
||||
//
|
||||
Icon small = getIcon(action, true);
|
||||
Icon large = getIcon(action, false);
|
||||
Icon largePressed = null;
|
||||
|
||||
// ToggleIcons have the pressed name with X
|
||||
if (m_toggle)
|
||||
{
|
||||
m_smallPressed = getIcon(action+"X", true);
|
||||
if (m_smallPressed == null)
|
||||
m_smallPressed = small;
|
||||
largePressed = getIcon(action+"X", false);
|
||||
if (largePressed == null)
|
||||
largePressed = large;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
putValue(Action.NAME, toolTipText); // Display
|
||||
putValue(Action.SMALL_ICON, small); // Icon
|
||||
putValue(Action.SHORT_DESCRIPTION, toolTipText); // Tooltip
|
||||
putValue(Action.ACTION_COMMAND_KEY, m_action); // ActionCammand
|
||||
putValue(Action.ACCELERATOR_KEY, accelerator); // KeyStroke
|
||||
// putValue(Action.MNEMONIC_KEY, new Integer(0)); // Mnemonic
|
||||
// putValue(Action.DEFAULT, text); // Not Used
|
||||
|
||||
// Create Button
|
||||
if (toggle)
|
||||
{
|
||||
m_button = new CToggleButton(this);
|
||||
m_button.setSelectedIcon(largePressed);
|
||||
}
|
||||
else
|
||||
m_button = new CButton(this);
|
||||
m_button.setName(action);
|
||||
// Correcting Action items
|
||||
if (large != null)
|
||||
{
|
||||
m_button.setIcon(large);
|
||||
m_button.setText(null);
|
||||
}
|
||||
m_button.setActionCommand(m_action);
|
||||
m_button.setMargin(BUTTON_INSETS);
|
||||
m_button.setSize(BUTTON_SIZE);
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Application Action.
|
||||
* Creates Action with MenuItem and Button
|
||||
* The ActionCommand is translated for display
|
||||
* If translated text contains &, the next character is the Mnemonic
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: AppsAction.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public final class AppsAction extends AbstractAction
|
||||
{
|
||||
/**
|
||||
* Application Action
|
||||
*
|
||||
* @param action base action command - used as AD_Message for Text and Icon name
|
||||
* @param accelerator optional keystroke for accelerator
|
||||
* @param toggle is toggle action (maintains state)
|
||||
*/
|
||||
public AppsAction (String action, KeyStroke accelerator, boolean toggle)
|
||||
{
|
||||
this (action, accelerator, null, toggle);
|
||||
}
|
||||
/**
|
||||
* Application Action
|
||||
*
|
||||
* @param action base action command - used as AD_Message for Text and Icon name
|
||||
* @param accelerator optional keystroke for accelerator
|
||||
* @param text text, if null defered from action
|
||||
*/
|
||||
public AppsAction (String action, KeyStroke accelerator, String text)
|
||||
{
|
||||
this (action, accelerator, text, false);
|
||||
} // AppsAction
|
||||
|
||||
/**
|
||||
* Application Action
|
||||
*
|
||||
* @param action base action command - used as AD_Message for Text and Icon name
|
||||
* @param accelerator optional keystroke for accelerator
|
||||
* @param toolTipText text, if null defered from action
|
||||
* @param toggle is toggle action (maintains state)
|
||||
*/
|
||||
public AppsAction (String action, KeyStroke accelerator, String toolTipText, boolean toggle)
|
||||
{
|
||||
super();
|
||||
m_action = action;
|
||||
m_accelerator = accelerator;
|
||||
m_toggle = toggle;
|
||||
|
||||
// Data
|
||||
if (toolTipText == null)
|
||||
toolTipText = Msg.getMsg(Env.getCtx(), action);
|
||||
int pos = toolTipText.indexOf("&");
|
||||
if (pos != -1 && toolTipText.length() > pos) // We have a nemonic - creates ALT-_
|
||||
{
|
||||
Character ch = new Character(toolTipText.toUpperCase().charAt(pos+1));
|
||||
if (ch != ' ')
|
||||
{
|
||||
toolTipText = toolTipText.substring(0, pos) + toolTipText.substring(pos+1);
|
||||
putValue(Action.MNEMONIC_KEY, new Integer(ch.hashCode()));
|
||||
}
|
||||
}
|
||||
//
|
||||
Icon small = getIcon(action, true);
|
||||
Icon large = getIcon(action, false);
|
||||
Icon largePressed = null;
|
||||
|
||||
// ToggleIcons have the pressed name with X
|
||||
if (m_toggle)
|
||||
{
|
||||
m_smallPressed = getIcon(action+"X", true);
|
||||
if (m_smallPressed == null)
|
||||
m_smallPressed = small;
|
||||
largePressed = getIcon(action+"X", false);
|
||||
if (largePressed == null)
|
||||
largePressed = large;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
putValue(Action.NAME, toolTipText); // Display
|
||||
putValue(Action.SMALL_ICON, small); // Icon
|
||||
putValue(Action.SHORT_DESCRIPTION, toolTipText); // Tooltip
|
||||
putValue(Action.ACTION_COMMAND_KEY, m_action); // ActionCammand
|
||||
putValue(Action.ACCELERATOR_KEY, accelerator); // KeyStroke
|
||||
// putValue(Action.MNEMONIC_KEY, new Integer(0)); // Mnemonic
|
||||
// putValue(Action.DEFAULT, text); // Not Used
|
||||
|
||||
// Create Button
|
||||
if (toggle)
|
||||
{
|
||||
m_button = new CToggleButton(this);
|
||||
m_button.setSelectedIcon(largePressed);
|
||||
}
|
||||
else
|
||||
m_button = new CButton(this);
|
||||
m_button.setName(action);
|
||||
// Correcting Action items
|
||||
if (large != null)
|
||||
{
|
||||
m_button.setIcon(large);
|
||||
m_button.setText(null);
|
||||
}
|
||||
m_button.setActionCommand(m_action);
|
||||
m_button.setMargin(BUTTON_INSETS);
|
||||
m_button.setSize(BUTTON_SIZE);
|
||||
//
|
||||
if (accelerator != null)
|
||||
{
|
||||
m_button.getInputMap(CButton.WHEN_IN_FOCUSED_WINDOW).put(accelerator, action);
|
||||
m_button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(accelerator, action);
|
||||
m_button.getActionMap().put(action, this);
|
||||
}
|
||||
} // Action
|
||||
|
||||
/** Button Size */
|
||||
public static final Dimension BUTTON_SIZE = new Dimension(28,28);
|
||||
/** Button Insets */
|
||||
public static final Insets BUTTON_INSETS = new Insets(0, 0, 0, 0);
|
||||
/** CButton or CToggelButton */
|
||||
private AbstractButton m_button;
|
||||
/** Menu */
|
||||
private JMenuItem m_menu;
|
||||
|
||||
private String m_action = null;
|
||||
private KeyStroke m_accelerator = null;
|
||||
private Icon m_smallPressed = null;
|
||||
private ActionListener m_delegate = null;
|
||||
private boolean m_toggle = false;
|
||||
private boolean m_pressed = false;
|
||||
|
||||
/**
|
||||
* Get Icon with name action
|
||||
* @param name name
|
||||
* @param small small
|
||||
* @return Icon
|
||||
|
||||
/** Button Size */
|
||||
public static final Dimension BUTTON_SIZE = new Dimension(28,28);
|
||||
/** Button Insets */
|
||||
public static final Insets BUTTON_INSETS = new Insets(0, 0, 0, 0);
|
||||
/** CButton or CToggelButton */
|
||||
private AbstractButton m_button;
|
||||
/** Menu */
|
||||
private JMenuItem m_menu;
|
||||
|
||||
private String m_action = null;
|
||||
private KeyStroke m_accelerator = null;
|
||||
private Icon m_smallPressed = null;
|
||||
private ActionListener m_delegate = null;
|
||||
private boolean m_toggle = false;
|
||||
private boolean m_pressed = false;
|
||||
|
||||
/**
|
||||
* Get Icon with name action
|
||||
* @param name name
|
||||
* @param small small
|
||||
* @return Icon
|
||||
*/
|
||||
private ImageIcon getIcon(String name, boolean small)
|
||||
{
|
||||
String fullName = name + (small ? "16" : "24");
|
||||
return Env.getImageIcon2(fullName);
|
||||
String fullName = name + (small ? "16.gif" : "24.gif");
|
||||
return Env.getImageIcon(fullName);
|
||||
} // getIcon
|
||||
|
||||
/**
|
||||
* Get Name/ActionCommand
|
||||
* @return ActionName
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return m_action;
|
||||
} // getName
|
||||
|
||||
/**
|
||||
* Return Button
|
||||
* @return Button
|
||||
*/
|
||||
public AbstractButton getButton()
|
||||
{
|
||||
return m_button;
|
||||
} // getButton
|
||||
|
||||
/**
|
||||
* Return MenuItem
|
||||
* @return MenuItem
|
||||
*/
|
||||
public JMenuItem getMenuItem()
|
||||
{
|
||||
if (m_menu == null)
|
||||
{
|
||||
if (m_toggle)
|
||||
{
|
||||
m_menu = new CCheckBoxMenuItem(this);
|
||||
m_menu.setSelectedIcon(m_smallPressed);
|
||||
}
|
||||
else
|
||||
m_menu = new CMenuItem(this);
|
||||
m_menu.setAccelerator(m_accelerator);
|
||||
m_menu.setActionCommand(m_action);
|
||||
}
|
||||
return m_menu;
|
||||
} // getMenuItem
|
||||
|
||||
/**
|
||||
* Set Delegate to receive the actionPerformed calls
|
||||
* @param al listener
|
||||
*/
|
||||
public void setDelegate(ActionListener al)
|
||||
{
|
||||
m_delegate = al;
|
||||
} // setDelegate
|
||||
|
||||
/**
|
||||
* Toggle
|
||||
* @param pressed pressed
|
||||
*/
|
||||
public void setPressed (boolean pressed)
|
||||
{
|
||||
if (!m_toggle)
|
||||
return;
|
||||
m_pressed = pressed;
|
||||
|
||||
// Set Button
|
||||
m_button.setSelected(pressed);
|
||||
// Set Menu
|
||||
m_menu.setSelected(pressed);
|
||||
} // setPressed
|
||||
|
||||
/**
|
||||
* IsPressed
|
||||
* @return true if pressed
|
||||
*/
|
||||
public boolean isPressed()
|
||||
{
|
||||
return m_pressed;
|
||||
} // isPressed
|
||||
|
||||
/**
|
||||
* Get Mnemonic character
|
||||
* @return character
|
||||
*/
|
||||
public Character getMnemonic()
|
||||
{
|
||||
Object oo = getValue(Action.MNEMONIC_KEY);
|
||||
if (oo instanceof Integer)
|
||||
return (char)((Integer)oo).intValue();
|
||||
return null;
|
||||
} // getMnemonic
|
||||
|
||||
/**
|
||||
* ActionListener
|
||||
* @param e Event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
// log.info( "AppsAction.actionPerformed", e.getActionCommand());
|
||||
// Toggle Items
|
||||
if (m_toggle)
|
||||
setPressed(!m_pressed);
|
||||
// Inform
|
||||
if (m_delegate != null)
|
||||
m_delegate.actionPerformed(e);
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_button = null;
|
||||
m_menu = null;
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* String Info
|
||||
* @return String Representation
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer("AppsAction[");
|
||||
sb.append(m_action);
|
||||
Object oo = getValue(Action.ACCELERATOR_KEY);
|
||||
if (oo != null)
|
||||
sb.append(",Accelerator=").append(oo);
|
||||
oo = getMnemonic();
|
||||
if (oo != null)
|
||||
sb.append(",MnemonicKey=").append(oo);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
} // toString
|
||||
|
||||
} // AppsAction
|
||||
* Get Name/ActionCommand
|
||||
* @return ActionName
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return m_action;
|
||||
} // getName
|
||||
|
||||
/**
|
||||
* Return Button
|
||||
* @return Button
|
||||
*/
|
||||
public AbstractButton getButton()
|
||||
{
|
||||
return m_button;
|
||||
} // getButton
|
||||
|
||||
/**
|
||||
* Return MenuItem
|
||||
* @return MenuItem
|
||||
*/
|
||||
public JMenuItem getMenuItem()
|
||||
{
|
||||
if (m_menu == null)
|
||||
{
|
||||
if (m_toggle)
|
||||
{
|
||||
m_menu = new CCheckBoxMenuItem(this);
|
||||
m_menu.setSelectedIcon(m_smallPressed);
|
||||
}
|
||||
else
|
||||
m_menu = new CMenuItem(this);
|
||||
m_menu.setAccelerator(m_accelerator);
|
||||
m_menu.setActionCommand(m_action);
|
||||
}
|
||||
return m_menu;
|
||||
} // getMenuItem
|
||||
|
||||
/**
|
||||
* Set Delegate to receive the actionPerformed calls
|
||||
* @param al listener
|
||||
*/
|
||||
public void setDelegate(ActionListener al)
|
||||
{
|
||||
m_delegate = al;
|
||||
} // setDelegate
|
||||
|
||||
/**
|
||||
* Toggle
|
||||
* @param pressed pressed
|
||||
*/
|
||||
public void setPressed (boolean pressed)
|
||||
{
|
||||
if (!m_toggle)
|
||||
return;
|
||||
m_pressed = pressed;
|
||||
|
||||
// Set Button
|
||||
m_button.setSelected(pressed);
|
||||
// Set Menu
|
||||
m_menu.setSelected(pressed);
|
||||
} // setPressed
|
||||
|
||||
/**
|
||||
* IsPressed
|
||||
* @return true if pressed
|
||||
*/
|
||||
public boolean isPressed()
|
||||
{
|
||||
return m_pressed;
|
||||
} // isPressed
|
||||
|
||||
/**
|
||||
* Get Mnemonic character
|
||||
* @return character
|
||||
*/
|
||||
public Character getMnemonic()
|
||||
{
|
||||
Object oo = getValue(Action.MNEMONIC_KEY);
|
||||
if (oo instanceof Integer)
|
||||
return (char)((Integer)oo).intValue();
|
||||
return null;
|
||||
} // getMnemonic
|
||||
|
||||
/**
|
||||
* ActionListener
|
||||
* @param e Event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
// log.info( "AppsAction.actionPerformed", e.getActionCommand());
|
||||
// Toggle Items
|
||||
if (m_toggle)
|
||||
setPressed(!m_pressed);
|
||||
// Inform
|
||||
if (m_delegate != null)
|
||||
m_delegate.actionPerformed(e);
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_button = null;
|
||||
m_menu = null;
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* String Info
|
||||
* @return String Representation
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer("AppsAction[");
|
||||
sb.append(m_action);
|
||||
Object oo = getValue(Action.ACCELERATOR_KEY);
|
||||
if (oo != null)
|
||||
sb.append(",Accelerator=").append(oo);
|
||||
oo = getMnemonic();
|
||||
if (oo != null)
|
||||
sb.append(",MnemonicKey=").append(oo);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
} // toString
|
||||
|
||||
} // AppsAction
|
||||
|
|
|
@ -0,0 +1,662 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
import javax.swing.plaf.metal.MetalTheme;
|
||||
import javax.swing.table.*;
|
||||
//
|
||||
import org.adempiere.plaf.PLAFEditor;
|
||||
import org.adempiere.plaf.PLAFEditorPanel;
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.db.*;
|
||||
import org.compiere.grid.ed.*;
|
||||
import org.compiere.minigrid.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.plaf.*;
|
||||
import org.compiere.print.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Customize settings like L&F, AutoCommit, etc. & Diagnostics
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: Preference.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*
|
||||
* @author Low Heng Sin
|
||||
* @version 2006-11-27
|
||||
*/
|
||||
public final class Preference extends CDialog
|
||||
implements ActionListener, ListSelectionListener
|
||||
{
|
||||
/**
|
||||
* Standard Constructor
|
||||
* @param frame frame
|
||||
* @param WindowNo window
|
||||
*/
|
||||
public Preference(Frame frame, int WindowNo)
|
||||
{
|
||||
super(frame, Msg.getMsg(Env.getCtx(), "Preference"), true);
|
||||
log.config("Preference");
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, ex.getMessage());
|
||||
}
|
||||
load();
|
||||
//
|
||||
StringBuffer sta = new StringBuffer("#");
|
||||
sta.append(Env.getCtx().size()).append(" - ")
|
||||
.append(Msg.translate(Env.getCtx(), "AD_Window_ID"))
|
||||
.append("=").append(WindowNo);
|
||||
statusBar.setStatusLine(sta.toString());
|
||||
statusBar.setStatusDB("");
|
||||
AEnv.positionCenterWindow(frame, this);
|
||||
} // Preference
|
||||
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(Preference.class);
|
||||
|
||||
private CPanel panel = new CPanel();
|
||||
private BorderLayout panelLayout = new BorderLayout();
|
||||
private CTabbedPane tabPane = new CTabbedPane();
|
||||
private CPanel customizePane = new CPanel();
|
||||
private CPanel contextPane = new CPanel();
|
||||
private GridBagLayout customizeLayout = new GridBagLayout();
|
||||
private CCheckBox autoCommit = new CCheckBox();
|
||||
private CCheckBox autoNew = new CCheckBox();
|
||||
private CCheckBox printPreview = new CCheckBox();
|
||||
private CCheckBox validateConnectionOnStartup = new CCheckBox();
|
||||
private CCheckBox singleInstancePerWindow = new CCheckBox();
|
||||
private CCheckBox openWindowMaximized = new CCheckBox();
|
||||
private CPanel southPanel = new CPanel();
|
||||
private BorderLayout southLayout = new BorderLayout();
|
||||
private BorderLayout icontextLayout = new BorderLayout();
|
||||
private JList infoList = new JList();
|
||||
private JScrollPane contextListScrollPane = new JScrollPane(infoList);
|
||||
private CPanel contextSouthPanel = new CPanel();
|
||||
private CTextArea contextHeader = new CTextArea(4,15);
|
||||
private CTextArea contextDetail = new CTextArea(4,35);
|
||||
private CTextArea infoArea = new CTextArea(5, 30);
|
||||
private BorderLayout contextSouthLayout = new BorderLayout();
|
||||
private StatusBar statusBar = new StatusBar();
|
||||
private ConfirmPanel confirm = new ConfirmPanel(true);
|
||||
private CComboBox traceLevel = new CComboBox(CLogMgt.LEVELS);
|
||||
private CLabel traceLabel = new CLabel();
|
||||
private CCheckBox traceFile = new CCheckBox();
|
||||
private CCheckBox autoLogin = new CCheckBox();
|
||||
private CCheckBox adempiereSys = new CCheckBox();
|
||||
private CCheckBox storePassword = new CCheckBox();
|
||||
private CCheckBox showTrl = new CCheckBox();
|
||||
private CCheckBox showAcct = new CCheckBox();
|
||||
private CCheckBox showAdvanced = new CCheckBox();
|
||||
private CCheckBox cacheWindow = new CCheckBox();
|
||||
private CButton uiTheme = new CButton();
|
||||
private CLabel lPrinter = new CLabel();
|
||||
private CPrinter fPrinter = new CPrinter();
|
||||
private CLabel lDate = new CLabel();
|
||||
private VDate fDate = new VDate();
|
||||
private CComboBox connectionProfile = new CComboBox(CConnection.CONNECTIONProfiles);
|
||||
private CLabel connectionProfileLabel = new CLabel();
|
||||
private CPanel errorPane = new CPanel();
|
||||
private BorderLayout errorLayout = new BorderLayout();
|
||||
private JScrollPane errorScrollPane = new JScrollPane();
|
||||
private MiniTable errorTable = new MiniTable();
|
||||
private CPanel errorPanel = new CPanel(new FlowLayout(FlowLayout.TRAILING));
|
||||
private CToggleButton bErrorsOnly = new CToggleButton(Msg.getMsg(Env.getCtx(), "ErrorsOnly"));
|
||||
private CButton bErrorReset = new CButton(Msg.getMsg(Env.getCtx(), "Reset"));
|
||||
private CButton bErrorEMail = new CButton(Msg.getMsg(Env.getCtx(), "SendEMail"));
|
||||
private CButton bErrorSave = new CButton(Msg.getMsg(Env.getCtx(), "SaveFile"));
|
||||
private CButton bRoleInfo = new CButton(Msg.translate(Env.getCtx(), "AD_Role_ID"));
|
||||
|
||||
private CPanel configPanel = new CPanel();
|
||||
|
||||
private PLAFEditorPanel plafEditor = new PLAFEditorPanel();
|
||||
|
||||
/**
|
||||
* Static Init.
|
||||
* <pre>
|
||||
* - panel
|
||||
* - tabPane
|
||||
* - customizePane
|
||||
* - infoArea
|
||||
* - fields ...
|
||||
* - contextPane
|
||||
* - contextList
|
||||
* - contextSouthPanel
|
||||
* - contextHeader
|
||||
* - contextDetail
|
||||
* - errorPane
|
||||
* - errorScollPane
|
||||
* - errorTable
|
||||
* - southPanel
|
||||
* </pre>
|
||||
* @throws Exception
|
||||
*/
|
||||
void jbInit() throws Exception
|
||||
{
|
||||
traceLabel.setRequestFocusEnabled(false);
|
||||
traceLabel.setText(Msg.getMsg(Env.getCtx(), "TraceLevel", true));
|
||||
traceLabel.setToolTipText(Msg.getMsg(Env.getCtx(), "TraceLevel", false));
|
||||
traceFile.setText(Msg.getMsg(Env.getCtx(), "TraceFile", true));
|
||||
traceFile.setToolTipText(Msg.getMsg(Env.getCtx(), "TraceFile", false));
|
||||
|
||||
uiTheme.setText(Msg.getMsg(Env.getCtx(), "UITheme", true));
|
||||
uiTheme.setToolTipText(Msg.getMsg(Env.getCtx(), "UITheme", false));
|
||||
autoCommit.setText(Msg.getMsg(Env.getCtx(), "AutoCommit", true));
|
||||
autoCommit.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoCommit", false));
|
||||
autoNew.setText(Msg.getMsg(Env.getCtx(), "AutoNew", true));
|
||||
autoNew.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoNew", false));
|
||||
adempiereSys.setText(Msg.getMsg(Env.getCtx(), "AdempiereSys", true));
|
||||
adempiereSys.setToolTipText(Msg.getMsg(Env.getCtx(), "AdempiereSys", false));
|
||||
printPreview.setText(Msg.getMsg(Env.getCtx(), "AlwaysPrintPreview", true));
|
||||
printPreview.setToolTipText(Msg.getMsg(Env.getCtx(), "AlwaysPrintPreview", false));
|
||||
validateConnectionOnStartup.setText(Msg.getMsg(Env.getCtx(), "ValidateConnectionOnStartup", true));
|
||||
validateConnectionOnStartup.setToolTipText(Msg.getMsg(Env.getCtx(), "ValidateConnectionOnStartup", false));
|
||||
singleInstancePerWindow.setText(Msg.getMsg(Env.getCtx(), "SingleInstancePerWindow", true));
|
||||
singleInstancePerWindow.setToolTipText(Msg.getMsg(Env.getCtx(), "SingleInstancePerWindow", false));
|
||||
openWindowMaximized.setText(Msg.getMsg(Env.getCtx(), "OpenWindowMaximized", true));
|
||||
openWindowMaximized.setToolTipText(Msg.getMsg(Env.getCtx(), "OpenWindowMaximized", false));
|
||||
autoLogin.setText(Msg.getMsg(Env.getCtx(), "AutoLogin", true));
|
||||
autoLogin.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoLogin", false));
|
||||
storePassword.setText(Msg.getMsg(Env.getCtx(), "StorePassword", true));
|
||||
storePassword.setToolTipText(Msg.getMsg(Env.getCtx(), "StorePassword", false));
|
||||
showTrl.setText(Msg.getMsg(Env.getCtx(), "ShowTrlTab", true));
|
||||
showTrl.setToolTipText(Msg.getMsg(Env.getCtx(), "ShowTrlTab", false));
|
||||
showAcct.setText(Msg.getMsg(Env.getCtx(), "ShowAcctTab", true));
|
||||
showAcct.setToolTipText(Msg.getMsg(Env.getCtx(), "ShowAcctTab", false));
|
||||
showAdvanced.setText(Msg.getMsg(Env.getCtx(), "ShowAdvancedTab", true));
|
||||
showAdvanced.setToolTipText(Msg.getMsg(Env.getCtx(), "ShowAdvancedTab", false));
|
||||
connectionProfileLabel.setText(Msg.getElement(Env.getCtx(), "ConnectionProfile"));
|
||||
cacheWindow.setText(Msg.getMsg(Env.getCtx(), "CacheWindow", true));
|
||||
cacheWindow.setToolTipText(Msg.getMsg(Env.getCtx(), "CacheWindow", false));
|
||||
lPrinter.setText(Msg.getMsg(Env.getCtx(), "Printer"));
|
||||
lDate.setText(Msg.getMsg(Env.getCtx(), "Date"));
|
||||
infoArea.setReadWrite(false);
|
||||
getContentPane().add(panel);
|
||||
panel.setLayout(panelLayout);
|
||||
panel.add(tabPane, BorderLayout.CENTER);
|
||||
// Customize
|
||||
// tabPane.add(customizePane, Msg.getMsg(Env.getCtx(), "Preference"));
|
||||
tabPane.add(customizePane, Msg.getMsg(Env.getCtx(), "Preference"));
|
||||
customizePane.setLayout(customizeLayout);
|
||||
customizePane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
||||
Border insetBorder = BorderFactory.createEmptyBorder(2, 2, 2, 0);
|
||||
CPanel loginPanel = new CPanel();
|
||||
loginPanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "Login")));
|
||||
loginPanel.setLayout(new GridLayout(1, 2));
|
||||
autoLogin.setBorder(insetBorder);
|
||||
storePassword.setBorder(insetBorder);
|
||||
loginPanel.add(autoLogin);
|
||||
loginPanel.add(storePassword);
|
||||
customizePane.add(loginPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
|
||||
|
||||
CPanel windowPanel = new CPanel();
|
||||
windowPanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "Window")));
|
||||
windowPanel.setLayout(new GridLayout(4, 2));
|
||||
windowPanel.add(showAcct);showAcct.setBorder(insetBorder);
|
||||
windowPanel.add(showTrl);showTrl.setBorder(insetBorder);
|
||||
windowPanel.add(showAdvanced);showAdvanced.setBorder(insetBorder);
|
||||
windowPanel.add(autoCommit);autoCommit.setBorder(insetBorder);
|
||||
windowPanel.add(autoNew);autoNew.setBorder(insetBorder);
|
||||
windowPanel.add(cacheWindow);cacheWindow.setBorder(insetBorder);
|
||||
windowPanel.add(openWindowMaximized);openWindowMaximized.setBorder(insetBorder);
|
||||
windowPanel.add(singleInstancePerWindow);singleInstancePerWindow.setBorder(insetBorder);
|
||||
customizePane.add(windowPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
|
||||
|
||||
CPanel connPanel = new CPanel();
|
||||
connPanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "Connection")));
|
||||
connPanel.setLayout(new GridBagLayout());
|
||||
connPanel.add(connectionProfileLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
connPanel.add(connectionProfile, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
connPanel.add(validateConnectionOnStartup, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
customizePane.add(connPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
|
||||
|
||||
CPanel tracePanel = new CPanel();
|
||||
tracePanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "TraceInfo")));
|
||||
tracePanel.setLayout(new GridBagLayout());
|
||||
tracePanel.add(traceLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
tracePanel.add(traceLevel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
tracePanel.add(traceFile, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
customizePane.add(tracePanel, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
|
||||
|
||||
CPanel printPanel = new CPanel();
|
||||
printPanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "Printing")));
|
||||
printPanel.setLayout(new GridBagLayout());
|
||||
printPanel.add(lPrinter, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
printPanel.add(fPrinter, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
printPanel.add(printPreview, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
|
||||
customizePane.add(printPanel, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
|
||||
|
||||
CPanel otherPanel = new CPanel();
|
||||
otherPanel.setBorder(BorderFactory.createEmptyBorder());
|
||||
otherPanel.setLayout(new GridLayout());
|
||||
CPanel datePanel = new CPanel();
|
||||
datePanel.setLayout(new FlowLayout());
|
||||
((FlowLayout)datePanel.getLayout()).setAlignment(FlowLayout.LEFT);
|
||||
datePanel.add(lDate);
|
||||
datePanel.add(fDate);
|
||||
otherPanel.add(datePanel);datePanel.setBorder(insetBorder);
|
||||
otherPanel.add(adempiereSys);adempiereSys.setBorder(insetBorder);
|
||||
customizePane.add(otherPanel, new GridBagConstraints(0, 5, 1, 1, 1.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0));
|
||||
|
||||
CPanel themePanel = new CPanel();
|
||||
themePanel.setLayout(new GridLayout(1, 1));
|
||||
|
||||
themePanel.add(plafEditor);
|
||||
tabPane.add(themePanel, Msg.getMsg(Env.getCtx(), "UITheme", true));
|
||||
|
||||
configPanel.setLayout(new BorderLayout());
|
||||
configPanel.add(infoArea, BorderLayout.CENTER);
|
||||
CPanel configSouth = new CPanel();
|
||||
configSouth.setLayout(new FlowLayout());
|
||||
((FlowLayout)configSouth.getLayout()).setAlignment(FlowLayout.RIGHT);
|
||||
configSouth.add(bRoleInfo);
|
||||
configPanel.add(configSouth, BorderLayout.SOUTH);
|
||||
tabPane.add(configPanel, Msg.getMsg(Env.getCtx(), "Info"));
|
||||
|
||||
customizePane.add(lDate, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0
|
||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||
customizePane.add(fDate, new GridBagConstraints(1, 9, 2, 1, 0.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||
customizePane.add(printPreview, new GridBagConstraints(2, 9, 1, 1, 0.0, 0.0
|
||||
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||
// Info
|
||||
// tabPane.add(contextPane, Msg.getMsg(Env.getCtx(), "Context"));
|
||||
tabPane.add(contextPane, Msg.getMsg(Env.getCtx(), "Context"));
|
||||
contextPane.setLayout(icontextLayout);
|
||||
contextPane.add(contextListScrollPane, BorderLayout.CENTER);
|
||||
contextListScrollPane.setPreferredSize(new Dimension(200, 300));
|
||||
infoList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||
infoList.setBackground(AdempierePLAF.getFieldBackground_Inactive());
|
||||
infoList.addListSelectionListener(this);
|
||||
infoList.setFixedCellWidth(30);
|
||||
contextPane.add(contextSouthPanel, BorderLayout.SOUTH);
|
||||
contextSouthPanel.setLayout(contextSouthLayout);
|
||||
contextSouthPanel.add(contextHeader, BorderLayout.WEST);
|
||||
contextHeader.setBackground(SystemColor.info);
|
||||
contextHeader.setReadWrite(false);
|
||||
contextHeader.setLineWrap(true);
|
||||
contextHeader.setWrapStyleWord(true);
|
||||
contextHeader.setBorder(BorderFactory.createLoweredBevelBorder());
|
||||
contextSouthPanel.add(contextDetail, BorderLayout.CENTER);
|
||||
contextDetail.setBackground(SystemColor.info);
|
||||
contextDetail.setReadWrite(false);
|
||||
contextDetail.setLineWrap(true);
|
||||
contextDetail.setWrapStyleWord(true);
|
||||
contextDetail.setBorder(BorderFactory.createLoweredBevelBorder());
|
||||
// Error Pane
|
||||
errorPane.setLayout(errorLayout);
|
||||
// tabPane.add(errorPane, Msg.getMsg(Env.getCtx(), "Errors"));
|
||||
tabPane.add(errorPane, "Errors");
|
||||
errorPane.add(errorScrollPane, BorderLayout.CENTER);
|
||||
errorScrollPane.getViewport().add(errorTable, null);
|
||||
//
|
||||
errorPanel.add(bErrorsOnly);
|
||||
errorPanel.add(bErrorReset);
|
||||
errorPanel.add(bErrorEMail);
|
||||
errorPanel.add(bErrorSave);
|
||||
errorPane.add(errorPanel, BorderLayout.SOUTH);
|
||||
// South
|
||||
panel.add(southPanel, BorderLayout.SOUTH);
|
||||
southPanel.setLayout(southLayout);
|
||||
southPanel.add(statusBar, BorderLayout.SOUTH);
|
||||
southPanel.add(confirm, BorderLayout.CENTER);
|
||||
//
|
||||
bRoleInfo.addActionListener(this);
|
||||
confirm.addActionListener(this);
|
||||
} // jbInit
|
||||
|
||||
|
||||
/**
|
||||
* List Selection Listener - show info in header/detail fields
|
||||
* @param e evant
|
||||
*/
|
||||
public void valueChanged(ListSelectionEvent e)
|
||||
{
|
||||
if (e.getValueIsAdjusting())
|
||||
return;
|
||||
|
||||
String value = (String)infoList.getSelectedValue();
|
||||
if (value == null)
|
||||
return;
|
||||
int pos = value.indexOf("==");
|
||||
if (pos == -1)
|
||||
{
|
||||
contextHeader.setText("");
|
||||
contextDetail.setText(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
contextHeader.setText(value.substring(0, pos).replace('|','\n'));
|
||||
contextDetail.setText(value.substring(pos+3));
|
||||
}
|
||||
} // valueChanged
|
||||
|
||||
|
||||
/**
|
||||
* ActionListener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
// UI Change
|
||||
/*if (e.getSource() == uiTheme)
|
||||
{
|
||||
new AdempierePLAFEditor(this, false);
|
||||
}
|
||||
else */ if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
|
||||
dispose();
|
||||
else if (e.getActionCommand().equals(ConfirmPanel.A_OK))
|
||||
cmd_save();
|
||||
//
|
||||
else if (e.getSource() == bErrorsOnly)
|
||||
cmd_displayErrors();
|
||||
else if (e.getSource() == bErrorReset)
|
||||
cmd_errorReset();
|
||||
else if (e.getSource() == bErrorEMail)
|
||||
cmd_errorEMail();
|
||||
else if (e.getSource() == bErrorSave)
|
||||
cmd_errorSave();
|
||||
//
|
||||
else if (e.getSource() == bRoleInfo)
|
||||
ADialog.info(0, this, "RoleInfo", MRole.getDefault().toStringX(Env.getCtx()));
|
||||
} // actionPerformed
|
||||
|
||||
|
||||
/**
|
||||
* Load Settings - and Context
|
||||
*/
|
||||
private void load()
|
||||
{
|
||||
log.config("");
|
||||
infoArea.setText(CLogMgt.getInfo(null).toString());
|
||||
infoArea.setCaretPosition(0);
|
||||
|
||||
// -- Load Settings --
|
||||
// UI
|
||||
uiTheme.addActionListener(this);
|
||||
// AutoCommit
|
||||
autoCommit.setSelected(Env.isAutoCommit(Env.getCtx()));
|
||||
autoNew.setSelected(Env.isAutoNew(Env.getCtx()));
|
||||
// AdempiereSys
|
||||
adempiereSys.setSelected(Ini.isPropertyBool(Ini.P_ADEMPIERESYS));
|
||||
if (Env.getAD_Client_ID(Env.getCtx()) > 20)
|
||||
{
|
||||
adempiereSys.setSelected(false);
|
||||
adempiereSys.setEnabled(false);
|
||||
}
|
||||
// AutoLogin
|
||||
autoLogin.setSelected(Ini.isPropertyBool(Ini.P_A_LOGIN));
|
||||
// Save Password
|
||||
storePassword.setSelected(Ini.isPropertyBool(Ini.P_STORE_PWD));
|
||||
// Show Acct Tab
|
||||
if (MRole.getDefault().isShowAcct())
|
||||
showAcct.setSelected(Ini.isPropertyBool(Ini.P_SHOW_ACCT));
|
||||
else
|
||||
{
|
||||
showAcct.setSelected(false);
|
||||
showAcct.setReadWrite(false);
|
||||
}
|
||||
// Show Trl/Advanced Tab
|
||||
showTrl.setSelected(Ini.isPropertyBool(Ini.P_SHOW_TRL));
|
||||
showAdvanced.setSelected(Ini.isPropertyBool(Ini.P_SHOW_ADVANCED));
|
||||
|
||||
// Connection Profile
|
||||
MUser user = MUser.get(Env.getCtx());
|
||||
String cp = user.getConnectionProfile();
|
||||
if (cp == null)
|
||||
cp = MRole.getDefault().getConnectionProfile();
|
||||
if (cp != null)
|
||||
{
|
||||
CConnection.get().setConnectionProfile(cp);
|
||||
connectionProfile.setReadWrite(false);
|
||||
}
|
||||
connectionProfile.setSelectedItem(CConnection.get().getConnectionProfilePair());
|
||||
cacheWindow.setSelected(Ini.isCacheWindow());
|
||||
|
||||
// Print Preview
|
||||
printPreview.setSelected(Ini.isPropertyBool(Ini.P_PRINTPREVIEW));
|
||||
|
||||
// Validate Connection on Startup
|
||||
validateConnectionOnStartup.setSelected(Ini.isPropertyBool(Ini.P_VALIDATE_CONNECTION_ON_STARTUP));
|
||||
|
||||
// Single Instance per Window
|
||||
singleInstancePerWindow.setSelected(Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW));
|
||||
|
||||
// Open Window Maximized
|
||||
openWindowMaximized.setSelected(Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED));
|
||||
|
||||
// TraceLevel
|
||||
traceLevel.setSelectedItem(CLogMgt.getLevel());
|
||||
traceFile.setSelected(Ini.isPropertyBool(Ini.P_TRACEFILE));
|
||||
// Printer
|
||||
fPrinter.setValue(Env.getContext(Env.getCtx(), "#Printer"));
|
||||
// Date
|
||||
fDate.setValue(Env.getContextAsDate(Env.getCtx(), "#Date"));
|
||||
|
||||
// -- Load and sort Context --
|
||||
String[] context = Env.getEntireContext(Env.getCtx());
|
||||
Arrays.sort(context);
|
||||
infoList.setListData(context);
|
||||
|
||||
// Load Errors
|
||||
// CLogMgt mgt = new CLogMgt(); // creates test trace
|
||||
bErrorsOnly.setSelected(true);
|
||||
errorTable.setCellSelectionEnabled(true);
|
||||
cmd_displayErrors();
|
||||
// for (int i = 2; i < 6; i++)
|
||||
// errorTable.setColumnReadOnly(i, false);
|
||||
//
|
||||
bErrorsOnly.addActionListener(this);
|
||||
bErrorReset.addActionListener(this);
|
||||
bErrorSave.addActionListener(this);
|
||||
bErrorEMail.addActionListener(this);
|
||||
} // load
|
||||
|
||||
/**
|
||||
* Save Settings
|
||||
*/
|
||||
private void cmd_save()
|
||||
{
|
||||
log.config("");
|
||||
// UI
|
||||
// AutoCommit
|
||||
Ini.setProperty(Ini.P_A_COMMIT, (autoCommit.isSelected()));
|
||||
Env.setAutoCommit(Env.getCtx(), autoCommit.isSelected());
|
||||
Ini.setProperty(Ini.P_A_NEW, (autoNew.isSelected()));
|
||||
Env.setAutoNew(Env.getCtx(), autoNew.isSelected());
|
||||
// AdempiereSys
|
||||
Ini.setProperty(Ini.P_ADEMPIERESYS, adempiereSys.isSelected());
|
||||
// AutoLogin
|
||||
Ini.setProperty(Ini.P_A_LOGIN, (autoLogin.isSelected()));
|
||||
// Save Password
|
||||
Ini.setProperty(Ini.P_STORE_PWD, (storePassword.isSelected()));
|
||||
// Show Acct Tab
|
||||
Ini.setProperty(Ini.P_SHOW_ACCT, (showAcct.isSelected()));
|
||||
Env.setContext(Env.getCtx(), "#ShowAcct", (showAcct.isSelected()));
|
||||
// Show Trl Tab
|
||||
Ini.setProperty(Ini.P_SHOW_TRL, (showTrl.isSelected()));
|
||||
Env.setContext(Env.getCtx(), "#ShowTrl", (showTrl.isSelected()));
|
||||
// Show Advanced Tab
|
||||
Ini.setProperty(Ini.P_SHOW_ADVANCED, (showAdvanced.isSelected()));
|
||||
Env.setContext(Env.getCtx(), "#ShowAdvanced", (showAdvanced.isSelected()));
|
||||
|
||||
// ConnectionProfile
|
||||
ValueNamePair ppNew = (ValueNamePair)connectionProfile.getSelectedItem();
|
||||
String cpNew = ppNew.getValue();
|
||||
String cpOld = CConnection.get().getConnectionProfile();
|
||||
CConnection.get().setConnectionProfile(cpNew);
|
||||
if (!cpNew.equals(cpOld)
|
||||
&& (cpNew.equals(CConnection.PROFILE_WAN) || cpOld.equals(CConnection.PROFILE_WAN)))
|
||||
ADialog.info(0, this, "ConnectionProfileChange");
|
||||
Ini.setProperty(Ini.P_CACHE_WINDOW, cacheWindow.isSelected());
|
||||
|
||||
// Print Preview
|
||||
Ini.setProperty(Ini.P_PRINTPREVIEW, (printPreview.isSelected()));
|
||||
// Validate Connection on Startup
|
||||
Ini.setProperty(Ini.P_VALIDATE_CONNECTION_ON_STARTUP, (validateConnectionOnStartup.isSelected()));
|
||||
// Single Instance per Window
|
||||
Ini.setProperty(Ini.P_SINGLE_INSTANCE_PER_WINDOW, (singleInstancePerWindow.isSelected()));
|
||||
// Open Window Maximized
|
||||
Ini.setProperty(Ini.P_OPEN_WINDOW_MAXIMIZED, (openWindowMaximized.isSelected()));
|
||||
// TraceLevel/File
|
||||
Level level = (Level)traceLevel.getSelectedItem();
|
||||
CLogMgt.setLevel(level);
|
||||
Ini.setProperty(Ini.P_TRACELEVEL, level.getName());
|
||||
Ini.setProperty(Ini.P_TRACEFILE, traceFile.isSelected());
|
||||
// Printer
|
||||
String printer = (String)fPrinter.getSelectedItem();
|
||||
Env.setContext(Env.getCtx(), "#Printer", printer);
|
||||
Ini.setProperty(Ini.P_PRINTER, printer);
|
||||
// Date (remove seconds)
|
||||
java.sql.Timestamp ts = (java.sql.Timestamp)fDate.getValue();
|
||||
if (ts != null)
|
||||
Env.setContext(Env.getCtx(), "#Date", ts);
|
||||
|
||||
//UI
|
||||
ValueNamePair laf = plafEditor.getSelectedLook();
|
||||
ValueNamePair theme = plafEditor.getSelectedTheme();
|
||||
if ( laf != null ) {
|
||||
String clazz = laf.getValue();
|
||||
String currentLaf = UIManager.getLookAndFeel().getClass().getName();
|
||||
if (clazz != null && clazz.length() > 0 && !currentLaf.equals(clazz))
|
||||
{
|
||||
//laf changed
|
||||
AdempierePLAF.setPLAF(laf, theme, true);
|
||||
//AEnv.updateUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel)
|
||||
{
|
||||
MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme();
|
||||
String themeClass = currentTheme.getClass().getName();
|
||||
String sTheme = theme.getValue();
|
||||
if (sTheme != null && sTheme.length() > 0 && !sTheme.equals(themeClass))
|
||||
{
|
||||
ValueNamePair plaf = new ValueNamePair(
|
||||
UIManager.getLookAndFeel().getClass().getName(),
|
||||
UIManager.getLookAndFeel().getName());
|
||||
AdempierePLAF.setPLAF(plaf, theme, true);
|
||||
//AEnv.updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ini.saveProperties(Ini.isClient());
|
||||
dispose();
|
||||
} // cmd_save
|
||||
|
||||
/**
|
||||
* (Re)Display Errors
|
||||
*/
|
||||
private void cmd_displayErrors()
|
||||
{
|
||||
Vector data = CLogErrorBuffer.get(true).getLogData(bErrorsOnly.isSelected());
|
||||
Vector columnNames = CLogErrorBuffer.get(true).getColumnNames(Env.getCtx());
|
||||
DefaultTableModel model = new DefaultTableModel(data, columnNames);
|
||||
errorTable.setModel(model);
|
||||
//
|
||||
if (bErrorsOnly.isSelected())
|
||||
tabPane.setTitleAt(2, Msg.getMsg(Env.getCtx(), "Errors") + " (" + data.size() + ")");
|
||||
else
|
||||
tabPane.setTitleAt(2, Msg.getMsg(Env.getCtx(), "TraceInfo") + " (" + data.size() + ")");
|
||||
errorTable.autoSize();
|
||||
} // cmd_errorsOnly
|
||||
|
||||
/**
|
||||
* Reset Errors
|
||||
*/
|
||||
private void cmd_errorReset()
|
||||
{
|
||||
CLogErrorBuffer.get(true).resetBuffer(bErrorsOnly.isSelected());
|
||||
cmd_displayErrors();
|
||||
} // cmd_errorReset
|
||||
|
||||
/**
|
||||
* EMail Errors
|
||||
*/
|
||||
private void cmd_errorEMail()
|
||||
{
|
||||
EMailDialog emd = new EMailDialog(this,
|
||||
"EMail Trace",
|
||||
MUser.get(Env.getCtx()),
|
||||
"", // to
|
||||
"Adempiere Trace Info",
|
||||
CLogErrorBuffer.get(true).getErrorInfo(Env.getCtx(), bErrorsOnly.isSelected()),
|
||||
null);
|
||||
|
||||
} // cmd_errorEMail
|
||||
|
||||
/**
|
||||
* Save Error to File
|
||||
*/
|
||||
private void cmd_errorSave()
|
||||
{
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setDialogType(JFileChooser.SAVE_DIALOG);
|
||||
chooser.setDialogTitle("Adempiere Trace File");
|
||||
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
chooser.setSelectedFile(new File ("traceInfo.log"));
|
||||
int returnVal = chooser.showSaveDialog(this);
|
||||
if(returnVal != JFileChooser.APPROVE_OPTION)
|
||||
return;
|
||||
try
|
||||
{
|
||||
File file = chooser.getSelectedFile();
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write(CLogErrorBuffer.get(true).getErrorInfo(Env.getCtx(), bErrorsOnly.isSelected()));
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // cmd_errorSave
|
||||
|
||||
} // Preference
|
|
@ -548,7 +548,7 @@ public final class Preference extends CDialog
|
|||
{
|
||||
//laf changed
|
||||
AdempierePLAF.setPLAF(laf, theme, true);
|
||||
AEnv.updateUI();
|
||||
//AEnv.updateUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -563,7 +563,7 @@ public final class Preference extends CDialog
|
|||
UIManager.getLookAndFeel().getClass().getName(),
|
||||
UIManager.getLookAndFeel().getName());
|
||||
AdempierePLAF.setPLAF(plaf, theme, true);
|
||||
AEnv.updateUI();
|
||||
//AEnv.updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,89 +3,89 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.rmi.*;
|
||||
import java.sql.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
import org.compiere.db.*;
|
||||
import org.compiere.interfaces.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.print.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.wf.*;
|
||||
|
||||
/**
|
||||
* Process Interface Controller.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ProcessCtl.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class ProcessCtl extends Thread
|
||||
{
|
||||
/**
|
||||
* Async Process - Do it all.
|
||||
* <code>
|
||||
* - Get Instance ID
|
||||
* - Get Parameters
|
||||
* - execute (lock - start process - unlock)
|
||||
* </code>
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.rmi.*;
|
||||
import java.sql.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
import org.compiere.db.*;
|
||||
import org.compiere.interfaces.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.print.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.wf.*;
|
||||
|
||||
/**
|
||||
* Process Interface Controller.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ProcessCtl.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class ProcessCtl extends Thread
|
||||
{
|
||||
/**
|
||||
* Async Process - Do it all.
|
||||
* <code>
|
||||
* - Get Instance ID
|
||||
* - Get Parameters
|
||||
* - execute (lock - start process - unlock)
|
||||
* </code>
|
||||
* Creates a ProcessCtl instance, which calls
|
||||
* lockUI and unlockUI if parent is a ASyncProcess
|
||||
* <br>
|
||||
* Called from ProcessCtl.startProcess, APanel.cmd_print,
|
||||
* APanel.actionButton, VPaySelect.cmd_generate
|
||||
* Called from ProcessCtl.startProcess, ProcessDialog.actionPerformed,
|
||||
* APanel.cmd_print, APanel.actionButton, VPaySelect.cmd_generate
|
||||
*
|
||||
* @param parent ASyncProcess & Container
|
||||
* @param WindowNo window no
|
||||
* @param pi ProcessInfo process info
|
||||
* @param trx Transaction
|
||||
* @return worker started ProcessCtl instance or null for workflow
|
||||
*/
|
||||
public static ProcessCtl process (ASyncProcess parent, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||
|
||||
MPInstance instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID());
|
||||
if (!instance.save())
|
||||
{
|
||||
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
|
||||
pi.setError (true);
|
||||
return null;
|
||||
}
|
||||
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
|
||||
|
||||
// Get Parameters (Dialog)
|
||||
ProcessParameter para = new ProcessParameter (Env.getFrame((Container)parent), WindowNo, pi);
|
||||
if (para.initDialog())
|
||||
{
|
||||
para.setVisible(true);
|
||||
if (!para.isOK())
|
||||
{
|
||||
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled"));
|
||||
pi.setError (true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// execute
|
||||
ProcessCtl worker = new ProcessCtl(parent, pi, trx);
|
||||
* @param pi ProcessInfo process info
|
||||
* @param trx Transaction
|
||||
* @return worker started ProcessCtl instance or null for workflow
|
||||
*/
|
||||
public static ProcessCtl process (ASyncProcess parent, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||
|
||||
MPInstance instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID());
|
||||
if (!instance.save())
|
||||
{
|
||||
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
|
||||
pi.setError (true);
|
||||
return null;
|
||||
}
|
||||
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
|
||||
|
||||
// Get Parameters (Dialog)
|
||||
ProcessParameter para = new ProcessParameter (Env.getFrame((Container)parent), WindowNo, pi);
|
||||
if (para.initDialog())
|
||||
{
|
||||
para.setVisible(true);
|
||||
if (!para.isOK())
|
||||
{
|
||||
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled"));
|
||||
pi.setError (true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// execute
|
||||
ProcessCtl worker = new ProcessCtl(parent, pi, trx);
|
||||
worker.start(); // MUST be start!
|
||||
return worker;
|
||||
} // execute
|
||||
|
@ -138,303 +138,303 @@ public class ProcessCtl extends Thread
|
|||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Constructor
|
||||
* @param parent Container & ASyncProcess
|
||||
* @param pi Process info
|
||||
* @param trx Transaction
|
||||
* Created in process(), VInvoiceGen.generateInvoices
|
||||
*/
|
||||
public ProcessCtl (ASyncProcess parent, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
m_parent = parent;
|
||||
m_pi = pi;
|
||||
m_trx = trx; // handeled correctly
|
||||
} // ProcessCtl
|
||||
|
||||
private ASyncProcess m_parent;
|
||||
private ProcessInfo m_pi;
|
||||
private Trx m_trx;
|
||||
private Waiting m_waiting;
|
||||
private boolean m_IsServerProcess = false;
|
||||
|
||||
/** Static Logger */
|
||||
private static CLogger log = CLogger.getCLogger (ProcessCtl.class);
|
||||
|
||||
/**
|
||||
* 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(Env.getCtx(), "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(Env.getCtx()) + "') "
|
||||
+ "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(Env.getCtx(), "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(Env.getCtx(), "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
|
||||
|
||||
/**
|
||||
* Lock UI & show Waiting
|
||||
*/
|
||||
private void lock ()
|
||||
{
|
||||
// log.info("...");
|
||||
JFrame frame = Env.getFrame((Container)m_parent);
|
||||
if (frame instanceof AWindow)
|
||||
((AWindow)frame).setBusyTimer(m_pi.getEstSeconds());
|
||||
else
|
||||
m_waiting = new Waiting (frame, Msg.getMsg(Env.getCtx(), "Processing"), false, m_pi.getEstSeconds());
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
log.finer("lock");
|
||||
m_parent.lockUI(m_pi);
|
||||
}
|
||||
});
|
||||
if (m_waiting != null)
|
||||
{
|
||||
m_waiting.toFront();
|
||||
m_waiting.setVisible(true);
|
||||
}
|
||||
} // lock
|
||||
|
||||
/**
|
||||
* Unlock UI & dispose Waiting.
|
||||
* Called from run()
|
||||
*/
|
||||
private void unlock ()
|
||||
{
|
||||
// log.info("...");
|
||||
if (m_pi.isBatch())
|
||||
m_pi.setIsTimeout(true);
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
String summary = m_pi.getSummary();
|
||||
log.finer("unlock - " + summary);
|
||||
if (summary != null && summary.indexOf("@") != -1)
|
||||
m_pi.setSummary(Msg.parseTranslation(Env.getCtx(), summary));
|
||||
m_parent.unlockUI(m_pi);
|
||||
}
|
||||
});
|
||||
// Remove Waiting/Processing Indicator
|
||||
if (m_waiting != null)
|
||||
m_waiting.dispose();
|
||||
m_waiting = null;
|
||||
} // unlock
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Start Workflow.
|
||||
*
|
||||
* @param AD_Workflow_ID workflow
|
||||
* @return true if started
|
||||
*/
|
||||
private boolean startWorkflow (int AD_Workflow_ID)
|
||||
{
|
||||
log.fine(AD_Workflow_ID + " - " + m_pi);
|
||||
boolean started = false;
|
||||
if (DB.isRemoteProcess())
|
||||
{
|
||||
Server server = CConnection.get().getServer();
|
||||
try
|
||||
{
|
||||
if (server != null)
|
||||
{ // See ServerBean
|
||||
m_pi = server.workflow (Env.getCtx(), m_pi, AD_Workflow_ID);
|
||||
log.finest("server => " + m_pi);
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
catch (RemoteException ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
// Run locally
|
||||
if (!started && !m_IsServerProcess)
|
||||
{
|
||||
MWorkflow wf = MWorkflow.get (Env.getCtx(), AD_Workflow_ID);
|
||||
MWFProcess wfProcess = null;
|
||||
if (m_pi.isBatch())
|
||||
wfProcess = wf.start(m_pi); // may return null
|
||||
else
|
||||
wfProcess = wf.startWait(m_pi); // may return null
|
||||
started = wfProcess != null;
|
||||
}
|
||||
return started;
|
||||
} // startWorkflow
|
||||
|
||||
/**************************************************************************
|
||||
/**************************************************************************
|
||||
* Constructor
|
||||
* @param parent Container & ASyncProcess
|
||||
* @param pi Process info
|
||||
* @param trx Transaction
|
||||
* Created in process(), VInvoiceGen.generateInvoices
|
||||
*/
|
||||
public ProcessCtl (ASyncProcess parent, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
m_parent = parent;
|
||||
m_pi = pi;
|
||||
m_trx = trx; // handeled correctly
|
||||
} // ProcessCtl
|
||||
|
||||
private ASyncProcess m_parent;
|
||||
private ProcessInfo m_pi;
|
||||
private Trx m_trx;
|
||||
private Waiting m_waiting;
|
||||
private boolean m_IsServerProcess = false;
|
||||
|
||||
/** Static Logger */
|
||||
private static CLogger log = CLogger.getCLogger (ProcessCtl.class);
|
||||
|
||||
/**
|
||||
* 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(Env.getCtx(), "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(Env.getCtx()) + "') "
|
||||
+ "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(Env.getCtx(), "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(Env.getCtx(), "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
|
||||
|
||||
/**
|
||||
* Lock UI & show Waiting
|
||||
*/
|
||||
private void lock ()
|
||||
{
|
||||
// log.info("...");
|
||||
JFrame frame = Env.getFrame((Container)m_parent);
|
||||
if (frame instanceof AWindow)
|
||||
((AWindow)frame).setBusyTimer(m_pi.getEstSeconds());
|
||||
else
|
||||
m_waiting = new Waiting (frame, Msg.getMsg(Env.getCtx(), "Processing"), false, m_pi.getEstSeconds());
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
log.finer("lock");
|
||||
m_parent.lockUI(m_pi);
|
||||
}
|
||||
});
|
||||
if (m_waiting != null)
|
||||
{
|
||||
m_waiting.toFront();
|
||||
m_waiting.setVisible(true);
|
||||
}
|
||||
} // lock
|
||||
|
||||
/**
|
||||
* Unlock UI & dispose Waiting.
|
||||
* Called from run()
|
||||
*/
|
||||
private void unlock ()
|
||||
{
|
||||
// log.info("...");
|
||||
if (m_pi.isBatch())
|
||||
m_pi.setIsTimeout(true);
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
String summary = m_pi.getSummary();
|
||||
log.finer("unlock - " + summary);
|
||||
if (summary != null && summary.indexOf("@") != -1)
|
||||
m_pi.setSummary(Msg.parseTranslation(Env.getCtx(), summary));
|
||||
m_parent.unlockUI(m_pi);
|
||||
}
|
||||
});
|
||||
// Remove Waiting/Processing Indicator
|
||||
if (m_waiting != null)
|
||||
m_waiting.dispose();
|
||||
m_waiting = null;
|
||||
} // unlock
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Start Workflow.
|
||||
*
|
||||
* @param AD_Workflow_ID workflow
|
||||
* @return true if started
|
||||
*/
|
||||
private boolean startWorkflow (int AD_Workflow_ID)
|
||||
{
|
||||
log.fine(AD_Workflow_ID + " - " + m_pi);
|
||||
boolean started = false;
|
||||
if (DB.isRemoteProcess())
|
||||
{
|
||||
Server server = CConnection.get().getServer();
|
||||
try
|
||||
{
|
||||
if (server != null)
|
||||
{ // See ServerBean
|
||||
m_pi = server.workflow (Env.getCtx(), m_pi, AD_Workflow_ID);
|
||||
log.finest("server => " + m_pi);
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
catch (RemoteException ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "AppsServer error", ex);
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
// Run locally
|
||||
if (!started && !m_IsServerProcess)
|
||||
{
|
||||
MWorkflow wf = MWorkflow.get (Env.getCtx(), AD_Workflow_ID);
|
||||
MWFProcess wfProcess = null;
|
||||
if (m_pi.isBatch())
|
||||
wfProcess = wf.start(m_pi); // may return null
|
||||
else
|
||||
wfProcess = wf.startWait(m_pi); // may return null
|
||||
started = wfProcess != null;
|
||||
}
|
||||
return started;
|
||||
} // startWorkflow
|
||||
|
||||
/**************************************************************************
|
||||
* Start Java Process Class.
|
||||
* instanciate the class implementing the interface ProcessCall.
|
||||
* The class can be a Server/Client class (when in Package
|
||||
|
@ -442,109 +442,109 @@ public class ProcessCtl extends Thread
|
|||
* (e.g. in org.compiere.report)
|
||||
*
|
||||
* @return true if success
|
||||
*/
|
||||
private boolean startProcess ()
|
||||
{
|
||||
log.fine(m_pi.toString());
|
||||
boolean started = false;
|
||||
if (DB.isRemoteProcess())
|
||||
{
|
||||
Server server = CConnection.get().getServer();
|
||||
try
|
||||
{
|
||||
if (server != null)
|
||||
{ // See ServerBean
|
||||
m_pi = server.process (Env.getCtx(), m_pi);
|
||||
log.finest("server => " + m_pi);
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
catch (UndeclaredThrowableException ex)
|
||||
{
|
||||
Throwable cause = ex.getCause();
|
||||
if (cause != null)
|
||||
{
|
||||
if (cause instanceof InvalidClassException)
|
||||
log.log(Level.SEVERE, "Version Server <> Client: "
|
||||
+ cause.toString() + " - " + m_pi, ex);
|
||||
else
|
||||
log.log(Level.SEVERE, "AppsServer error(1b): "
|
||||
+ cause.toString() + " - " + m_pi, ex);
|
||||
}
|
||||
else
|
||||
log.log(Level.SEVERE, " AppsServer error(1) - "
|
||||
+ m_pi, ex);
|
||||
started = false;
|
||||
}
|
||||
catch (RemoteException ex)
|
||||
{
|
||||
Throwable cause = ex.getCause();
|
||||
if (cause == null)
|
||||
cause = ex;
|
||||
log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause);
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
// Run locally
|
||||
if (!started && !m_IsServerProcess)
|
||||
{
|
||||
ProcessCall myObject = null;
|
||||
try
|
||||
{
|
||||
Class myClass = Class.forName(m_pi.getClassName());
|
||||
myObject = (ProcessCall)myClass.newInstance();
|
||||
if (myObject == null)
|
||||
m_pi.setSummary("No Instance for " + m_pi.getClassName(), true);
|
||||
else
|
||||
myObject.startProcess(Env.getCtx(), m_pi, m_trx);
|
||||
if (m_trx != null)
|
||||
{
|
||||
m_trx.commit();
|
||||
m_trx.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_trx != null)
|
||||
{
|
||||
m_trx.rollback();
|
||||
m_trx.close();
|
||||
}
|
||||
m_pi.setSummary("Error starting Class " + m_pi.getClassName(), true);
|
||||
log.log(Level.SEVERE, m_pi.getClassName(), e);
|
||||
}
|
||||
}
|
||||
return !m_pi.isError();
|
||||
} // startProcess
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Start Database Process
|
||||
* @param ProcedureName PL/SQL procedure name
|
||||
* @return true if success
|
||||
*/
|
||||
private boolean startDBProcess (String ProcedureName)
|
||||
{
|
||||
// execute on this thread/connection
|
||||
log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")");
|
||||
String sql = "{call " + ProcedureName + "(?)}";
|
||||
try
|
||||
{
|
||||
CallableStatement cstmt = DB.prepareCall(sql); // ro??
|
||||
cstmt.setInt(1, m_pi.getAD_PInstance_ID());
|
||||
cstmt.executeUpdate();
|
||||
cstmt.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + e.getLocalizedMessage());
|
||||
m_pi.setError (true);
|
||||
return false;
|
||||
}
|
||||
// log.fine(Log.l4_Data, "ProcessCtl.startProcess - done");
|
||||
return true;
|
||||
} // startDBProcess
|
||||
|
||||
|
||||
} // ProcessCtl
|
||||
*/
|
||||
private boolean startProcess ()
|
||||
{
|
||||
log.fine(m_pi.toString());
|
||||
boolean started = false;
|
||||
if (DB.isRemoteProcess())
|
||||
{
|
||||
Server server = CConnection.get().getServer();
|
||||
try
|
||||
{
|
||||
if (server != null)
|
||||
{ // See ServerBean
|
||||
m_pi = server.process (Env.getCtx(), m_pi);
|
||||
log.finest("server => " + m_pi);
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
catch (UndeclaredThrowableException ex)
|
||||
{
|
||||
Throwable cause = ex.getCause();
|
||||
if (cause != null)
|
||||
{
|
||||
if (cause instanceof InvalidClassException)
|
||||
log.log(Level.SEVERE, "Version Server <> Client: "
|
||||
+ cause.toString() + " - " + m_pi, ex);
|
||||
else
|
||||
log.log(Level.SEVERE, "AppsServer error(1b): "
|
||||
+ cause.toString() + " - " + m_pi, ex);
|
||||
}
|
||||
else
|
||||
log.log(Level.SEVERE, " AppsServer error(1) - "
|
||||
+ m_pi, ex);
|
||||
started = false;
|
||||
}
|
||||
catch (RemoteException ex)
|
||||
{
|
||||
Throwable cause = ex.getCause();
|
||||
if (cause == null)
|
||||
cause = ex;
|
||||
log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause);
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
// Run locally
|
||||
if (!started && !m_IsServerProcess)
|
||||
{
|
||||
ProcessCall myObject = null;
|
||||
try
|
||||
{
|
||||
Class myClass = Class.forName(m_pi.getClassName());
|
||||
myObject = (ProcessCall)myClass.newInstance();
|
||||
if (myObject == null)
|
||||
m_pi.setSummary("No Instance for " + m_pi.getClassName(), true);
|
||||
else
|
||||
myObject.startProcess(Env.getCtx(), m_pi, m_trx);
|
||||
if (m_trx != null)
|
||||
{
|
||||
m_trx.commit();
|
||||
m_trx.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_trx != null)
|
||||
{
|
||||
m_trx.rollback();
|
||||
m_trx.close();
|
||||
}
|
||||
m_pi.setSummary("Error starting Class " + m_pi.getClassName(), true);
|
||||
log.log(Level.SEVERE, m_pi.getClassName(), e);
|
||||
}
|
||||
}
|
||||
return !m_pi.isError();
|
||||
} // startProcess
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Start Database Process
|
||||
* @param ProcedureName PL/SQL procedure name
|
||||
* @return true if success
|
||||
*/
|
||||
private boolean startDBProcess (String ProcedureName)
|
||||
{
|
||||
// execute on this thread/connection
|
||||
log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")");
|
||||
String sql = "{call " + ProcedureName + "(?)}";
|
||||
try
|
||||
{
|
||||
CallableStatement cstmt = DB.prepareCall(sql); // ro??
|
||||
cstmt.setInt(1, m_pi.getAD_PInstance_ID());
|
||||
cstmt.executeUpdate();
|
||||
cstmt.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + e.getLocalizedMessage());
|
||||
m_pi.setError (true);
|
||||
return false;
|
||||
}
|
||||
// log.fine(Log.l4_Data, "ProcessCtl.startProcess - done");
|
||||
return true;
|
||||
} // startDBProcess
|
||||
|
||||
|
||||
} // ProcessCtl
|
||||
|
|
|
@ -1,421 +1,378 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.sql.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.plaf.*;
|
||||
import org.compiere.print.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Dialog to Start process.
|
||||
* Displays information about the process
|
||||
* and lets the user decide to start it
|
||||
* and displays results (optionally print them).
|
||||
* Calls ProcessCtl to execute.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ProcessDialog.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class ProcessDialog extends CFrame
|
||||
implements ActionListener, ASyncProcess
|
||||
{
|
||||
/**
|
||||
* Dialog to start Process
|
||||
*
|
||||
* @param AD_Process_ID process
|
||||
* @param isSOTrx is sales trx
|
||||
*/
|
||||
public ProcessDialog (int AD_Process_ID, boolean isSOTrx)
|
||||
{
|
||||
super();
|
||||
log.info("Process=" + AD_Process_ID + "; SOTrx=" + isSOTrx);
|
||||
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
|
||||
m_AD_Process_ID = AD_Process_ID;
|
||||
m_WindowNo = Env.createWindowNo (this);
|
||||
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N");
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "", ex);
|
||||
}
|
||||
} // ProcessDialog
|
||||
|
||||
private int m_AD_Process_ID;
|
||||
private int m_WindowNo;
|
||||
private String m_Name = null;
|
||||
private boolean m_IsReport = false;
|
||||
private int[] m_ids = null;
|
||||
private boolean m_isLocked = false;
|
||||
private StringBuffer m_messageText = new StringBuffer();
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(ProcessDialog.class);
|
||||
//
|
||||
|
||||
private CPanel dialog = new CPanel()
|
||||
{
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension d = super.getPreferredSize();
|
||||
Dimension m = getMinimumSize();
|
||||
if ( d.height < m.height || d.width < m.width ) {
|
||||
Dimension d1 = new Dimension();
|
||||
d1.height = Math.max(d.height, m.height);
|
||||
d1.width = Math.max(d.width, m.width);
|
||||
return d1;
|
||||
} else
|
||||
return d;
|
||||
}
|
||||
};
|
||||
private BorderLayout mainLayout = new BorderLayout();
|
||||
private CPanel southPanel = new CPanel();
|
||||
private CButton bOK = ConfirmPanel.createOKButton(true);
|
||||
private FlowLayout southLayout = new FlowLayout();
|
||||
private JEditorPane message = new JEditorPane()
|
||||
{
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension d = super.getPreferredSize();
|
||||
Dimension m = getMaximumSize();
|
||||
if ( d.height > m.height || d.width > m.width ) {
|
||||
Dimension d1 = new Dimension();
|
||||
d1.height = Math.min(d.height, m.height);
|
||||
d1.width = Math.min(d.width, m.width);
|
||||
return d1;
|
||||
} else
|
||||
return d;
|
||||
}
|
||||
};
|
||||
private JScrollPane messagePane = new JScrollPane(message);
|
||||
private CButton bPrint = ConfirmPanel.createPrintButton(true);
|
||||
|
||||
private CPanel centerPanel = null;
|
||||
private ProcessParameterPanel parameterPanel = null;
|
||||
private JSeparator separator = new JSeparator();
|
||||
private ProcessInfo m_pi = null;
|
||||
|
||||
/**
|
||||
* Static Layout
|
||||
* @throws Exception
|
||||
*/
|
||||
private void jbInit() throws Exception
|
||||
{
|
||||
setIconImage(Env.getImage("mProcess.gif"));
|
||||
//
|
||||
dialog.setLayout(mainLayout);
|
||||
dialog.setMinimumSize(new Dimension(500, 200));
|
||||
bOK.addActionListener(this);
|
||||
bPrint.addActionListener(this);
|
||||
//
|
||||
southPanel.setLayout(southLayout);
|
||||
southLayout.setAlignment(FlowLayout.RIGHT);
|
||||
message.setContentType("text/html");
|
||||
message.setEditable(false);
|
||||
message.setBackground(Color.white);
|
||||
message.setFocusable(false);
|
||||
getContentPane().add(dialog);
|
||||
dialog.add(southPanel, BorderLayout.SOUTH);
|
||||
southPanel.add(bPrint, null);
|
||||
southPanel.add(bOK, null);
|
||||
dialog.add(messagePane, BorderLayout.NORTH);
|
||||
messagePane.setBorder(null);
|
||||
message.setMaximumSize(new Dimension(600, 300));
|
||||
centerPanel = new CPanel();
|
||||
centerPanel.setBorder(null);
|
||||
centerPanel.setLayout(new BorderLayout());
|
||||
dialog.add(centerPanel, BorderLayout.CENTER);
|
||||
//
|
||||
this.getRootPane().setDefaultButton(bOK);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
* (set focus to OK if visible)
|
||||
* @param visible true if visible
|
||||
*/
|
||||
public void setVisible (boolean visible)
|
||||
{
|
||||
super.setVisible(visible);
|
||||
if (visible) {
|
||||
bOK.requestFocus();
|
||||
}
|
||||
} // setVisible
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
Env.clearWinContext(m_WindowNo);
|
||||
super.dispose();
|
||||
} // dispose
|
||||
|
||||
|
||||
/**
|
||||
* Dynamic Init
|
||||
* @return true, if there is something to process (start from menu)
|
||||
*/
|
||||
public boolean init()
|
||||
{
|
||||
log.config("");
|
||||
//
|
||||
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Process");
|
||||
String sql = "SELECT Name, Description, Help, IsReport "
|
||||
+ "FROM AD_Process "
|
||||
+ "WHERE AD_Process_ID=?";
|
||||
if (trl)
|
||||
sql = "SELECT t.Name, t.Description, t.Help, p.IsReport "
|
||||
+ "FROM AD_Process p, AD_Process_Trl t "
|
||||
+ "WHERE p.AD_Process_ID=t.AD_Process_ID"
|
||||
+ " AND p.AD_Process_ID=? AND t.AD_Language=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_AD_Process_ID);
|
||||
if (trl)
|
||||
pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
m_Name = rs.getString(1);
|
||||
m_IsReport = rs.getString(4).equals("Y");
|
||||
//
|
||||
m_messageText.append("<b>");
|
||||
String s = rs.getString(2); // Description
|
||||
if (rs.wasNull())
|
||||
m_messageText.append(Msg.getMsg(Env.getCtx(), "StartProcess?"));
|
||||
else
|
||||
m_messageText.append(s);
|
||||
m_messageText.append("</b>");
|
||||
s = rs.getString(3); // Help
|
||||
if (!rs.wasNull())
|
||||
m_messageText.append("<p>").append(s).append("</p>");
|
||||
}
|
||||
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Name == null)
|
||||
return false;
|
||||
//
|
||||
this.setTitle(m_Name);
|
||||
message.setText(m_messageText.toString());
|
||||
bOK.setText(Msg.getMsg(Env.getCtx(), "Start"));
|
||||
|
||||
/** Start Reports w/o asking
|
||||
if (m_IsReport)
|
||||
{
|
||||
bOK.doClick();
|
||||
return false; // don't show
|
||||
}
|
||||
**/
|
||||
// Similar to APanel.actionButton
|
||||
m_pi = new ProcessInfo(m_Name, m_AD_Process_ID);
|
||||
m_pi.setAD_User_ID (Env.getAD_User_ID(Env.getCtx()));
|
||||
m_pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
|
||||
parameterPanel = new ProcessParameterPanel(m_WindowNo, m_pi);
|
||||
centerPanel.removeAll();
|
||||
if (parameterPanel.init()) {
|
||||
centerPanel.add(separator, BorderLayout.NORTH);
|
||||
centerPanel.add(parameterPanel, BorderLayout.CENTER);
|
||||
}
|
||||
dialog.revalidate();
|
||||
return true;
|
||||
} // init
|
||||
|
||||
/**
|
||||
* ActionListener (Start)
|
||||
* @param e ActionEvent
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
if (e.getSource() == bOK)
|
||||
{
|
||||
if (bOK.getText().length() == 0)
|
||||
dispose();
|
||||
else
|
||||
{
|
||||
// Trx trx = Trx.get(Trx.createTrxName("ProcessDialog"), true);
|
||||
ProcessCtl.process(this, m_WindowNo, parameterPanel, m_pi, null);
|
||||
}
|
||||
}
|
||||
|
||||
else if (e.getSource() == bPrint)
|
||||
printScreen();
|
||||
} // actionPerformed
|
||||
|
||||
|
||||
/**
|
||||
* Lock User Interface
|
||||
* Called from the Worker before processing
|
||||
* @param pi process info
|
||||
*/
|
||||
public void lockUI (ProcessInfo pi)
|
||||
{
|
||||
bOK.setText("");
|
||||
bOK.setEnabled(false);
|
||||
this.setEnabled(false);
|
||||
m_isLocked = true;
|
||||
} // lockUI
|
||||
|
||||
/**
|
||||
* Unlock User Interface.
|
||||
* Called from the Worker when processing is done
|
||||
* @param pi process info
|
||||
*/
|
||||
public void unlockUI (ProcessInfo pi)
|
||||
{
|
||||
ProcessInfoUtil.setLogFromDB(pi);
|
||||
m_messageText.append("<p><font color=\"").append(pi.isError() ? "#FF0000" : "#0000FF").append("\">** ")
|
||||
.append(pi.getSummary())
|
||||
.append("</font></p>");
|
||||
m_messageText.append(pi.getLogInfo(true));
|
||||
message.setText(m_messageText.toString());
|
||||
message.setCaretPosition(message.getDocument().getLength()); // scroll down
|
||||
m_ids = pi.getIDs();
|
||||
//
|
||||
bOK.setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
m_isLocked = false;
|
||||
//
|
||||
afterProcessTask();
|
||||
// Close automatically
|
||||
if (m_IsReport && !pi.isError())
|
||||
bOK.doClick();
|
||||
} // 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.config("-");
|
||||
} // executeASync
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Optional Processing Task
|
||||
*/
|
||||
private void afterProcessTask()
|
||||
{
|
||||
// something to do?
|
||||
if (m_ids != null && m_ids.length > 0)
|
||||
{
|
||||
log.config("");
|
||||
// Print invoices
|
||||
if (m_AD_Process_ID == 119)
|
||||
printInvoices();
|
||||
else if (m_AD_Process_ID == 118)
|
||||
printShipments();
|
||||
}
|
||||
|
||||
} // afterProcessTask
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Print Shipments
|
||||
*/
|
||||
private void printShipments()
|
||||
{
|
||||
if (m_ids == null)
|
||||
return;
|
||||
if (!ADialog.ask(m_WindowNo, this, "PrintShipments"))
|
||||
return;
|
||||
m_messageText.append("<p>").append(Msg.getMsg(Env.getCtx(), "PrintShipments")).append("</p>");
|
||||
message.setText(m_messageText.toString());
|
||||
int retValue = ADialogDialog.A_CANCEL;
|
||||
do
|
||||
{
|
||||
// Loop through all items
|
||||
for (int i = 0; i < m_ids.length; i++)
|
||||
{
|
||||
int M_InOut_ID = m_ids[i];
|
||||
ReportCtl.startDocumentPrint(ReportEngine.SHIPMENT, M_InOut_ID, true);
|
||||
}
|
||||
ADialogDialog d = new ADialogDialog (this,
|
||||
Env.getHeader(Env.getCtx(), m_WindowNo),
|
||||
Msg.getMsg(Env.getCtx(), "PrintoutOK?"),
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
retValue = d.getReturnCode();
|
||||
}
|
||||
while (retValue == ADialogDialog.A_CANCEL);
|
||||
} // printInvoices
|
||||
|
||||
/**
|
||||
* Print Invoices
|
||||
*/
|
||||
private void printInvoices()
|
||||
{
|
||||
if (m_ids == null)
|
||||
return;
|
||||
if (!ADialog.ask(m_WindowNo, this, "PrintInvoices"))
|
||||
return;
|
||||
m_messageText.append("<p>").append(Msg.getMsg(Env.getCtx(), "PrintInvoices")).append("</p>");
|
||||
message.setText(m_messageText.toString());
|
||||
int retValue = ADialogDialog.A_CANCEL;
|
||||
do
|
||||
{
|
||||
// Loop through all items
|
||||
for (int i = 0; i < m_ids.length; i++)
|
||||
{
|
||||
int AD_Invoice_ID = m_ids[i];
|
||||
ReportCtl.startDocumentPrint(ReportEngine.INVOICE, AD_Invoice_ID, true);
|
||||
}
|
||||
ADialogDialog d = new ADialogDialog (this,
|
||||
Env.getHeader(Env.getCtx(), m_WindowNo),
|
||||
Msg.getMsg(Env.getCtx(), "PrintoutOK?"),
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
retValue = d.getReturnCode();
|
||||
}
|
||||
while (retValue == ADialogDialog.A_CANCEL);
|
||||
} // printInvoices
|
||||
|
||||
/**
|
||||
* Print Screen
|
||||
*/
|
||||
private void printScreen()
|
||||
{
|
||||
PrintScreenPainter.printScreen (this);
|
||||
} // printScreen
|
||||
|
||||
} // ProcessDialog
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.sql.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.plaf.*;
|
||||
import org.compiere.print.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Dialog to Start process.
|
||||
* Displays information about the process
|
||||
* and lets the user decide to start it
|
||||
* and displays results (optionally print them).
|
||||
* Calls ProcessCtl to execute.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ProcessDialog.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class ProcessDialog extends CFrame
|
||||
implements ActionListener, ASyncProcess
|
||||
{
|
||||
/**
|
||||
* Dialog to start Process
|
||||
*
|
||||
* @param AD_Process_ID process
|
||||
* @param isSOTrx is sales trx
|
||||
*/
|
||||
public ProcessDialog (int AD_Process_ID, boolean isSOTrx)
|
||||
{
|
||||
super();
|
||||
log.info("Process=" + AD_Process_ID + "; SOTrx=" + isSOTrx);
|
||||
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
|
||||
m_AD_Process_ID = AD_Process_ID;
|
||||
m_WindowNo = Env.createWindowNo (this);
|
||||
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N");
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "", ex);
|
||||
}
|
||||
} // ProcessDialog
|
||||
|
||||
private int m_AD_Process_ID;
|
||||
private int m_WindowNo;
|
||||
private String m_Name = null;
|
||||
private boolean m_IsReport = false;
|
||||
private int[] m_ids = null;
|
||||
private boolean m_isLocked = false;
|
||||
private StringBuffer m_messageText = new StringBuffer();
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(ProcessDialog.class);
|
||||
//
|
||||
|
||||
private CPanel dialog = new CPanel();
|
||||
private BorderLayout mainLayout = new BorderLayout();
|
||||
private CPanel southPanel = new CPanel();
|
||||
private CButton bOK = ConfirmPanel.createOKButton(true);
|
||||
private FlowLayout southLayout = new FlowLayout();
|
||||
private JEditorPane message = new JEditorPane();
|
||||
private JScrollPane messagePane = new JScrollPane(message);
|
||||
private CButton bPrint = ConfirmPanel.createPrintButton(true);
|
||||
|
||||
/**
|
||||
* Static Layout
|
||||
* @throws Exception
|
||||
*/
|
||||
private void jbInit() throws Exception
|
||||
{
|
||||
setIconImage(Env.getImage("mProcess.gif"));
|
||||
//
|
||||
dialog.setLayout(mainLayout);
|
||||
bOK.addActionListener(this);
|
||||
bPrint.addActionListener(this);
|
||||
//
|
||||
southPanel.setLayout(southLayout);
|
||||
southLayout.setAlignment(FlowLayout.RIGHT);
|
||||
dialog.setPreferredSize(new Dimension(500, 150));
|
||||
message.setContentType("text/html");
|
||||
message.setEditable(false);
|
||||
message.setBackground(AdempierePLAF.getFieldBackground_Inactive());
|
||||
message.setFocusable(false);
|
||||
getContentPane().add(dialog);
|
||||
dialog.add(southPanel, BorderLayout.SOUTH);
|
||||
southPanel.add(bPrint, null);
|
||||
southPanel.add(bOK, null);
|
||||
dialog.add(messagePane, BorderLayout.CENTER);
|
||||
//
|
||||
this.getRootPane().setDefaultButton(bOK);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
* Set Visible
|
||||
* (set focus to OK if visible)
|
||||
* @param visible true if visible
|
||||
*/
|
||||
public void setVisible (boolean visible)
|
||||
{
|
||||
super.setVisible(visible);
|
||||
if (visible)
|
||||
bOK.requestFocus();
|
||||
} // setVisible
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
Env.clearWinContext(m_WindowNo);
|
||||
super.dispose();
|
||||
} // dispose
|
||||
|
||||
|
||||
/**
|
||||
* Dynamic Init
|
||||
* @return true, if there is something to process (start from menu)
|
||||
*/
|
||||
public boolean init()
|
||||
{
|
||||
log.config("");
|
||||
//
|
||||
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Process");
|
||||
String sql = "SELECT Name, Description, Help, IsReport "
|
||||
+ "FROM AD_Process "
|
||||
+ "WHERE AD_Process_ID=?";
|
||||
if (trl)
|
||||
sql = "SELECT t.Name, t.Description, t.Help, p.IsReport "
|
||||
+ "FROM AD_Process p, AD_Process_Trl t "
|
||||
+ "WHERE p.AD_Process_ID=t.AD_Process_ID"
|
||||
+ " AND p.AD_Process_ID=? AND t.AD_Language=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_AD_Process_ID);
|
||||
if (trl)
|
||||
pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
m_Name = rs.getString(1);
|
||||
m_IsReport = rs.getString(4).equals("Y");
|
||||
//
|
||||
m_messageText.append("<b>");
|
||||
String s = rs.getString(2); // Description
|
||||
if (rs.wasNull())
|
||||
m_messageText.append(Msg.getMsg(Env.getCtx(), "StartProcess?"));
|
||||
else
|
||||
m_messageText.append(s);
|
||||
m_messageText.append("</b>");
|
||||
s = rs.getString(3); // Help
|
||||
if (!rs.wasNull())
|
||||
m_messageText.append("<p>").append(s).append("</p>");
|
||||
}
|
||||
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Name == null)
|
||||
return false;
|
||||
//
|
||||
this.setTitle(m_Name);
|
||||
message.setText(m_messageText.toString());
|
||||
bOK.setText(Msg.getMsg(Env.getCtx(), "Start"));
|
||||
|
||||
/** Start Reports w/o asking
|
||||
if (m_IsReport)
|
||||
{
|
||||
bOK.doClick();
|
||||
return false; // don't show
|
||||
}
|
||||
**/
|
||||
return true;
|
||||
} // init
|
||||
|
||||
/**
|
||||
* ActionListener (Start)
|
||||
* @param e ActionEvent
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
if (e.getSource() == bOK)
|
||||
{
|
||||
if (bOK.getText().length() == 0)
|
||||
dispose();
|
||||
else
|
||||
{
|
||||
// Similar to APanel.actionButton
|
||||
ProcessInfo pi = new ProcessInfo(m_Name, m_AD_Process_ID);
|
||||
pi.setAD_User_ID (Env.getAD_User_ID(Env.getCtx()));
|
||||
pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
|
||||
m_messageText.append("<p>** ").append(m_Name).append("</p>");
|
||||
message.setText(m_messageText.toString());
|
||||
// Trx trx = Trx.get(Trx.createTrxName("ProcessDialog"), true);
|
||||
ProcessCtl.process(this, m_WindowNo, pi, null);
|
||||
}
|
||||
}
|
||||
|
||||
else if (e.getSource() == bPrint)
|
||||
printScreen();
|
||||
} // actionPerformed
|
||||
|
||||
|
||||
/**
|
||||
* Lock User Interface
|
||||
* Called from the Worker before processing
|
||||
* @param pi process info
|
||||
*/
|
||||
public void lockUI (ProcessInfo pi)
|
||||
{
|
||||
bOK.setText("");
|
||||
bOK.setEnabled(false);
|
||||
this.setEnabled(false);
|
||||
m_isLocked = true;
|
||||
} // lockUI
|
||||
|
||||
/**
|
||||
* Unlock User Interface.
|
||||
* Called from the Worker when processing is done
|
||||
* @param pi process info
|
||||
*/
|
||||
public void unlockUI (ProcessInfo pi)
|
||||
{
|
||||
ProcessInfoUtil.setLogFromDB(pi);
|
||||
m_messageText.append("<p><font color=\"").append(pi.isError() ? "#FF0000" : "#0000FF").append("\">** ")
|
||||
.append(pi.getSummary())
|
||||
.append("</font></p>");
|
||||
m_messageText.append(pi.getLogInfo(true));
|
||||
message.setText(m_messageText.toString());
|
||||
message.setCaretPosition(message.getDocument().getLength()); // scroll down
|
||||
m_ids = pi.getIDs();
|
||||
//
|
||||
bOK.setEnabled(true);
|
||||
this.setEnabled(true);
|
||||
m_isLocked = false;
|
||||
//
|
||||
afterProcessTask();
|
||||
// Close automatically
|
||||
if (m_IsReport && !pi.isError())
|
||||
bOK.doClick();
|
||||
} // 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.config("-");
|
||||
} // executeASync
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Optional Processing Task
|
||||
*/
|
||||
private void afterProcessTask()
|
||||
{
|
||||
// something to do?
|
||||
if (m_ids != null && m_ids.length > 0)
|
||||
{
|
||||
log.config("");
|
||||
// Print invoices
|
||||
if (m_AD_Process_ID == 119)
|
||||
printInvoices();
|
||||
else if (m_AD_Process_ID == 118)
|
||||
printShipments();
|
||||
}
|
||||
|
||||
} // afterProcessTask
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Print Shipments
|
||||
*/
|
||||
private void printShipments()
|
||||
{
|
||||
if (m_ids == null)
|
||||
return;
|
||||
if (!ADialog.ask(m_WindowNo, this, "PrintShipments"))
|
||||
return;
|
||||
m_messageText.append("<p>").append(Msg.getMsg(Env.getCtx(), "PrintShipments")).append("</p>");
|
||||
message.setText(m_messageText.toString());
|
||||
int retValue = ADialogDialog.A_CANCEL;
|
||||
do
|
||||
{
|
||||
// Loop through all items
|
||||
for (int i = 0; i < m_ids.length; i++)
|
||||
{
|
||||
int M_InOut_ID = m_ids[i];
|
||||
ReportCtl.startDocumentPrint(ReportEngine.SHIPMENT, M_InOut_ID, true);
|
||||
}
|
||||
ADialogDialog d = new ADialogDialog (this,
|
||||
Env.getHeader(Env.getCtx(), m_WindowNo),
|
||||
Msg.getMsg(Env.getCtx(), "PrintoutOK?"),
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
retValue = d.getReturnCode();
|
||||
}
|
||||
while (retValue == ADialogDialog.A_CANCEL);
|
||||
} // printInvoices
|
||||
|
||||
/**
|
||||
* Print Invoices
|
||||
*/
|
||||
private void printInvoices()
|
||||
{
|
||||
if (m_ids == null)
|
||||
return;
|
||||
if (!ADialog.ask(m_WindowNo, this, "PrintInvoices"))
|
||||
return;
|
||||
m_messageText.append("<p>").append(Msg.getMsg(Env.getCtx(), "PrintInvoices")).append("</p>");
|
||||
message.setText(m_messageText.toString());
|
||||
int retValue = ADialogDialog.A_CANCEL;
|
||||
do
|
||||
{
|
||||
// Loop through all items
|
||||
for (int i = 0; i < m_ids.length; i++)
|
||||
{
|
||||
int AD_Invoice_ID = m_ids[i];
|
||||
ReportCtl.startDocumentPrint(ReportEngine.INVOICE, AD_Invoice_ID, true);
|
||||
}
|
||||
ADialogDialog d = new ADialogDialog (this,
|
||||
Env.getHeader(Env.getCtx(), m_WindowNo),
|
||||
Msg.getMsg(Env.getCtx(), "PrintoutOK?"),
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
retValue = d.getReturnCode();
|
||||
}
|
||||
while (retValue == ADialogDialog.A_CANCEL);
|
||||
} // printInvoices
|
||||
|
||||
/**
|
||||
* Print Screen
|
||||
*/
|
||||
private void printScreen()
|
||||
{
|
||||
PrintScreenPainter.printScreen (this);
|
||||
} // printScreen
|
||||
|
||||
} // ProcessDialog
|
||||
|
|
|
@ -3,476 +3,470 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
import org.compiere.grid.ed.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Parameter Dialog.
|
||||
* - called from ProcessCtl
|
||||
* - checks, if parameters exist and inquires and saves them
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ProcessParameter.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class ProcessParameter extends CDialog
|
||||
implements ActionListener, VetoableChangeListener
|
||||
{
|
||||
/**
|
||||
* Dynamic generated Parameter Dialog screen.
|
||||
* Called from ProcessCtl.process
|
||||
*
|
||||
* @param frame frame
|
||||
* @param WindowNo window
|
||||
* @param pi process info
|
||||
*/
|
||||
public ProcessParameter (Frame frame, int WindowNo, ProcessInfo pi)
|
||||
{
|
||||
super(frame, pi.getTitle(), true);
|
||||
m_frame = frame;
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, ex.getMessage());
|
||||
}
|
||||
//
|
||||
m_WindowNo = WindowNo;
|
||||
m_processInfo = pi;
|
||||
//
|
||||
} // ProcessParameter
|
||||
|
||||
private Frame m_frame;
|
||||
private int m_WindowNo;
|
||||
private ProcessInfo m_processInfo;
|
||||
private boolean m_isOK = false;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(ProcessParameter.class);
|
||||
//
|
||||
private GridBagConstraints gbc = new GridBagConstraints();
|
||||
private Insets nullInset = new Insets(0,0,0,0);
|
||||
private Insets labelInset = new Insets(2,12,2,0); // top,left,bottom,right
|
||||
private Insets fieldInset = new Insets(2,5,2,0); // top,left,bottom,right
|
||||
private Insets fieldInsetRight = new Insets(2,5,2,12); // top,left,bottom,right
|
||||
private int m_line = 0;
|
||||
//
|
||||
private ArrayList<VEditor> m_vEditors = new ArrayList<VEditor>();
|
||||
private ArrayList<VEditor> m_vEditors2 = new ArrayList<VEditor>(); // for ranges
|
||||
private ArrayList<GridField> m_mFields = new ArrayList<GridField>();
|
||||
private ArrayList<GridField> m_mFields2 = new ArrayList<GridField>();
|
||||
//
|
||||
private CPanel mainPanel = new CPanel();
|
||||
private BorderLayout mainLayout = new BorderLayout();
|
||||
private CPanel centerPanel = new CPanel();
|
||||
private GridBagLayout centerLayout = new GridBagLayout();
|
||||
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||
|
||||
/**
|
||||
* Static Layout
|
||||
* @throws Exception
|
||||
*/
|
||||
void jbInit() throws Exception
|
||||
{
|
||||
mainPanel.setLayout(mainLayout);
|
||||
centerPanel.setLayout(centerLayout);
|
||||
this.getContentPane().add(mainPanel);
|
||||
mainPanel.add(centerPanel, BorderLayout.CENTER);
|
||||
mainPanel.add(confirmPanel, BorderLayout.SOUTH);
|
||||
confirmPanel.addActionListener(this);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_vEditors.clear();
|
||||
m_vEditors2.clear();
|
||||
m_mFields.clear();
|
||||
m_mFields2.clear();
|
||||
this.removeAll();
|
||||
super.dispose();
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Read Fields to display
|
||||
* @return true if loaded OK
|
||||
*/
|
||||
public boolean initDialog()
|
||||
{
|
||||
log.config("");
|
||||
|
||||
// Prepare panel
|
||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||
gbc.weightx = 0;
|
||||
gbc.weighty = 0;
|
||||
gbc.gridy = m_line++;
|
||||
gbc.gridx = 0;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.insets = nullInset;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
centerPanel.add(Box.createVerticalStrut(10), gbc); // top gap 10+2=12
|
||||
|
||||
//
|
||||
String sql = null;
|
||||
if (Env.isBaseLanguage(Env.getCtx(), "AD_Process_Para"))
|
||||
sql = "SELECT p.Name, p.Description, p.Help, "
|
||||
+ "p.AD_Reference_ID, p.AD_Process_Para_ID, "
|
||||
+ "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, "
|
||||
+ "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, "
|
||||
+ "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode "
|
||||
+ "FROM AD_Process_Para p"
|
||||
+ " LEFT OUTER JOIN AD_Val_Rule vr ON (p.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) "
|
||||
+ "WHERE p.AD_Process_ID=?" // 1
|
||||
+ " AND p.IsActive='Y' "
|
||||
+ "ORDER BY SeqNo";
|
||||
else
|
||||
sql = "SELECT t.Name, t.Description, t.Help, "
|
||||
+ "p.AD_Reference_ID, p.AD_Process_Para_ID, "
|
||||
+ "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, "
|
||||
+ "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, "
|
||||
+ "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode "
|
||||
+ "FROM AD_Process_Para p"
|
||||
+ " INNER JOIN AD_Process_Para_Trl t ON (p.AD_Process_Para_ID=t.AD_Process_Para_ID)"
|
||||
+ " LEFT OUTER JOIN AD_Val_Rule vr ON (p.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) "
|
||||
+ "WHERE p.AD_Process_ID=?" // 1
|
||||
+ " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'"
|
||||
+ " AND p.IsActive='Y' "
|
||||
+ "ORDER BY SeqNo";
|
||||
|
||||
// Create Fields
|
||||
boolean hasFields = false;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_processInfo.getAD_Process_ID());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
hasFields = true;
|
||||
createField (rs);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch(SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
// both vectors the same?
|
||||
if (m_mFields.size() != m_mFields2.size()
|
||||
|| m_mFields.size() != m_vEditors.size()
|
||||
|| m_mFields2.size() != m_vEditors2.size())
|
||||
log.log(Level.SEVERE, "View & Model vector size is different");
|
||||
|
||||
// clean up
|
||||
if (hasFields)
|
||||
{
|
||||
gbc.gridy = m_line++;
|
||||
centerPanel.add(Box.createVerticalStrut(10), gbc); // bottom gap
|
||||
gbc.gridx = 3;
|
||||
centerPanel.add(Box.createHorizontalStrut(12), gbc); // right gap
|
||||
AEnv.positionCenterWindow(m_frame, this);
|
||||
}
|
||||
else
|
||||
dispose();
|
||||
return hasFields;
|
||||
} // initDialog
|
||||
|
||||
|
||||
/**
|
||||
* Create Field.
|
||||
* - creates Fields and adds it to m_mFields list
|
||||
* - creates Editor and adds it to m_vEditors list
|
||||
* Handeles Ranges by adding additional mField/vEditor.
|
||||
* <p>
|
||||
* mFields are used for default value and mandatory checking;
|
||||
* vEditors are used to retrieve the value (no data binding)
|
||||
*
|
||||
* @param rs result set
|
||||
*/
|
||||
private void createField (ResultSet rs)
|
||||
{
|
||||
// Create Field
|
||||
GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, rs);
|
||||
GridField mField = new GridField (voF);
|
||||
m_mFields.add(mField); // add to Fields
|
||||
|
||||
// Label Preparation
|
||||
gbc.gridy = m_line++;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL; // required for right justified
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 0;
|
||||
JLabel label = VEditorFactory.getLabel(mField);
|
||||
if (label == null)
|
||||
{
|
||||
gbc.insets = nullInset;
|
||||
centerPanel.add(Box.createHorizontalStrut(12), gbc); // left gap
|
||||
}
|
||||
else
|
||||
{
|
||||
gbc.insets = labelInset;
|
||||
centerPanel.add(label, gbc);
|
||||
}
|
||||
|
||||
// Field Preparation
|
||||
gbc.insets = fieldInset;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 1;
|
||||
|
||||
// The Editor
|
||||
VEditor vEditor = VEditorFactory.getEditor(mField, false);
|
||||
vEditor.addVetoableChangeListener(this);
|
||||
// MField => VEditor - New Field value to be updated to editor
|
||||
mField.addPropertyChangeListener(vEditor);
|
||||
// Set Default
|
||||
Object defaultObject = mField.getDefault();
|
||||
mField.setValue (defaultObject, true);
|
||||
//
|
||||
centerPanel.add ((Component)vEditor, gbc);
|
||||
m_vEditors.add (vEditor); // add to Editors
|
||||
//
|
||||
if (voF.isRange)
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
import org.compiere.grid.ed.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Parameter Dialog.
|
||||
* - called from ProcessCtl
|
||||
* - checks, if parameters exist and inquires and saves them
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ProcessParameter.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public class ProcessParameter extends CDialog
|
||||
implements ActionListener, VetoableChangeListener
|
||||
{
|
||||
/**
|
||||
* Dynamic generated Parameter Dialog screen.
|
||||
* Called from ProcessCtl.process
|
||||
*
|
||||
* @param frame frame
|
||||
* @param WindowNo window
|
||||
* @param pi process info
|
||||
*/
|
||||
public ProcessParameter (Frame frame, int WindowNo, ProcessInfo pi)
|
||||
{
|
||||
super(frame, pi.getTitle(), true);
|
||||
m_frame = frame;
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, ex.getMessage());
|
||||
}
|
||||
//
|
||||
m_WindowNo = WindowNo;
|
||||
m_processInfo = pi;
|
||||
//
|
||||
} // ProcessParameter
|
||||
|
||||
private Frame m_frame;
|
||||
private int m_WindowNo;
|
||||
private ProcessInfo m_processInfo;
|
||||
private boolean m_isOK = false;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(ProcessParameter.class);
|
||||
//
|
||||
private GridBagConstraints gbc = new GridBagConstraints();
|
||||
private Insets nullInset = new Insets(0,0,0,0);
|
||||
private Insets labelInset = new Insets(2,12,2,0); // top,left,bottom,right
|
||||
private Insets fieldInset = new Insets(2,5,2,0); // top,left,bottom,right
|
||||
private Insets fieldInsetRight = new Insets(2,5,2,12); // top,left,bottom,right
|
||||
private int m_line = 0;
|
||||
//
|
||||
private ArrayList<VEditor> m_vEditors = new ArrayList<VEditor>();
|
||||
private ArrayList<VEditor> m_vEditors2 = new ArrayList<VEditor>(); // for ranges
|
||||
private ArrayList<GridField> m_mFields = new ArrayList<GridField>();
|
||||
private ArrayList<GridField> m_mFields2 = new ArrayList<GridField>();
|
||||
//
|
||||
private CPanel mainPanel = new CPanel();
|
||||
private BorderLayout mainLayout = new BorderLayout();
|
||||
private CPanel centerPanel = new CPanel();
|
||||
private GridBagLayout centerLayout = new GridBagLayout();
|
||||
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||
|
||||
/**
|
||||
* Static Layout
|
||||
* @throws Exception
|
||||
*/
|
||||
void jbInit() throws Exception
|
||||
{
|
||||
mainPanel.setLayout(mainLayout);
|
||||
centerPanel.setLayout(centerLayout);
|
||||
this.getContentPane().add(mainPanel);
|
||||
mainPanel.add(centerPanel, BorderLayout.CENTER);
|
||||
mainPanel.add(confirmPanel, BorderLayout.SOUTH);
|
||||
confirmPanel.addActionListener(this);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_vEditors.clear();
|
||||
m_vEditors2.clear();
|
||||
m_mFields.clear();
|
||||
m_mFields2.clear();
|
||||
this.removeAll();
|
||||
super.dispose();
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Read Fields to display
|
||||
* @return true if loaded OK
|
||||
*/
|
||||
public boolean initDialog()
|
||||
{
|
||||
log.config("");
|
||||
|
||||
// Prepare panel
|
||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||
gbc.weightx = 0;
|
||||
gbc.weighty = 0;
|
||||
gbc.gridy = m_line++;
|
||||
gbc.gridx = 0;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.insets = nullInset;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
centerPanel.add(Box.createVerticalStrut(10), gbc); // top gap 10+2=12
|
||||
|
||||
//
|
||||
String sql = null;
|
||||
if (Env.isBaseLanguage(Env.getCtx(), "AD_Process_Para"))
|
||||
sql = "SELECT p.Name, p.Description, p.Help, "
|
||||
+ "p.AD_Reference_ID, p.AD_Process_Para_ID, "
|
||||
+ "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, "
|
||||
+ "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, "
|
||||
+ "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode "
|
||||
+ "FROM AD_Process_Para p"
|
||||
+ " LEFT OUTER JOIN AD_Val_Rule vr ON (p.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) "
|
||||
+ "WHERE p.AD_Process_ID=?" // 1
|
||||
+ " AND p.IsActive='Y' "
|
||||
+ "ORDER BY SeqNo";
|
||||
else
|
||||
sql = "SELECT t.Name, t.Description, t.Help, "
|
||||
+ "p.AD_Reference_ID, p.AD_Process_Para_ID, "
|
||||
+ "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, "
|
||||
+ "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, "
|
||||
+ "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode "
|
||||
+ "FROM AD_Process_Para p"
|
||||
+ " INNER JOIN AD_Process_Para_Trl t ON (p.AD_Process_Para_ID=t.AD_Process_Para_ID)"
|
||||
+ " LEFT OUTER JOIN AD_Val_Rule vr ON (p.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) "
|
||||
+ "WHERE p.AD_Process_ID=?" // 1
|
||||
+ " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'"
|
||||
+ " AND p.IsActive='Y' "
|
||||
+ "ORDER BY SeqNo";
|
||||
|
||||
// Create Fields
|
||||
boolean hasFields = false;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_processInfo.getAD_Process_ID());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
hasFields = true;
|
||||
createField (rs);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch(SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
|
||||
// both vectors the same?
|
||||
if (m_mFields.size() != m_mFields2.size()
|
||||
|| m_mFields.size() != m_vEditors.size()
|
||||
|| m_mFields2.size() != m_vEditors2.size())
|
||||
log.log(Level.SEVERE, "View & Model vector size is different");
|
||||
|
||||
// clean up
|
||||
if (hasFields)
|
||||
{
|
||||
gbc.gridy = m_line++;
|
||||
centerPanel.add(Box.createVerticalStrut(10), gbc); // bottom gap
|
||||
gbc.gridx = 3;
|
||||
centerPanel.add(Box.createHorizontalStrut(12), gbc); // right gap
|
||||
AEnv.positionCenterWindow(m_frame, this);
|
||||
}
|
||||
else
|
||||
dispose();
|
||||
return hasFields;
|
||||
} // initDialog
|
||||
|
||||
|
||||
/**
|
||||
* Create Field.
|
||||
* - creates Fields and adds it to m_mFields list
|
||||
* - creates Editor and adds it to m_vEditors list
|
||||
* Handeles Ranges by adding additional mField/vEditor.
|
||||
* <p>
|
||||
* mFields are used for default value and mandatory checking;
|
||||
* vEditors are used to retrieve the value (no data binding)
|
||||
*
|
||||
* @param rs result set
|
||||
*/
|
||||
private void createField (ResultSet rs)
|
||||
{
|
||||
// Create Field
|
||||
GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, rs);
|
||||
GridField mField = new GridField (voF);
|
||||
m_mFields.add(mField); // add to Fields
|
||||
|
||||
// Label Preparation
|
||||
gbc.gridy = m_line++;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL; // required for right justified
|
||||
gbc.gridx = 0;
|
||||
gbc.weightx = 0;
|
||||
JLabel label = VEditorFactory.getLabel(mField);
|
||||
if (label == null)
|
||||
{
|
||||
gbc.insets = nullInset;
|
||||
centerPanel.add(Box.createHorizontalStrut(12), gbc); // left gap
|
||||
}
|
||||
else
|
||||
{
|
||||
gbc.insets = labelInset;
|
||||
centerPanel.add(label, gbc);
|
||||
}
|
||||
|
||||
// Field Preparation
|
||||
gbc.insets = fieldInset;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridx = 1;
|
||||
gbc.weightx = 1;
|
||||
|
||||
// The Editor
|
||||
VEditor vEditor = VEditorFactory.getEditor(mField, false);
|
||||
vEditor.addVetoableChangeListener(this);
|
||||
// MField => VEditor - New Field value to be updated to editor
|
||||
mField.addPropertyChangeListener(vEditor);
|
||||
// Set Default
|
||||
Object defaultObject = mField.getDefault();
|
||||
mField.setValue (defaultObject, true);
|
||||
//
|
||||
centerPanel.add ((Component)vEditor, gbc);
|
||||
m_vEditors.add (vEditor); // add to Editors
|
||||
//
|
||||
if (voF.isRange)
|
||||
{
|
||||
// To Label
|
||||
gbc.gridx = 2;
|
||||
gbc.weightx = 0;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
centerPanel.add (new JLabel(" - "), gbc);
|
||||
// To Field
|
||||
gbc.gridx = 3;
|
||||
gbc.insets = fieldInsetRight;
|
||||
gbc.weightx = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
|
||||
//
|
||||
GridFieldVO voF2 = GridFieldVO.createParameter(voF);
|
||||
GridField mField2 = new GridField (voF2);
|
||||
m_mFields2.add (mField2);
|
||||
// The Editor
|
||||
VEditor vEditor2 = VEditorFactory.getEditor(mField2, false);
|
||||
// New Field value to be updated to editor
|
||||
mField2.addPropertyChangeListener(vEditor2);
|
||||
// Set Default
|
||||
Object defaultObject2 = mField2.getDefault();
|
||||
mField2.setValue (defaultObject2, true);
|
||||
//
|
||||
centerPanel.add ((Component)vEditor2, gbc);
|
||||
m_vEditors2.add (vEditor2);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mFields2.add (null);
|
||||
m_vEditors2.add (null);
|
||||
}
|
||||
} // createField
|
||||
|
||||
/**
|
||||
* Action Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
m_isOK = false;
|
||||
if (e.getActionCommand().equals(ConfirmPanel.A_OK))
|
||||
{
|
||||
// check if saving parameters is complete
|
||||
if (saveParameters())
|
||||
{
|
||||
m_isOK = true;
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
|
||||
dispose();
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Editor Listener
|
||||
* @param evt Event
|
||||
* @exception PropertyVetoException if the recipient wishes to roll back.
|
||||
*/
|
||||
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
|
||||
{
|
||||
// log.fine( "ProcessParameter.vetoableChange");
|
||||
String value = evt.getNewValue() == null ? "" : evt.getNewValue().toString();
|
||||
Env.setContext(Env.getCtx(), m_WindowNo, evt.getPropertyName(), value);
|
||||
} // vetoableChange
|
||||
|
||||
/**
|
||||
* Save Parameter values
|
||||
* @return true if parameters saved
|
||||
*/
|
||||
private boolean saveParameters()
|
||||
{
|
||||
log.config("");
|
||||
|
||||
/**
|
||||
* Mandatory fields
|
||||
* see - MTable.getMandatory
|
||||
*/
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int size = m_mFields.size();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
GridField field = (GridField)m_mFields.get(i);
|
||||
if (field.isMandatory(true)) // check context
|
||||
{
|
||||
VEditor vEditor = (VEditor)m_vEditors.get(i);
|
||||
Object data = vEditor.getValue();
|
||||
if (data == null || data.toString().length() == 0)
|
||||
{
|
||||
field.setInserting (true); // set editable (i.e. updateable) otherwise deadlock
|
||||
field.setError(true);
|
||||
if (sb.length() > 0)
|
||||
sb.append(", ");
|
||||
sb.append(field.getHeader());
|
||||
}
|
||||
else
|
||||
field.setError(false);
|
||||
// Check for Range
|
||||
VEditor vEditor2 = (VEditor)m_vEditors2.get(i);
|
||||
if (vEditor2 != null)
|
||||
{
|
||||
Object data2 = vEditor.getValue();
|
||||
GridField field2 = (GridField)m_mFields2.get(i);
|
||||
if (data2 == null || data2.toString().length() == 0)
|
||||
{
|
||||
field.setInserting (true); // set editable (i.e. updateable) otherwise deadlock
|
||||
field2.setError(true);
|
||||
if (sb.length() > 0)
|
||||
sb.append(", ");
|
||||
sb.append(field.getHeader());
|
||||
}
|
||||
else
|
||||
field2.setError(false);
|
||||
} // range field
|
||||
} // mandatory
|
||||
} // field loop
|
||||
|
||||
|
||||
if (sb.length() != 0)
|
||||
{
|
||||
ADialog.error(m_WindowNo, this, "FillMandatory", sb.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* Save Now
|
||||
*/
|
||||
for (int i = 0; i < m_mFields.size(); i++)
|
||||
{
|
||||
// Get Values
|
||||
VEditor editor = (VEditor)m_vEditors.get(i);
|
||||
VEditor editor2 = (VEditor)m_vEditors2.get(i);
|
||||
Object result = editor.getValue();
|
||||
Object result2 = null;
|
||||
if (editor2 != null)
|
||||
result2 = editor2.getValue();
|
||||
|
||||
// Don't save NULL values
|
||||
if (result == null && result2 == null)
|
||||
continue;
|
||||
|
||||
// Create Parameter
|
||||
MPInstancePara para = new MPInstancePara (Env.getCtx(), m_processInfo.getAD_PInstance_ID(), i);
|
||||
GridField mField = (GridField)m_mFields.get(i);
|
||||
para.setParameterName(mField.getColumnName());
|
||||
|
||||
// Date
|
||||
if (result instanceof Timestamp || result2 instanceof Timestamp)
|
||||
{
|
||||
para.setP_Date((Timestamp)result);
|
||||
if (editor2 != null && result2 != null)
|
||||
para.setP_Date_To((Timestamp)result2);
|
||||
}
|
||||
// Integer
|
||||
else if (result instanceof Integer || result2 instanceof Integer)
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
Integer ii = (Integer)result;
|
||||
para.setP_Number(ii.intValue());
|
||||
}
|
||||
if (editor2 != null && result2 != null)
|
||||
{
|
||||
Integer ii = (Integer)result2;
|
||||
para.setP_Number_To(ii.intValue());
|
||||
}
|
||||
}
|
||||
// BigDecimal
|
||||
else if (result instanceof BigDecimal || result2 instanceof BigDecimal)
|
||||
{
|
||||
para.setP_Number ((BigDecimal)result);
|
||||
if (editor2 != null && result2 != null)
|
||||
para.setP_Number_To ((BigDecimal)result2);
|
||||
}
|
||||
// Boolean
|
||||
else if (result instanceof Boolean)
|
||||
{
|
||||
Boolean bb = (Boolean)result;
|
||||
String value = bb.booleanValue() ? "Y" : "N";
|
||||
para.setP_String (value);
|
||||
// to does not make sense
|
||||
}
|
||||
// String
|
||||
else
|
||||
{
|
||||
if (result != null)
|
||||
para.setP_String (result.toString());
|
||||
if (editor2 != null && result2 != null)
|
||||
para.setP_String_To (result2.toString());
|
||||
}
|
||||
|
||||
// Info
|
||||
para.setInfo (editor.getDisplay());
|
||||
if (editor2 != null)
|
||||
para.setInfo_To (editor2.getDisplay());
|
||||
//
|
||||
para.save();
|
||||
log.fine(para.toString());
|
||||
} // for every parameter
|
||||
|
||||
return true;
|
||||
} // saveParameters
|
||||
|
||||
/**
|
||||
* Is everything OK?
|
||||
* @return true if parameters saved correctly
|
||||
*/
|
||||
public boolean isOK()
|
||||
{
|
||||
return m_isOK;
|
||||
} // isOK
|
||||
|
||||
} // ProcessParameter
|
||||
m_mFields2.add (mField2);
|
||||
// The Editor
|
||||
VEditor vEditor2 = VEditorFactory.getEditor(mField2, false);
|
||||
// New Field value to be updated to editor
|
||||
mField2.addPropertyChangeListener(vEditor2);
|
||||
// Set Default
|
||||
Object defaultObject2 = mField2.getDefault();
|
||||
mField2.setValue (defaultObject2, true);
|
||||
//
|
||||
centerPanel.add ((Component)vEditor2, gbc);
|
||||
m_vEditors2.add (vEditor2);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mFields2.add (null);
|
||||
m_vEditors2.add (null);
|
||||
}
|
||||
} // createField
|
||||
|
||||
/**
|
||||
* Action Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
m_isOK = false;
|
||||
if (e.getActionCommand().equals(ConfirmPanel.A_OK))
|
||||
{
|
||||
// check if saving parameters is complete
|
||||
if (saveParameters())
|
||||
{
|
||||
m_isOK = true;
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
|
||||
dispose();
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Editor Listener
|
||||
* @param evt Event
|
||||
* @exception PropertyVetoException if the recipient wishes to roll back.
|
||||
*/
|
||||
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
|
||||
{
|
||||
// log.fine( "ProcessParameter.vetoableChange");
|
||||
String value = evt.getNewValue() == null ? "" : evt.getNewValue().toString();
|
||||
Env.setContext(Env.getCtx(), m_WindowNo, evt.getPropertyName(), value);
|
||||
} // vetoableChange
|
||||
|
||||
/**
|
||||
* Save Parameter values
|
||||
* @return true if parameters saved
|
||||
*/
|
||||
private boolean saveParameters()
|
||||
{
|
||||
log.config("");
|
||||
|
||||
/**
|
||||
* Mandatory fields
|
||||
* see - MTable.getMandatory
|
||||
*/
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int size = m_mFields.size();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
GridField field = (GridField)m_mFields.get(i);
|
||||
if (field.isMandatory(true)) // check context
|
||||
{
|
||||
VEditor vEditor = (VEditor)m_vEditors.get(i);
|
||||
Object data = vEditor.getValue();
|
||||
if (data == null || data.toString().length() == 0)
|
||||
{
|
||||
field.setInserting (true); // set editable (i.e. updateable) otherwise deadlock
|
||||
field.setError(true);
|
||||
if (sb.length() > 0)
|
||||
sb.append(", ");
|
||||
sb.append(field.getHeader());
|
||||
}
|
||||
else
|
||||
field.setError(false);
|
||||
// Check for Range
|
||||
VEditor vEditor2 = (VEditor)m_vEditors2.get(i);
|
||||
if (vEditor2 != null)
|
||||
{
|
||||
Object data2 = vEditor.getValue();
|
||||
GridField field2 = (GridField)m_mFields2.get(i);
|
||||
if (data2 == null || data2.toString().length() == 0)
|
||||
{
|
||||
field.setInserting (true); // set editable (i.e. updateable) otherwise deadlock
|
||||
field2.setError(true);
|
||||
if (sb.length() > 0)
|
||||
sb.append(", ");
|
||||
sb.append(field.getHeader());
|
||||
}
|
||||
else
|
||||
field2.setError(false);
|
||||
} // range field
|
||||
} // mandatory
|
||||
} // field loop
|
||||
|
||||
|
||||
if (sb.length() != 0)
|
||||
{
|
||||
ADialog.error(m_WindowNo, this, "FillMandatory", sb.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* Save Now
|
||||
*/
|
||||
for (int i = 0; i < m_mFields.size(); i++)
|
||||
{
|
||||
// Get Values
|
||||
VEditor editor = (VEditor)m_vEditors.get(i);
|
||||
VEditor editor2 = (VEditor)m_vEditors2.get(i);
|
||||
Object result = editor.getValue();
|
||||
Object result2 = null;
|
||||
if (editor2 != null)
|
||||
result2 = editor2.getValue();
|
||||
|
||||
// Don't save NULL values
|
||||
if (result == null && result2 == null)
|
||||
continue;
|
||||
|
||||
// Create Parameter
|
||||
MPInstancePara para = new MPInstancePara (Env.getCtx(), m_processInfo.getAD_PInstance_ID(), i);
|
||||
GridField mField = (GridField)m_mFields.get(i);
|
||||
para.setParameterName(mField.getColumnName());
|
||||
|
||||
// Date
|
||||
if (result instanceof Timestamp || result2 instanceof Timestamp)
|
||||
{
|
||||
para.setP_Date((Timestamp)result);
|
||||
if (editor2 != null && result2 != null)
|
||||
para.setP_Date_To((Timestamp)result2);
|
||||
}
|
||||
// Integer
|
||||
else if (result instanceof Integer || result2 instanceof Integer)
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
Integer ii = (Integer)result;
|
||||
para.setP_Number(ii.intValue());
|
||||
}
|
||||
if (editor2 != null && result2 != null)
|
||||
{
|
||||
Integer ii = (Integer)result2;
|
||||
para.setP_Number_To(ii.intValue());
|
||||
}
|
||||
}
|
||||
// BigDecimal
|
||||
else if (result instanceof BigDecimal || result2 instanceof BigDecimal)
|
||||
{
|
||||
para.setP_Number ((BigDecimal)result);
|
||||
if (editor2 != null && result2 != null)
|
||||
para.setP_Number_To ((BigDecimal)result2);
|
||||
}
|
||||
// Boolean
|
||||
else if (result instanceof Boolean)
|
||||
{
|
||||
Boolean bb = (Boolean)result;
|
||||
String value = bb.booleanValue() ? "Y" : "N";
|
||||
para.setP_String (value);
|
||||
// to does not make sense
|
||||
}
|
||||
// String
|
||||
else
|
||||
{
|
||||
if (result != null)
|
||||
para.setP_String (result.toString());
|
||||
if (editor2 != null && result2 != null)
|
||||
para.setP_String_To (result2.toString());
|
||||
}
|
||||
|
||||
// Info
|
||||
para.setInfo (editor.getDisplay());
|
||||
if (editor2 != null)
|
||||
para.setInfo_To (editor2.getDisplay());
|
||||
//
|
||||
para.save();
|
||||
log.fine(para.toString());
|
||||
} // for every parameter
|
||||
|
||||
return true;
|
||||
} // saveParameters
|
||||
|
||||
/**
|
||||
* Is everything OK?
|
||||
* @return true if parameters saved correctly
|
||||
*/
|
||||
public boolean isOK()
|
||||
{
|
||||
return m_isOK;
|
||||
} // isOK
|
||||
|
||||
} // ProcessParameter
|
||||
|
|
|
@ -123,7 +123,7 @@ public class WindowManager {
|
|||
for ( CFrame w : windows ) {
|
||||
if ( w instanceof FormFrame ) {
|
||||
FormFrame ff = (FormFrame)w;
|
||||
if ( ff.getAD_Form_ID() == AD_FORM_ID )
|
||||
//if ( ff.getAD_Form_ID() == AD_FORM_ID )
|
||||
return ff;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,88 +3,85 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps.form;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import org.compiere.apps.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Form Framework
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: FormFrame.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class FormFrame extends CFrame
|
||||
implements ActionListener
|
||||
{
|
||||
/**
|
||||
* Create Form.
|
||||
* Need to call openForm
|
||||
*/
|
||||
public FormFrame ()
|
||||
{
|
||||
super();
|
||||
addWindowListener(new java.awt.event.WindowAdapter()
|
||||
{
|
||||
public void windowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
formWindowOpened(evt);
|
||||
}
|
||||
});
|
||||
|
||||
m_WindowNo = Env.createWindowNo (this);
|
||||
setGlassPane(m_glassPane);
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
createMenu();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // FormFrame
|
||||
|
||||
/** WindowNo */
|
||||
private int m_WindowNo;
|
||||
/** The GlassPane */
|
||||
private AGlassPane m_glassPane = new AGlassPane();
|
||||
/** Description */
|
||||
private String m_Description = null;
|
||||
/** Help */
|
||||
private String m_Help = null;
|
||||
/** Menu Bar */
|
||||
private JMenuBar menuBar = new JMenuBar();
|
||||
/** The Panel to be displayed */
|
||||
private FormPanel m_panel = null;
|
||||
/** Maximize Window */
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.apps.form;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import org.compiere.apps.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Form Framework
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: FormFrame.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class FormFrame extends CFrame
|
||||
implements ActionListener
|
||||
{
|
||||
/**
|
||||
* Create Form.
|
||||
* Need to call openForm
|
||||
*/
|
||||
public FormFrame ()
|
||||
{
|
||||
super();
|
||||
addWindowListener(new java.awt.event.WindowAdapter()
|
||||
{
|
||||
public void windowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
formWindowOpened(evt);
|
||||
}
|
||||
});
|
||||
|
||||
m_WindowNo = Env.createWindowNo (this);
|
||||
setGlassPane(m_glassPane);
|
||||
try
|
||||
{
|
||||
jbInit();
|
||||
createMenu();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // FormFrame
|
||||
|
||||
/** WindowNo */
|
||||
private int m_WindowNo;
|
||||
/** The GlassPane */
|
||||
private AGlassPane m_glassPane = new AGlassPane();
|
||||
/** Description */
|
||||
private String m_Description = null;
|
||||
/** Help */
|
||||
private String m_Help = null;
|
||||
/** Menu Bar */
|
||||
private JMenuBar menuBar = new JMenuBar();
|
||||
/** The Panel to be displayed */
|
||||
private FormPanel m_panel = null;
|
||||
/** Maximize Window */
|
||||
public boolean m_maximize = false;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(FormFrame.class);
|
||||
|
||||
/** Form ID */
|
||||
private int p_AD_Form_ID = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Static Init
|
||||
* @throws Exception
|
||||
|
@ -95,280 +92,266 @@ public class FormFrame extends CFrame
|
|||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
this.setJMenuBar(menuBar);
|
||||
} // jbInit
|
||||
|
||||
/**
|
||||
* Create Menu
|
||||
*/
|
||||
private void createMenu()
|
||||
{
|
||||
// File
|
||||
JMenu mFile = AEnv.getMenu("File");
|
||||
menuBar.add(mFile);
|
||||
AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this);
|
||||
AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, Event.SHIFT_MASK), mFile, this);
|
||||
AEnv.addMenuItem("Report", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.ALT_MASK), mFile, this);
|
||||
mFile.addSeparator();
|
||||
AEnv.addMenuItem("End", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.ALT_MASK), mFile, this);
|
||||
AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.SHIFT_MASK+Event.ALT_MASK), mFile, this);
|
||||
|
||||
// View
|
||||
JMenu mView = AEnv.getMenu("View");
|
||||
menuBar.add(mView);
|
||||
AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK), mView, this);
|
||||
AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK), mView, this);
|
||||
AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK+Event.CTRL_MASK), mView, this);
|
||||
mView.addSeparator();
|
||||
AEnv.addMenuItem("InfoOrder", "Info", null, mView, this);
|
||||
AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this);
|
||||
AEnv.addMenuItem("InfoInOut", "Info", null, mView, this);
|
||||
AEnv.addMenuItem("InfoPayment", "Info", null, mView, this);
|
||||
AEnv.addMenuItem("InfoSchedule", "Info", null, mView, this);
|
||||
|
||||
// Tools
|
||||
JMenu mTools = AEnv.getMenu("Tools");
|
||||
menuBar.add(mTools);
|
||||
AEnv.addMenuItem("Calculator", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Calendar", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Editor", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Script", null, null, mTools, this);
|
||||
if (MRole.getDefault().isShowPreference())
|
||||
{
|
||||
|
||||
/**
|
||||
* Create Menu
|
||||
*/
|
||||
private void createMenu()
|
||||
{
|
||||
// File
|
||||
JMenu mFile = AEnv.getMenu("File");
|
||||
menuBar.add(mFile);
|
||||
AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this);
|
||||
AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, Event.SHIFT_MASK), mFile, this);
|
||||
AEnv.addMenuItem("Report", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.ALT_MASK), mFile, this);
|
||||
mFile.addSeparator();
|
||||
AEnv.addMenuItem("End", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.ALT_MASK), mFile, this);
|
||||
AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.SHIFT_MASK+Event.ALT_MASK), mFile, this);
|
||||
|
||||
// View
|
||||
JMenu mView = AEnv.getMenu("View");
|
||||
menuBar.add(mView);
|
||||
AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK), mView, this);
|
||||
AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK), mView, this);
|
||||
AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK+Event.CTRL_MASK), mView, this);
|
||||
mView.addSeparator();
|
||||
AEnv.addMenuItem("InfoOrder", "Info", null, mView, this);
|
||||
AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this);
|
||||
AEnv.addMenuItem("InfoInOut", "Info", null, mView, this);
|
||||
AEnv.addMenuItem("InfoPayment", "Info", null, mView, this);
|
||||
AEnv.addMenuItem("InfoSchedule", "Info", null, mView, this);
|
||||
|
||||
// Tools
|
||||
JMenu mTools = AEnv.getMenu("Tools");
|
||||
menuBar.add(mTools);
|
||||
AEnv.addMenuItem("Calculator", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Calendar", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Editor", null, null, mTools, this);
|
||||
AEnv.addMenuItem("Script", null, null, mTools, this);
|
||||
if (MRole.getDefault().isShowPreference())
|
||||
{
|
||||
mTools.addSeparator();
|
||||
AEnv.addMenuItem("Preference", null, null, mTools, this);
|
||||
}
|
||||
|
||||
// Window
|
||||
AMenu aMenu = (AMenu)Env.getWindow(0);
|
||||
JMenu mWindow = new WindowMenu(aMenu.getWindowManager(), this);
|
||||
menuBar.add(mWindow);
|
||||
|
||||
// Help
|
||||
JMenu mHelp = AEnv.getMenu("Help");
|
||||
menuBar.add(mHelp);
|
||||
AEnv.addMenuItem("Help", "Help", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), mHelp, this);
|
||||
AEnv.addMenuItem("Online", null, null, mHelp, this);
|
||||
AEnv.addMenuItem("EMailSupport", null, null, mHelp, this);
|
||||
AEnv.addMenuItem("About", null, null, mHelp, this);
|
||||
} // createMenu
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
log.config("");
|
||||
// recursive calls
|
||||
if (Trace.isCalledFrom("JFrame")) // [x] close window pressed
|
||||
m_panel.dispose();
|
||||
m_panel = null;
|
||||
Env.clearWinContext(m_WindowNo);
|
||||
super.dispose();
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Open Form
|
||||
* @param AD_Form_ID form
|
||||
* @return true if form opened
|
||||
*/
|
||||
public boolean openForm (int AD_Form_ID)
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
//
|
||||
String name = null;
|
||||
String className = null;
|
||||
String sql = "SELECT Name, Description, ClassName, Help FROM AD_Form WHERE AD_Form_ID=?";
|
||||
boolean trl = !Env.isBaseLanguage(ctx, "AD_Form");
|
||||
if (trl)
|
||||
sql = "SELECT t.Name, t.Description, f.ClassName, t.Help "
|
||||
+ "FROM AD_Form f INNER JOIN AD_Form_Trl t"
|
||||
+ " ON (f.AD_Form_ID=t.AD_Form_ID AND AD_Language=?)"
|
||||
+ "WHERE f.AD_Form_ID=?";
|
||||
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement (sql, null);
|
||||
if (trl)
|
||||
{
|
||||
pstmt.setString(1, Env.getAD_Language(ctx));
|
||||
pstmt.setInt(2, AD_Form_ID);
|
||||
}
|
||||
else
|
||||
pstmt.setInt(1, AD_Form_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
name = rs.getString(1);
|
||||
m_Description = rs.getString(2);
|
||||
className = rs.getString(3);
|
||||
m_Help = rs.getString(4);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (className == null)
|
||||
return false;
|
||||
//
|
||||
return openForm(AD_Form_ID, className, name);
|
||||
} // openForm
|
||||
|
||||
/**
|
||||
* Open Form
|
||||
* @param AD_Form_ID Form
|
||||
* @param className class name
|
||||
* @param name title
|
||||
* @return true if started
|
||||
*/
|
||||
protected boolean openForm (int AD_Form_ID, String className, String name)
|
||||
{
|
||||
log.info("AD_Form_ID=" + AD_Form_ID + " - Class=" + className);
|
||||
Properties ctx = Env.getCtx();
|
||||
Env.setContext(ctx, m_WindowNo, "WindowName", name);
|
||||
setTitle(Env.getHeader(ctx, m_WindowNo));
|
||||
|
||||
try
|
||||
{
|
||||
// Create instance w/o parameters
|
||||
m_panel = (FormPanel)Class.forName(className).newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "Class=" + className + ", AD_Form_ID=" + AD_Form_ID, e);
|
||||
return false;
|
||||
menuBar.add(mHelp);
|
||||
AEnv.addMenuItem("Help", "Help", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), mHelp, this);
|
||||
AEnv.addMenuItem("Online", null, null, mHelp, this);
|
||||
AEnv.addMenuItem("EMailSupport", null, null, mHelp, this);
|
||||
AEnv.addMenuItem("About", null, null, mHelp, this);
|
||||
} // createMenu
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
log.config("");
|
||||
// recursive calls
|
||||
if (Trace.isCalledFrom("JFrame")) // [x] close window pressed
|
||||
m_panel.dispose();
|
||||
m_panel = null;
|
||||
Env.clearWinContext(m_WindowNo);
|
||||
super.dispose();
|
||||
} // dispose
|
||||
|
||||
/**
|
||||
* Open Form
|
||||
* @param AD_Form_ID form
|
||||
* @return true if form opened
|
||||
*/
|
||||
public boolean openForm (int AD_Form_ID)
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
//
|
||||
String name = null;
|
||||
String className = null;
|
||||
String sql = "SELECT Name, Description, ClassName, Help FROM AD_Form WHERE AD_Form_ID=?";
|
||||
boolean trl = !Env.isBaseLanguage(ctx, "AD_Form");
|
||||
if (trl)
|
||||
sql = "SELECT t.Name, t.Description, f.ClassName, t.Help "
|
||||
+ "FROM AD_Form f INNER JOIN AD_Form_Trl t"
|
||||
+ " ON (f.AD_Form_ID=t.AD_Form_ID AND AD_Language=?)"
|
||||
+ "WHERE f.AD_Form_ID=?";
|
||||
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement (sql, null);
|
||||
if (trl)
|
||||
{
|
||||
pstmt.setString(1, Env.getAD_Language(ctx));
|
||||
pstmt.setInt(2, AD_Form_ID);
|
||||
}
|
||||
else
|
||||
pstmt.setInt(1, AD_Form_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
name = rs.getString(1);
|
||||
m_Description = rs.getString(2);
|
||||
className = rs.getString(3);
|
||||
m_Help = rs.getString(4);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
if (className == null)
|
||||
return false;
|
||||
//
|
||||
return openForm(AD_Form_ID, className, name);
|
||||
} // openForm
|
||||
|
||||
/**
|
||||
* Open Form
|
||||
* @param AD_Form_ID Form
|
||||
* @param className class name
|
||||
* @param name title
|
||||
* @return true if started
|
||||
*/
|
||||
protected boolean openForm (int AD_Form_ID, String className, String name)
|
||||
{
|
||||
log.info("AD_Form_ID=" + AD_Form_ID + " - Class=" + className);
|
||||
Properties ctx = Env.getCtx();
|
||||
Env.setContext(ctx, m_WindowNo, "WindowName", name);
|
||||
setTitle(Env.getHeader(ctx, m_WindowNo));
|
||||
|
||||
try
|
||||
{
|
||||
// Create instance w/o parameters
|
||||
m_panel = (FormPanel)Class.forName(className).newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "Class=" + className + ", AD_Form_ID=" + AD_Form_ID, e);
|
||||
return false;
|
||||
}
|
||||
//
|
||||
m_panel.init(m_WindowNo, this);
|
||||
p_AD_Form_ID = AD_Form_ID;
|
||||
return true;
|
||||
} // openForm
|
||||
|
||||
/**
|
||||
* Get Form Panel
|
||||
* @return form panel
|
||||
*/
|
||||
public FormPanel getFormPanel()
|
||||
{
|
||||
return m_panel;
|
||||
} // getFormPanel
|
||||
|
||||
/**
|
||||
* Action Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
String cmd = e.getActionCommand();
|
||||
if (cmd.equals("End"))
|
||||
dispose();
|
||||
else if (cmd.equals("Help"))
|
||||
actionHelp();
|
||||
else if (!AEnv.actionPerformed(cmd, m_WindowNo, this))
|
||||
log.log(Level.SEVERE, "Not handeled=" + cmd);
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Show Help
|
||||
*/
|
||||
private void actionHelp()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("<h2>").append(m_Description).append("</h2><p>")
|
||||
.append(m_Help);
|
||||
Help hlp = new Help (Env.getFrame(this), this.getTitle(), sb.toString());
|
||||
hlp.setVisible(true);
|
||||
} // actionHelp
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Set Window Busy
|
||||
* @param busy busy
|
||||
*/
|
||||
public void setBusy (boolean busy)
|
||||
{
|
||||
if (busy == m_glassPane.isVisible())
|
||||
return;
|
||||
log.info("Busy=" + busy);
|
||||
if (busy)
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
else
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
m_glassPane.setMessage(null);
|
||||
m_glassPane.setVisible(busy);
|
||||
m_glassPane.requestFocus();
|
||||
} // setBusy
|
||||
|
||||
/**
|
||||
* Set Busy Message
|
||||
* @param AD_Message message
|
||||
*/
|
||||
public void setBusyMessage (String AD_Message)
|
||||
{
|
||||
m_glassPane.setMessage(AD_Message);
|
||||
} // setBusyMessage
|
||||
|
||||
/**
|
||||
* Set and start Busy Counter
|
||||
* @param time in seconds
|
||||
*/
|
||||
public void setBusyTimer (int time)
|
||||
{
|
||||
m_glassPane.setBusyTimer (time);
|
||||
} // setBusyTimer
|
||||
|
||||
|
||||
/**
|
||||
* Set Maximize Window
|
||||
* @param max maximize
|
||||
*/
|
||||
public void setMaximize (boolean max)
|
||||
{
|
||||
m_maximize = max;
|
||||
} // setMaximize
|
||||
|
||||
|
||||
/**
|
||||
* Form Window Opened.
|
||||
* Maximize window if required
|
||||
* @param evt event
|
||||
*/
|
||||
private void formWindowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
if (m_maximize == true)
|
||||
{
|
||||
super.setVisible(true);
|
||||
super.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
}
|
||||
} // formWindowOpened
|
||||
|
||||
/**
|
||||
* Start Batch
|
||||
* @param process
|
||||
* @return running thread
|
||||
*/
|
||||
public Thread startBatch (final Runnable process)
|
||||
{
|
||||
Thread worker = new Thread()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
setBusy(true);
|
||||
process.run();
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Get Form Panel
|
||||
* @return form panel
|
||||
*/
|
||||
public FormPanel getFormPanel()
|
||||
{
|
||||
return m_panel;
|
||||
} // getFormPanel
|
||||
|
||||
/**
|
||||
* Action Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
String cmd = e.getActionCommand();
|
||||
if (cmd.equals("End"))
|
||||
dispose();
|
||||
else if (cmd.equals("Help"))
|
||||
actionHelp();
|
||||
else if (!AEnv.actionPerformed(cmd, m_WindowNo, this))
|
||||
log.log(Level.SEVERE, "Not handeled=" + cmd);
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Show Help
|
||||
*/
|
||||
private void actionHelp()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("<h2>").append(m_Description).append("</h2><p>")
|
||||
.append(m_Help);
|
||||
Help hlp = new Help (Env.getFrame(this), this.getTitle(), sb.toString());
|
||||
hlp.setVisible(true);
|
||||
} // actionHelp
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Set Window Busy
|
||||
* @param busy busy
|
||||
*/
|
||||
public void setBusy (boolean busy)
|
||||
{
|
||||
if (busy == m_glassPane.isVisible())
|
||||
return;
|
||||
log.info("Busy=" + busy);
|
||||
if (busy)
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
else
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
m_glassPane.setMessage(null);
|
||||
m_glassPane.setVisible(busy);
|
||||
m_glassPane.requestFocus();
|
||||
} // setBusy
|
||||
|
||||
/**
|
||||
* Set Busy Message
|
||||
* @param AD_Message message
|
||||
*/
|
||||
public void setBusyMessage (String AD_Message)
|
||||
{
|
||||
m_glassPane.setMessage(AD_Message);
|
||||
} // setBusyMessage
|
||||
|
||||
/**
|
||||
* Set and start Busy Counter
|
||||
* @param time in seconds
|
||||
*/
|
||||
public void setBusyTimer (int time)
|
||||
{
|
||||
m_glassPane.setBusyTimer (time);
|
||||
} // setBusyTimer
|
||||
|
||||
|
||||
/**
|
||||
* Set Maximize Window
|
||||
* @param max maximize
|
||||
*/
|
||||
public void setMaximize (boolean max)
|
||||
{
|
||||
m_maximize = max;
|
||||
} // setMaximize
|
||||
|
||||
|
||||
/**
|
||||
* Form Window Opened.
|
||||
* Maximize window if required
|
||||
* @param evt event
|
||||
*/
|
||||
private void formWindowOpened(java.awt.event.WindowEvent evt)
|
||||
{
|
||||
if (m_maximize == true)
|
||||
{
|
||||
super.setVisible(true);
|
||||
super.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
}
|
||||
} // formWindowOpened
|
||||
|
||||
/**
|
||||
* Start Batch
|
||||
* @param process
|
||||
* @return running thread
|
||||
*/
|
||||
public Thread startBatch (final Runnable process)
|
||||
{
|
||||
Thread worker = new Thread()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
setBusy(true);
|
||||
process.run();
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
worker.start();
|
||||
return worker;
|
||||
} // startBatch
|
||||
|
||||
/**
|
||||
* @return Returns the AD_Form_ID.
|
||||
*/
|
||||
public int getAD_Form_ID ()
|
||||
{
|
||||
return p_AD_Form_ID;
|
||||
} // getAD_Window_ID
|
||||
|
||||
|
||||
} // FormFrame
|
||||
|
|
|
@ -209,7 +209,7 @@ public class VFileImport extends CPanel
|
|||
confirmPanel.setEnabled(false);
|
||||
m_frame.setBusy(true);
|
||||
//
|
||||
SwingWorker worker = new SwingWorker()
|
||||
org.compiere.apps.SwingWorker worker = new org.compiere.apps.SwingWorker()
|
||||
{
|
||||
public Object construct()
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -403,7 +403,6 @@ public class VTrxMaterial extends CPanel
|
|||
setCursor(Cursor.getDefaultCursor());
|
||||
return;
|
||||
}
|
||||
AEnv.addToWindowManager(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
frame = null;
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
|
|
|
@ -686,7 +686,6 @@ public abstract class Info extends CDialog
|
|||
final AWindow frame = new AWindow();
|
||||
if (!frame.initWindow(AD_Window_ID, zoomQuery))
|
||||
return;
|
||||
AEnv.addToWindowManager(frame);
|
||||
// Modal Window causes UI lock
|
||||
if (isModal())
|
||||
{
|
||||
|
|
|
@ -509,7 +509,6 @@ public class WFActivity extends CPanel
|
|||
AWindow frame = new AWindow();
|
||||
if (!frame.initWindow(AD_Window_ID, query))
|
||||
return;
|
||||
AEnv.addToWindowManager(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
frame = null;
|
||||
}
|
||||
|
@ -519,7 +518,6 @@ public class WFActivity extends CPanel
|
|||
FormFrame ff = new FormFrame();
|
||||
ff.openForm(AD_Form_ID);
|
||||
ff.pack();
|
||||
AEnv.addToWindowManager(ff);
|
||||
AEnv.showCenterScreen(ff);
|
||||
}
|
||||
else if (MWFNode.ACTION_UserWorkbench.equals(node.getAction()))
|
||||
|
|
|
@ -432,7 +432,6 @@ public class WFPanel extends CPanel
|
|||
AWindow frame = new AWindow();
|
||||
if (!frame.initWindow (AD_Window_ID, query))
|
||||
return;
|
||||
AEnv.addToWindowManager(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
frame = null;
|
||||
} // zoom
|
||||
|
|
|
@ -3,255 +3,255 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid;
|
||||
|
||||
import java.beans.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.table.*;
|
||||
import org.compiere.apps.*;
|
||||
import org.compiere.grid.ed.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Create Transactions for Bank Statements
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VCreateFromStatement.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class VCreateFromStatement extends VCreateFrom implements VetoableChangeListener
|
||||
{
|
||||
/**
|
||||
* Protected Constructor
|
||||
* @param mTab MTab
|
||||
*/
|
||||
VCreateFromStatement(GridTab mTab)
|
||||
{
|
||||
super (mTab);
|
||||
log.info("");
|
||||
} // VCreateFromStatement
|
||||
|
||||
/**
|
||||
* Dynamic Init
|
||||
* @throws Exception if Lookups cannot be initialized
|
||||
* @return true if initialized
|
||||
*/
|
||||
protected boolean dynInit() throws Exception
|
||||
{
|
||||
if (p_mTab.getValue("C_BankStatement_ID") == null)
|
||||
{
|
||||
ADialog.error(0, this, "SaveErrorRowNotFound");
|
||||
return false;
|
||||
}
|
||||
|
||||
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||
parameterStdPanel.setVisible(false);
|
||||
|
||||
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
|
||||
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
||||
bankAccountField = new VLookup ("C_BankAccount_ID", true, false, true, lookup);
|
||||
bankAccountField.addVetoableChangeListener(this);
|
||||
// Set Default
|
||||
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
||||
bankAccountField.setValue(new Integer(C_BankAccount_ID));
|
||||
// initial Loading
|
||||
loadBankAccount(C_BankAccount_ID);
|
||||
|
||||
return true;
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
* Init Details (never called)
|
||||
* @param C_BPartner_ID BPartner
|
||||
*/
|
||||
protected void initBPDetails(int C_BPartner_ID)
|
||||
{
|
||||
} // initDetails
|
||||
|
||||
/**
|
||||
* Change Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void vetoableChange (PropertyChangeEvent e)
|
||||
{
|
||||
log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||
|
||||
// BankAccount
|
||||
if (e.getPropertyName() == "C_BankAccount_ID")
|
||||
{
|
||||
int C_BankAccount_ID = ((Integer)e.getNewValue()).intValue();
|
||||
loadBankAccount(C_BankAccount_ID);
|
||||
}
|
||||
tableChanged(null);
|
||||
} // vetoableChange
|
||||
|
||||
/**
|
||||
* Load Data - Bank Account
|
||||
* @param C_BankAccount_ID Bank Account
|
||||
*/
|
||||
private void loadBankAccount (int C_BankAccount_ID)
|
||||
{
|
||||
log.config ("C_BankAccount_ID=" + C_BankAccount_ID);
|
||||
/**
|
||||
* Selected - 0
|
||||
* Date - 1
|
||||
* C_Payment_ID - 2
|
||||
* C_Currenncy - 3
|
||||
* Amt - 4
|
||||
*/
|
||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||
String sql = "SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,"
|
||||
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID)," // #1
|
||||
+ " bp.Name "
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid;
|
||||
|
||||
import java.beans.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.table.*;
|
||||
import org.compiere.apps.*;
|
||||
import org.compiere.grid.ed.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Create Transactions for Bank Statements
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VCreateFromStatement.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class VCreateFromStatement extends VCreateFrom implements VetoableChangeListener
|
||||
{
|
||||
/**
|
||||
* Protected Constructor
|
||||
* @param mTab MTab
|
||||
*/
|
||||
VCreateFromStatement(GridTab mTab)
|
||||
{
|
||||
super (mTab);
|
||||
log.info("");
|
||||
} // VCreateFromStatement
|
||||
|
||||
/**
|
||||
* Dynamic Init
|
||||
* @throws Exception if Lookups cannot be initialized
|
||||
* @return true if initialized
|
||||
*/
|
||||
protected boolean dynInit() throws Exception
|
||||
{
|
||||
if (p_mTab.getValue("C_BankStatement_ID") == null)
|
||||
{
|
||||
ADialog.error(0, this, "SaveErrorRowNotFound");
|
||||
return false;
|
||||
}
|
||||
|
||||
setTitle(Msg.translate(Env.getCtx(), "C_BankStatement_ID") + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
|
||||
parameterStdPanel.setVisible(false);
|
||||
|
||||
int AD_Column_ID = 4917; // C_BankStatement.C_BankAccount_ID
|
||||
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
|
||||
bankAccountField = new VLookup ("C_BankAccount_ID", true, false, true, lookup);
|
||||
bankAccountField.addVetoableChangeListener(this);
|
||||
// Set Default
|
||||
int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID");
|
||||
bankAccountField.setValue(new Integer(C_BankAccount_ID));
|
||||
// initial Loading
|
||||
loadBankAccount(C_BankAccount_ID);
|
||||
|
||||
return true;
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
* Init Details (never called)
|
||||
* @param C_BPartner_ID BPartner
|
||||
*/
|
||||
protected void initBPDetails(int C_BPartner_ID)
|
||||
{
|
||||
} // initDetails
|
||||
|
||||
/**
|
||||
* Change Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void vetoableChange (PropertyChangeEvent e)
|
||||
{
|
||||
log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||
|
||||
// BankAccount
|
||||
if (e.getPropertyName() == "C_BankAccount_ID")
|
||||
{
|
||||
int C_BankAccount_ID = ((Integer)e.getNewValue()).intValue();
|
||||
loadBankAccount(C_BankAccount_ID);
|
||||
}
|
||||
tableChanged(null);
|
||||
} // vetoableChange
|
||||
|
||||
/**
|
||||
* Load Data - Bank Account
|
||||
* @param C_BankAccount_ID Bank Account
|
||||
*/
|
||||
private void loadBankAccount (int C_BankAccount_ID)
|
||||
{
|
||||
log.config ("C_BankAccount_ID=" + C_BankAccount_ID);
|
||||
/**
|
||||
* Selected - 0
|
||||
* Date - 1
|
||||
* C_Payment_ID - 2
|
||||
* C_Currenncy - 3
|
||||
* Amt - 4
|
||||
*/
|
||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||
String sql = "SELECT p.DateTrx,p.C_Payment_ID,p.DocumentNo, p.C_Currency_ID,c.ISO_Code, p.PayAmt,"
|
||||
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,ba.C_Currency_ID,?,null,p.AD_Client_ID,p.AD_Org_ID)," // #1
|
||||
+ " bp.Name "
|
||||
+ "FROM C_BankAccount ba"
|
||||
+ " INNER JOIN C_Payment_v p ON (p.C_BankAccount_ID=ba.C_BankAccount_ID)"
|
||||
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID)"
|
||||
+ " INNER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
|
||||
+ " LEFT OUTER JOIN C_BPartner bp ON (p.C_BPartner_ID=bp.C_BPartner_ID) "
|
||||
+ "WHERE p.Processed='Y' AND p.IsReconciled='N'"
|
||||
+ " AND p.DocStatus IN ('CO','CL','RE','VO') AND p.PayAmt<>0" // Bug 1564453 Added Voided payment to bank statement payement selection
|
||||
+ " AND p.C_BankAccount_ID=?" // #2
|
||||
+ " AND NOT EXISTS (SELECT * FROM C_BankStatementLine l "
|
||||
// Voided Bank Statements have 0 StmtAmt
|
||||
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
|
||||
|
||||
// Get StatementDate
|
||||
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
|
||||
if (ts == null)
|
||||
ts = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt.setTimestamp(1, ts);
|
||||
pstmt.setInt(2, C_BankAccount_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
Vector<Object> line = new Vector<Object>(6);
|
||||
line.add(new Boolean(false)); // 0-Selection
|
||||
line.add(rs.getTimestamp(1)); // 1-DateTrx
|
||||
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
|
||||
line.add(pp); // 2-C_Payment_ID
|
||||
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
|
||||
line.add(pp); // 3-Currency
|
||||
line.add(rs.getBigDecimal(6)); // 4-PayAmt
|
||||
line.add(rs.getBigDecimal(7)); // 5-Conv Amt
|
||||
line.add(rs.getString(8)); // 6-BParner
|
||||
data.add(line);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
// Header Info
|
||||
Vector<String> columnNames = new Vector<String>(6);
|
||||
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
|
||||
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "Amount"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "ConvertedAmount"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
||||
|
||||
// Remove previous listeners
|
||||
dataTable.getModel().removeTableModelListener(this);
|
||||
// Set Model
|
||||
DefaultTableModel model = new DefaultTableModel(data, columnNames);
|
||||
model.addTableModelListener(this);
|
||||
dataTable.setModel(model);
|
||||
//
|
||||
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||
dataTable.setColumnClass(1, Timestamp.class, true); // 1-TrxDate
|
||||
dataTable.setColumnClass(2, String.class, true); // 2-Payment
|
||||
dataTable.setColumnClass(3, String.class, true); // 3-Currency
|
||||
dataTable.setColumnClass(4, BigDecimal.class, true); // 4-Amount
|
||||
dataTable.setColumnClass(5, BigDecimal.class, true); // 5-ConvAmount
|
||||
dataTable.setColumnClass(6, String.class, true); // 6-BPartner
|
||||
// Table UI
|
||||
dataTable.autoSize();
|
||||
} // loadBankAccount
|
||||
|
||||
/**
|
||||
* List total amount
|
||||
*/
|
||||
protected void info()
|
||||
{
|
||||
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||
|
||||
TableModel model = dataTable.getModel();
|
||||
BigDecimal total = new BigDecimal(0.0);
|
||||
int rows = model.getRowCount();
|
||||
int count = 0;
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||
{
|
||||
total = total.add((BigDecimal)model.getValueAt(i, 4));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
statusBar.setStatusLine(String.valueOf(count) + " - " + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
|
||||
} // infoStatement
|
||||
|
||||
/**
|
||||
* Save Statement - Insert Data
|
||||
* @return true if saved
|
||||
*/
|
||||
protected boolean save()
|
||||
{
|
||||
log.config("");
|
||||
TableModel model = dataTable.getModel();
|
||||
int rows = model.getRowCount();
|
||||
if (rows == 0)
|
||||
return false;
|
||||
|
||||
// fixed values
|
||||
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
|
||||
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
|
||||
log.config(bs.toString());
|
||||
|
||||
// Lines
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||
{
|
||||
Timestamp trxDate = (Timestamp)model.getValueAt(i, 1); // 1-DateTrx
|
||||
KeyNamePair pp = (KeyNamePair)model.getValueAt(i, 2); // 2-C_Payment_ID
|
||||
int C_Payment_ID = pp.getKey();
|
||||
+ "WHERE p.C_Payment_ID=l.C_Payment_ID AND l.StmtAmt <> 0)";
|
||||
|
||||
// Get StatementDate
|
||||
Timestamp ts = (Timestamp)p_mTab.getValue("StatementDate");
|
||||
if (ts == null)
|
||||
ts = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt.setTimestamp(1, ts);
|
||||
pstmt.setInt(2, C_BankAccount_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
Vector<Object> line = new Vector<Object>(6);
|
||||
line.add(new Boolean(false)); // 0-Selection
|
||||
line.add(rs.getTimestamp(1)); // 1-DateTrx
|
||||
KeyNamePair pp = new KeyNamePair(rs.getInt(2), rs.getString(3));
|
||||
line.add(pp); // 2-C_Payment_ID
|
||||
pp = new KeyNamePair(rs.getInt(4), rs.getString(5));
|
||||
line.add(pp); // 3-Currency
|
||||
line.add(rs.getBigDecimal(6)); // 4-PayAmt
|
||||
line.add(rs.getBigDecimal(7)); // 5-Conv Amt
|
||||
line.add(rs.getString(8)); // 6-BParner
|
||||
data.add(line);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
// Header Info
|
||||
Vector<String> columnNames = new Vector<String>(6);
|
||||
columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
|
||||
columnNames.add(Msg.getElement(Env.getCtx(), "C_Payment_ID"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "Amount"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "ConvertedAmount"));
|
||||
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
|
||||
|
||||
// Remove previous listeners
|
||||
dataTable.getModel().removeTableModelListener(this);
|
||||
// Set Model
|
||||
DefaultTableModel model = new DefaultTableModel(data, columnNames);
|
||||
model.addTableModelListener(this);
|
||||
dataTable.setModel(model);
|
||||
//
|
||||
dataTable.setColumnClass(0, Boolean.class, false); // 0-Selection
|
||||
dataTable.setColumnClass(1, Timestamp.class, true); // 1-TrxDate
|
||||
dataTable.setColumnClass(2, String.class, true); // 2-Payment
|
||||
dataTable.setColumnClass(3, String.class, true); // 3-Currency
|
||||
dataTable.setColumnClass(4, BigDecimal.class, true); // 4-Amount
|
||||
dataTable.setColumnClass(5, BigDecimal.class, true); // 5-ConvAmount
|
||||
dataTable.setColumnClass(6, String.class, true); // 6-BPartner
|
||||
// Table UI
|
||||
dataTable.autoSize();
|
||||
} // loadBankAccount
|
||||
|
||||
/**
|
||||
* List total amount
|
||||
*/
|
||||
protected void info()
|
||||
{
|
||||
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount);
|
||||
|
||||
TableModel model = dataTable.getModel();
|
||||
BigDecimal total = new BigDecimal(0.0);
|
||||
int rows = model.getRowCount();
|
||||
int count = 0;
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||
{
|
||||
total = total.add((BigDecimal)model.getValueAt(i, 4));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
statusBar.setStatusLine(String.valueOf(count) + " - " + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(total));
|
||||
} // infoStatement
|
||||
|
||||
/**
|
||||
* Save Statement - Insert Data
|
||||
* @return true if saved
|
||||
*/
|
||||
protected boolean save()
|
||||
{
|
||||
log.config("");
|
||||
TableModel model = dataTable.getModel();
|
||||
int rows = model.getRowCount();
|
||||
if (rows == 0)
|
||||
return false;
|
||||
|
||||
// fixed values
|
||||
int C_BankStatement_ID = ((Integer)p_mTab.getValue("C_BankStatement_ID")).intValue();
|
||||
MBankStatement bs = new MBankStatement (Env.getCtx(), C_BankStatement_ID, null);
|
||||
log.config(bs.toString());
|
||||
|
||||
// Lines
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
if (((Boolean)model.getValueAt(i, 0)).booleanValue())
|
||||
{
|
||||
Timestamp trxDate = (Timestamp)model.getValueAt(i, 1); // 1-DateTrx
|
||||
KeyNamePair pp = (KeyNamePair)model.getValueAt(i, 2); // 2-C_Payment_ID
|
||||
int C_Payment_ID = pp.getKey();
|
||||
pp = (KeyNamePair)model.getValueAt(i, 3); // 3-Currency
|
||||
int C_Currency_ID = pp.getKey();
|
||||
BigDecimal TrxAmt = (BigDecimal)model.getValueAt(i, 4); // 4-PayAmt
|
||||
BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
|
||||
// BigDecimal StmtAmt = (BigDecimal)model.getValueAt(i, 5);// 5-Conv Amt
|
||||
//
|
||||
log.fine("Line Date=" + trxDate
|
||||
+ ", Payment=" + C_Payment_ID + ", Currency=" + C_Currency_ID + ", Amt=" + TrxAmt);
|
||||
//
|
||||
MBankStatementLine bsl = new MBankStatementLine (bs);
|
||||
bsl.setStatementLineDate(trxDate);
|
||||
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
|
||||
if (!bsl.save())
|
||||
log.log(Level.SEVERE, "Line not created #" + i);
|
||||
} // if selected
|
||||
} // for all rows
|
||||
return true;
|
||||
} // save
|
||||
|
||||
} // VCreateFromStatement
|
||||
//
|
||||
MBankStatementLine bsl = new MBankStatementLine (bs);
|
||||
bsl.setStatementLineDate(trxDate);
|
||||
bsl.setPayment(new MPayment(Env.getCtx(), C_Payment_ID, null));
|
||||
if (!bsl.save())
|
||||
log.log(Level.SEVERE, "Line not created #" + i);
|
||||
} // if selected
|
||||
} // for all rows
|
||||
return true;
|
||||
} // save
|
||||
|
||||
} // VCreateFromStatement
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,22 +3,22 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
@ -27,104 +27,104 @@ import org.adempiere.plaf.AdempierePLAF;
|
|||
import org.compiere.model.*;
|
||||
import org.compiere.plaf.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Cell Editor.
|
||||
* <pre>
|
||||
* Sequence of events:
|
||||
* isCellEditable
|
||||
* getTableCellEditor
|
||||
* shouldSelectCell
|
||||
* getCellEditorValue
|
||||
* </pre>
|
||||
* A new Editor is created for editable columns.
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VCellEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public final class VCellEditor extends AbstractCellEditor
|
||||
implements TableCellEditor, VetoableChangeListener, ActionListener
|
||||
{
|
||||
/**
|
||||
* Constructor for Grid
|
||||
* @param mField
|
||||
*/
|
||||
public VCellEditor (GridField mField)
|
||||
{
|
||||
super();
|
||||
m_mField = mField;
|
||||
// Click
|
||||
} // VCellEditor
|
||||
|
||||
/** The Field */
|
||||
private GridField m_mField = null;
|
||||
/** The Table Editor */
|
||||
private VEditor m_editor = null;
|
||||
/** Table */
|
||||
private JTable m_table = null;
|
||||
/** ClickCount */
|
||||
private static int CLICK_TO_START = 2;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VCellEditor.class);
|
||||
|
||||
/**
|
||||
* Create Editor
|
||||
*/
|
||||
private void createEditor()
|
||||
{
|
||||
m_editor = VEditorFactory.getEditor(m_mField, true);
|
||||
m_editor.addVetoableChangeListener(this);
|
||||
m_editor.addActionListener(this);
|
||||
} // createEditor
|
||||
|
||||
/**
|
||||
* Ask the editor if it can start editing using anEvent.
|
||||
* If editing can be started this method returns true.
|
||||
* Previously called: MTable.isCellEditable
|
||||
* @param anEvent event
|
||||
* @return true if editable
|
||||
*/
|
||||
public boolean isCellEditable (EventObject anEvent)
|
||||
{
|
||||
if (!m_mField.isEditable (true)) // row data is in context
|
||||
return false;
|
||||
log.fine(m_mField.getHeader()); // event may be null if CellEdit
|
||||
// not enough mouse clicks
|
||||
if (anEvent instanceof MouseEvent
|
||||
&& ((MouseEvent)anEvent).getClickCount() < CLICK_TO_START)
|
||||
return false;
|
||||
|
||||
if (m_editor == null)
|
||||
createEditor();
|
||||
return true;
|
||||
} // isCellEditable
|
||||
|
||||
/**
|
||||
* Sets an initial value for the editor. This will cause the editor to
|
||||
* stopEditing and lose any partially edited value if the editor is editing
|
||||
* when this method is called.
|
||||
* Returns the component that should be added to the client's Component hierarchy.
|
||||
* Once installed in the client's hierarchy this component
|
||||
* will then be able to draw and receive user input.
|
||||
*
|
||||
* @param table
|
||||
* @param value
|
||||
* @param isSelected
|
||||
* @param row
|
||||
* @param col
|
||||
* @return component
|
||||
*/
|
||||
public Component getTableCellEditorComponent (JTable table, Object value, boolean isSelected, int row, int col)
|
||||
{
|
||||
log.finest(m_mField.getColumnName() + ": Value=" + value + ", row=" + row + ", col=" + col);
|
||||
if (row >= 0)
|
||||
table.setRowSelectionInterval(row,row); // force moving to new row
|
||||
if (m_editor == null)
|
||||
createEditor();
|
||||
|
||||
m_table = table;
|
||||
|
||||
// Set Value
|
||||
m_editor.setValue(value);
|
||||
|
||||
/**
|
||||
* Cell Editor.
|
||||
* <pre>
|
||||
* Sequence of events:
|
||||
* isCellEditable
|
||||
* getTableCellEditor
|
||||
* shouldSelectCell
|
||||
* getCellEditorValue
|
||||
* </pre>
|
||||
* A new Editor is created for editable columns.
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VCellEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public final class VCellEditor extends AbstractCellEditor
|
||||
implements TableCellEditor, VetoableChangeListener, ActionListener
|
||||
{
|
||||
/**
|
||||
* Constructor for Grid
|
||||
* @param mField
|
||||
*/
|
||||
public VCellEditor (GridField mField)
|
||||
{
|
||||
super();
|
||||
m_mField = mField;
|
||||
// Click
|
||||
} // VCellEditor
|
||||
|
||||
/** The Field */
|
||||
private GridField m_mField = null;
|
||||
/** The Table Editor */
|
||||
private VEditor m_editor = null;
|
||||
/** Table */
|
||||
private JTable m_table = null;
|
||||
/** ClickCount */
|
||||
private static int CLICK_TO_START = 2;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VCellEditor.class);
|
||||
|
||||
/**
|
||||
* Create Editor
|
||||
*/
|
||||
private void createEditor()
|
||||
{
|
||||
m_editor = VEditorFactory.getEditor(m_mField, true);
|
||||
m_editor.addVetoableChangeListener(this);
|
||||
m_editor.addActionListener(this);
|
||||
} // createEditor
|
||||
|
||||
/**
|
||||
* Ask the editor if it can start editing using anEvent.
|
||||
* If editing can be started this method returns true.
|
||||
* Previously called: MTable.isCellEditable
|
||||
* @param anEvent event
|
||||
* @return true if editable
|
||||
*/
|
||||
public boolean isCellEditable (EventObject anEvent)
|
||||
{
|
||||
if (!m_mField.isEditable (true)) // row data is in context
|
||||
return false;
|
||||
log.fine(m_mField.getHeader()); // event may be null if CellEdit
|
||||
// not enough mouse clicks
|
||||
if (anEvent instanceof MouseEvent
|
||||
&& ((MouseEvent)anEvent).getClickCount() < CLICK_TO_START)
|
||||
return false;
|
||||
|
||||
if (m_editor == null)
|
||||
createEditor();
|
||||
return true;
|
||||
} // isCellEditable
|
||||
|
||||
/**
|
||||
* Sets an initial value for the editor. This will cause the editor to
|
||||
* stopEditing and lose any partially edited value if the editor is editing
|
||||
* when this method is called.
|
||||
* Returns the component that should be added to the client's Component hierarchy.
|
||||
* Once installed in the client's hierarchy this component
|
||||
* will then be able to draw and receive user input.
|
||||
*
|
||||
* @param table
|
||||
* @param value
|
||||
* @param isSelected
|
||||
* @param row
|
||||
* @param col
|
||||
* @return component
|
||||
*/
|
||||
public Component getTableCellEditorComponent (JTable table, Object value, boolean isSelected, int row, int col)
|
||||
{
|
||||
log.finest(m_mField.getColumnName() + ": Value=" + value + ", row=" + row + ", col=" + col);
|
||||
if (row >= 0)
|
||||
table.setRowSelectionInterval(row,row); // force moving to new row
|
||||
if (m_editor == null)
|
||||
createEditor();
|
||||
|
||||
m_table = table;
|
||||
|
||||
// Set Value
|
||||
m_editor.setValue(value);
|
||||
|
||||
// Set Background/Foreground to "normal" (unselected) colors
|
||||
m_editor.setBackground(m_mField.isError());
|
||||
|
@ -132,84 +132,75 @@ public final class VCellEditor extends AbstractCellEditor
|
|||
|
||||
// Other UI
|
||||
m_editor.setFont(table.getFont());
|
||||
if ( m_editor instanceof VLookup) {
|
||||
VLookup lookup = (VLookup)m_editor;
|
||||
if (lookup.getComponents()[0] instanceof JComboBox) {
|
||||
lookup.setBorder(BorderFactory.createEmptyBorder());
|
||||
} else {
|
||||
lookup.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
|
||||
}
|
||||
} else {
|
||||
m_editor.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
|
||||
}
|
||||
m_editor.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
|
||||
//
|
||||
return (Component)m_editor;
|
||||
} // getTableCellEditorComponent
|
||||
|
||||
/**
|
||||
* The editing cell should be selected or not
|
||||
* @param e event
|
||||
* @return true (constant)
|
||||
*/
|
||||
public boolean shouldSelectCell(EventObject e)
|
||||
{
|
||||
log.finest(m_mField.getColumnName());
|
||||
return true;
|
||||
} // shouldSelectCell
|
||||
|
||||
/**
|
||||
* Returns the value contained in the editor
|
||||
* @return value
|
||||
*/
|
||||
public Object getCellEditorValue()
|
||||
{
|
||||
log.finest(m_mField.getColumnName() + ": " + m_editor.getValue());
|
||||
return m_editor.getValue();
|
||||
} // getCellEditorValue
|
||||
|
||||
/**
|
||||
* VEditor Change Listener (property name is columnName).
|
||||
* - indicate change (for String/Text/..) <br>
|
||||
* When editing is complete the value is retrieved via getCellEditorValue
|
||||
* @param e event
|
||||
*/
|
||||
public void vetoableChange(PropertyChangeEvent e)
|
||||
{
|
||||
if (m_table == null)
|
||||
return;
|
||||
log.fine(e.getPropertyName() + "=" + e.getNewValue());
|
||||
//
|
||||
((GridTable)m_table.getModel()).setChanged(true);
|
||||
} // vetoableChange
|
||||
|
||||
/**
|
||||
* Get Actual Editor.
|
||||
* Called from GridController to add ActionListener to Button
|
||||
* @return VEditor
|
||||
*/
|
||||
public VEditor getEditor()
|
||||
{
|
||||
return m_editor;
|
||||
} // getEditor
|
||||
|
||||
/**
|
||||
* Action Editor - Stop Editor
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
log.finer(m_mField.getColumnName() + ": Value=" + m_editor.getValue());
|
||||
// super.stopCellEditing(); // causes VLookup.Search Text not to work
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_editor = null;
|
||||
m_mField = null;
|
||||
m_table = null;
|
||||
} // dispose
|
||||
|
||||
} // VCellEditor
|
||||
|
||||
/**
|
||||
* The editing cell should be selected or not
|
||||
* @param e event
|
||||
* @return true (constant)
|
||||
*/
|
||||
public boolean shouldSelectCell(EventObject e)
|
||||
{
|
||||
log.finest(m_mField.getColumnName());
|
||||
return true;
|
||||
} // shouldSelectCell
|
||||
|
||||
/**
|
||||
* Returns the value contained in the editor
|
||||
* @return value
|
||||
*/
|
||||
public Object getCellEditorValue()
|
||||
{
|
||||
log.finest(m_mField.getColumnName() + ": " + m_editor.getValue());
|
||||
return m_editor.getValue();
|
||||
} // getCellEditorValue
|
||||
|
||||
/**
|
||||
* VEditor Change Listener (property name is columnName).
|
||||
* - indicate change (for String/Text/..) <br>
|
||||
* When editing is complete the value is retrieved via getCellEditorValue
|
||||
* @param e event
|
||||
*/
|
||||
public void vetoableChange(PropertyChangeEvent e)
|
||||
{
|
||||
if (m_table == null)
|
||||
return;
|
||||
log.fine(e.getPropertyName() + "=" + e.getNewValue());
|
||||
//
|
||||
((GridTable)m_table.getModel()).setChanged(true);
|
||||
} // vetoableChange
|
||||
|
||||
/**
|
||||
* Get Actual Editor.
|
||||
* Called from GridController to add ActionListener to Button
|
||||
* @return VEditor
|
||||
*/
|
||||
public VEditor getEditor()
|
||||
{
|
||||
return m_editor;
|
||||
} // getEditor
|
||||
|
||||
/**
|
||||
* Action Editor - Stop Editor
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
log.finer(m_mField.getColumnName() + ": Value=" + m_editor.getValue());
|
||||
// super.stopCellEditing(); // causes VLookup.Search Text not to work
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_editor = null;
|
||||
m_mField = null;
|
||||
m_table = null;
|
||||
} // dispose
|
||||
|
||||
} // VCellEditor
|
||||
|
|
|
@ -1,250 +1,249 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.*;
|
||||
import java.text.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.apps.graph.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.plaf.*;
|
||||
import java.util.logging.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
import sun.security.krb5.internal.*;
|
||||
|
||||
/**
|
||||
* Table Cell Renderer based on DisplayType
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VCellRenderer.java,v 1.4 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public final class VCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
/**
|
||||
* Constructor for Grid
|
||||
* @param mField field model
|
||||
*/
|
||||
public VCellRenderer(GridField mField)
|
||||
{
|
||||
this (mField.getDisplayType());
|
||||
m_columnName = mField.getColumnName();
|
||||
this.setName(m_columnName);
|
||||
m_lookup = mField.getLookup();
|
||||
m_password = mField.isEncryptedField();
|
||||
} // VCellRenderer
|
||||
|
||||
/**
|
||||
* Constructor for MiniGrid
|
||||
* @param displayType Display Type
|
||||
*/
|
||||
public VCellRenderer (int displayType)
|
||||
{
|
||||
super();
|
||||
m_displayType = displayType;
|
||||
// Number
|
||||
if (DisplayType.isNumeric(m_displayType))
|
||||
{
|
||||
m_numberFormat = DisplayType.getNumberFormat(m_displayType);
|
||||
setHorizontalAlignment(JLabel.RIGHT);
|
||||
}
|
||||
// Date
|
||||
else if (DisplayType.isDate(m_displayType))
|
||||
m_dateFormat = DisplayType.getDateFormat(m_displayType);
|
||||
//
|
||||
else if (m_displayType == DisplayType.YesNo)
|
||||
{
|
||||
m_check = new JCheckBox();
|
||||
m_check.setMargin(new Insets(0,0,0,0));
|
||||
m_check.setHorizontalAlignment(JLabel.CENTER);
|
||||
m_check.setOpaque(true);
|
||||
}
|
||||
} // VCellRenderer
|
||||
|
||||
private int m_displayType;
|
||||
private String m_columnName = null;
|
||||
private Lookup m_lookup = null;
|
||||
private boolean m_password = false;
|
||||
//
|
||||
private SimpleDateFormat m_dateFormat = null;
|
||||
private DecimalFormat m_numberFormat = null;
|
||||
private JCheckBox m_check = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VCellRenderer.class);
|
||||
|
||||
/**
|
||||
* Get TableCell RendererComponent.
|
||||
* @param table table
|
||||
* @param value value
|
||||
* @param isSelected selected
|
||||
* @param hasFocus focus
|
||||
* @param row row
|
||||
* @param col col
|
||||
* @return component
|
||||
*/
|
||||
public Component getTableCellRendererComponent (JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus, int row, int col)
|
||||
{
|
||||
// log.finest(m_columnName
|
||||
// + ": Value=" + (value == null ? "null" : value.toString())
|
||||
// + ", Row=" + row + ", Col=" + col);
|
||||
|
||||
Component c = null;
|
||||
if (m_displayType == DisplayType.YesNo)
|
||||
c = m_check;
|
||||
else
|
||||
{ // returns JLabel
|
||||
c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
|
||||
//c.setFont(AdempierePLAF.getFont_Field());
|
||||
c.setFont(table.getFont());
|
||||
}
|
||||
|
||||
// Background & Foreground
|
||||
Color bg = AdempierePLAF.getFieldBackground_Normal();
|
||||
Color fg = AdempierePLAF.getTextColor_Normal();
|
||||
// Inactive Background
|
||||
boolean ro = !table.isCellEditable(row, col);
|
||||
if (ro)
|
||||
bg = AdempierePLAF.getFieldBackground_Inactive();
|
||||
|
||||
// Foreground
|
||||
int cCode = 0;
|
||||
// Grid
|
||||
if (table instanceof org.compiere.grid.VTable)
|
||||
cCode = ((org.compiere.grid.VTable)table).getColorCode (row);
|
||||
// MiniGrid
|
||||
else if (table instanceof org.compiere.minigrid.MiniTable)
|
||||
cCode = ((org.compiere.minigrid.MiniTable)table).getColorCode (row);
|
||||
//
|
||||
if (cCode == 0)
|
||||
; // Black
|
||||
else if (cCode < 0)
|
||||
fg = AdempierePLAF.getTextColor_Issue(); // Red
|
||||
else
|
||||
fg = AdempierePLAF.getTextColor_OK(); // Blue
|
||||
|
||||
// Highlighted row
|
||||
if (isSelected)
|
||||
{
|
||||
// Windows is white on blue
|
||||
bg = table.getSelectionBackground();
|
||||
fg = table.getSelectionForeground();
|
||||
if (hasFocus)
|
||||
bg = GraphUtil.brighter(bg, .9);
|
||||
}
|
||||
|
||||
// Set Color
|
||||
c.setBackground(bg);
|
||||
c.setForeground(fg);
|
||||
//
|
||||
// log.fine( "r=" + row + " c=" + col, // + " - " + c.getClass().getName(),
|
||||
// "sel=" + isSelected + ", focus=" + hasFocus + ", edit=" + table.isCellEditable(row, col));
|
||||
// Log.trace(7, "BG=" + (bg.equals(Color.white) ? "white" : bg.toString()), "FG=" + (fg.equals(Color.black) ? "black" : fg.toString()));
|
||||
|
||||
// Format it
|
||||
setValue(value);
|
||||
return c;
|
||||
} // getTableCellRendererComponent
|
||||
|
||||
|
||||
/**
|
||||
* Format Display Value.
|
||||
* Default is JLabel
|
||||
* @param value (key)value
|
||||
*/
|
||||
protected void setValue (Object value)
|
||||
{
|
||||
String retValue = null;
|
||||
try
|
||||
{
|
||||
// Checkbox
|
||||
if (m_displayType == DisplayType.YesNo)
|
||||
{
|
||||
if (value instanceof Boolean)
|
||||
m_check.setSelected(((Boolean)value).booleanValue());
|
||||
else
|
||||
m_check.setSelected("Y".equals(value));
|
||||
return;
|
||||
}
|
||||
else if (value == null)
|
||||
;
|
||||
// Number
|
||||
else if (DisplayType.isNumeric(m_displayType))
|
||||
retValue = m_numberFormat.format(value);
|
||||
// Date
|
||||
else if (DisplayType.isDate(m_displayType))
|
||||
retValue = m_dateFormat.format(value);
|
||||
// Row ID
|
||||
else if (m_displayType == DisplayType.RowID)
|
||||
retValue = "";
|
||||
// Lookup
|
||||
else if (m_lookup != null && (DisplayType.isLookup(m_displayType)
|
||||
|| m_displayType == DisplayType.Location
|
||||
|| m_displayType == DisplayType.Account
|
||||
|| m_displayType == DisplayType.Locator
|
||||
|| m_displayType == DisplayType.PAttribute ))
|
||||
retValue = m_lookup.getDisplay(value);
|
||||
// Button
|
||||
else if (m_displayType == DisplayType.Button)
|
||||
{
|
||||
if ("Record_ID".equals(m_columnName))
|
||||
retValue = "#" + value + "#";
|
||||
else
|
||||
retValue = null;
|
||||
}
|
||||
// Password (fixed string)
|
||||
else if (m_password)
|
||||
retValue = "**********";
|
||||
// other (String ...)
|
||||
else
|
||||
{
|
||||
super.setValue(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "(" + value + ") " + value.getClass().getName() , e);
|
||||
retValue = value.toString();
|
||||
}
|
||||
super.setValue(retValue);
|
||||
} // setValue
|
||||
|
||||
/**
|
||||
* to String
|
||||
* @return String representation
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return "VCellRenderer[" + m_columnName
|
||||
+ ",DisplayType=" + m_displayType + " - " + m_lookup + "]";
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
if (m_lookup != null)
|
||||
m_lookup.dispose();
|
||||
m_lookup = null;
|
||||
} // dispose
|
||||
|
||||
} // VCellRenderer
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.*;
|
||||
import java.text.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.apps.graph.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.plaf.*;
|
||||
import java.util.logging.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
import sun.security.krb5.internal.*;
|
||||
|
||||
/**
|
||||
* Table Cell Renderer based on DisplayType
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VCellRenderer.java,v 1.4 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public final class VCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
/**
|
||||
* Constructor for Grid
|
||||
* @param mField field model
|
||||
*/
|
||||
public VCellRenderer(GridField mField)
|
||||
{
|
||||
this (mField.getDisplayType());
|
||||
m_columnName = mField.getColumnName();
|
||||
this.setName(m_columnName);
|
||||
m_lookup = mField.getLookup();
|
||||
m_password = mField.isEncryptedField();
|
||||
} // VCellRenderer
|
||||
|
||||
/**
|
||||
* Constructor for MiniGrid
|
||||
* @param displayType Display Type
|
||||
*/
|
||||
public VCellRenderer (int displayType)
|
||||
{
|
||||
super();
|
||||
m_displayType = displayType;
|
||||
// Number
|
||||
if (DisplayType.isNumeric(m_displayType))
|
||||
{
|
||||
m_numberFormat = DisplayType.getNumberFormat(m_displayType);
|
||||
setHorizontalAlignment(JLabel.RIGHT);
|
||||
}
|
||||
// Date
|
||||
else if (DisplayType.isDate(m_displayType))
|
||||
m_dateFormat = DisplayType.getDateFormat(m_displayType);
|
||||
//
|
||||
else if (m_displayType == DisplayType.YesNo)
|
||||
{
|
||||
m_check = new JCheckBox();
|
||||
m_check.setMargin(new Insets(0,0,0,0));
|
||||
m_check.setHorizontalAlignment(JLabel.CENTER);
|
||||
m_check.setOpaque(true);
|
||||
}
|
||||
} // VCellRenderer
|
||||
|
||||
private int m_displayType;
|
||||
private String m_columnName = null;
|
||||
private Lookup m_lookup = null;
|
||||
private boolean m_password = false;
|
||||
//
|
||||
private SimpleDateFormat m_dateFormat = null;
|
||||
private DecimalFormat m_numberFormat = null;
|
||||
private JCheckBox m_check = null;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VCellRenderer.class);
|
||||
|
||||
/**
|
||||
* Get TableCell RendererComponent.
|
||||
* @param table table
|
||||
* @param value value
|
||||
* @param isSelected selected
|
||||
* @param hasFocus focus
|
||||
* @param row row
|
||||
* @param col col
|
||||
* @return component
|
||||
*/
|
||||
public Component getTableCellRendererComponent (JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus, int row, int col)
|
||||
{
|
||||
// log.finest(m_columnName
|
||||
// + ": Value=" + (value == null ? "null" : value.toString())
|
||||
// + ", Row=" + row + ", Col=" + col);
|
||||
|
||||
Component c = null;
|
||||
if (m_displayType == DisplayType.YesNo)
|
||||
c = m_check;
|
||||
else
|
||||
{ // returns JLabel
|
||||
c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
|
||||
c.setFont(AdempierePLAF.getFont_Field());
|
||||
}
|
||||
|
||||
// Background & Foreground
|
||||
Color bg = AdempierePLAF.getFieldBackground_Normal();
|
||||
Color fg = AdempierePLAF.getTextColor_Normal();
|
||||
// Inactive Background
|
||||
boolean ro = !table.isCellEditable(row, col);
|
||||
if (ro)
|
||||
bg = AdempierePLAF.getFieldBackground_Inactive();
|
||||
|
||||
// Foreground
|
||||
int cCode = 0;
|
||||
// Grid
|
||||
if (table instanceof org.compiere.grid.VTable)
|
||||
cCode = ((org.compiere.grid.VTable)table).getColorCode (row);
|
||||
// MiniGrid
|
||||
else if (table instanceof org.compiere.minigrid.MiniTable)
|
||||
cCode = ((org.compiere.minigrid.MiniTable)table).getColorCode (row);
|
||||
//
|
||||
if (cCode == 0)
|
||||
; // Black
|
||||
else if (cCode < 0)
|
||||
fg = AdempierePLAF.getTextColor_Issue(); // Red
|
||||
else
|
||||
fg = AdempierePLAF.getTextColor_OK(); // Blue
|
||||
|
||||
// Highlighted row
|
||||
if (isSelected)
|
||||
{
|
||||
// Windows is white on blue
|
||||
bg = table.getSelectionBackground();
|
||||
fg = table.getSelectionForeground();
|
||||
if (hasFocus)
|
||||
bg = GraphUtil.brighter(bg, .9);
|
||||
}
|
||||
|
||||
// Set Color
|
||||
c.setBackground(bg);
|
||||
c.setForeground(fg);
|
||||
//
|
||||
// log.fine( "r=" + row + " c=" + col, // + " - " + c.getClass().getName(),
|
||||
// "sel=" + isSelected + ", focus=" + hasFocus + ", edit=" + table.isCellEditable(row, col));
|
||||
// Log.trace(7, "BG=" + (bg.equals(Color.white) ? "white" : bg.toString()), "FG=" + (fg.equals(Color.black) ? "black" : fg.toString()));
|
||||
|
||||
// Format it
|
||||
setValue(value);
|
||||
return c;
|
||||
} // getTableCellRendererComponent
|
||||
|
||||
|
||||
/**
|
||||
* Format Display Value.
|
||||
* Default is JLabel
|
||||
* @param value (key)value
|
||||
*/
|
||||
protected void setValue (Object value)
|
||||
{
|
||||
String retValue = null;
|
||||
try
|
||||
{
|
||||
// Checkbox
|
||||
if (m_displayType == DisplayType.YesNo)
|
||||
{
|
||||
if (value instanceof Boolean)
|
||||
m_check.setSelected(((Boolean)value).booleanValue());
|
||||
else
|
||||
m_check.setSelected("Y".equals(value));
|
||||
return;
|
||||
}
|
||||
else if (value == null)
|
||||
;
|
||||
// Number
|
||||
else if (DisplayType.isNumeric(m_displayType))
|
||||
retValue = m_numberFormat.format(value);
|
||||
// Date
|
||||
else if (DisplayType.isDate(m_displayType))
|
||||
retValue = m_dateFormat.format(value);
|
||||
// Row ID
|
||||
else if (m_displayType == DisplayType.RowID)
|
||||
retValue = "";
|
||||
// Lookup
|
||||
else if (m_lookup != null && (DisplayType.isLookup(m_displayType)
|
||||
|| m_displayType == DisplayType.Location
|
||||
|| m_displayType == DisplayType.Account
|
||||
|| m_displayType == DisplayType.Locator
|
||||
|| m_displayType == DisplayType.PAttribute ))
|
||||
retValue = m_lookup.getDisplay(value);
|
||||
// Button
|
||||
else if (m_displayType == DisplayType.Button)
|
||||
{
|
||||
if ("Record_ID".equals(m_columnName))
|
||||
retValue = "#" + value + "#";
|
||||
else
|
||||
retValue = null;
|
||||
}
|
||||
// Password (fixed string)
|
||||
else if (m_password)
|
||||
retValue = "**********";
|
||||
// other (String ...)
|
||||
else
|
||||
{
|
||||
super.setValue(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "(" + value + ") " + value.getClass().getName() , e);
|
||||
retValue = value.toString();
|
||||
}
|
||||
super.setValue(retValue);
|
||||
} // setValue
|
||||
|
||||
/**
|
||||
* to String
|
||||
* @return String representation
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return "VCellRenderer[" + m_columnName
|
||||
+ ",DisplayType=" + m_displayType + " - " + m_lookup + "]";
|
||||
} // toString
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
if (m_lookup != null)
|
||||
m_lookup.dispose();
|
||||
m_lookup = null;
|
||||
} // dispose
|
||||
|
||||
} // VCellRenderer
|
||||
|
|
|
@ -1,334 +1,334 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.plaf.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Color Editor.
|
||||
* The editor stores/gets the attributes from the tab.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VColor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class VColor extends CButton
|
||||
implements VEditor, ActionListener
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param mTab Tab
|
||||
* @param mandatory mandatory
|
||||
* @param isReadOnly read only
|
||||
*/
|
||||
public VColor (GridTab mTab, boolean mandatory, boolean isReadOnly)
|
||||
{
|
||||
m_mTab = mTab;
|
||||
setMandatory(mandatory);
|
||||
setReadWrite(!isReadOnly);
|
||||
addActionListener(this);
|
||||
} // VColor
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_mTab = null;
|
||||
} // dispose
|
||||
|
||||
private GridTab m_mTab;
|
||||
private boolean m_mandatory;
|
||||
// private int m_AD_Color_ID = 0;
|
||||
private CompiereColor m_cc = null;
|
||||
private Object m_value;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VColor.class);
|
||||
|
||||
/**
|
||||
* Set Mandatory
|
||||
* @param mandatory mandatory
|
||||
*/
|
||||
public void setMandatory (boolean mandatory)
|
||||
{
|
||||
m_mandatory = mandatory;
|
||||
} // setMandatory
|
||||
|
||||
/**
|
||||
* Is Mandatory
|
||||
* @return true if Mandatory
|
||||
*/
|
||||
public boolean isMandatory()
|
||||
{
|
||||
return m_mandatory;
|
||||
} // isMandatory
|
||||
|
||||
/**
|
||||
* Set Background (nop)
|
||||
* @param error error
|
||||
*/
|
||||
public void setBackground (boolean error)
|
||||
{
|
||||
} // setBackground
|
||||
|
||||
/**
|
||||
* Set Value
|
||||
* @param value value
|
||||
*/
|
||||
public void setValue (Object value)
|
||||
{
|
||||
log.config("Value=" + value);
|
||||
m_value = value;
|
||||
m_cc = getAdempiereColor();
|
||||
|
||||
// Display It
|
||||
setText(getDisplay());
|
||||
if (m_cc != null)
|
||||
setBackgroundColor(m_cc);
|
||||
else
|
||||
{
|
||||
setOpaque(false);
|
||||
putClientProperty(CompiereLookAndFeel.BACKGROUND, null);
|
||||
}
|
||||
repaint();
|
||||
} // setValue
|
||||
|
||||
/**
|
||||
* GetValue
|
||||
* @return value
|
||||
*/
|
||||
public Object getValue()
|
||||
{
|
||||
return m_value;
|
||||
} // getValue
|
||||
|
||||
/**
|
||||
* Get Displayed Value
|
||||
* @return String representation
|
||||
*/
|
||||
public String getDisplay()
|
||||
{
|
||||
if (m_cc == null)
|
||||
return "-/-";
|
||||
return " ";
|
||||
} // getDisplay
|
||||
|
||||
/**
|
||||
* Property Change Listener
|
||||
* @param evt event
|
||||
*/
|
||||
public void propertyChange (PropertyChangeEvent evt)
|
||||
{
|
||||
// log.config( "VColor.propertyChange", evt);
|
||||
if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY))
|
||||
{
|
||||
setValue(evt.getNewValue());
|
||||
setBackground(false);
|
||||
}
|
||||
} // propertyChange
|
||||
|
||||
/**
|
||||
* Set Field/WindowNo for ValuePreference
|
||||
* @param mField field
|
||||
*/
|
||||
public void setField (GridField mField)
|
||||
{
|
||||
mField.setValueNoFire(false); // fire every time
|
||||
} // setField
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Load Color from Tab
|
||||
* @return true if loaded
|
||||
* @see org.compiere.model.MColor#getAdempiereColor
|
||||
*/
|
||||
private CompiereColor getAdempiereColor()
|
||||
{
|
||||
Integer AD_Color_ID = (Integer)m_mTab.getValue("AD_Color_ID");
|
||||
log.fine("AD_Color_ID=" + AD_Color_ID);
|
||||
CompiereColor cc = null;
|
||||
|
||||
// Color Type
|
||||
String ColorType = (String)m_mTab.getValue("ColorType");
|
||||
if (ColorType == null)
|
||||
{
|
||||
log.fine("No ColorType");
|
||||
return null;
|
||||
}
|
||||
//
|
||||
if (ColorType.equals(CompiereColor.TYPE_FLAT))
|
||||
{
|
||||
cc = new CompiereColor(getColor(true), true);
|
||||
}
|
||||
else if (ColorType.equals(CompiereColor.TYPE_GRADIENT))
|
||||
{
|
||||
Integer RepeatDistance = (Integer)m_mTab.getValue("RepeatDistance");
|
||||
String StartPoint = (String)m_mTab.getValue("StartPoint");
|
||||
int repeatDistance = RepeatDistance == null ? 0 : RepeatDistance.intValue();
|
||||
int startPoint = StartPoint == null ? 0 : Integer.parseInt(StartPoint);
|
||||
cc = new CompiereColor(getColor(true), getColor(false), startPoint, repeatDistance);
|
||||
}
|
||||
else if (ColorType.equals(CompiereColor.TYPE_LINES))
|
||||
{
|
||||
BigDecimal LineWidth = (BigDecimal)m_mTab.getValue("LineWidth");
|
||||
BigDecimal LineDistance = (BigDecimal)m_mTab.getValue("LineDistance");
|
||||
int lineWidth = LineWidth == null ? 0 : LineWidth.intValue();
|
||||
int lineDistance = LineDistance == null ? 0 : LineDistance.intValue();
|
||||
cc = new CompiereColor(getColor(false), getColor(true), lineWidth, lineDistance);
|
||||
}
|
||||
else if (ColorType.equals(CompiereColor.TYPE_TEXTURE))
|
||||
{
|
||||
Integer AD_Image_ID = (Integer)m_mTab.getValue("AD_Image_ID");
|
||||
String url = getURL(AD_Image_ID);
|
||||
if (url == null)
|
||||
return null;
|
||||
BigDecimal ImageAlpha = (BigDecimal)m_mTab.getValue("ImageAlpha");
|
||||
float compositeAlpha = ImageAlpha == null ? 0.7f : ImageAlpha.floatValue();
|
||||
cc = new CompiereColor(url, getColor(true), compositeAlpha);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
|
||||
log.fine("AdempiereColor=" + cc);
|
||||
return cc;
|
||||
} // getAdempiereColor
|
||||
|
||||
/**
|
||||
* Get Color from Tab
|
||||
* @param primary true if primary false if secondary
|
||||
* @return Color
|
||||
*/
|
||||
private Color getColor (boolean primary)
|
||||
{
|
||||
String add = primary ? "" : "_1";
|
||||
// is either BD or Int
|
||||
Integer Red = (Integer)m_mTab.getValue("Red" + add);
|
||||
Integer Green = (Integer)m_mTab.getValue("Green" + add);
|
||||
Integer Blue = (Integer)m_mTab.getValue("Blue" + add);
|
||||
//
|
||||
int red = Red == null ? 0 : Red.intValue();
|
||||
int green = Green == null ? 0 : Green.intValue();
|
||||
int blue = Blue == null ? 0 : Blue.intValue();
|
||||
//
|
||||
return new Color (red, green, blue);
|
||||
} // getColor
|
||||
|
||||
/**
|
||||
* Get URL from Image
|
||||
* @param AD_Image_ID image
|
||||
* @return URL as String or null
|
||||
*/
|
||||
private String getURL (Integer AD_Image_ID)
|
||||
{
|
||||
if (AD_Image_ID == null || AD_Image_ID.intValue() == 0)
|
||||
return null;
|
||||
//
|
||||
String retValue = null;
|
||||
String sql = "SELECT ImageURL FROM AD_Image WHERE AD_Image_ID=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt (1, AD_Image_ID.intValue());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
retValue = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
return retValue;
|
||||
} // getURL
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Action Listener - Open Dialog
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
// Show Dialog
|
||||
CompiereColor cc = ColorEditor.showDialog((JFrame)Env.getParent(this), m_cc);
|
||||
if (cc == null)
|
||||
{
|
||||
log.info( "VColor.actionPerformed - no color");
|
||||
return;
|
||||
}
|
||||
setBackgroundColor(cc); // set Button
|
||||
repaint();
|
||||
|
||||
// Update Values
|
||||
m_mTab.setValue("ColorType", cc.getType());
|
||||
if (cc.isFlat())
|
||||
{
|
||||
setColor (cc.getFlatColor(), true);
|
||||
}
|
||||
else if (cc.isGradient())
|
||||
{
|
||||
setColor (cc.getGradientUpperColor(), true);
|
||||
setColor (cc.getGradientLowerColor(), false);
|
||||
m_mTab.setValue("RepeatDistance", new BigDecimal(cc.getGradientRepeatDistance()));
|
||||
m_mTab.setValue("StartPoint", String.valueOf(cc.getGradientStartPoint()));
|
||||
}
|
||||
else if (cc.isLine())
|
||||
{
|
||||
setColor (cc.getLineBackColor(), true);
|
||||
setColor (cc.getLineColor(), false);
|
||||
m_mTab.getValue("LineWidth");
|
||||
m_mTab.getValue("LineDistance");
|
||||
}
|
||||
else if (cc.isTexture())
|
||||
{
|
||||
setColor (cc.getTextureTaintColor(), true);
|
||||
// URL url = cc.getTextureURL();
|
||||
// m_mTab.setValue("AD_Image_ID");
|
||||
m_mTab.setValue("ImageAlpha", new BigDecimal(cc.getTextureCompositeAlpha()));
|
||||
}
|
||||
m_cc = cc;
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Set Color in Tab
|
||||
* @param c Color
|
||||
* @param primary true if primary false if secondary
|
||||
*/
|
||||
private void setColor (Color c, boolean primary)
|
||||
{
|
||||
String add = primary ? "" : "_1";
|
||||
m_mTab.setValue("Red" + add, new BigDecimal(c.getRed()));
|
||||
m_mTab.setValue("Green" + add, new BigDecimal(c.getGreen()));
|
||||
m_mTab.setValue("Blue" + add, new BigDecimal(c.getBlue()));
|
||||
} // setColor
|
||||
|
||||
} // VColor
|
||||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.logging.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.plaf.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Color Editor.
|
||||
* The editor stores/gets the attributes from the tab.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VColor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class VColor extends CButton
|
||||
implements VEditor, ActionListener
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param mTab Tab
|
||||
* @param mandatory mandatory
|
||||
* @param isReadOnly read only
|
||||
*/
|
||||
public VColor (GridTab mTab, boolean mandatory, boolean isReadOnly)
|
||||
{
|
||||
m_mTab = mTab;
|
||||
setMandatory(mandatory);
|
||||
setReadWrite(!isReadOnly);
|
||||
addActionListener(this);
|
||||
} // VColor
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_mTab = null;
|
||||
} // dispose
|
||||
|
||||
private GridTab m_mTab;
|
||||
private boolean m_mandatory;
|
||||
// private int m_AD_Color_ID = 0;
|
||||
private CompiereColor m_cc = null;
|
||||
private Object m_value;
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(VColor.class);
|
||||
|
||||
/**
|
||||
* Set Mandatory
|
||||
* @param mandatory mandatory
|
||||
*/
|
||||
public void setMandatory (boolean mandatory)
|
||||
{
|
||||
m_mandatory = mandatory;
|
||||
} // setMandatory
|
||||
|
||||
/**
|
||||
* Is Mandatory
|
||||
* @return true if Mandatory
|
||||
*/
|
||||
public boolean isMandatory()
|
||||
{
|
||||
return m_mandatory;
|
||||
} // isMandatory
|
||||
|
||||
/**
|
||||
* Set Background (nop)
|
||||
* @param error error
|
||||
*/
|
||||
public void setBackground (boolean error)
|
||||
{
|
||||
} // setBackground
|
||||
|
||||
/**
|
||||
* Set Value
|
||||
* @param value value
|
||||
*/
|
||||
public void setValue (Object value)
|
||||
{
|
||||
log.config("Value=" + value);
|
||||
m_value = value;
|
||||
m_cc = getAdempiereColor();
|
||||
|
||||
// Display It
|
||||
setText(getDisplay());
|
||||
if (m_cc != null)
|
||||
setBackgroundColor(m_cc);
|
||||
else
|
||||
{
|
||||
setOpaque(false);
|
||||
putClientProperty(AdempierePLAF.BACKGROUND, null);
|
||||
}
|
||||
repaint();
|
||||
} // setValue
|
||||
|
||||
/**
|
||||
* GetValue
|
||||
* @return value
|
||||
*/
|
||||
public Object getValue()
|
||||
{
|
||||
return m_value;
|
||||
} // getValue
|
||||
|
||||
/**
|
||||
* Get Displayed Value
|
||||
* @return String representation
|
||||
*/
|
||||
public String getDisplay()
|
||||
{
|
||||
if (m_cc == null)
|
||||
return "-/-";
|
||||
return " ";
|
||||
} // getDisplay
|
||||
|
||||
/**
|
||||
* Property Change Listener
|
||||
* @param evt event
|
||||
*/
|
||||
public void propertyChange (PropertyChangeEvent evt)
|
||||
{
|
||||
// log.config( "VColor.propertyChange", evt);
|
||||
if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY))
|
||||
{
|
||||
setValue(evt.getNewValue());
|
||||
setBackground(false);
|
||||
}
|
||||
} // propertyChange
|
||||
|
||||
/**
|
||||
* Set Field/WindowNo for ValuePreference
|
||||
* @param mField field
|
||||
*/
|
||||
public void setField (GridField mField)
|
||||
{
|
||||
mField.setValueNoFire(false); // fire every time
|
||||
} // setField
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Load Color from Tab
|
||||
* @return true if loaded
|
||||
* @see org.compiere.model.MColor#getAdempiereColor
|
||||
*/
|
||||
private CompiereColor getAdempiereColor()
|
||||
{
|
||||
Integer AD_Color_ID = (Integer)m_mTab.getValue("AD_Color_ID");
|
||||
log.fine("AD_Color_ID=" + AD_Color_ID);
|
||||
CompiereColor cc = null;
|
||||
|
||||
// Color Type
|
||||
String ColorType = (String)m_mTab.getValue("ColorType");
|
||||
if (ColorType == null)
|
||||
{
|
||||
log.fine("No ColorType");
|
||||
return null;
|
||||
}
|
||||
//
|
||||
if (ColorType.equals(CompiereColor.TYPE_FLAT))
|
||||
{
|
||||
cc = new CompiereColor(getColor(true), true);
|
||||
}
|
||||
else if (ColorType.equals(CompiereColor.TYPE_GRADIENT))
|
||||
{
|
||||
Integer RepeatDistance = (Integer)m_mTab.getValue("RepeatDistance");
|
||||
String StartPoint = (String)m_mTab.getValue("StartPoint");
|
||||
int repeatDistance = RepeatDistance == null ? 0 : RepeatDistance.intValue();
|
||||
int startPoint = StartPoint == null ? 0 : Integer.parseInt(StartPoint);
|
||||
cc = new CompiereColor(getColor(true), getColor(false), startPoint, repeatDistance);
|
||||
}
|
||||
else if (ColorType.equals(CompiereColor.TYPE_LINES))
|
||||
{
|
||||
BigDecimal LineWidth = (BigDecimal)m_mTab.getValue("LineWidth");
|
||||
BigDecimal LineDistance = (BigDecimal)m_mTab.getValue("LineDistance");
|
||||
int lineWidth = LineWidth == null ? 0 : LineWidth.intValue();
|
||||
int lineDistance = LineDistance == null ? 0 : LineDistance.intValue();
|
||||
cc = new CompiereColor(getColor(false), getColor(true), lineWidth, lineDistance);
|
||||
}
|
||||
else if (ColorType.equals(CompiereColor.TYPE_TEXTURE))
|
||||
{
|
||||
Integer AD_Image_ID = (Integer)m_mTab.getValue("AD_Image_ID");
|
||||
String url = getURL(AD_Image_ID);
|
||||
if (url == null)
|
||||
return null;
|
||||
BigDecimal ImageAlpha = (BigDecimal)m_mTab.getValue("ImageAlpha");
|
||||
float compositeAlpha = ImageAlpha == null ? 0.7f : ImageAlpha.floatValue();
|
||||
cc = new CompiereColor(url, getColor(true), compositeAlpha);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
|
||||
log.fine("AdempiereColor=" + cc);
|
||||
return cc;
|
||||
} // getAdempiereColor
|
||||
|
||||
/**
|
||||
* Get Color from Tab
|
||||
* @param primary true if primary false if secondary
|
||||
* @return Color
|
||||
*/
|
||||
private Color getColor (boolean primary)
|
||||
{
|
||||
String add = primary ? "" : "_1";
|
||||
// is either BD or Int
|
||||
Integer Red = (Integer)m_mTab.getValue("Red" + add);
|
||||
Integer Green = (Integer)m_mTab.getValue("Green" + add);
|
||||
Integer Blue = (Integer)m_mTab.getValue("Blue" + add);
|
||||
//
|
||||
int red = Red == null ? 0 : Red.intValue();
|
||||
int green = Green == null ? 0 : Green.intValue();
|
||||
int blue = Blue == null ? 0 : Blue.intValue();
|
||||
//
|
||||
return new Color (red, green, blue);
|
||||
} // getColor
|
||||
|
||||
/**
|
||||
* Get URL from Image
|
||||
* @param AD_Image_ID image
|
||||
* @return URL as String or null
|
||||
*/
|
||||
private String getURL (Integer AD_Image_ID)
|
||||
{
|
||||
if (AD_Image_ID == null || AD_Image_ID.intValue() == 0)
|
||||
return null;
|
||||
//
|
||||
String retValue = null;
|
||||
String sql = "SELECT ImageURL FROM AD_Image WHERE AD_Image_ID=?";
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt (1, AD_Image_ID.intValue());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
retValue = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
return retValue;
|
||||
} // getURL
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Action Listener - Open Dialog
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
// Show Dialog
|
||||
CompiereColor cc = ColorEditor.showDialog((JFrame)Env.getParent(this), m_cc);
|
||||
if (cc == null)
|
||||
{
|
||||
log.info( "VColor.actionPerformed - no color");
|
||||
return;
|
||||
}
|
||||
setBackgroundColor(cc); // set Button
|
||||
repaint();
|
||||
|
||||
// Update Values
|
||||
m_mTab.setValue("ColorType", cc.getType());
|
||||
if (cc.isFlat())
|
||||
{
|
||||
setColor (cc.getFlatColor(), true);
|
||||
}
|
||||
else if (cc.isGradient())
|
||||
{
|
||||
setColor (cc.getGradientUpperColor(), true);
|
||||
setColor (cc.getGradientLowerColor(), false);
|
||||
m_mTab.setValue("RepeatDistance", new BigDecimal(cc.getGradientRepeatDistance()));
|
||||
m_mTab.setValue("StartPoint", String.valueOf(cc.getGradientStartPoint()));
|
||||
}
|
||||
else if (cc.isLine())
|
||||
{
|
||||
setColor (cc.getLineBackColor(), true);
|
||||
setColor (cc.getLineColor(), false);
|
||||
m_mTab.getValue("LineWidth");
|
||||
m_mTab.getValue("LineDistance");
|
||||
}
|
||||
else if (cc.isTexture())
|
||||
{
|
||||
setColor (cc.getTextureTaintColor(), true);
|
||||
// URL url = cc.getTextureURL();
|
||||
// m_mTab.setValue("AD_Image_ID");
|
||||
m_mTab.setValue("ImageAlpha", new BigDecimal(cc.getTextureCompositeAlpha()));
|
||||
}
|
||||
m_cc = cc;
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Set Color in Tab
|
||||
* @param c Color
|
||||
* @param primary true if primary false if secondary
|
||||
*/
|
||||
private void setColor (Color c, boolean primary)
|
||||
{
|
||||
String add = primary ? "" : "_1";
|
||||
m_mTab.setValue("Red" + add, new BigDecimal(c.getRed()));
|
||||
m_mTab.setValue("Green" + add, new BigDecimal(c.getGreen()));
|
||||
m_mTab.setValue("Blue" + add, new BigDecimal(c.getBlue()));
|
||||
} // setColor
|
||||
|
||||
} // VColor
|
||||
|
|
|
@ -30,13 +30,6 @@ import org.compiere.util.*;
|
|||
*/
|
||||
public final class VHeaderRenderer implements TableCellRenderer
|
||||
{
|
||||
public VHeaderRenderer()
|
||||
{
|
||||
m_button = new CButton();
|
||||
m_button.setMargin(new Insets(0,0,0,0));
|
||||
m_button.putClientProperty("Plastic.is3D", Boolean.FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param displayType
|
||||
|
@ -46,17 +39,16 @@ public final class VHeaderRenderer implements TableCellRenderer
|
|||
super();
|
||||
// Alignment
|
||||
if (DisplayType.isNumeric(displayType))
|
||||
m_alignment = JLabel.RIGHT;
|
||||
m_button.setHorizontalAlignment(JLabel.RIGHT);
|
||||
else if (displayType == DisplayType.YesNo)
|
||||
m_alignment = JLabel.CENTER;
|
||||
m_button.setHorizontalAlignment(JLabel.CENTER);
|
||||
else
|
||||
m_alignment = JLabel.LEFT;
|
||||
m_button.setHorizontalAlignment(JLabel.LEFT);
|
||||
m_button.setMargin(new Insets(0,0,0,0));
|
||||
} // VHeaderRenderer
|
||||
|
||||
// for 3D effect in Windows
|
||||
private CButton m_button;
|
||||
|
||||
private int m_alignment;
|
||||
private CButton m_button = new CButton();
|
||||
|
||||
/**
|
||||
* Get TableCell RendererComponent
|
||||
|
@ -73,25 +65,6 @@ public final class VHeaderRenderer implements TableCellRenderer
|
|||
{
|
||||
// Log.trace(this,10, "VHeaderRenderer.getTableCellRendererComponent", value==null ? "null" : value.toString());
|
||||
// indicator for invisible column
|
||||
|
||||
TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer();
|
||||
Component headerComponent = headerRenderer == null ? null :
|
||||
headerRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
if (headerComponent != null && headerComponent instanceof JComponent) {
|
||||
if (headerComponent instanceof JLabel ) {
|
||||
JLabel label = (JLabel)headerComponent;
|
||||
label.setHorizontalAlignment(m_alignment);
|
||||
if (value == null)
|
||||
label.setPreferredSize(new Dimension(0,0));
|
||||
else
|
||||
label.setText(value.toString());
|
||||
return label;
|
||||
}
|
||||
m_button.setBorder(((JComponent)headerComponent).getBorder());
|
||||
} else {
|
||||
m_button.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
m_button.setPreferredSize(new Dimension(0,0));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1134,7 +1134,6 @@ public class VLookup extends JComponent
|
|||
}
|
||||
else
|
||||
{
|
||||
AEnv.addToWindowManager(frame);
|
||||
AEnv.showCenterScreen(frame);
|
||||
}
|
||||
// async window - not able to get feedback
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.*;
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import javax.swing.*;
|
||||
|
@ -25,68 +25,68 @@ import org.adempiere.plaf.AdempierePLAF;
|
|||
import org.compiere.model.*;
|
||||
import org.compiere.plaf.*;
|
||||
import org.compiere.swing.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Data Binding:
|
||||
* VEditors call fireVetoableChange(m_columnName, null, getText());
|
||||
* GridController (for Single-Row) and VCellExitor (for Multi-Row)
|
||||
* listen to Vetoable Change Listener (vetoableChange)
|
||||
* then set the value for that column in the current row in the table
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VString.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public final class VString extends CTextField
|
||||
implements VEditor, ActionListener, FocusListener
|
||||
{
|
||||
/** Max Display Length - 60 */
|
||||
public static final int MAXDISPLAY_LENGTH = org.compiere.model.GridField.MAXDISPLAY_LENGTH;
|
||||
|
||||
/**
|
||||
* IDE Bean Constructor for 30 character updateable field
|
||||
*/
|
||||
public VString()
|
||||
{
|
||||
this("String", false, false, true, 30, 30, "", null);
|
||||
} // VString
|
||||
|
||||
/**
|
||||
* Detail Constructor
|
||||
* @param columnName column name
|
||||
* @param mandatory mandatory
|
||||
* @param isReadOnly read only
|
||||
* @param isUpdateable updateable
|
||||
* @param displayLength display length
|
||||
* @param fieldLength field length
|
||||
* @param VFormat format
|
||||
* @param ObscureType obscure type
|
||||
*/
|
||||
public VString (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable,
|
||||
int displayLength, int fieldLength, String VFormat, String ObscureType)
|
||||
{
|
||||
super(displayLength>MAXDISPLAY_LENGTH ? MAXDISPLAY_LENGTH : displayLength);
|
||||
super.setName(columnName);
|
||||
m_columnName = columnName;
|
||||
if (VFormat == null)
|
||||
VFormat = "";
|
||||
m_VFormat = VFormat;
|
||||
m_fieldLength = fieldLength;
|
||||
if (m_VFormat.length() != 0 || m_fieldLength != 0)
|
||||
setDocument(new MDocString(m_VFormat, m_fieldLength, this));
|
||||
if (m_VFormat.length() != 0)
|
||||
setCaret(new VOvrCaret());
|
||||
//
|
||||
setMandatory(mandatory);
|
||||
if (ObscureType != null && ObscureType.length() > 0)
|
||||
{
|
||||
m_obscure = new Obscure ("", ObscureType);
|
||||
m_stdFont = getFont();
|
||||
m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize());
|
||||
addFocusListener(this);
|
||||
}
|
||||
|
||||
// Editable
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Data Binding:
|
||||
* VEditors call fireVetoableChange(m_columnName, null, getText());
|
||||
* GridController (for Single-Row) and VCellExitor (for Multi-Row)
|
||||
* listen to Vetoable Change Listener (vetoableChange)
|
||||
* then set the value for that column in the current row in the table
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: VString.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||
*/
|
||||
public final class VString extends CTextField
|
||||
implements VEditor, ActionListener, FocusListener
|
||||
{
|
||||
/** Max Display Length - 60 */
|
||||
public static final int MAXDISPLAY_LENGTH = org.compiere.model.GridField.MAXDISPLAY_LENGTH;
|
||||
|
||||
/**
|
||||
* IDE Bean Constructor for 30 character updateable field
|
||||
*/
|
||||
public VString()
|
||||
{
|
||||
this("String", false, false, true, 30, 30, "", null);
|
||||
} // VString
|
||||
|
||||
/**
|
||||
* Detail Constructor
|
||||
* @param columnName column name
|
||||
* @param mandatory mandatory
|
||||
* @param isReadOnly read only
|
||||
* @param isUpdateable updateable
|
||||
* @param displayLength display length
|
||||
* @param fieldLength field length
|
||||
* @param VFormat format
|
||||
* @param ObscureType obscure type
|
||||
*/
|
||||
public VString (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable,
|
||||
int displayLength, int fieldLength, String VFormat, String ObscureType)
|
||||
{
|
||||
super(displayLength>MAXDISPLAY_LENGTH ? MAXDISPLAY_LENGTH : displayLength);
|
||||
super.setName(columnName);
|
||||
m_columnName = columnName;
|
||||
if (VFormat == null)
|
||||
VFormat = "";
|
||||
m_VFormat = VFormat;
|
||||
m_fieldLength = fieldLength;
|
||||
if (m_VFormat.length() != 0 || m_fieldLength != 0)
|
||||
setDocument(new MDocString(m_VFormat, m_fieldLength, this));
|
||||
if (m_VFormat.length() != 0)
|
||||
setCaret(new VOvrCaret());
|
||||
//
|
||||
setMandatory(mandatory);
|
||||
if (ObscureType != null && ObscureType.length() > 0)
|
||||
{
|
||||
m_obscure = new Obscure ("", ObscureType);
|
||||
m_stdFont = getFont();
|
||||
m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize());
|
||||
addFocusListener(this);
|
||||
}
|
||||
|
||||
// Editable
|
||||
if (isReadOnly || !isUpdateable)
|
||||
{
|
||||
setEditable(false);
|
||||
|
@ -94,12 +94,12 @@ public final class VString extends CTextField
|
|||
}
|
||||
|
||||
this.addKeyListener(this);
|
||||
this.addActionListener(this);
|
||||
// Popup for Editor
|
||||
if (fieldLength > displayLength)
|
||||
{
|
||||
addMouseListener(new VString_mouseAdapter(this));
|
||||
mEditor = new CMenuItem (Msg.getMsg(Env.getCtx(), "Editor"), Env.getImageIcon("Editor16.gif"));
|
||||
this.addActionListener(this);
|
||||
// Popup for Editor
|
||||
if (fieldLength > displayLength)
|
||||
{
|
||||
addMouseListener(new VString_mouseAdapter(this));
|
||||
mEditor = new CMenuItem (Msg.getMsg(Env.getCtx(), "Editor"), Env.getImageIcon("Editor16.gif"));
|
||||
mEditor.addActionListener(this);
|
||||
popupMenu.add(mEditor);
|
||||
}
|
||||
|
@ -108,171 +108,171 @@ public final class VString extends CTextField
|
|||
} // VString
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_mField = null;
|
||||
} // dispose
|
||||
|
||||
/** Popup Menu */
|
||||
JPopupMenu popupMenu = new JPopupMenu();
|
||||
/** Editor Menu Item */
|
||||
private CMenuItem mEditor;
|
||||
/** Grid Field */
|
||||
private GridField m_mField = null;
|
||||
/** Column Name */
|
||||
private String m_columnName;
|
||||
private String m_oldText;
|
||||
private String m_initialText;
|
||||
private String m_VFormat;
|
||||
/** Field Length */
|
||||
private int m_fieldLength;
|
||||
/** Obcure Setting */
|
||||
private Obscure m_obscure = null;
|
||||
private Font m_stdFont = null;
|
||||
private Font m_obscureFont = null;
|
||||
/** Setting new value */
|
||||
private volatile boolean m_setting = false;
|
||||
/** Field in focus */
|
||||
private volatile boolean m_infocus = false;
|
||||
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger (VString.class);
|
||||
|
||||
/**
|
||||
* Set Editor to value
|
||||
* @param value value
|
||||
*/
|
||||
public void setValue(Object value)
|
||||
{
|
||||
// log.config( "VString.setValue", value);
|
||||
if (value == null)
|
||||
m_oldText = "";
|
||||
else
|
||||
m_oldText = value.toString();
|
||||
// only set when not updated here
|
||||
if (m_setting)
|
||||
return;
|
||||
setText (m_oldText);
|
||||
m_initialText = m_oldText;
|
||||
// If R/O left justify
|
||||
if (!isEditable() || !isEnabled())
|
||||
setCaretPosition(0);
|
||||
} // setValue
|
||||
|
||||
/**
|
||||
* Property Change Listener
|
||||
* @param evt event
|
||||
*/
|
||||
public void propertyChange (PropertyChangeEvent evt)
|
||||
{
|
||||
if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY))
|
||||
setValue(evt.getNewValue());
|
||||
} // propertyChange
|
||||
|
||||
/**
|
||||
* Return Editor value
|
||||
* @return value
|
||||
*/
|
||||
public Object getValue()
|
||||
{
|
||||
return getText();
|
||||
} // getValue
|
||||
|
||||
/**
|
||||
* Return Display Value
|
||||
* @return value
|
||||
*/
|
||||
public String getDisplay()
|
||||
{
|
||||
return super.getText(); // optionally obscured
|
||||
} // getDisplay
|
||||
|
||||
|
||||
/**
|
||||
* Key Released.
|
||||
* if Escape Restore old Text
|
||||
* @param e event
|
||||
*/
|
||||
public void keyReleased(KeyEvent e)
|
||||
{
|
||||
log.finest("Key=" + e.getKeyCode() + " - " + e.getKeyChar()
|
||||
+ " -> " + getText());
|
||||
// ESC
|
||||
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
|
||||
setText(m_initialText);
|
||||
m_setting = true;
|
||||
try
|
||||
{
|
||||
String clear = getText();
|
||||
if (clear.length() > m_fieldLength)
|
||||
clear = clear.substring(0, m_fieldLength);
|
||||
fireVetoableChange (m_columnName, m_oldText, clear);
|
||||
}
|
||||
catch (PropertyVetoException pve)
|
||||
{
|
||||
}
|
||||
m_setting = false;
|
||||
} // keyReleased
|
||||
|
||||
/**
|
||||
* Data Binding to MTable (via GridController) - Enter pressed
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if (e.getActionCommand().equals(ValuePreference.NAME))
|
||||
{
|
||||
if (MRole.getDefault().isShowPreference())
|
||||
ValuePreference.start (m_mField, getValue());
|
||||
return;
|
||||
}
|
||||
|
||||
// Invoke Editor
|
||||
if (e.getSource() == mEditor)
|
||||
{
|
||||
String s = Editor.startEditor(this, Msg.translate(Env.getCtx(), m_columnName),
|
||||
getText(), isEditable(), m_fieldLength);
|
||||
setText(s);
|
||||
}
|
||||
// Data Binding
|
||||
try
|
||||
{
|
||||
fireVetoableChange(m_columnName, m_oldText, getText());
|
||||
}
|
||||
catch (PropertyVetoException pve)
|
||||
{
|
||||
}
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Set Field/WindowNo for ValuePreference
|
||||
* @param mField field
|
||||
*/
|
||||
public void setField (GridField mField)
|
||||
{
|
||||
m_mField = mField;
|
||||
if (m_mField != null
|
||||
&& MRole.getDefault().isShowPreference())
|
||||
ValuePreference.addMenu (this, popupMenu);
|
||||
} // setField
|
||||
|
||||
|
||||
/**
|
||||
* Set Text (optionally obscured)
|
||||
* @param text text
|
||||
*/
|
||||
public void setText (String text)
|
||||
{
|
||||
if (m_obscure != null && !m_infocus)
|
||||
{
|
||||
super.setFont(m_obscureFont);
|
||||
super.setText (m_obscure.getObscuredValue(text));
|
||||
super.setForeground(Color.gray);
|
||||
}
|
||||
else
|
||||
{
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
m_mField = null;
|
||||
} // dispose
|
||||
|
||||
/** Popup Menu */
|
||||
JPopupMenu popupMenu = new JPopupMenu();
|
||||
/** Editor Menu Item */
|
||||
private CMenuItem mEditor;
|
||||
/** Grid Field */
|
||||
private GridField m_mField = null;
|
||||
/** Column Name */
|
||||
private String m_columnName;
|
||||
private String m_oldText;
|
||||
private String m_initialText;
|
||||
private String m_VFormat;
|
||||
/** Field Length */
|
||||
private int m_fieldLength;
|
||||
/** Obcure Setting */
|
||||
private Obscure m_obscure = null;
|
||||
private Font m_stdFont = null;
|
||||
private Font m_obscureFont = null;
|
||||
/** Setting new value */
|
||||
private volatile boolean m_setting = false;
|
||||
/** Field in focus */
|
||||
private volatile boolean m_infocus = false;
|
||||
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger (VString.class);
|
||||
|
||||
/**
|
||||
* Set Editor to value
|
||||
* @param value value
|
||||
*/
|
||||
public void setValue(Object value)
|
||||
{
|
||||
// log.config( "VString.setValue", value);
|
||||
if (value == null)
|
||||
m_oldText = "";
|
||||
else
|
||||
m_oldText = value.toString();
|
||||
// only set when not updated here
|
||||
if (m_setting)
|
||||
return;
|
||||
setText (m_oldText);
|
||||
m_initialText = m_oldText;
|
||||
// If R/O left justify
|
||||
if (!isEditable() || !isEnabled())
|
||||
setCaretPosition(0);
|
||||
} // setValue
|
||||
|
||||
/**
|
||||
* Property Change Listener
|
||||
* @param evt event
|
||||
*/
|
||||
public void propertyChange (PropertyChangeEvent evt)
|
||||
{
|
||||
if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY))
|
||||
setValue(evt.getNewValue());
|
||||
} // propertyChange
|
||||
|
||||
/**
|
||||
* Return Editor value
|
||||
* @return value
|
||||
*/
|
||||
public Object getValue()
|
||||
{
|
||||
return getText();
|
||||
} // getValue
|
||||
|
||||
/**
|
||||
* Return Display Value
|
||||
* @return value
|
||||
*/
|
||||
public String getDisplay()
|
||||
{
|
||||
return super.getText(); // optionally obscured
|
||||
} // getDisplay
|
||||
|
||||
|
||||
/**
|
||||
* Key Released.
|
||||
* if Escape Restore old Text
|
||||
* @param e event
|
||||
*/
|
||||
public void keyReleased(KeyEvent e)
|
||||
{
|
||||
log.finest("Key=" + e.getKeyCode() + " - " + e.getKeyChar()
|
||||
+ " -> " + getText());
|
||||
// ESC
|
||||
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
|
||||
setText(m_initialText);
|
||||
m_setting = true;
|
||||
try
|
||||
{
|
||||
String clear = getText();
|
||||
if (clear.length() > m_fieldLength)
|
||||
clear = clear.substring(0, m_fieldLength);
|
||||
fireVetoableChange (m_columnName, m_oldText, clear);
|
||||
}
|
||||
catch (PropertyVetoException pve)
|
||||
{
|
||||
}
|
||||
m_setting = false;
|
||||
} // keyReleased
|
||||
|
||||
/**
|
||||
* Data Binding to MTable (via GridController) - Enter pressed
|
||||
* @param e event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if (e.getActionCommand().equals(ValuePreference.NAME))
|
||||
{
|
||||
if (MRole.getDefault().isShowPreference())
|
||||
ValuePreference.start (m_mField, getValue());
|
||||
return;
|
||||
}
|
||||
|
||||
// Invoke Editor
|
||||
if (e.getSource() == mEditor)
|
||||
{
|
||||
String s = Editor.startEditor(this, Msg.translate(Env.getCtx(), m_columnName),
|
||||
getText(), isEditable(), m_fieldLength);
|
||||
setText(s);
|
||||
}
|
||||
// Data Binding
|
||||
try
|
||||
{
|
||||
fireVetoableChange(m_columnName, m_oldText, getText());
|
||||
}
|
||||
catch (PropertyVetoException pve)
|
||||
{
|
||||
}
|
||||
} // actionPerformed
|
||||
|
||||
/**
|
||||
* Set Field/WindowNo for ValuePreference
|
||||
* @param mField field
|
||||
*/
|
||||
public void setField (GridField mField)
|
||||
{
|
||||
m_mField = mField;
|
||||
if (m_mField != null
|
||||
&& MRole.getDefault().isShowPreference())
|
||||
ValuePreference.addMenu (this, popupMenu);
|
||||
} // setField
|
||||
|
||||
|
||||
/**
|
||||
* Set Text (optionally obscured)
|
||||
* @param text text
|
||||
*/
|
||||
public void setText (String text)
|
||||
{
|
||||
if (m_obscure != null && !m_infocus)
|
||||
{
|
||||
super.setFont(m_obscureFont);
|
||||
super.setText (m_obscure.getObscuredValue(text));
|
||||
super.setForeground(Color.gray);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_stdFont != null)
|
||||
{
|
||||
super.setFont(m_stdFont);
|
||||
|
@ -280,81 +280,74 @@ public final class VString extends CTextField
|
|||
}
|
||||
super.setText (text);
|
||||
}
|
||||
} // setText
|
||||
|
||||
|
||||
/**
|
||||
* Get Text (clear)
|
||||
* @return text
|
||||
*/
|
||||
public String getText ()
|
||||
{
|
||||
String text = super.getText();
|
||||
if (m_obscure != null && text != null && text.length() > 0)
|
||||
{
|
||||
if (text.equals(m_obscure.getObscuredValue()))
|
||||
text = m_obscure.getClearValue();
|
||||
}
|
||||
return text;
|
||||
} // getText
|
||||
|
||||
/**
|
||||
* Focus Gained.
|
||||
* Enabled with Obscure
|
||||
* @param e event
|
||||
*/
|
||||
public void focusGained (FocusEvent e)
|
||||
{
|
||||
m_infocus = true;
|
||||
setText(getText()); // clear
|
||||
} // focusGained
|
||||
|
||||
/**
|
||||
* Focus Lost
|
||||
* Enabled with Obscure
|
||||
* @param e event
|
||||
*/
|
||||
public void focusLost (FocusEvent e)
|
||||
{
|
||||
} // setText
|
||||
|
||||
|
||||
/**
|
||||
* Get Text (clear)
|
||||
* @return text
|
||||
*/
|
||||
public String getText ()
|
||||
{
|
||||
String text = super.getText();
|
||||
if (m_obscure != null && text != null && text.length() > 0)
|
||||
{
|
||||
if (text.equals(m_obscure.getObscuredValue()))
|
||||
text = m_obscure.getClearValue();
|
||||
}
|
||||
return text;
|
||||
} // getText
|
||||
|
||||
/**
|
||||
* Focus Gained.
|
||||
* Enabled with Obscure
|
||||
* @param e event
|
||||
*/
|
||||
public void focusGained (FocusEvent e)
|
||||
{
|
||||
m_infocus = true;
|
||||
setText(getText()); // clear
|
||||
} // focusGained
|
||||
|
||||
/**
|
||||
* Focus Lost
|
||||
* Enabled with Obscure
|
||||
* @param e event
|
||||
*/
|
||||
public void focusLost (FocusEvent e)
|
||||
{
|
||||
m_infocus = false;
|
||||
setText(getText()); // obscure
|
||||
} // focus Lost
|
||||
|
||||
@Override
|
||||
public void setFont(Font f) {
|
||||
super.setFont(f);
|
||||
m_stdFont = f;
|
||||
m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize());
|
||||
}
|
||||
|
||||
} // VString
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Mouse Listener
|
||||
*/
|
||||
final class VString_mouseAdapter extends MouseAdapter
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param adaptee adaptee
|
||||
*/
|
||||
VString_mouseAdapter(VString adaptee)
|
||||
{
|
||||
m_adaptee = adaptee;
|
||||
} // VString_mouseAdapter
|
||||
|
||||
private VString m_adaptee;
|
||||
|
||||
/**
|
||||
* Mouse Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
// popup menu
|
||||
if (SwingUtilities.isRightMouseButton(e))
|
||||
m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY());
|
||||
} // mouseClicked
|
||||
|
||||
} // VText_mouseAdapter
|
||||
|
||||
/******************************************************************************
|
||||
* Mouse Listener
|
||||
*/
|
||||
final class VString_mouseAdapter extends MouseAdapter
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param adaptee adaptee
|
||||
*/
|
||||
VString_mouseAdapter(VString adaptee)
|
||||
{
|
||||
m_adaptee = adaptee;
|
||||
} // VString_mouseAdapter
|
||||
|
||||
private VString m_adaptee;
|
||||
|
||||
/**
|
||||
* Mouse Listener
|
||||
* @param e event
|
||||
*/
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
// popup menu
|
||||
if (SwingUtilities.isRightMouseButton(e))
|
||||
m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY());
|
||||
} // mouseClicked
|
||||
|
||||
} // VText_mouseAdapter
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.print;
|
||||
|
||||
import java.util.logging.*;
|
||||
|
@ -23,180 +23,174 @@ import javax.swing.JFrame;
|
|||
import org.compiere.apps.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Report Controller.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ReportCtl.java,v 1.3 2006/10/08 07:05:08 comdivision Exp $
|
||||
*/
|
||||
public class ReportCtl
|
||||
{
|
||||
/**
|
||||
* Constructor - prevent instance
|
||||
*/
|
||||
private ReportCtl()
|
||||
{
|
||||
} // ReportCtrl
|
||||
|
||||
/** Static Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (ReportCtl.class);
|
||||
|
||||
/**
|
||||
* Create Report.
|
||||
* Called from ProcessCtl.
|
||||
* - Check special reports first, if not, create standard Report
|
||||
*
|
||||
* @param pi process info
|
||||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if created
|
||||
*/
|
||||
static public boolean start (ProcessInfo pi, boolean IsDirectPrint)
|
||||
{
|
||||
s_log.info("start - " + pi);
|
||||
|
||||
/**
|
||||
* Order Print
|
||||
*/
|
||||
if (pi.getAD_Process_ID() == 110) // C_Order
|
||||
return startDocumentPrint(ReportEngine.ORDER, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 116) // C_Invoice
|
||||
return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 117) // M_InOut
|
||||
return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 217) // C_Project
|
||||
return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 276) // C_RfQResponse
|
||||
return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 313) // C_Payment
|
||||
return startCheckPrint(pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ
|
||||
return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), IsDirectPrint);
|
||||
/**
|
||||
else if (pi.AD_Process_ID == 9999999) // PaySelection
|
||||
return startDocumentPrint(CHECK, pi, IsDirectPrint);
|
||||
else if (pi.AD_Process_ID == 9999999) // PaySelection
|
||||
return startDocumentPrint(REMITTANCE, pi, IsDirectPrint);
|
||||
**/
|
||||
else if (pi.getAD_Process_ID() == 159) // Dunning
|
||||
return startDocumentPrint(ReportEngine.DUNNING, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 202 // Financial Report
|
||||
|| pi.getAD_Process_ID() == 204) // Financial Statement
|
||||
return startFinReport (pi);
|
||||
/********************
|
||||
* Standard Report
|
||||
*******************/
|
||||
return startStandardReport (pi, IsDirectPrint);
|
||||
} // create
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Start Standard Report.
|
||||
* - Get Table Info & submit
|
||||
* @param pi Process Info
|
||||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if OK
|
||||
*/
|
||||
static public boolean startStandardReport (ProcessInfo pi, boolean IsDirectPrint)
|
||||
{
|
||||
ReportEngine re = ReportEngine.get(Env.getCtx(), pi);
|
||||
if (re == null)
|
||||
{
|
||||
pi.setSummary("No ReportEngine");
|
||||
return false;
|
||||
}
|
||||
if (IsDirectPrint)
|
||||
{
|
||||
import org.compiere.util.*;
|
||||
|
||||
/**
|
||||
* Report Controller.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ReportCtl.java,v 1.3 2006/10/08 07:05:08 comdivision Exp $
|
||||
*/
|
||||
public class ReportCtl
|
||||
{
|
||||
/**
|
||||
* Constructor - prevent instance
|
||||
*/
|
||||
private ReportCtl()
|
||||
{
|
||||
} // ReportCtrl
|
||||
|
||||
/** Static Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (ReportCtl.class);
|
||||
|
||||
/**
|
||||
* Create Report.
|
||||
* Called from ProcessCtl.
|
||||
* - Check special reports first, if not, create standard Report
|
||||
*
|
||||
* @param pi process info
|
||||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if created
|
||||
*/
|
||||
static public boolean start (ProcessInfo pi, boolean IsDirectPrint)
|
||||
{
|
||||
s_log.info("start - " + pi);
|
||||
|
||||
/**
|
||||
* Order Print
|
||||
*/
|
||||
if (pi.getAD_Process_ID() == 110) // C_Order
|
||||
return startDocumentPrint(ReportEngine.ORDER, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 116) // C_Invoice
|
||||
return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 117) // M_InOut
|
||||
return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 217) // C_Project
|
||||
return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 276) // C_RfQResponse
|
||||
return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 313) // C_Payment
|
||||
return startCheckPrint(pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ
|
||||
return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), IsDirectPrint);
|
||||
/**
|
||||
else if (pi.AD_Process_ID == 9999999) // PaySelection
|
||||
return startDocumentPrint(CHECK, pi, IsDirectPrint);
|
||||
else if (pi.AD_Process_ID == 9999999) // PaySelection
|
||||
return startDocumentPrint(REMITTANCE, pi, IsDirectPrint);
|
||||
**/
|
||||
else if (pi.getAD_Process_ID() == 159) // Dunning
|
||||
return startDocumentPrint(ReportEngine.DUNNING, pi.getRecord_ID(), IsDirectPrint);
|
||||
else if (pi.getAD_Process_ID() == 202 // Financial Report
|
||||
|| pi.getAD_Process_ID() == 204) // Financial Statement
|
||||
return startFinReport (pi);
|
||||
/********************
|
||||
* Standard Report
|
||||
*******************/
|
||||
return startStandardReport (pi, IsDirectPrint);
|
||||
} // create
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Start Standard Report.
|
||||
* - Get Table Info & submit
|
||||
* @param pi Process Info
|
||||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if OK
|
||||
*/
|
||||
static public boolean startStandardReport (ProcessInfo pi, boolean IsDirectPrint)
|
||||
{
|
||||
ReportEngine re = ReportEngine.get(Env.getCtx(), pi);
|
||||
if (re == null)
|
||||
{
|
||||
pi.setSummary("No ReportEngine");
|
||||
return false;
|
||||
}
|
||||
if (IsDirectPrint)
|
||||
{
|
||||
re.print();
|
||||
}
|
||||
else
|
||||
preview(re);
|
||||
new Viewer(re);
|
||||
return true;
|
||||
} // startStandardReport
|
||||
|
||||
/**
|
||||
* Start Financial Report.
|
||||
* @param pi Process Info
|
||||
* @return true if OK
|
||||
*/
|
||||
static public boolean startFinReport (ProcessInfo pi)
|
||||
{
|
||||
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
|
||||
// Create Query from Parameters
|
||||
String TableName = pi.getAD_Process_ID() == 202 ? "T_Report" : "T_ReportStatement";
|
||||
MQuery query = MQuery.get (Env.getCtx(), pi.getAD_PInstance_ID(), TableName);
|
||||
|
||||
// Get PrintFormat
|
||||
MPrintFormat format = (MPrintFormat)pi.getTransientObject();
|
||||
if (format == null)
|
||||
format = (MPrintFormat)pi.getSerializableObject();
|
||||
if (format == null)
|
||||
{
|
||||
s_log.log(Level.SEVERE, "startFinReport - No PrintFormat");
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Start Financial Report.
|
||||
* @param pi Process Info
|
||||
* @return true if OK
|
||||
*/
|
||||
static public boolean startFinReport (ProcessInfo pi)
|
||||
{
|
||||
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
|
||||
|
||||
// Create Query from Parameters
|
||||
String TableName = pi.getAD_Process_ID() == 202 ? "T_Report" : "T_ReportStatement";
|
||||
MQuery query = MQuery.get (Env.getCtx(), pi.getAD_PInstance_ID(), TableName);
|
||||
|
||||
// Get PrintFormat
|
||||
MPrintFormat format = (MPrintFormat)pi.getTransientObject();
|
||||
if (format == null)
|
||||
format = (MPrintFormat)pi.getSerializableObject();
|
||||
if (format == null)
|
||||
{
|
||||
s_log.log(Level.SEVERE, "startFinReport - No PrintFormat");
|
||||
return false;
|
||||
}
|
||||
PrintInfo info = new PrintInfo(pi);
|
||||
|
||||
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
|
||||
preview(re);
|
||||
new Viewer(re);
|
||||
return true;
|
||||
} // startFinReport
|
||||
|
||||
|
||||
/**
|
||||
* Start Document Print for Type.
|
||||
* Called also directly from ProcessDialog, VInOutGen, VInvoiceGen, VPayPrint
|
||||
* @param type document type in ReportEngine
|
||||
* @param Record_ID id
|
||||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean startDocumentPrint (int type, int Record_ID, boolean IsDirectPrint)
|
||||
{
|
||||
ReportEngine re = ReportEngine.get (Env.getCtx(), type, Record_ID);
|
||||
if (re == null)
|
||||
{
|
||||
ADialog.error(0, null, "NoDocPrintFormat");
|
||||
return false;
|
||||
}
|
||||
if (IsDirectPrint)
|
||||
{
|
||||
re.print ();
|
||||
|
||||
/**
|
||||
* Start Document Print for Type.
|
||||
* Called also directly from ProcessDialog, VInOutGen, VInvoiceGen, VPayPrint
|
||||
* @param type document type in ReportEngine
|
||||
* @param Record_ID id
|
||||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean startDocumentPrint (int type, int Record_ID, boolean IsDirectPrint)
|
||||
{
|
||||
ReportEngine re = ReportEngine.get (Env.getCtx(), type, Record_ID);
|
||||
if (re == null)
|
||||
{
|
||||
ADialog.error(0, null, "NoDocPrintFormat");
|
||||
return false;
|
||||
}
|
||||
if (IsDirectPrint)
|
||||
{
|
||||
re.print ();
|
||||
ReportEngine.printConfirm (type, Record_ID);
|
||||
}
|
||||
else
|
||||
preview(re);
|
||||
new Viewer(re);
|
||||
return true;
|
||||
} // StartDocumentPrint
|
||||
|
||||
/**
|
||||
* Start Check Print.
|
||||
* Find/Create
|
||||
* @param C_Payment_ID Payment
|
||||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean startCheckPrint (int C_Payment_ID, boolean IsDirectPrint)
|
||||
{
|
||||
int C_PaySelectionCheck_ID = 0;
|
||||
MPaySelectionCheck psc = MPaySelectionCheck.getOfPayment(Env.getCtx(), C_Payment_ID, null);
|
||||
if (psc != null)
|
||||
C_PaySelectionCheck_ID = psc.getC_PaySelectionCheck_ID();
|
||||
else
|
||||
{
|
||||
psc = MPaySelectionCheck.createForPayment(Env.getCtx(), C_Payment_ID, null);
|
||||
if (psc != null)
|
||||
C_PaySelectionCheck_ID = psc.getC_PaySelectionCheck_ID();
|
||||
}
|
||||
/**
|
||||
* Start Check Print.
|
||||
* Find/Create
|
||||
* @param C_Payment_ID Payment
|
||||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean startCheckPrint (int C_Payment_ID, boolean IsDirectPrint)
|
||||
{
|
||||
int C_PaySelectionCheck_ID = 0;
|
||||
MPaySelectionCheck psc = MPaySelectionCheck.getOfPayment(Env.getCtx(), C_Payment_ID, null);
|
||||
if (psc != null)
|
||||
C_PaySelectionCheck_ID = psc.getC_PaySelectionCheck_ID();
|
||||
else
|
||||
{
|
||||
psc = MPaySelectionCheck.createForPayment(Env.getCtx(), C_Payment_ID, null);
|
||||
if (psc != null)
|
||||
C_PaySelectionCheck_ID = psc.getC_PaySelectionCheck_ID();
|
||||
}
|
||||
return startDocumentPrint (ReportEngine.CHECK, C_PaySelectionCheck_ID, IsDirectPrint);
|
||||
} // startCheckPrint
|
||||
|
||||
private static void preview(ReportEngine re) {
|
||||
Viewer viewer = new Viewer(re);
|
||||
JFrame top = Env.getWindow(0);
|
||||
if (top instanceof AMenu)
|
||||
((AMenu)top).getWindowManager().add(viewer);
|
||||
}
|
||||
} // ReportCtl
|
||||
|
|
Loading…
Reference in New Issue