BF [ 1960523 ] Server Process functionality not working
*/
-public class ProcessCtl implements Runnable
+public class ProcessCtl extends AbstractProcessCtl
{
/**
* Process Control
@@ -111,7 +96,7 @@ public class ProcessCtl implements Runnable
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
// Get Parameters (Dialog)
- ProcessParameter para = new ProcessParameter (Env.getFrame((Container)parent), WindowNo, pi);
+ ProcessParameter para = new ProcessParameter (AEnv.getFrame((Container)parent), WindowNo, pi);
if (para.initDialog())
{
para.setVisible(true);
@@ -223,278 +208,54 @@ public class ProcessCtl implements Runnable
*/
public ProcessCtl (ASyncProcess parent, int WindowNo, ProcessInfo pi, Trx trx)
{
- windowno = WindowNo;
- m_parent = parent;
- m_pi = pi;
- m_trx = trx; // handeled correctly
+ super(parent, WindowNo, pi, trx);
} // ProcessCtl
- /** Windowno */
- int windowno;
- /** Parenr */
- ASyncProcess m_parent;
- /** Process Info */
- 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);
- /**
- * Run this process in a new thread
- */
- public void start()
- {
- Thread thread = new Thread(this);
- // Set thread name - teo_sarca FR [ 1807922 ]
- if (m_pi != null)
- thread.setName(m_pi.getTitle()+"-"+m_pi.getAD_PInstance_ID());
- thread.start();
- }
-
- /**
- * Execute Process Instance and Lock UI.
- * Calls lockUI and unlockUI if parent is a ASyncProcess
- *
- * - Get Process Information
- * - Call Class
- * - Submit SQL Procedure
- * - Run SQL Procedure
- *
- */
- 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 = "";
- String JasperReport = "";
- int AD_ReportView_ID = 0;
- int AD_Workflow_ID = 0;
- boolean IsReport = false;
- boolean IsDirectPrint = false;
- boolean isPrintPreview = m_pi.isPrintPreview();
-
- //
- 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, p.JasperReport "
- + "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, p.JasperReport "
- + "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=?";
- //
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try
- {
- pstmt = DB.prepareStatement(sql,
- ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, null);
- pstmt.setInt(1, m_pi.getAD_PInstance_ID());
- 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)
- && !isPrintPreview )
- 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));
- JasperReport = rs.getString(11);
- }
- else
- log.log(Level.SEVERE, "No AD_PInstance_ID=" + m_pi.getAD_PInstance_ID());
- }
- catch (Throwable e)
- {
- m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoProcedure") + " " + e.getLocalizedMessage(), true);
- unlock();
- log.log(Level.SEVERE, "run", e);
- return;
- }
- finally
- {
- DB.close(rs, pstmt);
- rs = null; pstmt = null;
- }
-
- // No PL/SQL Procedure
- if (ProcedureName == null)
- ProcedureName = "";
-
-
- /**********************************************************************
- * Workflow
- */
- if (AD_Workflow_ID > 0)
- {
- startWorkflow (AD_Workflow_ID);
- unlock();
- return;
- }
-
- // Clear Jasper Report class if default - to be executed later
- boolean isJasper = false;
- if (JasperReport != null && JasperReport.trim().length() > 0) {
- isJasper = true;
- if (ProcessUtil.JASPER_STARTER_CLASS.equals(m_pi.getClassName())) {
- m_pi.setClassName(null);
- }
- }
-
- /**********************************************************************
- * Start Optional Class
- */
- if (m_pi.getClassName() != null)
- {
- if (isJasper)
- {
- m_pi.setReportingProcess(true);
- }
-
- // 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 && ! isJasper)
- {
- unlock ();
- return;
- }
- }
-
- /**********************************************************************
- * Report submission
- */
- // Optional Pre-Report Process
- if (IsReport && ProcedureName.length() > 0)
- {
- m_pi.setReportingProcess(true);
- if (!startDBProcess(ProcedureName))
- {
- unlock();
- return;
- }
- } // Pre-Report
-
- if (isJasper)
- {
- m_pi.setReportingProcess(true);
- m_pi.setClassName(ProcessUtil.JASPER_STARTER_CLASS);
- startProcess();
- unlock();
- return;
- }
-
- if (IsReport)
- {
- m_pi.setReportingProcess(true);
- // Start Report -----------------------------------------------
- boolean ok = ReportCtl.start(m_parent, windowno, 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 ()
+ protected void lock ()
{
// log.info("...");
//m_parent is null for synchrous execution
- if (m_parent != null)
+ if (getParent() != null)
{
- if (m_parent instanceof Container)
+ if (getParent() instanceof Container)
{
//swing client
- JFrame frame = Env.getFrame((Container)m_parent);
+ JFrame frame = AEnv.getFrame((Container)getParent());
if (frame instanceof AWindow)
- ((AWindow)frame).setBusyTimer(m_pi.getEstSeconds());
+ ((AWindow)frame).setBusyTimer(getProcessInfo().getEstSeconds());
else
- m_waiting = new Waiting (frame, Msg.getMsg(Env.getCtx(), "Processing"), false, m_pi.getEstSeconds());
- SwingUtilities.invokeLater(new Runnable()
- {
+ m_waiting = new Waiting (frame, Msg.getMsg(Env.getCtx(), "Processing"), false, getProcessInfo().getEstSeconds());
+ ProcessUpdateRunnable runnable = new ProcessUpdateRunnable() {
+ @Override
public void run()
{
+ if (m_waiting != null)
+ {
+ m_waiting.toFront();
+ m_waiting.setVisible(true);
+ }
+
log.finer("lock");
- m_parent.lockUI(m_pi);
+ parent.lockUI(pi);
}
- });
- if (m_waiting != null)
- {
- m_waiting.toFront();
- m_waiting.setVisible(true);
- }
+ };
+ runnable.setParent(getParent());
+ runnable.setProcessInfo(getProcessInfo());
+ SwingUtilities.invokeLater(runnable);
}
else
{
//other client
log.finer("lock");
- m_parent.lockUI(m_pi);
+ getParent().lockUI(getProcessInfo());
}
}
} // lock
@@ -503,221 +264,69 @@ public class ProcessCtl implements Runnable
* Unlock UI & dispose Waiting.
* Called from run()
*/
- private void unlock ()
+ protected void unlock ()
{
// log.info("...");
- if (m_pi.isBatch())
- m_pi.setIsTimeout(true);
- if (m_parent != null)
+ if (getProcessInfo().isBatch())
+ getProcessInfo().setIsTimeout(true);
+ if (getParent() != null)
{
- if (m_parent instanceof Container)
+ if (getParent() instanceof Container)
{
- //swing client
- SwingUtilities.invokeLater(new Runnable()
+ ProcessUpdateRunnable runnable = new ProcessUpdateRunnable()
{
+ @Override
public void run()
{
- String summary = m_pi.getSummary();
+ // Remove Waiting/Processing Indicator
+ if (m_waiting != null)
+ m_waiting.dispose();
+ m_waiting = null;
+
+ String summary = 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;
+ pi.setSummary(Msg.parseTranslation(Env.getCtx(), summary));
+ parent.unlockUI(pi);
+ }
+ };
+ runnable.setParent(getParent());
+ runnable.setProcessInfo(getProcessInfo());
+ SwingUtilities.invokeLater(runnable);
}
else
{
//other client
- m_parent.unlockUI(m_pi);
+ getParent().unlockUI(getProcessInfo());
}
}
} // 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 (m_IsServerProcess)
- {
- Server server = CConnection.get().getServer();
- try
- {
- if (server != null)
- { // See ServerBean
- m_pi = server.workflow (Env.getRemoteCallCtx(Env.getCtx()), m_pi, AD_Workflow_ID);
- log.finest("server => " + m_pi);
- started = true;
- }
- }
- catch (Exception ex)
- {
- log.log(Level.SEVERE, "AppsServer error", ex);
- started = false;
- }
- }
- // Run locally
- if (!started && !m_IsServerProcess)
- {
- if (m_trx != null)
- m_pi.setTransactionName(m_trx.getTrxName());
- MWFProcess wfProcess = ProcessUtil.startWorkFlow(Env.getCtx(), m_pi, AD_Workflow_ID);
- started = wfProcess != null;
- }
- return started;
- } // startWorkflow
+ @Override
+ protected void updateProgressWindowTimerEstimate(int estSeconds) {
+ if (m_waiting != null)
+ m_waiting.setTimerEstimate(getProcessInfo().getEstSeconds());
+ }
- /**************************************************************************
- * Start Java Process Class.
- * instanciate the class implementing the interface ProcessCall.
- * The class can be a Server/Client class (when in Package
- * org adempiere.process or org.compiere.model) or a client only class
- * (e.g. in org.compiere.report)
- *
- * @return true if success
- */
- private boolean startProcess ()
+ @Override
+ protected void updateProgressWindowTitle(String title) {
+ if (m_waiting != null)
+ m_waiting.setTitle(getProcessInfo().getTitle());
+ }
+
+ abstract class ProcessUpdateRunnable implements Runnable
{
- log.fine(m_pi.toString());
- boolean started = false;
+ protected ProcessInfo pi = null;
+ protected ASyncProcess parent = null;
- //hengsin, bug [ 1633995 ]
- boolean clientOnly = false;
- if (! m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) {
- try {
- Class> processClass = Class.forName(m_pi.getClassName());
- if (ClientProcess.class.isAssignableFrom(processClass))
- clientOnly = true;
- } catch (Exception e) {}
+ public void setProcessInfo(ProcessInfo pi)
+ {
+ this.pi = pi;
}
- if (m_IsServerProcess && !clientOnly)
+ public void setParent(ASyncProcess parent)
{
- Server server = CConnection.get().getServer();
- try
- {
- if (server != null)
- {
- // See ServerBean
- m_pi = server.process (Env.getRemoteCallCtx(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 (Exception ex)
- {
- Throwable cause = ex.getCause();
- if (cause == null)
- cause = ex;
- log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause);
- started = false;
- }
+ this.parent = parent;
}
- // Run locally
- if (!started && (!m_IsServerProcess || clientOnly ))
- {
- if (m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) {
- return ProcessUtil.startScriptProcess(Env.getCtx(), m_pi, m_trx);
- } else {
- return ProcessUtil.startJavaProcess(Env.getCtx(), m_pi, m_trx);
- }
- }
- 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() + ")");
- boolean started = false;
- String trxName = m_trx != null ? m_trx.getTrxName() : null;
- if (m_IsServerProcess)
- {
- Server server = CConnection.get().getServer();
- try
- {
- if (server != null)
- { // See ServerBean
- m_pi = server.dbProcess(m_pi, ProcedureName);
- 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);
- cause = ex;
- }
- m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + cause.getLocalizedMessage());
- m_pi.setError (true);
- return false;
- }
- catch (Exception ex)
- {
- Throwable cause = ex.getCause();
- if (cause == null)
- cause = ex;
- log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause);
- m_pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + cause.getLocalizedMessage());
- m_pi.setError (true);
- return false;
- }
- }
-
- //try locally
- if (!started)
- {
- return ProcessUtil.startDatabaseProcedure(m_pi, ProcedureName, m_trx);
- }
- // log.fine(Log.l4_Data, "ProcessCtl.startProcess - done");
- return true;
- } // startDBProcess
-
-
+ }
} // ProcessCtl
diff --git a/client/src/org/compiere/apps/ProcessDialog.java b/client/src/org/compiere/apps/ProcessDialog.java
index 907dfcbd10..946032a84c 100644
--- a/client/src/org/compiere/apps/ProcessDialog.java
+++ b/client/src/org/compiere/apps/ProcessDialog.java
@@ -100,7 +100,7 @@ public class ProcessDialog extends CFrame
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);
+ m_WindowNo = AEnv.createWindowNo (this);
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N");
try
{
@@ -468,7 +468,7 @@ public class ProcessDialog extends CFrame
for (int i = 0; i < m_ids.length; i++)
{
int M_InOut_ID = m_ids[i];
- ReportCtl.startDocumentPrint(ReportEngine.SHIPMENT, M_InOut_ID, this, Env.getWindowNo(this), true);
+ ReportCtl.startDocumentPrint(ReportEngine.SHIPMENT, M_InOut_ID, this, AEnv.getWindowNo(this), true);
}
ADialogDialog d = new ADialogDialog (this,
Env.getHeader(Env.getCtx(), m_WindowNo),
@@ -497,7 +497,7 @@ public class ProcessDialog extends CFrame
for (int i = 0; i < m_ids.length; i++)
{
int AD_Invoice_ID = m_ids[i];
- ReportCtl.startDocumentPrint(ReportEngine.INVOICE, AD_Invoice_ID, this, Env.getWindowNo(this), true);
+ ReportCtl.startDocumentPrint(ReportEngine.INVOICE, AD_Invoice_ID, this, AEnv.getWindowNo(this), true);
}
ADialogDialog d = new ADialogDialog (this,
Env.getHeader(Env.getCtx(), m_WindowNo),
diff --git a/client/src/org/compiere/apps/StatusBar.java b/client/src/org/compiere/apps/StatusBar.java
index 7f1d394e8d..ffd41e1128 100644
--- a/client/src/org/compiere/apps/StatusBar.java
+++ b/client/src/org/compiere/apps/StatusBar.java
@@ -262,7 +262,7 @@ public class StatusBar extends CPanel implements IStatusBar
return;
//
String title = Msg.getMsg(Env.getCtx(), "Who") + m_text;
- RecordInfo info = new RecordInfo (Env.getFrame(this), title, m_dse);
+ RecordInfo info = new RecordInfo (AEnv.getFrame(this), title, m_dse);
AEnv.showCenterScreen(info);
} // addStatusComponent
diff --git a/client/src/org/compiere/apps/WindowMenu.java b/client/src/org/compiere/apps/WindowMenu.java
index 6ac59f1802..6021afef24 100644
--- a/client/src/org/compiere/apps/WindowMenu.java
+++ b/client/src/org/compiere/apps/WindowMenu.java
@@ -266,7 +266,7 @@ public class WindowMenu extends JMenu {
}
if ( !(frame instanceof AMenu) ) {
- JFrame frame = Env.getWindow(0);
+ JFrame frame = AEnv.getWindow(0);
if (frame != null && frame instanceof AMenu) {
menu = new ChildMenuItem((AMenu)frame);
menu.setState(false);
@@ -338,7 +338,7 @@ public class WindowMenu extends JMenu {
int width = ( s.width - 30 ) / 3;
int height = ( s.height - 30 ) / 3;
int count = 0;
- JFrame frame = Env.getWindow(0);
+ JFrame frame = AEnv.getWindow(0);
if (frame != null && frame instanceof AMenu) {
JXTitledPanel box = createImageBox(p, dialog, width, height,
(CFrame)frame);
diff --git a/client/src/org/compiere/apps/form/FormFrame.java b/client/src/org/compiere/apps/form/FormFrame.java
index ef48824de4..fdf0b4c9f9 100644
--- a/client/src/org/compiere/apps/form/FormFrame.java
+++ b/client/src/org/compiere/apps/form/FormFrame.java
@@ -93,7 +93,7 @@ public class FormFrame extends CFrame
}
});
- m_WindowNo = Env.createWindowNo (this);
+ m_WindowNo = AEnv.createWindowNo (this);
setGlassPane(m_glassPane);
try
{
@@ -219,7 +219,7 @@ public class FormFrame extends CFrame
}
// Window
- AMenu aMenu = (AMenu)Env.getWindow(0);
+ AMenu aMenu = (AMenu)AEnv.getWindow(0);
JMenu mWindow = new WindowMenu(aMenu.getWindowManager(), this);
menuBar.add(mWindow);
@@ -367,7 +367,7 @@ public class FormFrame extends CFrame
sb.append("").append(m_Description).append("
");
if (m_Help != null && m_Help.length() > 0)
sb.append("").append(m_Help);
- Help hlp = new Help (Env.getFrame(this), this.getTitle(), sb.toString());
+ Help hlp = new Help (AEnv.getFrame(this), this.getTitle(), sb.toString());
hlp.setVisible(true);
} // actionHelp
diff --git a/client/src/org/compiere/apps/form/FormPanel.java b/client/src/org/compiere/apps/form/FormPanel.java
index f0adf52f76..dae1ca1b5d 100644
--- a/client/src/org/compiere/apps/form/FormPanel.java
+++ b/client/src/org/compiere/apps/form/FormPanel.java
@@ -16,7 +16,6 @@
*****************************************************************************/
package org.compiere.apps.form;
-import org.adempiere.base.IService;
/**
* Form Panel Interface.
@@ -24,7 +23,7 @@ import org.adempiere.base.IService;
* @author Jorg Janke
* @version $Id: FormPanel.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
*/
-public interface FormPanel extends IService
+public interface FormPanel
{
/**
* Initialize Panel
diff --git a/client/src/org/compiere/apps/form/VGenPanel.java b/client/src/org/compiere/apps/form/VGenPanel.java
index 918ef527a9..34df10603d 100644
--- a/client/src/org/compiere/apps/form/VGenPanel.java
+++ b/client/src/org/compiere/apps/form/VGenPanel.java
@@ -30,6 +30,7 @@ import javax.swing.event.TableModelListener;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.apps.ADialog;
import org.compiere.apps.ADialogDialog;
+import org.compiere.apps.AEnv;
import org.compiere.apps.ConfirmPanel;
import org.compiere.apps.ProcessCtl;
import org.compiere.apps.StatusBar;
@@ -243,7 +244,7 @@ public class VGenPanel extends CPanel implements ActionListener, ChangeListener,
public void generate()
{
info.setText(genForm.generate());
- ProcessCtl worker = new ProcessCtl(this, Env.getWindowNo(this), genForm.getProcessInfo(), genForm.getTrx());
+ ProcessCtl worker = new ProcessCtl(this, AEnv.getWindowNo(this), genForm.getProcessInfo(), genForm.getTrx());
worker.start();
//
}
@@ -306,7 +307,7 @@ public class VGenPanel extends CPanel implements ActionListener, ChangeListener,
new Viewer(m_frame.getGraphicsConfiguration(), re);
}
else
- ReportCtl.startDocumentPrint(genForm.getReportEngineType(), Record_ID, this, Env.getWindowNo(this), true);
+ ReportCtl.startDocumentPrint(genForm.getReportEngineType(), Record_ID, this, AEnv.getWindowNo(this), true);
}
ADialogDialog d = new ADialogDialog (m_frame,
diff --git a/client/src/org/compiere/apps/form/VPayPrint.java b/client/src/org/compiere/apps/form/VPayPrint.java
index eba87abe79..1ecf7f2c08 100644
--- a/client/src/org/compiere/apps/form/VPayPrint.java
+++ b/client/src/org/compiere/apps/form/VPayPrint.java
@@ -31,6 +31,7 @@ import javax.swing.JButton;
import javax.swing.JFileChooser;
import org.compiere.apps.ADialog;
+import org.compiere.apps.AEnv;
import org.compiere.apps.ConfirmPanel;
import org.compiere.grid.ed.VNumber;
import org.compiere.model.MPaySelectionCheck;
@@ -389,7 +390,7 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener
{
MPaySelectionCheck check = m_checks[i];
// ReportCtrl will check BankAccountDoc for PrintFormat
- boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
+ boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, check.get_ID(), null, AEnv.getWindowNo(panel), directPrint);
if (!somethingPrinted && ok)
somethingPrinted = true;
}
@@ -413,7 +414,7 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener
for (int i = 0; i < m_checks.length; i++)
{
MPaySelectionCheck check = m_checks[i];
- ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
+ ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, check.get_ID(), null, AEnv.getWindowNo(panel), directPrint);
}
} // remittance
diff --git a/client/src/org/compiere/apps/search/VSchedulePanel.java b/client/src/org/compiere/apps/search/VSchedulePanel.java
index 41c77b4920..83dfcb49ab 100644
--- a/client/src/org/compiere/apps/search/VSchedulePanel.java
+++ b/client/src/org/compiere/apps/search/VSchedulePanel.java
@@ -37,6 +37,7 @@ import java.util.GregorianCalendar;
import javax.swing.JComponent;
+import org.compiere.apps.AEnv;
import org.compiere.grid.ed.VAssignmentDialog;
import org.compiere.model.MAssignmentSlot;
import org.compiere.model.MResourceAssignment;
@@ -378,7 +379,7 @@ public class VSchedulePanel extends JComponent implements MouseListener
if (!mas.isAssignment())
return;
//
- VAssignmentDialog vad = new VAssignmentDialog (Env.getFrame(this),
+ VAssignmentDialog vad = new VAssignmentDialog (AEnv.getFrame(this),
m_slots[i].getMAssignment(), false, m_createNew);
m_infoSchedule.mAssignmentCallback(vad.getMResourceAssignment());
return;
@@ -391,7 +392,7 @@ public class VSchedulePanel extends JComponent implements MouseListener
ma.setAssignDateFrom(TimeUtil.getDayTime(TimeUtil.addDays(m_startDate, dayIndex),
m_timePanel.getTimeSlot(timeIndex).getStartTime()));
ma.setQty(new BigDecimal(1));
- VAssignmentDialog vad = new VAssignmentDialog (Env.getFrame(this), ma, false, m_createNew);
+ VAssignmentDialog vad = new VAssignmentDialog (AEnv.getFrame(this), ma, false, m_createNew);
m_infoSchedule.mAssignmentCallback(vad.getMResourceAssignment());
return;
}
diff --git a/client/src/org/compiere/apps/wf/NodeMenu.java b/client/src/org/compiere/apps/wf/NodeMenu.java
new file mode 100644
index 0000000000..ff633a6e8b
--- /dev/null
+++ b/client/src/org/compiere/apps/wf/NodeMenu.java
@@ -0,0 +1,113 @@
+/**
+ *
+ */
+package org.compiere.apps.wf;
+
+import java.awt.Point;
+
+import javax.swing.JPopupMenu;
+
+import org.compiere.util.Env;
+import org.compiere.util.Msg;
+import org.compiere.wf.MWFNode;
+import org.compiere.wf.MWFNodeNext;
+import org.compiere.wf.MWorkflow;
+import org.netbeans.api.visual.action.PopupMenuProvider;
+import org.netbeans.api.visual.widget.Widget;
+
+/**
+ * @author hengsin
+ *
+ */
+public class NodeMenu implements PopupMenuProvider {
+
+ private WFContentPanel panel;
+ private MWorkflow m_wf;
+
+ /**
+ *
+ */
+ public NodeMenu(WFContentPanel panel, MWorkflow wf) {
+ this.panel = panel;
+ m_wf = wf;
+ }
+
+ /* (non-Javadoc)
+ * @see org.netbeans.api.visual.action.PopupMenuProvider#getPopupMenu(org.netbeans.api.visual.widget.Widget, java.awt.Point)
+ */
+ public JPopupMenu getPopupMenu(Widget w, Point p) {
+ WFNodeWidget widget = (WFNodeWidget) w;
+ MWFNode node = widget.getModel();
+ JPopupMenu m_LinePopupMenu = new JPopupMenu(node.getName());
+ if (node.getAD_Client_ID() == Env.getAD_Client_ID(Env.getCtx()))
+ {
+ String title = Msg.getMsg(Env.getCtx(), "DeleteNode") +
+ ": " + node.getName();
+ addMenuItem(m_LinePopupMenu, title, node, -1);
+ m_LinePopupMenu.addSeparator();
+ }
+ MWFNode[] nodes = m_wf.getNodes(true, Env.getAD_Client_ID(Env.getCtx()));
+ MWFNodeNext[] lines = node.getTransitions(Env.getAD_Client_ID(Env.getCtx()));
+ // Add New Line
+ for (int n = 0; n < nodes.length; n++)
+ {
+ MWFNode nn = nodes[n];
+ if (nn.getAD_WF_Node_ID() == node.getAD_WF_Node_ID())
+ continue; // same
+ boolean found = false;
+ for (int i = 0; i < lines.length; i++)
+ {
+ MWFNodeNext line = lines[i];
+ if (nn.getAD_WF_Node_ID() == line.getAD_WF_Next_ID())
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ String title = Msg.getMsg(Env.getCtx(), "AddLine")
+ + ": " + node.getName() + " -> " + nn.getName();
+ addMenuItem(m_LinePopupMenu, title, node, nn.getAD_WF_Node_ID());
+ }
+ }
+ m_LinePopupMenu.addSeparator();
+ // Delete Lines
+ for (int i = 0; i < lines.length; i++)
+ {
+ MWFNodeNext line = lines[i];
+ if (line.getAD_Client_ID() != Env.getAD_Client_ID(Env.getCtx()))
+ continue;
+ MWFNode next = MWFNode.get(Env.getCtx(), line.getAD_WF_Next_ID());
+ String title = Msg.getMsg(Env.getCtx(), "DeleteLine")
+ + ": " + node.getName() + " -> " + next.getName();
+ addMenuItem(m_LinePopupMenu, title, line);
+ }
+ return m_LinePopupMenu;
+ }
+
+ /**
+ * Add Menu Item to - add new line to node
+ * @param menu base menu
+ * @param title title
+ */
+ private void addMenuItem (JPopupMenu menu, String title, MWFNode node, int AD_WF_NodeTo_ID)
+ {
+ WFPopupItem item = new WFPopupItem (title, node, AD_WF_NodeTo_ID);
+ menu.add(item);
+ item.addActionListener(panel);
+ } // addMenuItem
+
+ /**
+ * Add Menu Item to - delete line
+ * @param menu base menu
+ * @param title title
+ */
+ private void addMenuItem (JPopupMenu menu, String title, MWFNodeNext line)
+ {
+ WFPopupItem item = new WFPopupItem (title, line);
+ menu.add(item);
+ item.addActionListener(panel);
+ } // addMenuItem
+
+}
diff --git a/client/src/org/compiere/apps/wf/SceneMainMenu.java b/client/src/org/compiere/apps/wf/SceneMainMenu.java
new file mode 100644
index 0000000000..be21c54f14
--- /dev/null
+++ b/client/src/org/compiere/apps/wf/SceneMainMenu.java
@@ -0,0 +1,44 @@
+/**
+ *
+ */
+package org.compiere.apps.wf;
+
+import java.awt.Point;
+
+import javax.swing.JPopupMenu;
+
+import org.compiere.swing.CMenuItem;
+import org.compiere.util.Env;
+import org.compiere.util.Msg;
+import org.netbeans.api.visual.action.PopupMenuProvider;
+import org.netbeans.api.visual.widget.Widget;
+
+/**
+ * @author hengsin
+ *
+ */
+public class SceneMainMenu implements PopupMenuProvider {
+
+ private JPopupMenu m_NewPopupMenu = new JPopupMenu();
+ private CMenuItem m_NewMenuNode = new CMenuItem(Msg.getMsg(Env.getCtx(), "CreateNewNode"));
+
+ public static final String ADD_NEW_NODE_ACTION = "addNewNodeAction";
+
+ /**
+ * @param wfContentPanel
+ *
+ */
+ public SceneMainMenu(WFContentPanel wfContentPanel) {
+ m_NewMenuNode.setActionCommand(ADD_NEW_NODE_ACTION);
+ m_NewMenuNode.addActionListener(wfContentPanel);
+ m_NewPopupMenu.add(m_NewMenuNode);
+ }
+
+ /* (non-Javadoc)
+ * @see org.netbeans.api.visual.action.PopupMenuProvider#getPopupMenu(org.netbeans.api.visual.widget.Widget, java.awt.Point)
+ */
+ public JPopupMenu getPopupMenu(Widget arg0, Point arg1) {
+ return m_NewPopupMenu;
+ }
+
+}
diff --git a/client/src/org/compiere/apps/wf/WFContentPanel.java b/client/src/org/compiere/apps/wf/WFContentPanel.java
index 9c09e10568..0c135014f3 100644
--- a/client/src/org/compiere/apps/wf/WFContentPanel.java
+++ b/client/src/org/compiere/apps/wf/WFContentPanel.java
@@ -1,597 +1,221 @@
-/******************************************************************************
- * 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.wf;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.awt.font.TextLayout;
-import java.util.ArrayList;
-
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.SwingUtilities;
-
-import org.compiere.swing.CMenuItem;
-import org.compiere.swing.CPanel;
-import org.compiere.util.CLogger;
-import org.compiere.util.Env;
-import org.compiere.util.Msg;
-import org.compiere.util.Util;
-import org.compiere.wf.MWFNode;
-import org.compiere.wf.MWFNodeNext;
-import org.compiere.wf.MWorkflow;
-
-/**
- * Workflow Content Panel.
- *
- *
- * @author Jorg Janke
- * @version $Id: WFContentPanel.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
- */
-public class WFContentPanel extends CPanel
- implements MouseListener, MouseMotionListener, ActionListener
-{
- /**
- *
- */
- private static final long serialVersionUID = 4868946962536126669L;
-
- /**
- * WFContentPanel
- */
- public WFContentPanel (WFPanel parent)
- {
- super (new WFLayoutManager());
- m_parent = parent;
- // setBorder (BorderFactory.createEmptyBorder(5,5,5,5));
- // setBackground(Color.red);
- // setBackground(new Color(236,236,236));
- // setOpaque(false);
- //
- m_NewPopupMenu.add(m_NewMenuNode);
- m_NewMenuNode.addActionListener(this);
- } // WFContentPanel
-
- private WFPanel m_parent = null;
- /** Logger */
- private static CLogger log = CLogger.getCLogger(WFContentPanel.class);
- /** Node List */
- private ArrayList m_nodes = new ArrayList();
- /** Line List */
- private ArrayList m_lines = new ArrayList();
- /** Last Pressed Point */
- private Point m_draggedStart = null;
- /** Last Dragged Node */
- private WFNode m_draggedNode = null;
- /** Dragged */
- private boolean m_dragged = false;
-
- /** ReadWrite */
- private boolean m_readWrite = false;
- /** The Workflow */
- private MWorkflow m_wf = null;
-
- private JPopupMenu m_NewPopupMenu = new JPopupMenu();
- private CMenuItem m_NewMenuNode = new CMenuItem(Msg.getMsg(Env.getCtx(), "CreateNewNode"));
-
- private JPopupMenu m_LinePopupMenu = null;
-
- /**
- * Set Read/Write
- * @param readWrite read/write
- */
- public void setReadWrite (boolean readWrite)
- {
- m_readWrite = readWrite;
- if (m_readWrite)
- addMouseListener(this);
- else
- removeMouseListener(this);
- } // setReadWrite
-
- /**
- * Set Workflow
- * @param wf workflow
- */
- public void setWorkflow (MWorkflow wf)
- {
- m_wf = wf;
- } // setWorkflow
-
-
- /**
- * Remove All and their listeners
- */
- public void removeAll ()
- {
- m_nodes.clear();
- m_lines.clear();
- Component[] components = getComponents();
- for (int i = 0; i < components.length; i++)
- {
- Component component = components[i];
- component.removeMouseListener(this);
- component.removeMouseMotionListener(this);
- }
- super.removeAll ();
- } // removeAll
-
-
- /**
- * Add Component and add Mouse Listener
- * @param comp component
- * @param rw read/write
- * @return component
- */
- public Component add (Component comp, boolean rw)
- {
- // Line
- if (comp instanceof WFLine)
- {
- m_lines.add((WFLine)comp);
- return comp;
- }
- // Node
- if (comp instanceof WFNode)
- {
- m_nodes.add((WFNode)comp);
- comp.addMouseListener(this);
- if (m_readWrite && rw) // can be moved
- comp.addMouseMotionListener(this);
- }
- return super.add (comp);
- } // add
-
- /**
- * Create Lines.
- * Called by WF Layout Manager
- */
- protected void createLines()
- {
- log.fine("Lines #" + m_lines.size());
- for (int i = 0; i < m_lines.size(); i++)
- {
- WFLine line = (WFLine)m_lines.get(i);
- Rectangle from = findBounds (line.getAD_WF_Node_ID());
- Rectangle to = findBounds (line.getAD_WF_Next_ID());
- line.setFromTo(from, to);
- // same bounds as parent
- // line.setBounds(0,0, width, height);
- } // for all lines
- }
-
- /**
- * Get Bounds of WF Node Icon
- * @param AD_WF_Node_ID node id
- * @return bounds of node with ID or null
- */
- private Rectangle findBounds (int AD_WF_Node_ID)
- {
- for (int i = 0; i < m_nodes.size(); i++)
- {
- WFNode node = (WFNode)m_nodes.get(i);
- if (node.getAD_WF_Node_ID() == AD_WF_Node_ID)
- return node.getBounds();
- }
- return null;
- } // findBounds
-
-
- /**
- * Get Component At point
- * @param p point
- * @return Node (ignore lines)
- */
- public Component getComponentAt (Point p)
- {
- return getComponentAt (p.x, p.y);
- } // getComponentAt
-
- /**
- * Get Node at x/y
- * @param x x
- * @param y y
- * @return Node (ignore lines)
- */
- public Component getComponentAt (int x, int y)
- {
- Component comp = super.getComponentAt (x, y);
- if (comp instanceof WFNode)
- return comp;
- for (int i = 0; i < m_nodes.size(); i++)
- {
- WFNode node = (WFNode)m_nodes.get(i);
- int xx = x - node.getX();
- int yy = y - node.getY();
- if (node.contains(xx, yy))
- return node;
- }
- return comp;
- } // getComponentAt
-
-
- /**************************************************************************
- * Mouse Clicked.
- * Pressed - Released - Clicked.
- * @param e event
- */
- public void mouseClicked (MouseEvent e)
- {
- if (m_readWrite && SwingUtilities.isRightMouseButton(e))
- {
- int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
- if (e.getSource() == this && m_wf != null)
- {
- m_NewPopupMenu.show(this, e.getX(), e.getY());
- }
- else if (e.getSource() instanceof WFNode)
- {
- MWFNode node = ((WFNode)e.getSource()).getModel();
- m_LinePopupMenu = new JPopupMenu(node.getName());
- if (node.getAD_Client_ID() == AD_Client_ID)
- {
- String title = Msg.getMsg(Env.getCtx(), "DeleteNode") +
- ": " + node.getName();
- addMenuItem(m_LinePopupMenu, title, node, -1);
- m_LinePopupMenu.addSeparator();
- }
- MWFNode[] nodes = m_wf.getNodes(true, AD_Client_ID);
- MWFNodeNext[] lines = node.getTransitions(AD_Client_ID);
- // Add New Line
- for (int n = 0; n < nodes.length; n++)
- {
- MWFNode nn = nodes[n];
- if (nn.getAD_WF_Node_ID() == node.getAD_WF_Node_ID())
- continue; // same
- boolean found = false;
- for (int i = 0; i < lines.length; i++)
- {
- MWFNodeNext line = lines[i];
- if (nn.getAD_WF_Node_ID() == line.getAD_WF_Next_ID())
- {
- found = true;
- break;
- }
- }
- if (!found)
- {
- String title = Msg.getMsg(Env.getCtx(), "AddLine")
- + ": " + node.getName() + " -> " + nn.getName();
- addMenuItem(m_LinePopupMenu, title, node, nn.getAD_WF_Node_ID());
- }
- }
- m_LinePopupMenu.addSeparator();
- // Delete Lines
- for (int i = 0; i < lines.length; i++)
- {
- MWFNodeNext line = lines[i];
- if (line.getAD_Client_ID() != AD_Client_ID)
- continue;
- MWFNode next = MWFNode.get(Env.getCtx(), line.getAD_WF_Next_ID());
- String title = Msg.getMsg(Env.getCtx(), "DeleteLine")
- + ": " + node.getName() + " -> " + next.getName();
- addMenuItem(m_LinePopupMenu, title, line);
- }
- m_LinePopupMenu.show(this, e.getX(), e.getY());
- }
- }
-
- // Selection
- else if (e.getSource() instanceof WFNode)
- {
- WFNode selected = (WFNode)e.getSource();
- log.fine(selected.toString());
- for (int i = 0; i < m_nodes.size(); i++)
- {
- WFNode node = (WFNode)m_nodes.get(i);
- if (selected.getAD_WF_Node_ID() == node.getAD_WF_Node_ID())
- node.setSelected(true);
- else
- node.setSelected(false);
- }
- }
- m_dragged = false;
- } // mouseClicked
-
-
- /**
- * Mouse Entered
- * @param e event
- */
- public void mouseEntered (MouseEvent e)
- {
- } // mouseEntered
-
- /**
- * Mouse Exited
- * @param e event
- */
- public void mouseExited (MouseEvent e)
- {
- } // mouseExited
-
- /**
- * Mouse Pressed.
- * Initial drag
- * @param e event
- */
- public void mousePressed (MouseEvent e)
- {
- if (e.getSource() instanceof WFNode)
- {
- WFNode node = (WFNode)e.getSource();
- if (node.isEditable())
- {
- m_draggedNode = node;
- m_draggedStart = SwingUtilities.convertPoint(m_draggedNode, e.getX(), e.getY(), this);
- }
- else
- {
- m_dragged = false;
- m_draggedNode = null;
- m_draggedStart = null;
- }
- }
- } // mousePressed
-
-
- /**********************************
- * Mouse Dragged
- * @param e event
- */
- public void mouseDragged (MouseEvent e)
- {
- // Nothing selected
- if (m_draggedNode == null || e.getSource() != m_draggedNode)
- {
- if (e.getSource() instanceof WFNode)
- {
- WFNode node = (WFNode)e.getSource();
- if (node.isEditable())
- m_draggedNode = node;
- m_draggedStart = null;
- }
- }
- // Move Node
- if (m_draggedNode != null)
- {
- m_dragged = true;
- if (m_draggedStart == null)
- m_draggedStart = SwingUtilities.convertPoint(m_draggedNode, e.getX(), e.getY(), this);
- // If not converted to coordinate system of parent, it gets jumpy
- Point mousePosition = SwingUtilities.convertPoint(m_draggedNode, e.getX(), e.getY(), this);
- int xDelta = mousePosition.x - m_draggedStart.x;
- int yDelta = mousePosition.y - m_draggedStart.y;
- Point newLocation = m_draggedNode.getLocation();
- newLocation.x += xDelta;
- if (newLocation.x < 0)
- newLocation.x = 0;
- newLocation.y += yDelta;
- if (newLocation.y < 0)
- newLocation.y = 0;
- m_draggedNode.setLocation(newLocation.x, newLocation.y);
- // log.fine("mouseDragged - " + m_draggedNode + " - " + e);
- // log.fine("mouseDragged - Delta=" + xDelta + "/" + yDelta);
- m_draggedStart = mousePosition;
- invalidate();
- validate();
- repaint();
- }
- } // mouseDragged
-
- /**
- * Mouse Released.
- * Finals dragging
- * @param e event
- */
- public void mouseReleased (MouseEvent e)
- {
- // log.fine("mouseReleased - " + m_draggedNode);
- m_dragged = false;
- m_draggedNode = null;
- m_draggedStart = null;
- repaint();
- } // mouseReleased
-
- /**
- * Mouse Moved
- * @param e event
- */
- public void mouseMoved (MouseEvent e)
- {
- } // mouseMoved
-
-
- /**************************************************************************
- * Paint Component.
- * Paint Lines directly as not added.
- * @param g graphics
- */
- protected void paintComponent (Graphics g)
- {
- super.paintComponent(g);
- // Paint Lines
- for (int i = 0; i < m_lines.size(); i++)
- {
- WFLine line = (WFLine)m_lines.get(i);
- line.paint(g);
- }
- // Paint Position = right next to the box
- if (m_dragged && m_draggedNode != null)
- {
- Point loc = m_draggedNode.getLocation();
- String text = "(" + loc.x + "," + loc.y +")";
- Graphics2D g2D = (Graphics2D)g;
- Font font = new Font("Dialog", Font.PLAIN, 10);
- g2D.setColor(Color.magenta);
- TextLayout layout = new TextLayout (text, font, g2D.getFontRenderContext());
- loc.x += m_draggedNode.getWidth();
- loc.y += layout.getAscent();
- layout.draw(g2D, loc.x, loc.y);
- }
- } // paintComponents
-
- /**
- * Add Menu Item to - add new line to node
- * @param menu base menu
- * @param title title
- */
- private void addMenuItem (JPopupMenu menu, String title, MWFNode node, int AD_WF_NodeTo_ID)
- {
- WFPopupItem item = new WFPopupItem (title, node, AD_WF_NodeTo_ID);
- menu.add(item);
- item.addActionListener(this);
- } // addMenuItem
-
- /**
- * Add Menu Item to - delete line
- * @param menu base menu
- * @param title title
- */
- private void addMenuItem (JPopupMenu menu, String title, MWFNodeNext line)
- {
- WFPopupItem item = new WFPopupItem (title, line);
- menu.add(item);
- item.addActionListener(this);
- } // addMenuItem
-
- /**
- * Action Listener
- * @param e event
- */
- public void actionPerformed (ActionEvent e)
- {
- log.info(e.toString());
-
- // Add new Node
- if (e.getSource()== m_NewMenuNode)
- {
- log.info("Create New Node");
- String nameLabel = Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Name"));
- String name = JOptionPane.showInputDialog(this,
- nameLabel, // message
- Msg.getMsg(Env.getCtx(), "CreateNewNode"), // title
- JOptionPane.QUESTION_MESSAGE);
- if (name != null && name.length() > 0)
- {
- int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
- MWFNode node = new MWFNode(m_wf, name, name);
- node.setClientOrg(AD_Client_ID, 0);
- node.save();
- m_parent.load(m_wf.getAD_Workflow_ID(), true);
- }
- }
- // Add/Delete Line
- else if (e.getSource() instanceof WFPopupItem)
- {
- WFPopupItem item = (WFPopupItem)e.getSource();
- item.execute();
- }
-
- } // actionPerformed
-
-
- /**************************************************************************
- * WF Content Panel Popup Item
- * @author Jorg Janke
- * @version $Id: WFContentPanel.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
- */
- class WFPopupItem extends JMenuItem
- {
- /**
- *
- */
- private static final long serialVersionUID = 4634863991042969718L;
-
- /**
- * Add Line Item
- * @param title title
- * @param node node
- * @param AD_WF_NodeTo_ID line to
- */
- public WFPopupItem (String title, MWFNode node, int AD_WF_NodeTo_ID)
- {
- super (title);
- m_node = node;
- m_AD_WF_NodeTo_ID = AD_WF_NodeTo_ID;
- } // WFPopupItem
-
- /**
- * Delete Line Item
- * @param title title
- * @param line line to be deleted
- */
- public WFPopupItem (String title, MWFNodeNext line)
- {
- super (title);
- m_line = line;
- } // WFPopupItem
-
- /** The Node */
- private MWFNode m_node;
- /** The Line */
- private MWFNodeNext m_line;
- /** The Next Node ID */
- private int m_AD_WF_NodeTo_ID;
-
- /**
- * Execute
- */
- public void execute()
- {
- // Add Line
- if (m_node != null && m_AD_WF_NodeTo_ID > 0)
- {
- int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
- MWFNodeNext newLine = new MWFNodeNext(m_node, m_AD_WF_NodeTo_ID);
- newLine.setClientOrg(AD_Client_ID, 0);
- newLine.save();
- log.info("Add Line to " + m_node + " -> " + newLine);
- m_parent.load(m_wf.getAD_Workflow_ID(), true);
- }
- // Delete Node
- else if (m_node != null && m_AD_WF_NodeTo_ID == -1)
- {
- log.info("Delete Node: " + m_node);
- m_node.delete(false);
- m_parent.load(m_wf.getAD_Workflow_ID(), true);
- }
- // Delete Line
- else if (m_line != null)
- {
- log.info("Delete Line: " + m_line);
- m_line.delete(false);
- m_parent.load(m_wf.getAD_Workflow_ID(), true);
- }
- else
- log.severe("No Action??");
- } // execute
-
- } // WFPopupItem
-
-} // WFContentPanel
+package org.compiere.apps.wf;
+
+
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JOptionPane;
+
+import org.compiere.model.X_AD_Workflow;
+import org.compiere.swing.CPanel;
+import org.compiere.util.Env;
+import org.compiere.util.Msg;
+import org.compiere.util.Util;
+import org.compiere.wf.MWFNode;
+import org.compiere.wf.MWFNodeNext;
+import org.compiere.wf.MWorkflow;
+import org.netbeans.api.visual.action.ActionFactory;
+import org.netbeans.api.visual.action.MoveProvider;
+import org.netbeans.api.visual.action.WidgetAction;
+import org.netbeans.api.visual.graph.layout.GraphLayout;
+import org.netbeans.api.visual.layout.LayoutFactory;
+import org.netbeans.api.visual.layout.SceneLayout;
+import org.netbeans.api.visual.widget.Widget;
+
+public class WFContentPanel extends CPanel implements ActionListener, MoveProvider {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4589292821059374372L;
+
+ private WidgetAction moveAction = ActionFactory.createMoveAction(new WFNodeMoveStrategy(), this);
+
+ private WorkflowGraphScene graphScene = new WorkflowGraphScene();
+ private WFPanel m_parent;
+ private int currentRow = 1;
+ private int currentColumn = 0;
+ private int noOfColumns = 4;
+
+ private MWorkflow m_wf;
+ private boolean readWrite = false;
+
+ public final static int NODE_WIDTH = 180;
+ public final static int NODE_HEIGHT = 120;
+
+ private Map matrix = null;
+
+ public WFContentPanel (WFPanel parent) {
+ super();
+ m_parent = parent;
+ matrix = new HashMap();
+ }
+
+ public void setReadWrite(boolean readWrite) {
+ this.readWrite = readWrite;
+ }
+
+ public void setWorkflow(MWorkflow mWf) {
+ m_wf = mWf;
+ }
+
+ public void addNode(MWFNode node) {
+ int oldRow = currentRow;
+ int oldColumn = currentColumn;
+ if (node.getXPosition() > 0 && node.getYPosition() > 0) {
+ currentColumn = node.getXPosition();
+ currentRow = node.getYPosition();
+ if (currentColumn > noOfColumns) {
+ currentColumn = 1;
+ currentRow ++;
+ }
+ } else if (currentColumn == noOfColumns) {
+ currentColumn = 1;
+ if (m_wf.getWorkflowType().equals(X_AD_Workflow.WORKFLOWTYPE_General)) {
+ currentRow++;
+ } else {
+ currentRow = currentRow + 2;
+ }
+ } else {
+ if (m_wf.getWorkflowType().equals(X_AD_Workflow.WORKFLOWTYPE_General) || currentColumn == 0) {
+ currentColumn++;
+ } else {
+ currentColumn = currentColumn + 2;
+ if (currentColumn > noOfColumns) {
+ currentColumn = 1;
+ currentRow = currentRow + 2;
+ }
+ }
+ }
+ Integer[] nodes = matrix.get(currentRow);
+ if (nodes == null) {
+ nodes = new Integer[noOfColumns];
+ matrix.put(currentRow, nodes);
+ } else {
+ //detect collision
+ while (nodes[currentColumn - 1] != null) {
+ if (nodes[currentColumn - 1] == node.getAD_WF_Node_ID()) {
+ break;
+ } else if (currentColumn == noOfColumns) {
+ currentColumn = 1;
+ currentRow ++;
+ nodes = matrix.get(currentRow);
+ if (nodes == null) {
+ nodes = new Integer[noOfColumns];
+ matrix.put(currentRow, nodes);
+ }
+ } else {
+ currentColumn ++;
+ }
+ }
+ }
+
+ WFNodeWidget w = (WFNodeWidget) graphScene.addNode(node.getAD_WF_Node_ID());
+ w.setColumn(currentColumn);
+ w.setRow(currentRow);
+
+ nodes[currentColumn - 1] = node.getAD_WF_Node_ID();
+
+ if (readWrite && node.getAD_Client_ID() == Env.getAD_Client_ID(Env.getCtx())) {
+ w.getActions().addAction(ActionFactory.createPopupMenuAction(new NodeMenu(this, m_wf)));
+ w.getActions().addAction(moveAction);
+ }
+
+ if (currentRow < oldRow) {
+ currentRow = oldRow;
+ currentColumn = oldColumn;
+ } else if ( currentRow == oldRow && currentColumn < oldColumn) {
+ currentColumn = oldColumn;
+ }
+ }
+
+ public void addEdge(MWFNodeNext edge) {
+ graphScene.addEdge(edge);
+ graphScene.setEdgeSource(edge, edge.getAD_WF_Node_ID());
+ graphScene.setEdgeTarget(edge, edge.getAD_WF_Next_ID());
+ }
+
+ public void relayout() {
+ GraphLayout graphLayout = new WFGraphLayout();
+ graphLayout.setAnimated(false);
+ SceneLayout sceneGraphLayout = LayoutFactory.createSceneGraphLayout (graphScene, graphLayout);
+ sceneGraphLayout.invokeLayout ();
+
+ this.add(graphScene.createView());
+
+ if (readWrite) {
+ graphScene.getActions().addAction(ActionFactory.createPopupMenuAction(new SceneMainMenu(this)));
+ }
+ }
+
+ @Override
+ public void removeAll() {
+ super.removeAll();
+ graphScene = new WorkflowGraphScene();
+ currentColumn = 0;
+ currentRow = 1;
+ matrix = new HashMap();
+ }
+
+ public WorkflowGraphScene getGraphScene() {
+ return graphScene;
+ }
+
+ private void createNewNode() {
+ String nameLabel = Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Name"));
+ String name = JOptionPane.showInputDialog(this,
+ nameLabel, // message
+ Msg.getMsg(Env.getCtx(), "CreateNewNode"), // title
+ JOptionPane.QUESTION_MESSAGE);
+ if (name != null && name.length() > 0)
+ {
+ int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
+ MWFNode node = new MWFNode(m_wf, name, name);
+ node.setClientOrg(AD_Client_ID, 0);
+ node.saveEx();
+ m_parent.load(m_wf.getAD_Workflow_ID(), true);
+ }
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ if (e.getActionCommand().equals(SceneMainMenu.ADD_NEW_NODE_ACTION))
+ {
+ createNewNode();
+ }
+ //Add/Delete Line
+ else if (e.getSource() instanceof WFPopupItem)
+ {
+ WFPopupItem item = (WFPopupItem)e.getSource();
+ item.execute(m_parent);
+ }
+ }
+
+ public Point getOriginalLocation(Widget widget) {
+ return widget.getLocation();
+ }
+
+ public void movementFinished(Widget widget) {
+ WFNodeWidget nodeWidget = (WFNodeWidget) widget;
+ Point location = widget.getPreferredLocation();
+ int x = location.x / WFGraphLayout.COLUMN_WIDTH + 1;
+ int y = location.y / WFGraphLayout.ROW_HEIGHT + 1;
+ Integer[] nodes = matrix.get(y);
+ if (nodes == null || nodes[x - 1] == null ||
+ nodes[x - 1] == nodeWidget.getModel().getAD_WF_Node_ID()) {
+ nodeWidget.getModel().setXPosition(x);
+ nodeWidget.getModel().setYPosition(y);
+ nodeWidget.getModel().saveEx();
+ }
+ m_parent.load(m_wf.getAD_Workflow_ID(), true);
+ }
+
+ public void movementStarted(Widget widget) {
+ }
+
+ public void setNewLocation(Widget widget, Point point) {
+ widget.setPreferredLocation(point);
+ }
+}
diff --git a/client/src/org/compiere/apps/wf/WFIcon.java b/client/src/org/compiere/apps/wf/WFIcon.java
deleted file mode 100644
index 37580bbad8..0000000000
--- a/client/src/org/compiere/apps/wf/WFIcon.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/******************************************************************************
- * 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.wf;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-
-import javax.swing.Icon;
-
-import org.compiere.model.MTreeNode;
-
-
-/**
- * Work Flow Icon
- *
- * @author Jorg Janke
- * @version $Id: WFIcon.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
- */
-public class WFIcon implements Icon
-{
- /**
- * Constructor
- * @param type see MTreeNode.TYPE_
- */
- public WFIcon (int type)
- {
- if (type > 0 && type < MTreeNode.IMAGES.length)
- m_type = type;
- } // WFIcon
-
- /**
- * Constructor
- * @param action image indicator
- */
- public WFIcon (String action)
- {
- if (action != null)
- m_type = MTreeNode.getImageIndex(action);
- } // WFIcon
-
-
- private static int WIDTH = 20; // Image is 16x16
- private static int HEIGHT = 20;
-
- /** Image Index */
- private int m_type = 0;
-
- /**
- * Draw the icon at the specified location. Icon implementations
- * may use the Component argument to get properties useful for
- * painting, e.g. the foreground or background color.
- *
- * @param c Component
- * @param g Graphics
- * @param x X
- * @param y Y
- * @see javax.swing.Icon#paintIcon(Component, Graphics, int, int)
- */
- public void paintIcon (Component c, Graphics g, int x, int y)
- {
- Graphics2D g2D = (Graphics2D)g;
- Icon icon = MTreeNode.getIcon(m_type);
- if (icon != null)
- {
- int xI = x + ((WIDTH - icon.getIconWidth()) / 2);
- int yI = y + ((HEIGHT - icon.getIconHeight()) / 2);
- icon.paintIcon(c, g, xI, yI);
- }
- else // draw dot
- {
- int size = 10;
- int xI = x + ((WIDTH - size) / 2);
- int yI = y + ((HEIGHT - size) / 2);
- g2D.setColor(Color.magenta);
- g2D.fillOval(xI, yI, size, size);
- }
- } // PaintIcon
-
- /**
- * Returns the icon's width.
- * @return an int specifying the fixed width of the icon.
- * @see javax.swing.Icon#getIconWidth()
- */
- public int getIconWidth()
- {
- return WIDTH;
- } // getIconWidth
-
- /**
- * Returns the icon's height.
- * @return an int specifying the fixed height of the icon.
- * @see javax.swing.Icon#getIconHeight()
- */
- public int getIconHeight()
- {
- return HEIGHT;
- } // getIconHeight
-
-} // WFIcon
diff --git a/client/src/org/compiere/apps/wf/WFLayoutManager.java b/client/src/org/compiere/apps/wf/WFLayoutManager.java
deleted file mode 100644
index d1cea74699..0000000000
--- a/client/src/org/compiere/apps/wf/WFLayoutManager.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/******************************************************************************
- * 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.wf;
-
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Insets;
-import java.awt.LayoutManager;
-import java.awt.Point;
-
-import org.compiere.util.CLogger;
-
-/**
- * WorkFlow Layout Manager
- *
- * @author Jorg Janke
- * @version $Id: WFLayoutManager.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
- */
-public class WFLayoutManager implements LayoutManager
-{
- /**
- * Constructor
- */
- public WFLayoutManager()
- {
- } // WFLayoutManager
-
- /** Logger */
- private static CLogger log = CLogger.getCLogger(WFLayoutManager.class);
- /** Cached Size */
- private Dimension m_size = null;
-
- /**
- * If the layout manager uses a per-component string,
- * adds the component comp
to the layout,
- * associating it
- * with the string specified by name
.
- *
- * @param name the string to be associated with the component
- * @param comp the component to be added
- * @see java.awt.LayoutManager#addLayoutComponent(String, Component)
- */
- public void addLayoutComponent (String name, Component comp)
- {
- invalidateLayout();
- } // addLayoutComponent
-
- /**
- * Removes the specified component from the layout.
- * @param comp the component to be removed
- * @see java.awt.LayoutManager#removeLayoutComponent(Component)
- */
- public void removeLayoutComponent(Component comp)
- {
- if (comp == null)
- return;
- invalidateLayout();
- } // removeLayoutComponent
-
- /**
- * Calculates the preferred size dimensions for the specified
- * container, given the components it contains.
- * @param parent the container to be laid out
- * @return preferred size
- * @see #minimumLayoutSize
- */
- public Dimension preferredLayoutSize(Container parent)
- {
- if (m_size == null)
- layoutContainer(parent);
- return m_size;
- } // preferredLayoutSize
-
- /**
- * Calculates the minimum size dimensions for the specified
- * container, given the components it contains.
- * @param parent the component to be laid out
- * @return preferred size
- * @see #preferredLayoutSize
- */
- public Dimension minimumLayoutSize(Container parent)
- {
- return preferredLayoutSize(parent);
- } // minimumLayoutSize
-
-
- /**************************************************************************
- * Lays out the specified container.
- * @param parent the container to be laid out
- * @see java.awt.LayoutManager#layoutContainer(Container)
- */
- public void layoutContainer (Container parent)
- {
- Insets insets = parent.getInsets();
- //
- int width = insets.left;
- int height = insets.top;
-
- // We need to layout
- if (needLayout(parent))
- {
- int x = 5;
- int y = 5;
- // Go through all components
- for (int i = 0; i < parent.getComponentCount(); i++)
- {
- Component comp = parent.getComponent(i);
- if (comp.isVisible() && comp instanceof WFNode)
- {
- Dimension ps = comp.getPreferredSize();
- comp.setLocation(x, y);
- comp.setBounds(x, y, ps.width, ps.height);
- //
- width = x + ps.width;
- height = y + ps.height;
- // next pos
- if (x == 5)
- x = 230;
- else
- {
- x = 5;
- y += 100;
- }
- // x += ps.width-20;
- // y += ps.height+20;
- }
- }
- }
- else // we have an Layout
- {
- // Go through all components
- for (int i = 0; i < parent.getComponentCount(); i++)
- {
- Component comp = parent.getComponent(i);
- if (comp.isVisible() && comp instanceof WFNode)
- {
- Dimension ps = comp.getPreferredSize();
- Point loc = comp.getLocation();
- int maxWidth = comp.getX() + ps.width;
- int maxHeight = comp.getY() + ps.height;
- if (width < maxWidth)
- width = maxWidth;
- if (height < maxHeight)
- height = maxHeight;
- comp.setBounds(loc.x, loc.y, ps.width, ps.height);
- }
- } // for all components
- } // have layout
-
-
- // Create Lines
- WFContentPanel panel = (WFContentPanel)parent;
- panel.createLines();
-
- // Calculate size
- width += insets.right;
- height += insets.bottom;
-
- // return size
- m_size = new Dimension(width, height);
- log.finer("Size=" + m_size);
- } // layoutContainer
-
- /**
- * Need Layout
- * @param parent parent
- * @return true if we need to layout
- */
- private boolean needLayout (Container parent)
- {
- Point p00 = new Point(0,0);
- // Go through all components
- for (int i = 0; i < parent.getComponentCount(); i++)
- {
- Component comp = parent.getComponent(i);
- if (comp instanceof WFNode && comp.getLocation().equals(p00))
- {
- log.fine(comp.toString());
- return true;
- }
- }
- return false;
- } // needLayout
-
- /**
- * Invalidates the layout, indicating that if the layout manager
- * has cached information it should be discarded.
- */
- private void invalidateLayout()
- {
- m_size = null;
- } // invalidateLayout
-
-} // WFLayoutManager
diff --git a/client/src/org/compiere/apps/wf/WFLine.java b/client/src/org/compiere/apps/wf/WFLine.java
deleted file mode 100644
index 5c5f3dfa80..0000000000
--- a/client/src/org/compiere/apps/wf/WFLine.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/******************************************************************************
- * 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.wf;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Polygon;
-import java.awt.Rectangle;
-import java.awt.font.TextLayout;
-
-import javax.swing.SwingConstants;
-
-import org.compiere.util.CLogger;
-import org.compiere.wf.MWFNodeNext;
-
-
-/**
- * Work Flow Line between Nodes.
- * Coordinates based on WFContentPanel.
- *
- * @author Jorg Janke
- * @version $Id: WFLine.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
- */
-public class WFLine extends Component
-{
- /**
- *
- */
- private static final long serialVersionUID = 7599996355185021897L;
-
- /**
- * Create Line
- * @param next model
- */
- public WFLine (MWFNodeNext next)
- {
- m_next = next;
- // setOpaque(false);
- setFocusable(false);
- //
- m_description = next.getDescription();
- if (m_description != null && m_description.length() > 0)
- m_description = "{" + String.valueOf(next.getSeqNo())
- + ": " + m_description + "}";
- } // WFLine
-
- /** Model */
- private MWFNodeNext m_next = null;
- /** From Node */
- private Rectangle m_from = null;
- /** To Node */
- private Rectangle m_to = null;
- /** Descriprion */
- private String m_description = null;
- /** Visited value */
- private boolean m_visited = false;
- /** Logger */
- private static CLogger log = CLogger.getCLogger(WFLine.class);
-
- /**
- * Get From rectangle
- * @return from node rectangle
- */
- public Rectangle getFrom()
- {
- return m_from;
- } // getFrom
-
- /**
- * Get To rectangle
- * @return to node rectangle
- */
- public Rectangle getTo()
- {
- return m_to;
- } // getTo
-
- /**
- * Set From/To rectangle.
- * Called from WFLayoutManager.layoutContainer
- * @param from from node rectangle
- * @param to to node rectangle
- */
- public void setFromTo (Rectangle from, Rectangle to)
- {
- m_from = from;
- m_to = to;
- } // setFrom
-
- /**
- * Get From Node ID
- * @return from node id
- */
- public int getAD_WF_Node_ID()
- {
- return m_next.getAD_WF_Node_ID(); // Node ->
- } // getAD_WF_Node_ID
-
- /**
- * Get To Node ID
- * @return to node id
- */
- public int getAD_WF_Next_ID()
- {
- return m_next.getAD_WF_Next_ID(); // -> Next
- } // getAD_WF_Next_ID
-
- /**
- * Set Visited.
- * @param visited visited
- */
- public void setVisited (boolean visited)
- {
- m_visited = visited;
- } // setVisited
-
- /**
- * From: Right - To: Top = left \ down
- */
- private boolean isRightTop() // \
- {
- return (m_from.x+m_from.width <= m_to.x // right.bottom - left.top
- && m_from.y+m_from.height <= m_to.y);
- }
- /**
- * From: Bottom - To: Top = top | down
- */
- private boolean isBottomTop() // |
- {
- return (m_from.y+m_from.height <= m_to.y);
- }
- /**
- * From: Top - To: Bottom = bottom / up
- */
- private boolean isTopBottom() // |
- {
- return (m_to.y+m_to.height <= m_from.y);
- }
- /**
- * From: Left - To: Right = right o <- o left
- */
- private boolean isLeftRight() // ->
- {
- return (m_to.x+m_to.width <= m_from.x);
- }
-
-
- /**************************************************************************
- * Paint it.
- * Coordinates based on WFContentPanel.
- * @param g Graph
- */
- public void paint (Graphics g)
- {
- if (m_from == null || m_to == null)
- return;
-
- Polygon arrow = new Polygon();
- Point from = null;
- Point to = null;
-
- //
- if (isRightTop())
- {
- from = addPoint (arrow, m_from, SwingConstants.RIGHT, true);
- to = addPoint (arrow, m_to, SwingConstants.TOP, false);
- }
- else if (isBottomTop())
- {
- from = addPoint (arrow, m_from, SwingConstants.BOTTOM, true);
- to = addPoint (arrow, m_to, SwingConstants.TOP, false);
- }
- //
- else if (isTopBottom())
- {
- from = addPoint (arrow, m_from, SwingConstants.TOP, true);
- to = addPoint (arrow, m_to, SwingConstants.BOTTOM, false);
- }
- else if (isLeftRight())
- {
- from = addPoint (arrow, m_from, SwingConstants.LEFT, true);
- to = addPoint (arrow, m_to, SwingConstants.RIGHT, false);
- }
- else // if (isRightLeft())
- {
- from = addPoint (arrow, m_from, SwingConstants.RIGHT, true);
- to = addPoint (arrow, m_to, SwingConstants.LEFT, false);
- }
-
- /**
- * Paint Arrow:
- * Unconditional: no fill - black text
- * Conditional: red fill - red text
- * Visited: green line
- * NotVisited: black line
- * Split/Join: AND: Magenta Dot -- XOR: -
- */
- if (!m_next.isUnconditional())
- {
- g.setColor(Color.red);
- g.fillPolygon(arrow); // fill
- }
- if (m_visited)
- g.setColor(Color.green);
- else
- g.setColor(Color.black);
- g.drawPolygon(arrow); // line
-
- // Paint Dot for AND From
- if (m_next.isFromSplitAnd())
- {
- g.setColor(Color.magenta);
- g.fillOval(from.x-3, from.y-3, 6, 6);
- }
- // Paint Dot for AND To
- if (m_next.isToJoinAnd())
- {
- g.setColor(Color.magenta);
- g.fillOval(to.x-3, to.y-3, 6, 6);
- }
-
- // Paint Description in red
- if (m_description != null)
- {
- Graphics2D g2D = (Graphics2D)g;
- Font font = new Font("Dialog", Font.PLAIN, 9);
- if (m_next.isUnconditional())
- g2D.setColor(Color.black);
- else
- g2D.setColor(Color.red);
- TextLayout layout = new TextLayout (m_description, font, g2D.getFontRenderContext());
-
- // Mid Point
- int x = 0;
- if (from.x < to.x)
- x = from.x + ((to.x - from.x) / 2);
- else
- x = to.x + ((from.x - to.x) / 2);
- int y = 0;
- if (from.y < to.y)
- y = from.y + ((to.y - from.y) / 2);
- else
- y = to.y + ((from.y - to.y) / 2);
-
- // Adjust |
- y -= (layout.getAscent() - 3); // above center
-
- // Adjust -
- x -= (layout.getAdvance() / 2); // center
- if (x < 2)
- x = 2;
-
- layout.draw(g2D, x, y);
- }
-
- } // paintComponent
-
- /**
- * Get Point of Rectangle
- * @param arrow Polygon to draw arrow
- * @param rect Rectangle (icon)
- * @param pos SwingConstants.BOTTOM / TOP / RIGHT / LEFT
- * @param from if true from (base) else to (tip) of arrow
- * @return point docking position two point away
- */
- private Point addPoint (Polygon arrow, Rectangle rect, int pos, boolean from)
- {
- int x = rect.x;
- int y = rect.y;
- Point point = null;
-
- if (pos == SwingConstants.TOP)
- {
- x += rect.width/2;
- if (from)
- {
- arrow.addPoint(x-2, y);
- arrow.addPoint(x+2, y);
- }
- else
- arrow.addPoint(x, y);
- point = new Point (x, y-2);
- }
- else if (pos == SwingConstants.RIGHT)
- {
- x += rect.width;
- y += rect.height/2;
- if (from)
- {
- arrow.addPoint(x, y-2);
- arrow.addPoint(x, y+2);
- }
- else
- arrow.addPoint(x, y);
- point = new Point (x+2, y);
- }
- else if (pos == SwingConstants.LEFT)
- {
- y += rect.height/2;
- if (from)
- {
- arrow.addPoint(x, y-2);
- arrow.addPoint(x, y+2);
- }
- else
- arrow.addPoint(x, y);
- point = new Point (x-2, y);
- }
- else // if (pos == SwingConstants.BOTTOM)
- {
- x += rect.width/2;
- y += rect.height;
- if (from)
- {
- arrow.addPoint(x-2, y);
- arrow.addPoint(x+2, y);
- }
- else
- arrow.addPoint(x, y);
- point = new Point (x, y+2);
- }
- return point;
- } // getPoint
-
- /**
- * String Representation
- * @return info
- */
- public String toString()
- {
- StringBuffer sb = new StringBuffer("WFLine[");
- sb.append(getAD_WF_Node_ID()).append("->").append(getAD_WF_Next_ID());
- sb.append("]");
- return sb.toString();
- } // toString
-
-} // WFLine
diff --git a/client/src/org/compiere/apps/wf/WFNode.java b/client/src/org/compiere/apps/wf/WFNode.java
deleted file mode 100644
index 4881722144..0000000000
--- a/client/src/org/compiere/apps/wf/WFNode.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/******************************************************************************
- * 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.wf;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Rectangle;
-import java.awt.font.LineBreakMeasurer;
-import java.awt.font.TextAttribute;
-import java.awt.font.TextLayout;
-import java.text.AttributedCharacterIterator;
-import java.text.AttributedString;
-
-import javax.swing.BorderFactory;
-import javax.swing.JComponent;
-import javax.swing.border.BevelBorder;
-import javax.swing.border.Border;
-
-import org.compiere.util.CLogger;
-import org.compiere.util.Env;
-import org.compiere.wf.MWFNode;
-
-/**
- * Graphical Work Flow Node.
- * Listen to PropertyChange for selection
- *
- * @author Jorg Janke
- * @version $Id: WFNode.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
- */
-public class WFNode extends JComponent
-{
- /**
- *
- */
- private static final long serialVersionUID = -3267215731910132678L;
-
-
- /**
- * Create WF Node
- * @param node model
- */
- public WFNode (MWFNode node)
- {
- super();
- setOpaque(true);
- m_node = node;
- setName(m_node.getName());
- m_icon = new WFIcon(node.getAction());
- m_name = m_node.getName(true);
- setBorder(s_border);
-
- // Tool Tip
- String description = node.getDescription(true);
- if (description != null && description.length() > 0)
- setToolTipText(description);
- else
- setToolTipText(node.getName(true));
-
- // Location
- setBounds(node.getXPosition(), node.getYPosition(), s_size.width, s_size.height);
- log.config(node.getAD_WF_Node_ID()
- + "," + node.getName() + " - " + getLocation());
- setSelected(false);
- setVisited(false);
- } // WFNode
-
- /** Selected Property value */
- public static String PROPERTY_SELECTED = "selected";
- /** Standard (raised) Border */
- private static Border s_border = BorderFactory.createBevelBorder(BevelBorder.RAISED);
- /** Selected (lowered) Border */
- private static Border s_borderSelected = BorderFactory.createBevelBorder(BevelBorder.LOWERED);
- /** Size of the Node */
- private static Dimension s_size = new Dimension (120, 50);
- /** Logger */
- private static CLogger log = CLogger.getCLogger(WFNode.class);
-
- /** ID */
- private MWFNode m_node = null;
- /** Icon */
- private WFIcon m_icon = null;
- /** Name to paint */
- private String m_name = null;
- /** Selected Value */
- private boolean m_selected = false;
- /** Visited Value */
- private boolean m_visited = false;
- /** Was node moved */
- private boolean m_moved = false;
-
-
- /**************************************************************************
- * Set Selected.
- * Selected: blue foreground - lowered border
- * UnSelected: black foreground - raised border
- * @param selected selected
- */
- public void setSelected (boolean selected)
- {
- firePropertyChange(PROPERTY_SELECTED, m_selected, selected);
- m_selected = selected;
- if (m_selected)
- {
- setBorder (s_borderSelected);
- setForeground(Color.blue);
- }
- else
- {
- setBorder (s_border);
- setForeground (Color.black);
- }
- } // setSelected
-
- /**
- * Set Visited.
- * Visited: green background
- * NotVisited:
- * @param visited visited
- */
- public void setVisited (boolean visited)
- {
- m_visited = visited;
- if (m_visited)
- {
- setBackground(Color.green);
- }
- else
- {
- setBackground(Color.lightGray);
- }
- } // setVisited
-
- /**
- * Get Selected
- * @return selected
- */
- public boolean isSelected()
- {
- return m_selected;
- } // isSelected
-
- /**
- * Get Client ID
- * @return Client ID
- */
- public int getAD_Client_ID()
- {
- return m_node.getAD_Client_ID();
- } // getAD_Client_ID
-
- /**
- * Is the node Editable
- * @return yes if the Client is the same
- */
- public boolean isEditable()
- {
- return getAD_Client_ID() == Env.getAD_Client_ID(Env.getCtx());
- } // isEditable
-
-
- /**
- * Get Node ID
- * @return Node ID
- */
- public int getAD_WF_Node_ID()
- {
- return m_node.getAD_WF_Node_ID();
- } // getAD_WF_Node_ID
-
- /**
- * Get Node Model
- * @return Node Model
- */
- public MWFNode getModel()
- {
- return m_node;
- } // getModel
-
- /**
- * Set Location - also for Node.
- * @param x x
- * @param y y
- */
- public void setLocation (int x, int y)
- {
- super.setLocation (x, y);
- m_node.setPosition(x, y);
- }
-
- /**
- * String Representation
- * @return info
- */
- public String toString()
- {
- StringBuffer sb = new StringBuffer("WFNode[");
- sb.append(getAD_WF_Node_ID()).append("-").append(m_name)
- .append(",").append(getBounds())
- .append("]");
- return sb.toString();
- } // toString
-
- /**
- * Get Font.
- * Italics if not editable
- * @return font
- */
- public Font getFont ()
- {
- Font base = new Font(null);
- if (!isEditable())
- return base;
- // Return Bold Italic Font
- return new Font(base.getName(), Font.ITALIC | Font.BOLD, base.getSize());
- } // getFont
-
- /**************************************************************************
- * Get Preferred Size
- * @return size
- */
- public Dimension getPreferredSize ()
- {
- return s_size;
- } // getPreferredSize
-
- /**
- * Paint Component
- * @param g Graphics
- */
- protected void paintComponent (Graphics g)
- {
- Graphics2D g2D = (Graphics2D)g;
- Rectangle bounds = getBounds();
- m_icon.paintIcon(this, g2D, 0, 0);
- // Paint Text
- Color color = getForeground();
- g2D.setPaint(color);
- Font font = getFont();
- //
- AttributedString aString = new AttributedString(m_name);
- aString.addAttribute(TextAttribute.FONT, font);
- aString.addAttribute(TextAttribute.FOREGROUND, color);
- AttributedCharacterIterator iter = aString.getIterator();
- //
- LineBreakMeasurer measurer = new LineBreakMeasurer(iter, g2D.getFontRenderContext());
- float width = s_size.width - m_icon.getIconWidth() - 2;
- TextLayout layout = measurer.nextLayout(width);
- float xPos = m_icon.getIconWidth();
- float yPos = layout.getAscent() + 2;
- //
- layout.draw(g2D, xPos, yPos);
- width = s_size.width - 4; // 2 pt
- while (measurer.getPosition() < iter.getEndIndex())
- {
- layout = measurer.nextLayout(width);
- yPos += layout.getAscent() + layout.getDescent() + layout.getLeading();
- layout.draw(g2D, 2, yPos);
- }
- } // paintComponent
-
-} // WFNode
diff --git a/client/src/org/compiere/apps/wf/WFNodeMoveStrategy.java b/client/src/org/compiere/apps/wf/WFNodeMoveStrategy.java
new file mode 100644
index 0000000000..9679a2e872
--- /dev/null
+++ b/client/src/org/compiere/apps/wf/WFNodeMoveStrategy.java
@@ -0,0 +1,15 @@
+package org.compiere.apps.wf;
+
+import java.awt.Point;
+
+import org.netbeans.api.visual.action.MoveStrategy;
+import org.netbeans.api.visual.widget.Widget;
+
+public class WFNodeMoveStrategy implements MoveStrategy {
+
+ public Point locationSuggested(Widget widget, Point originalLocation, Point suggestedLocation) {
+ return new Point (suggestedLocation.x - suggestedLocation.x % WFGraphLayout.COLUMN_WIDTH ,
+ suggestedLocation.y - suggestedLocation.y % WFGraphLayout.ROW_HEIGHT);
+ }
+
+}
diff --git a/client/src/org/compiere/apps/wf/WFPanel.java b/client/src/org/compiere/apps/wf/WFPanel.java
index 8bb723087d..65f95cadc6 100644
--- a/client/src/org/compiere/apps/wf/WFPanel.java
+++ b/client/src/org/compiere/apps/wf/WFPanel.java
@@ -17,6 +17,7 @@
package org.compiere.apps.wf;
import java.awt.BorderLayout;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
@@ -25,9 +26,10 @@ import java.awt.Insets;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
+import java.util.Set;
import java.util.logging.Level;
import javax.swing.JButton;
@@ -43,7 +45,6 @@ import org.compiere.apps.AMenuStartItem;
import org.compiere.apps.AWindow;
import org.compiere.apps.form.FormFrame;
import org.compiere.apps.form.FormPanel;
-import org.compiere.grid.ed.AutoCompletion;
import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.model.MTable;
@@ -60,32 +61,28 @@ import org.compiere.util.Util;
import org.compiere.wf.MWFNode;
import org.compiere.wf.MWFNodeNext;
import org.compiere.wf.MWorkflow;
+import org.netbeans.api.visual.model.ObjectSceneEvent;
+import org.netbeans.api.visual.model.ObjectSceneEventType;
+import org.netbeans.api.visual.model.ObjectSceneListener;
+import org.netbeans.api.visual.model.ObjectState;
+import org.netbeans.api.visual.widget.Widget;
/**
* WorkFlow Panel
*
* @author Jorg Janke
* @version $Id: WFPanel.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
- *
+ *
* @author Teo Sarca, www.arhipac.ro
* FR [ 2048081 ] Mf. Workflow editor should display only mf. workflows
- * BF [ 2844102 ] Workfow Editor is displaying manufacturing routings too
- * https://sourceforge.net/tracker/?func=detail&aid=2844102&group_id=176962&atid=879332
*/
public class WFPanel extends CPanel
- implements PropertyChangeListener, ActionListener, FormPanel
+ implements ActionListener, FormPanel, ObjectSceneListener
{
/**
- *
+ *
*/
private static final long serialVersionUID = 4478193785606693055L;
-
- /** Workflow WhereClause : General, Document Process, Document Value */
- private static final String WORKFLOW_WhereClause = "WorkflowType IN ("
- +DB.TO_STRING(MWorkflow.WORKFLOWTYPE_General)
- +","+DB.TO_STRING(MWorkflow.WORKFLOWTYPE_DocumentProcess)
- +","+DB.TO_STRING(MWorkflow.WORKFLOWTYPE_DocumentValue)
- +")";
/**
@@ -94,7 +91,7 @@ public class WFPanel extends CPanel
*/
public WFPanel()
{
- this (null, WORKFLOW_WhereClause, -1);
+ this (null, null, -1);
} // WFPanel
/**
@@ -103,7 +100,7 @@ public class WFPanel extends CPanel
*/
public WFPanel (AMenu menu)
{
- this(menu, WORKFLOW_WhereClause, -1);
+ this(menu, null, -1);
}
/**
@@ -140,10 +137,10 @@ public class WFPanel extends CPanel
/** Context */
private Properties m_ctx = Env.getCtx();
/** Active Node */
- private WFNode m_activeNode = null;
+ private MWFNode m_activeNode = null;
/** ReadWrite Mode (see WFNode) */
private boolean m_readWrite = false;
-
+
/** Workflows List Where Clause */
private String m_WF_whereClause = null;
/** Workflow Window ID */
@@ -151,7 +148,7 @@ public class WFPanel extends CPanel
/** Logger */
private static CLogger log = CLogger.getCLogger(WFPanel.class);
-
+
// UI
private BorderLayout mainLayout = new BorderLayout();
private CPanel southPanel = new CPanel();
@@ -171,8 +168,9 @@ public class WFPanel extends CPanel
private CButton bSaveLayout = AEnv.getButton ("Save");
private CButton bZoom = AEnv.getButton("Zoom");
private CButton bIgnore = AEnv.getButton("Ignore");
-
-
+ private WFNodeWidget selectedWidget;
+
+
/**
* Static Init
*
@@ -278,7 +276,6 @@ public class WFPanel extends CPanel
KeyNamePair[] pp = DB.getKeyNamePairs(sql, true);
//
workflow = new CComboBox(pp);
- AutoCompletion.enable(workflow);
loadPanel.add(workflow);
workflow.addActionListener(this);
//
@@ -291,8 +288,8 @@ public class WFPanel extends CPanel
loadPanel.add(bZoom);
bZoom.addActionListener(this);
} // loadPanel
-
-
+
+
/**************************************************************************
* Load Workflow & Nodes
* @param readWrite if true, you can move nodes
@@ -304,7 +301,7 @@ public class WFPanel extends CPanel
return;
load (pp.getKey(), readWrite);
} // load
-
+
/**
* Load Workflow & Nodes
* @param AD_Workflow_ID ID
@@ -320,23 +317,33 @@ public class WFPanel extends CPanel
m_wf = new MWorkflow (Env.getCtx(), AD_Workflow_ID, null);
centerPanel.removeAll();
centerPanel.setReadWrite(readWrite);
+ centerPanel.getGraphScene().addObjectSceneListener(this, ObjectSceneEventType.OBJECT_SELECTION_CHANGED);
+
if (readWrite)
centerPanel.setWorkflow(m_wf);
- // Add Nodes for Paint
+
+ // Add Nodes
MWFNode[] nodes = m_wf.getNodes(true, AD_Client_ID);
+ List added = new ArrayList();
for (int i = 0; i < nodes.length; i++)
{
- WFNode wfn = new WFNode (nodes[i]);
- wfn.addPropertyChangeListener(WFNode.PROPERTY_SELECTED, this);
boolean rw = readWrite // in editor mode & owned
&& (AD_Client_ID == nodes[i].getAD_Client_ID());
- centerPanel.add (wfn, rw);
- // Add Lines
+ if (!added.contains(nodes[i].getAD_WF_Node_ID()))
+ centerPanel.addNode(nodes[i]);
+ }
+
+ // Add Lines
+ for (int i = 0; i < nodes.length; i++)
+ {
MWFNodeNext[] nexts = nodes[i].getTransitions(AD_Client_ID);
for (int j = 0; j < nexts.length; j++)
- centerPanel.add (new WFLine (nexts[j]), false);
+ {
+ centerPanel.addEdge(nexts[j]);
+ }
}
- // Info Text
+
+ // Info Text
StringBuffer msg = new StringBuffer("");
msg.append("").append(m_wf.getName(true)).append("
");
String s = m_wf.getDescription(true);
@@ -350,22 +357,10 @@ public class WFPanel extends CPanel
infoTextPane.setCaretPosition(0);
// Layout
- centerPanel.validate();
- centerPanel.repaint();
+ centerPanel.relayout();
validate();
} // load
- /**
- * Property Change Listener
- * @param e event
- * @see java.beans.PropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange (PropertyChangeEvent e)
- {
- if (e.getNewValue() == Boolean.TRUE)
- start ((WFNode)e.getSource());
- } // propertyChange
-
/**
* Action Listener
* @param e event
@@ -416,17 +411,16 @@ public class WFPanel extends CPanel
* Start Node
* @param node node
*/
- public void start (WFNode node)
+ public void start (MWFNode node)
{
log.fine("Node=" + node);
- MWFNode model = node.getModel();
// Info Text
StringBuffer msg = new StringBuffer("");
- msg.append("").append(model.getName(true)).append("
");
- String s = model.getDescription(true);
+ msg.append("").append(node.getName(true)).append("
");
+ String s = node.getDescription(true);
if (s != null && s.length() > 0)
msg.append("").append(s).append("");
- s = model.getHelp(true);
+ s = node.getHelp(true);
if (s != null && s.length() > 0)
msg.append("
").append(s);
msg.append("");
@@ -435,7 +429,7 @@ public class WFPanel extends CPanel
// Load Window
if (m_menu != null)
- (new AMenuStartItem(model.getAD_WF_Node_ID(), false, model.getName(true), m_menu)).start(); // async load
+ (new AMenuStartItem(node.getAD_WF_Node_ID(), false, node.getName(true), m_menu)).start(); // async load
//
m_activeNode = node;
//
@@ -457,19 +451,15 @@ public class WFPanel extends CPanel
if (AD_WF_Node_ID == 0)
return;
//
- for (int i = 0; i < centerPanel.getComponentCount(); i++)
- {
- Component comp = centerPanel.getComponent(i);
- if (comp instanceof WFNode)
- {
- WFNode node = (WFNode)comp;
- if (node.getAD_WF_Node_ID() == AD_WF_Node_ID)
- {
- start (node);
- return;
- }
- } // WFNode
- } // for all components
+ Object object = centerPanel.getGraphScene().findWidget(AD_WF_Node_ID);
+ if (object != null) {
+ WFNodeWidget widget = (WFNodeWidget) object;
+ widget.setBackground (Color.CYAN);
+ if (selectedWidget != null)
+ selectedWidget.setBackground(Color.WHITE);
+ selectedWidget = widget;
+ start(widget.getModel());
+ }
} // start
/**
@@ -497,7 +487,7 @@ public class WFPanel extends CPanel
if (m_WF_Window_ID <= 0) {
throw new AdempiereException("@NotFound@ @AD_Window_ID@");
}
-
+
MQuery query = null;
if (m_wf != null)
query = MQuery.getEqualQuery("AD_Workflow_ID", m_wf.getAD_Workflow_ID());
@@ -538,4 +528,51 @@ public class WFPanel extends CPanel
} // main
+ //ObjectSceneListener
+ public void focusChanged(ObjectSceneEvent arg0, Object arg1, Object arg2) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void highlightingChanged(ObjectSceneEvent arg0, Set