package gve.calc.formula; import java.awt.event.*; import awt.*; import java.awt.*; import awt.Button; public class LoadRules implements ActionListener { private static String [] rulesets = {"propc","propcc","predc"}; private FormulaView fview; private LoadRules(FormulaView view) { fview = view; } public static void addLoadButtons(Container cont,FormulaView fview) { for (int i = 0; i < rulesets.length; i++) { Button b; cont.add(b = new Button("Load "+rulesets[i])); LoadRules listener = new LoadRules(fview); b.addActionListener(listener); } } public static MenuButton createLoadButton(Component comp,boolean direction,FormulaView fview) { MenuButton result = new MenuButton("Rules",comp,direction); addLoadButtons(result.popup,fview); result.pack(); return result; } public void actionPerformed(ActionEvent evt) { String filename = evt.getActionCommand().substring(5); Part p = fview.load(filename); if (p == null) { return; } Part rules = (Part)fview.getVar("rules"); if (rules == null) rules = p; else { rules = new OperatorUnion(rules,p).evaluate(new SingleEvaluator()); } fview.storeVar("rules",rules); } }