[ 1845211 ] ScriptEditor not working as field editor
This commit is contained in:
parent
da929b55d1
commit
9343ed0abc
|
@ -414,7 +414,7 @@ public final class AEnv
|
||||||
}
|
}
|
||||||
else if (actionCommand.equals("Script"))
|
else if (actionCommand.equals("Script"))
|
||||||
{
|
{
|
||||||
new ScriptEditor();
|
new ScriptEditor(Env.getFrame(c));
|
||||||
}
|
}
|
||||||
else if (actionCommand.equals("Preference"))
|
else if (actionCommand.equals("Preference"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,8 +34,10 @@ import org.compiere.util.*;
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: ScriptEditor.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
* @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
|
* Minimum Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +46,14 @@ public class ScriptEditor extends CFrame implements ActionListener
|
||||||
this (Msg.getMsg(Env.getCtx(), "Script"), null, 0);
|
this (Msg.getMsg(Env.getCtx(), "Script"), null, 0);
|
||||||
} // ScriptEditor
|
} // ScriptEditor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum Constructor
|
||||||
|
*/
|
||||||
|
public ScriptEditor(Frame owner)
|
||||||
|
{
|
||||||
|
this (owner, Msg.getMsg(Env.getCtx(), "Script"), null, 0);
|
||||||
|
} // ScriptEditor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -52,7 +62,25 @@ public class ScriptEditor extends CFrame implements ActionListener
|
||||||
*/
|
*/
|
||||||
public ScriptEditor (String title, Scriptlet script, int WindowNo)
|
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;
|
m_WindowNo = WindowNo;
|
||||||
if (m_WindowNo == 0)
|
if (m_WindowNo == 0)
|
||||||
m_WindowNo = Env.createWindowNo(this);
|
m_WindowNo = Env.createWindowNo(this);
|
||||||
|
@ -116,7 +144,6 @@ public class ScriptEditor extends CFrame implements ActionListener
|
||||||
*/
|
*/
|
||||||
void jbInit() throws Exception
|
void jbInit() throws Exception
|
||||||
{
|
{
|
||||||
this.setIconImage(Env.getImage("Bean16.gif"));
|
|
||||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),
|
titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),
|
||||||
Msg.getMsg(Env.getCtx(), "ScriptVariables"));
|
Msg.getMsg(Env.getCtx(), "ScriptVariables"));
|
||||||
|
@ -247,7 +274,10 @@ public class ScriptEditor extends CFrame implements ActionListener
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
{
|
{
|
||||||
if (e.getSource() == bOK)
|
if (e.getSource() == bOK)
|
||||||
|
{
|
||||||
|
m_script.setScript(editor.getText());
|
||||||
dispose();
|
dispose();
|
||||||
|
}
|
||||||
else if (e.getSource() == bCancel)
|
else if (e.getSource() == bCancel)
|
||||||
{
|
{
|
||||||
m_script.setScript(m_origScript);
|
m_script.setScript(m_origScript);
|
||||||
|
@ -258,7 +288,7 @@ public class ScriptEditor extends CFrame implements ActionListener
|
||||||
actionProcess();
|
actionProcess();
|
||||||
else if (e.getSource() == bHelp)
|
else if (e.getSource() == bHelp)
|
||||||
{
|
{
|
||||||
Help h = new Help (this ,
|
Help h = new Help (m_owner ,
|
||||||
Msg.getMsg(Env.getCtx(), "ScriptHelp"),
|
Msg.getMsg(Env.getCtx(), "ScriptHelp"),
|
||||||
getClass().getResource("Script.html"));
|
getClass().getResource("Script.html"));
|
||||||
h.setVisible(true);
|
h.setVisible(true);
|
||||||
|
@ -305,11 +335,27 @@ public class ScriptEditor extends CFrame implements ActionListener
|
||||||
* @param script ScriptCode
|
* @param script ScriptCode
|
||||||
* @param editable
|
* @param editable
|
||||||
* @return updated Script
|
* @return updated Script
|
||||||
|
*
|
||||||
|
* @deprecated since 3.3.1
|
||||||
*/
|
*/
|
||||||
public static String start (String header, String script, boolean editable, int WindowNo)
|
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);
|
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();
|
return scr.getScript();
|
||||||
} // start
|
} // start
|
||||||
|
|
||||||
|
|
|
@ -136,8 +136,11 @@ public class VMemo extends CTextArea
|
||||||
{
|
{
|
||||||
menuEditor.setEnabled(false);
|
menuEditor.setEnabled(false);
|
||||||
String s = null;
|
String s = null;
|
||||||
if (m_columnName.equals("Script"))
|
if (m_columnName.equals("Script") || m_columnName.endsWith("_Script"))
|
||||||
s = ScriptEditor.start (Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(), 0);
|
s = ScriptEditor.start (
|
||||||
|
Env.getFrame(this.getParent()),
|
||||||
|
Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(),
|
||||||
|
findWindowNo());
|
||||||
else
|
else
|
||||||
s = Editor.startEditor (this, Msg.translate(Env.getCtx(), m_columnName),
|
s = Editor.startEditor (this, Msg.translate(Env.getCtx(), m_columnName),
|
||||||
getText(), isEditable(), m_fieldLength);
|
getText(), isEditable(), m_fieldLength);
|
||||||
|
@ -151,6 +154,11 @@ public class VMemo extends CTextArea
|
||||||
catch (PropertyVetoException pve) {}
|
catch (PropertyVetoException pve) {}
|
||||||
}
|
}
|
||||||
} // actionPerformed
|
} // actionPerformed
|
||||||
|
|
||||||
|
private int findWindowNo() {
|
||||||
|
Container c = this.getParent();
|
||||||
|
return c != null ? Env.getWindowNo(c) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action Listener Interface - NOP
|
* Action Listener Interface - NOP
|
||||||
|
|
|
@ -129,8 +129,11 @@ public class VText extends CTextArea
|
||||||
{
|
{
|
||||||
menuEditor.setEnabled(false);
|
menuEditor.setEnabled(false);
|
||||||
String s = null;
|
String s = null;
|
||||||
if (m_columnName.equals("Script"))
|
if (m_columnName.equals("Script") || m_columnName.endsWith("_Script"))
|
||||||
s = ScriptEditor.start (Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(), 0);
|
s = ScriptEditor.start (
|
||||||
|
Env.getFrame(this.getParent()),
|
||||||
|
Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(),
|
||||||
|
findWindowNo());
|
||||||
else
|
else
|
||||||
s = Editor.startEditor (this, Msg.translate(Env.getCtx(), m_columnName),
|
s = Editor.startEditor (this, Msg.translate(Env.getCtx(), m_columnName),
|
||||||
getText(), isEditable(), m_fieldLength);
|
getText(), isEditable(), m_fieldLength);
|
||||||
|
@ -144,6 +147,11 @@ public class VText extends CTextArea
|
||||||
}
|
}
|
||||||
} // actionPerformed
|
} // actionPerformed
|
||||||
|
|
||||||
|
private int findWindowNo() {
|
||||||
|
Container c = this.getParent();
|
||||||
|
return c != null ? Env.getWindowNo(c) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action Listener Interface - NOP
|
* Action Listener Interface - NOP
|
||||||
* @param listener listener
|
* @param listener listener
|
||||||
|
|
Loading…
Reference in New Issue