[ 1845211 ] ScriptEditor not working as field editor

This commit is contained in:
Heng Sin Low 2007-12-05 23:43:57 +00:00
parent da929b55d1
commit 9343ed0abc
4 changed files with 72 additions and 10 deletions

View File

@ -414,7 +414,7 @@ public final class AEnv
}
else if (actionCommand.equals("Script"))
{
new ScriptEditor();
new ScriptEditor(Env.getFrame(c));
}
else if (actionCommand.equals("Preference"))
{

View File

@ -34,8 +34,10 @@ import org.compiere.util.*;
* @author Jorg Janke
* @version $Id: ScriptEditor.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
*/
public class ScriptEditor extends CFrame implements ActionListener
public class ScriptEditor extends CDialog implements ActionListener
{
private Frame m_owner;
/**
* Minimum Constructor
*/
@ -44,6 +46,14 @@ public class ScriptEditor extends CFrame implements ActionListener
this (Msg.getMsg(Env.getCtx(), "Script"), null, 0);
} // ScriptEditor
/**
* Minimum Constructor
*/
public ScriptEditor(Frame owner)
{
this (owner, Msg.getMsg(Env.getCtx(), "Script"), null, 0);
} // ScriptEditor
/**
* Constructor
*
@ -52,7 +62,25 @@ public class ScriptEditor extends CFrame implements ActionListener
*/
public ScriptEditor (String title, Scriptlet script, int WindowNo)
{
super(title);
this(null, title, script, WindowNo);
}
/**
* Constructor
*
* @param owner Owner frame
* @param title Field Name
* @param script The Script
*/
public ScriptEditor (Frame owner, String title, Scriptlet script, int WindowNo)
{
super(owner);
setTitle(title);
if (owner != null)
{
setModal(true);
}
m_owner = owner;
m_WindowNo = WindowNo;
if (m_WindowNo == 0)
m_WindowNo = Env.createWindowNo(this);
@ -116,7 +144,6 @@ public class ScriptEditor extends CFrame implements ActionListener
*/
void jbInit() throws Exception
{
this.setIconImage(Env.getImage("Bean16.gif"));
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),
Msg.getMsg(Env.getCtx(), "ScriptVariables"));
@ -247,7 +274,10 @@ public class ScriptEditor extends CFrame implements ActionListener
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == bOK)
{
m_script.setScript(editor.getText());
dispose();
}
else if (e.getSource() == bCancel)
{
m_script.setScript(m_origScript);
@ -258,7 +288,7 @@ public class ScriptEditor extends CFrame implements ActionListener
actionProcess();
else if (e.getSource() == bHelp)
{
Help h = new Help (this ,
Help h = new Help (m_owner ,
Msg.getMsg(Env.getCtx(), "ScriptHelp"),
getClass().getResource("Script.html"));
h.setVisible(true);
@ -305,11 +335,27 @@ public class ScriptEditor extends CFrame implements ActionListener
* @param script ScriptCode
* @param editable
* @return updated Script
*
* @deprecated since 3.3.1
*/
public static String start (String header, String script, boolean editable, int WindowNo)
{
return start(null, header, script, editable, WindowNo);
}
/**
* Start ScriptEditor
*
* @param owner
* @param header Title
* @param script ScriptCode
* @param editable
* @return updated Script
*/
public static String start (Frame owner, String header, String script, boolean editable, int WindowNo)
{
Scriptlet scr = new Scriptlet (Scriptlet.VARIABLE, script, Env.getCtx(), WindowNo);
ScriptEditor se = new ScriptEditor (header, scr, WindowNo);
ScriptEditor se = new ScriptEditor (owner, header, scr, WindowNo);
return scr.getScript();
} // start

View File

@ -136,8 +136,11 @@ public class VMemo extends CTextArea
{
menuEditor.setEnabled(false);
String s = null;
if (m_columnName.equals("Script"))
s = ScriptEditor.start (Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(), 0);
if (m_columnName.equals("Script") || m_columnName.endsWith("_Script"))
s = ScriptEditor.start (
Env.getFrame(this.getParent()),
Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(),
findWindowNo());
else
s = Editor.startEditor (this, Msg.translate(Env.getCtx(), m_columnName),
getText(), isEditable(), m_fieldLength);
@ -151,6 +154,11 @@ public class VMemo extends CTextArea
catch (PropertyVetoException pve) {}
}
} // actionPerformed
private int findWindowNo() {
Container c = this.getParent();
return c != null ? Env.getWindowNo(c) : 0;
}
/**
* Action Listener Interface - NOP

View File

@ -129,8 +129,11 @@ public class VText extends CTextArea
{
menuEditor.setEnabled(false);
String s = null;
if (m_columnName.equals("Script"))
s = ScriptEditor.start (Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(), 0);
if (m_columnName.equals("Script") || m_columnName.endsWith("_Script"))
s = ScriptEditor.start (
Env.getFrame(this.getParent()),
Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(),
findWindowNo());
else
s = Editor.startEditor (this, Msg.translate(Env.getCtx(), m_columnName),
getText(), isEditable(), m_fieldLength);
@ -144,6 +147,11 @@ public class VText extends CTextArea
}
} // actionPerformed
private int findWindowNo() {
Container c = this.getParent();
return c != null ? Env.getWindowNo(c) : 0;
}
/**
* Action Listener Interface - NOP
* @param listener listener