2 from javax.swing.filechooser
import FileFilter
14 ret = JOptionPane.showConfirmDialog(f, msg,
"waitInputConfirm",
15 JOptionPane.OK_CANCEL_OPTION)
17 raise StandardError,
"script is canceled" 25 ret = JOptionPane.showConfirmDialog(f, msg,
"waitInputSelect",
26 JOptionPane.YES_NO_CANCEL_OPTION)
32 raise StandardError,
"script is canceled" 44 def __init__(self, frame, label, cmd, isFirst):
50 self.panel.add(self.
bCmd)
52 self.
nstr = cmd.count(
"#T")
53 self.
nint = cmd.count(
"#I")
54 self.
ndbl = cmd.count(
"#D")
56 for i
in range(self.
nstr):
60 bc = JButton(
"select", actionPerformed=self.
selectFile)
63 for i
in range(self.
nint):
68 for i
in range(self.
ndbl):
72 if cmd.count(
"#continuous"):
74 self.cbContinuous.setSelected(
True)
82 self.
continuous = self.cbContinuous.isSelected()
85 jfc = JFileChooser(
".")
87 jfc.addChoosableFileFilter(pf)
88 ret = jfc.showOpenDialog(
None)
90 path = jfc.getSelectedFile().toString()
93 base = file.split(
".")[0]
94 self.
args[0].setText(base)
98 for i
in range(self.
nstr):
99 cmd = cmd.replace(
"#T", self.
args[i].getText(), 1)
101 for i
in range(self.
nint):
102 cmd = cmd.replace(
"#I", self.
args[i].getText(), 1)
104 for i
in range(self.
ndbl):
105 cmd = cmd.replace(
"#D", self.
args[i].getText(), 1)
106 self.frame.addHistory(cmd)
108 if self.
isFirst and self.frame.isSequential():
109 self.frame.advancePage()
114 self.
f = JFrame(
"waitInputMenu")
115 self.f.setSize(400, 600)
123 panel1.setLayout(BorderLayout())
129 p.setLayout(GridLayout(1,4))
139 self.cbSequential.setSelected(
True)
141 panel1.add(p, BorderLayout.SOUTH)
143 self.tabPane.addTab(
"Local", JScrollPane(panel1))
148 panel2.setLayout(BoxLayout(panel2, BoxLayout.Y_AXIS))
149 bQuit = JButton(
"Quit", actionPerformed=exit)
153 bRestart = JButton(
"Restart", actionPerformed=self.
restart)
156 for i
in range(len(gmenu)/2):
158 content = gmenu[i*2+1]
159 if content ==
"#label":
167 self.tabPane.addTab(
"Global", JScrollPane(panel2))
172 panel3.setLayout(BorderLayout())
173 panel3.add(sp, BorderLayout.CENTER)
174 self.tabPane.addTab(
"History", panel3)
177 self.f.setVisible(
True)
182 self.tabPane.setSelectedIndex(0)
185 return self.cbSequential.isSelected()
187 self.localMenuPanel.removeAll()
189 for i
in range(len(pmenu)/2):
192 cp.bCmd.setEnabled(
False)
194 cp.bCmd.setEnabled(
True)
195 self.localMenuPanel.add(cp.panel)
197 cp.processEvent(event)
198 self.f.setVisible(
True)
199 self.lPage.setText(str(self.
page+1)+
"/"+str(len(self.
lmenu)))
201 self.bPrev.setEnabled(
False)
203 self.bPrev.setEnabled(
True)
205 self.bNext.setEnabled(
False)
206 self.bSkip.setEnabled(
False)
208 self.bNext.setEnabled(
True)
209 self.bSkip.setEnabled(
True)
210 for c
in self.localMenuPanel.getComponents():
211 c.setBackground(self.
color)
219 self.tabPane.setSelectedIndex(1)
230 dstr = datetime.datetime.today().strftime(
"%Y-%m-%d %H:%M:%S")
231 str = dstr+
":"+msg+
"\n" 232 self.taHistory.append(str)
241 for comp
in wimf.localMenuPanel.getComponents():
242 comp.setBackground(c)
245 __builtin__.waitInputConfirm = waitInputConfirm
246 __builtin__.waitInputSelect = waitInputSelect
247 __builtin__.waitInputMenu = waitInputMenu