rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
case 1 :
case 3 :
public void setValueAt(Object value, int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : data.setMaltName(row, value.toString()); break; case 1 : data.setMaltAmount(row, Double.parseDouble(value.toString())); break; case 2 : // m.setUnits(value.toString()); break; case 3 : data.setMaltPppg(row, Double.parseDouble(value.toString())); break; case 4 : data.setMaltLov(row, Double.parseDouble(value.toString())); break; case 5 : data.setMaltCost(row, value.toString()); break; case 6 : // data.setMaltPercent(row, Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; app.myRecipe.calcMaltTotals(); fireTableCellUpdated(row, col); fireTableDataChanged(); app.displayRecipe(); }
case 2 :
case 4 :
public void setValueAt(Object value, int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : data.setMaltName(row, value.toString()); break; case 1 : data.setMaltAmount(row, Double.parseDouble(value.toString())); break; case 2 : // m.setUnits(value.toString()); break; case 3 : data.setMaltPppg(row, Double.parseDouble(value.toString())); break; case 4 : data.setMaltLov(row, Double.parseDouble(value.toString())); break; case 5 : data.setMaltCost(row, value.toString()); break; case 6 : // data.setMaltPercent(row, Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; app.myRecipe.calcMaltTotals(); fireTableCellUpdated(row, col); fireTableDataChanged(); app.displayRecipe(); }
case 3 :
case 5 :
public void setValueAt(Object value, int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : data.setMaltName(row, value.toString()); break; case 1 : data.setMaltAmount(row, Double.parseDouble(value.toString())); break; case 2 : // m.setUnits(value.toString()); break; case 3 : data.setMaltPppg(row, Double.parseDouble(value.toString())); break; case 4 : data.setMaltLov(row, Double.parseDouble(value.toString())); break; case 5 : data.setMaltCost(row, value.toString()); break; case 6 : // data.setMaltPercent(row, Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; app.myRecipe.calcMaltTotals(); fireTableCellUpdated(row, col); fireTableDataChanged(); app.displayRecipe(); }
case 4 :
case 6 :
public void setValueAt(Object value, int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : data.setMaltName(row, value.toString()); break; case 1 : data.setMaltAmount(row, Double.parseDouble(value.toString())); break; case 2 : // m.setUnits(value.toString()); break; case 3 : data.setMaltPppg(row, Double.parseDouble(value.toString())); break; case 4 : data.setMaltLov(row, Double.parseDouble(value.toString())); break; case 5 : data.setMaltCost(row, value.toString()); break; case 6 : // data.setMaltPercent(row, Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; app.myRecipe.calcMaltTotals(); fireTableCellUpdated(row, col); fireTableDataChanged(); app.displayRecipe(); }
case 5 :
case 7 :
public void setValueAt(Object value, int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : data.setMaltName(row, value.toString()); break; case 1 : data.setMaltAmount(row, Double.parseDouble(value.toString())); break; case 2 : // m.setUnits(value.toString()); break; case 3 : data.setMaltPppg(row, Double.parseDouble(value.toString())); break; case 4 : data.setMaltLov(row, Double.parseDouble(value.toString())); break; case 5 : data.setMaltCost(row, value.toString()); break; case 6 : // data.setMaltPercent(row, Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; app.myRecipe.calcMaltTotals(); fireTableCellUpdated(row, col); fireTableDataChanged(); app.displayRecipe(); }
case 6 :
case 8 :
public void setValueAt(Object value, int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : data.setMaltName(row, value.toString()); break; case 1 : data.setMaltAmount(row, Double.parseDouble(value.toString())); break; case 2 : // m.setUnits(value.toString()); break; case 3 : data.setMaltPppg(row, Double.parseDouble(value.toString())); break; case 4 : data.setMaltLov(row, Double.parseDouble(value.toString())); break; case 5 : data.setMaltCost(row, value.toString()); break; case 6 : // data.setMaltPercent(row, Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; app.myRecipe.calcMaltTotals(); fireTableCellUpdated(row, col); fireTableDataChanged(); app.displayRecipe(); }
public void addStep(String t, double st, double et, String tu, String m, int min,
public void addStep(String type, double st, double et, String tu, String m, int min,
public void addStep(String t, double st, double et, String tu, String m, int min, int rmin) { MashStep step = new MashStep(t, st, et, tu, m, min, rmin); steps.add(step); calcMashSchedule(); }
MashStep step = new MashStep(t, st, et, tu, m, min, rmin);
MashStep step = new MashStep(type, st, et, tu, m, min, rmin);
public void addStep(String t, double st, double et, String tu, String m, int min, int rmin) { MashStep step = new MashStep(t, st, et, tu, m, min, rmin); steps.add(step); calcMashSchedule(); }
private static void deleteFile(File child) throws IOException { if (!child.delete()) { if(!child.exists())
private static void deleteFile(File f) throws IOException { if (!f.delete()) { if(!f.exists())
private static void deleteFile(File child) throws IOException { if (!child.delete()) { if(!child.exists()) // we are trying to delete a file that no longer exists, so this is not an error return; throw new IOException("Unable to delete " + child.getPath()); } }
throw new IOException("Unable to delete " + child.getPath());
try { Chmod chmod = new Chmod(); chmod.setProject(new org.apache.tools.ant.Project()); chmod.setFile(f); chmod.setPerm("u+w"); chmod.execute(); } catch (BuildException e) { LOGGER.log(Level.INFO,"Failed to chmod "+f,e); } throw new IOException("Unable to delete " + f.getPath());
private static void deleteFile(File child) throws IOException { if (!child.delete()) { if(!child.exists()) // we are trying to delete a file that no longer exists, so this is not an error return; throw new IOException("Unable to delete " + child.getPath()); } }
j.dv.printDiffRules();
j.getDifferentationVisitor().printDiffRules();
private String getCommand() throws IOException { String s; if (br == null) return null; if ( (s = br.readLine()) == null) return null; if( s.equals("rules")) { j.dv.printDiffRules(); System.out.println("Operators:"); Operator.printOperators();// System.out.println("dJEPdx - Enter q to quit, rules to print the differentation rules,\ndiff(x^2,x) to differentiate,\neval(x^y,x,2,y,3) to evaluate"); System.out.print(prompt); return getCommand(); } if( s.equals("invalidate")) { this.j.getSymbolTable().clearValues(); j.getVarTab().print(j.pv); System.out.print(prompt); return getCommand(); } if (s.equals("q") || s.equals("quit") || s.equals("exit")) return null; return s; }
j.getVarTab().print(j.pv);
j.getVarTab().print(j.getPrintVisitor());
private String getCommand() throws IOException { String s; if (br == null) return null; if ( (s = br.readLine()) == null) return null; if( s.equals("rules")) { j.dv.printDiffRules(); System.out.println("Operators:"); Operator.printOperators();// System.out.println("dJEPdx - Enter q to quit, rules to print the differentation rules,\ndiff(x^2,x) to differentiate,\neval(x^y,x,2,y,3) to evaluate"); System.out.print(prompt); return getCommand(); } if( s.equals("invalidate")) { this.j.getSymbolTable().clearValues(); j.getVarTab().print(j.pv); System.out.print(prompt); return getCommand(); } if (s.equals("q") || s.equals("quit") || s.equals("exit")) return null; return s; }
j.dv.addStandardDiffRules();
j.addStandardDiffRules();
void initialise() { j = new MatrixJep(); j.addStandardConstants(); j.addStandardFunctions(); j.addComplex(); j.setAllowUndeclared(true); j.setImplicitMul(true); j.setAllowAssignment(true); j.dv.addStandardDiffRules(); // dv.addDiffRule(new MProductDiffRule(dv,MatrixOperatorSet.M_HAT)); }
j.pv.println(node);
j.println(node);
void processEquation(Node node) { if(node==null) return; try { System.out.print("fun:\t\t"); j.pv.println(node); MatrixNodeI matEqn = j.dec.preprocess(node,j); j.println(matEqn); Object res = j.evaluate(matEqn); System.out.println("Res: "+res); System.out.println("Variables"); j.getVarTab().print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println("Exception "+e3.getMessage()); e3.printStackTrace(); } }
j.getVarTab().print(j.pv);
j.getVarTab().print(j.getPrintVisitor());
void processEquation(Node node) { if(node==null) return; try { System.out.print("fun:\t\t"); j.pv.println(node); MatrixNodeI matEqn = j.dec.preprocess(node,j); j.println(matEqn); Object res = j.evaluate(matEqn); System.out.println("Res: "+res); System.out.println("Variables"); j.getVarTab().print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println("Exception "+e3.getMessage()); e3.printStackTrace(); } }
public DifferentationVisitor getDifferentationVisitor() { return dv; }
public DifferentiationVisitor getDifferentationVisitor() { return dv; }
public DifferentationVisitor getDifferentationVisitor() { return dv; }
checkAndRecord(that, r, that.getBuilds());
public SortedMap<Integer,RangeSet> getRelationship(Project that) { TreeMap<Integer,RangeSet> r = new TreeMap<Integer,RangeSet>(REVERSE_INTEGER_COMPARATOR); checkAndRecord(that, r, this.getBuilds()); checkAndRecord(that, r, that.getBuilds()); return r; }
else if (o == rbPercent){ evapAmountLbl.setText("%"); } else if (o == rbConstant){ evapAmountLbl.setText(Quantity.getVolAbrv(volUnitsComboModel.getSelectedItem().toString()) + "/hr"); }
public void actionPerformed(ActionEvent e) { Object o = e.getSource(); if (o == okButton) { saveOptions(); opts.saveProperties(); ((StrangeSwing)sb).displayRecipe(); setVisible(false); dispose(); } else if (o == cancelButton){ setVisible(false); dispose(); } else if (o == colMethod1rb || o == colMethod2rb){ redSpn.setEnabled(o == colMethod1rb); greenSpn.setEnabled(o == colMethod1rb); blueSpn.setEnabled(o == colMethod1rb); displayColour(); } }
rbPercent.addActionListener(this); rbConstant.addActionListener(this);
private JPanel getPnlEvaporation() { if (pnlEvaporation == null) { pnlEvaporation = new JPanel(); BoxLayout pnlEvaporationLayout = new BoxLayout(pnlEvaporation, javax.swing.BoxLayout.Y_AXIS); pnlEvaporation.setLayout(pnlEvaporationLayout); pnlEvaporation.setBorder(BorderFactory.createTitledBorder("Evaporation:")); pnlEvaporation.add(getRbPercent()); pnlEvaporation.add(getRbConstant()); bgEvap.add(rbPercent); bgEvap.add(rbConstant); } return pnlEvaporation; }
txtBottleSize.setPreferredSize(new java.awt.Dimension(61, 20));
private JTextField getTxtBottleSize() { if (txtBottleSize == null) { txtBottleSize = new JTextField(); txtBottleSize.setText("351"); } return txtBottleSize; }
jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0));
jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0));
jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0));
jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbBottleSize.setPreferredSize(new java.awt.Dimension(89, 20)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
private void layoutUi() { JPanel buttons = new JPanel(); okButton = new JButton("OK"); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); buttons.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttons.add(cancelButton); buttons.add(okButton); getContentPane().setLayout(new BorderLayout()); this.setFocusTraversalKeysEnabled(false); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { pnlCalculations = new JPanel(); jTabbedPane1.addTab("Calculations", null, pnlCalculations, null); { try { { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7, 7}; thisLayout.columnWeights = new double[]{0.1, 0.2}; thisLayout.columnWidths = new int[]{7, 7}; pnlCalculations.setLayout(thisLayout); pnlCalculations.setPreferredSize(new java.awt.Dimension(524, 372)); { { bgHopsCalc = new ButtonGroup(); { pnlHops = new JPanel(); GridLayout pnlHopsLayout = new GridLayout(2, 2); pnlHopsLayout.setColumns(2); pnlHopsLayout.setHgap(5); pnlHopsLayout.setVgap(5); pnlHopsLayout.setRows(2); pnlHops.setLayout(pnlHopsLayout); pnlCalculations.add(pnlHops, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHops .setBorder(BorderFactory .createTitledBorder("Hops:")); { jLabelc1 = new JLabel(); pnlHops.add(jLabelc1); jLabelc1.setText("Pellet Hops +%"); } { txtPellet = new JTextField(); pnlHops.add(txtPellet); txtPellet.setPreferredSize(new java.awt.Dimension(20, 20)); } { jLabelc2 = new JLabel(); pnlHops.add(jLabelc2); jLabelc2.setText("Tinseth Utilization Factor"); } { txtTinsethUtil = new JTextField(); pnlHops.add(txtTinsethUtil); txtTinsethUtil.setText("4.15"); } } { pnlAlc = new JPanel(); BoxLayout pnlAlcLayout = new BoxLayout(pnlAlc, javax.swing.BoxLayout.Y_AXIS); pnlAlc.setLayout(pnlAlcLayout); pnlCalculations.add(pnlAlc, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlAlc.setBorder(BorderFactory .createTitledBorder("Alcohol By:")); { rbABV = new JRadioButton(); pnlAlc.add(rbABV); bgAlc.add(rbABV); rbABV.setText("Volume"); } { rbABW = new JRadioButton(); pnlAlc.add(rbABW); bgAlc.add(rbABW); rbABW.setText("Weight"); } } { pnlHopTimes = new JPanel(); GridLayout pnlHopTimesLayout = new GridLayout(3, 2); pnlHopTimesLayout.setColumns(2); pnlHopTimesLayout.setHgap(5); pnlHopTimesLayout.setVgap(5); pnlHopTimesLayout.setRows(3); pnlHopTimes.setLayout(pnlHopTimesLayout); pnlCalculations.add(pnlHopTimes, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopTimes.setBorder(BorderFactory .createTitledBorder("Hop Times:")); { jLabelc3 = new JLabel(); pnlHopTimes.add(jLabelc3); jLabelc3.setText("Dry (min):"); } { txtDryHopTime = new JTextField(); pnlHopTimes.add(txtDryHopTime); txtDryHopTime.setText("0.0"); } { jLabelc4 = new JLabel(); pnlHopTimes.add(jLabelc4); jLabelc4.setText("FWH, boil minus (min):"); } { txtFWHTime = new JTextField(); pnlHopTimes.add(txtFWHTime); txtFWHTime.setText("20.0"); } { jLabelc5 = new JLabel(); pnlHopTimes.add(jLabelc5); jLabelc5.setText("Mash Hop (min):"); } { txtMashHopTime = new JTextField(); pnlHopTimes.add(txtMashHopTime); txtMashHopTime.setText("2.0"); } } } pnlHopsCalc = new JPanel(); BoxLayout pnlHopsCalcLayout = new BoxLayout(pnlHopsCalc, javax.swing.BoxLayout.Y_AXIS); pnlHopsCalc.setLayout(pnlHopsCalcLayout); pnlCalculations.add(pnlHopsCalc, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlWaterUsage(), new GridBagConstraints(1, 2, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlColourOptions(), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlCalculations.add(getPnlEvaporation(), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); pnlHopsCalc.setPreferredSize(new java.awt.Dimension(117, 107)); pnlHopsCalc.setBorder(BorderFactory .createTitledBorder("IBU Calc Method:")); { rbTinseth = new JRadioButton(); pnlHopsCalc.add(rbTinseth); rbTinseth.setText("Tinseth"); bgHopsCalc.add(rbTinseth); } { rbRager = new JRadioButton(); pnlHopsCalc.add(rbRager); rbRager.setText("Rager"); bgHopsCalc.add(rbRager); } { rbGaretz = new JRadioButton(); pnlHopsCalc.add(rbGaretz); rbGaretz.setText("Garetz"); bgHopsCalc.add(rbGaretz); } } } } catch (Exception e) { e.printStackTrace(); } } } { costCarbPanel = new JPanel(); BorderLayout costCarbPanelLayout = new BorderLayout(); costCarbPanel.setLayout(costCarbPanelLayout); jTabbedPane1.addTab("Cost & Carb", null, costCarbPanel, null); { carbPanel = new JPanel(); costCarbPanel.add(carbPanel, BorderLayout.CENTER); carbPanel.setBorder(BorderFactory.createTitledBorder(null, "Carbonation", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel3 = new JLabel(); carbPanel.add(jLabel3); jLabel3.setText("Not implemented"); } } { jPanel2 = new JPanel(); costCarbPanel.add(jPanel2, BorderLayout.NORTH); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.4}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7}; jPanel2.setPreferredSize(new java.awt.Dimension(232, 176)); jPanel2.setBorder(BorderFactory.createTitledBorder("Cost")); jPanel2.setLayout(jPanel2Layout); { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); jLabel1.setText("Other Cost:"); } { txtOtherCost = new JTextField(); jPanel2.add(txtOtherCost, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); txtOtherCost.setText("$0.00"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets( 0, 0, 0, 0), 0, 0)); jLabel2.setText("Bottle Size:"); } { cmbBottleSize = new JComboBox(); cmbBottleSizeModel = new ComboModel(); cmbBottleSizeModel.setList(new Quantity().getListofUnits("vol")); cmbBottleSize.setModel(cmbBottleSizeModel); jPanel2.add(cmbBottleSize, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel2.add(getTxtBottleSize(), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } { } } { pnlBrewer = new JPanel(); GridBagLayout pnlBrewerLayout = new GridBagLayout(); pnlBrewerLayout.rowWeights = new double[]{0.1, 0.1, 0.3, 0.3}; pnlBrewerLayout.rowHeights = new int[]{2, 2, 7, 7}; pnlBrewerLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; pnlBrewerLayout.columnWidths = new int[]{7, 7, 7, 7}; pnlBrewer.setLayout(pnlBrewerLayout); jTabbedPane1.addTab("Brewer", null, pnlBrewer, null); { jLabel4 = new JLabel(); pnlBrewer.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Name:"); } { txtBrewerName = new JTextField(); pnlBrewer.add(txtBrewerName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtBrewerName.setText("Your Name"); } { jLabel5 = new JLabel(); pnlBrewer.add(jLabel5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Phone:"); } { txtPhone = new JTextField(); pnlBrewer.add(txtPhone, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPhone.setText("Your Phone"); } { jLabel6 = new JLabel(); pnlBrewer.add(jLabel6, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Club Name:"); } { txtClubName = new JTextField(); pnlBrewer.add(txtClubName, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtClubName.setText("Club Name"); } { jLabel7 = new JLabel(); pnlBrewer.add(jLabel7, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Email:"); } { txtEmail = new JTextField(); pnlBrewer.add(txtEmail, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtEmail.setText("Email"); } } { pnlDatabase = new JPanel(); BorderLayout pnlDatabaseLayout = new BorderLayout(); pnlDatabase.setLayout(pnlDatabaseLayout); pnlDatabase.add(getPnlDefaultDB(), BorderLayout.NORTH); pnlDatabase.add(getPnlSortOrder(), BorderLayout.WEST); jTabbedPane1.addTab("Database", null, pnlDatabase, null); pnlDatabase.setVisible(false); } newRecipePanel = new JPanel(); GridBagLayout newRecipePanelLayout = new GridBagLayout(); newRecipePanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.rowHeights = new int[]{7, 7, 7, 7}; newRecipePanelLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; newRecipePanelLayout.columnWidths = new int[]{7, 7, 7, 7}; newRecipePanel.setLayout(newRecipePanelLayout); jTabbedPane1.addTab("New Recipe Defaults", null, newRecipePanel, null); appearancePanel = new JPanel(); BorderLayout appearancePanelLayout = new BorderLayout(); appearancePanel.setLayout(appearancePanelLayout); jTabbedPane1.addTab("Appearance", null, appearancePanel, null);/* landfPanel = new JPanel(); appearancePanel.add(landfPanel, BorderLayout.NORTH); jLabel19 = new JLabel(); landfPanel.add(jLabel19); jLabel19.setText("Look and Feel:"); landfCombo = new JComboBox(looks.toArray()); landfPanel.add(landfCombo);*/ colourPanel = new JPanel(); appearancePanel.add(colourPanel, BorderLayout.CENTER); GridBagLayout colourPanelLayout = new GridBagLayout(); colourPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; colourPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; colourPanelLayout.columnWidths = new int[] {7, 7, 7, 7, 7, 7}; colourPanel.setLayout(colourPanelLayout); colourPanel.setPreferredSize(new java.awt.Dimension(340, 223)); colourPanel.setBorder(BorderFactory.createTitledBorder("Colour Swatch")); colMethod1rb = new JRadioButton(); colMethod1rb.addActionListener(this); colourGroup.add(colMethod1rb); colourPanel.add(colMethod1rb, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod1rb.setText("Colour Method 1"); colMethod2rb = new JRadioButton(); colMethod2rb.addActionListener(this); colourGroup.add(colMethod2rb); colourPanel.add(colMethod2rb, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colMethod2rb.setText("Colour Method 2"); jLabel13 = new JLabel(); colourPanel.add(jLabel13, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel13.setText("Straw \n(2)"); jLabel14 = new JLabel(); colourPanel.add(jLabel14, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Pale\n(4)"); jLabel15 = new JLabel(); colourPanel.add(jLabel15, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Amber\n(8)"); jLabel16 = new JLabel(); colourPanel.add(jLabel16, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel16.setText("Copper (15)"); jLabel17 = new JLabel(); colourPanel.add(jLabel17, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel17.setText("Brown (20)"); jLabel18 = new JLabel(); colourPanel.add(jLabel18, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); jLabel18.setText("Black (30)"); stawPanel = new JPanel(); colourPanel.add(stawPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); stawPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); palePanel = new JPanel(); colourPanel.add(palePanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); palePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); amberPanel = new JPanel(); colourPanel.add(amberPanel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); amberPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); copperPanel = new JPanel(); colourPanel.add(copperPanel, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); copperPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); brownPanel = new JPanel(); colourPanel.add(brownPanel, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); brownPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); blackPanel = new JPanel(); colourPanel.add(blackPanel, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); blackPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); SpinnerNumberModel redSpnModel = new SpinnerNumberModel(8,0,255,1); redSpn = new JSpinner(); colourPanel.add(redSpn, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); redSpn.setModel(redSpnModel); redSpn.addChangeListener(this); SpinnerNumberModel greenSpnModel = new SpinnerNumberModel(30,0,255,1); greenSpn = new JSpinner(); colourPanel.add(greenSpn, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); greenSpn.setModel(greenSpnModel); greenSpn.addChangeListener(this); SpinnerNumberModel blueSpnModel = new SpinnerNumberModel(20,0,255,1); blueSpn = new JSpinner(); colourPanel.add(blueSpn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); blueSpn.setModel(blueSpnModel); blueSpn.addChangeListener(this); SpinnerNumberModel alphaSpnModel = new SpinnerNumberModel(255,0,255,1); alphaSpn = new JSpinner(); colourPanel.add(alphaSpn, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alphaSpn.setModel(alphaSpnModel); alphaSpn.addChangeListener(this); jLabel20 = new JLabel(); colourPanel.add(jLabel20, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Red:"); jLabel21 = new JLabel(); colourPanel.add(jLabel21, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel21.setText("Blue:"); jLabel22 = new JLabel(); colourPanel.add(jLabel22, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel22.setText("Green:"); jLabel23 = new JLabel(); colourPanel.add(jLabel23, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel23.setText("Alpha:"); mashPanel = new JPanel(); newRecipePanel.add(mashPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mashPanel.setBorder(BorderFactory.createTitledBorder("Mash")); jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[] {7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[] {0.1, 0.1}; jPanel1Layout.columnWidths = new int[] {7, 7}; jPanel1.setLayout(jPanel1Layout); newRecipePanel.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setBorder(BorderFactory.createTitledBorder("Units")); jLabel19 = new JLabel(); jPanel1.add(jLabel19, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Malt Units:"); maltUnitsCombo = new JComboBox(); jPanel1.add(maltUnitsCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); maltUnitsComboModel = new ComboModel(); maltUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltUnitsCombo.setModel(maltUnitsComboModel); jLabel24 = new JLabel(); jPanel1.add(jLabel24, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel24.setText("Hops Units:"); hopsUnitsCombo = new JComboBox(); jPanel1.add(hopsUnitsCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); hopsUnitsComboModel = new ComboModel(); hopsUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsUnitsCombo.setModel(hopsUnitsComboModel); jLabel25 = new JLabel(); jPanel1.add(jLabel25, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel25.setText("Vol Units:"); volUnitsCombo = new JComboBox(); jPanel1.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo.setModel(volUnitsComboModel); jLabel26 = new JLabel(); jPanel1.add(jLabel26, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel26.setText("Batch Size:"); batchSizeTxt = new JTextField(); jPanel1.add(batchSizeTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); batchSizeTxt.setText("jTextField1"); jLabel12 = new JLabel(); mashPanel.add(jLabel12); jLabel12.setText("Boil Temp (F):"); boilTempTxt = new JTextField(); mashPanel.add(boilTempTxt); boilTempTxt.setText("212"); boilTempTxt.setPreferredSize(new java.awt.Dimension(43, 20)); } getContentPane().add(BorderLayout.CENTER, jTabbedPane1); getContentPane().add(BorderLayout.SOUTH, buttons); setSize(500, 500); }
opts.setProperty("optEvaporation", evapAmountTxt.getText());
private void saveOptions() { // cost tab: opts.setProperty("optMiscCost", txtOtherCost.getText()); opts.setProperty("optBottleSize", txtBottleSize.getText()); opts.setProperty("optBottleU", (String) cmbBottleSize.getSelectedItem()); // Brewer tab: opts.setProperty("optBrewer", txtBrewerName.getText()); opts.setProperty("optPhone", txtPhone.getText()); opts.setProperty("optClub", txtClubName.getText()); opts.setProperty("optEmail", txtEmail.getText()); // calculations tab: if (rbTinseth.isSelected()) opts.setProperty("optIBUCalcMethod", "Tinseth"); if (rbRager.isSelected()) opts.setProperty("optIBUCalcMethod", "Rager"); if (rbGaretz.isSelected()) opts.setProperty("optIBUCalcMethod", "Garetz"); if (rbABV.isSelected()) opts.setProperty("optAlcCalcMethod", "Volume"); if (rbABW.isSelected()) opts.setProperty("optAlcCalcMethod", "Weight"); if (rbSRM.isSelected()) opts.setProperty("optColourMethod", "SRM"); if (rbEBC.isSelected()) opts.setProperty("optColourMethod", "EBC"); if (rbPercent.isSelected()) opts.setProperty("optEvapCalcMethod", "Percent"); if (rbConstant.isSelected()) opts.setProperty("optEvapCalcMethod", "Constant"); opts.setProperty("optPelletHopsPct", txtPellet.getText()); opts.setProperty("optHopsUtil", txtTinsethUtil.getText()); opts.setProperty("optDryHopTime", txtDryHopTime.getText()); opts.setProperty("optFWHTime", txtFWHTime.getText()); opts.setProperty("optMashHopTime", txtMashHopTime.getText()); opts.setProperty("optKettleLoss", txtLeftInKettle.getText()); opts.setProperty("optMiscLoss", txtMiscLosses.getText()); opts.setProperty("optTrubLoss", txtLostInTrub.getText()); // new recipe tab: opts.setProperty("optBoilTempF", boilTempTxt.getText()); opts.setProperty("optPostBoilVol", batchSizeTxt.getText()); opts.setProperty("optMaltU", maltUnitsComboModel.getSelectedItem().toString()); opts.setProperty("optHopsU", hopsUnitsComboModel.getSelectedItem().toString()); opts.setProperty("optSizeU", volUnitsComboModel.getSelectedItem().toString()); // appearances: opts.setProperty("optRed", redSpn.getValue().toString()); opts.setProperty("optGreen", greenSpn.getValue().toString()); opts.setProperty("optBlue", blueSpn.getValue().toString()); opts.setProperty("optAlpha", alphaSpn.getValue().toString()); if (colMethod1rb.isSelected()) opts.setProperty("optRGBMethod", "1"); else opts.setProperty("optRGBMethod", "2"); }
rbConstant .setSelected((opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Constant")));
rbConstant.setSelected((opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Constant"))); evapAmountTxt.setText(opts.getProperty("optEvaporation")); if (opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Percent")) evapAmountLbl.setText("%"); else evapAmountLbl.setText(opts.getProperty("optSizeU") + "/hr");
private void setOptions() { // cost tab: txtOtherCost.setText(opts.getProperty("optMiscCost")); txtBottleSize.setText(opts.getProperty("optBottleSize")); cmbBottleSizeModel.addOrInsert(opts.getProperty("optBottleU")); // brewer tab: txtBrewerName.setText(opts.getProperty("optBrewer")); txtPhone.setText(opts.getProperty("optPhone")); txtClubName.setText(opts.getProperty("optClub")); txtEmail.setText(opts.getProperty("optEmail")); // calculations tab: rbTinseth.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Tinseth")); rbRager.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Rager")); rbGaretz.setSelected(opts.getProperty("optIBUCalcMethod").equalsIgnoreCase("Garetz")); rbABV.setSelected((opts.getProperty("optAlcCalcMethod").equalsIgnoreCase("Volume"))); rbABW.setSelected((opts.getProperty("optAlcCalcMethod").equalsIgnoreCase("Weight"))); rbSRM.setSelected((opts.getProperty("optColourMethod").equalsIgnoreCase("SRM"))); rbEBC.setSelected((opts.getProperty("optColourMethod").equalsIgnoreCase("EBC"))); rbPercent.setSelected((opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Percent"))); rbConstant .setSelected((opts.getProperty("optEvapCalcMethod").equalsIgnoreCase("Constant"))); txtPellet.setText(opts.getProperty("optPelletHopsPct")); txtTinsethUtil.setText(opts.getProperty("optHopsUtil")); txtDryHopTime.setText(opts.getProperty("optDryHopTime")); txtFWHTime.setText(opts.getProperty("optFWHTime")); txtMashHopTime.setText(opts.getProperty("optMashHopTime")); txtLeftInKettle.setText(opts.getProperty("optKettleLoss")); txtMiscLosses.setText(opts.getProperty("optMiscLoss")); txtLostInTrub.setText(opts.getProperty("optTrubLoss")); // new recipe tab: boilTempTxt.setText(opts.getProperty("optBoilTempF")); batchSizeTxt.setText(opts.getProperty("optPostBoilVol")); maltUnitsComboModel.addOrInsert(opts.getProperty("optMaltU")); hopsUnitsComboModel.addOrInsert(opts.getProperty("optHopsU")); volUnitsComboModel.addOrInsert(opts.getProperty("optSizeU")); // appearances tab: redSpn.setValue(new Integer(opts.getIProperty("optRed"))); greenSpn.setValue(new Integer(opts.getIProperty("optGreen"))); blueSpn.setValue(new Integer(opts.getIProperty("optBlue"))); alphaSpn.setValue(new Integer(opts.getIProperty("optAlpha"))); colMethod1rb.setSelected(opts.getProperty("optRGBMethod").equals("1")); colMethod2rb.setSelected(opts.getProperty("optRGBMethod").equals("2")); displayColour(); }
public static String toNameList(Iterable<? extends Project> projects) {
public static String toNameList(Collection<? extends Project> projects) {
public static String toNameList(Iterable<? extends Project> projects) { StringBuilder buf = new StringBuilder(); for (Project project : projects) { if(buf.length()>0) buf.append(", "); buf.append(project.getName()); } return buf.toString(); }
rsp.sendRedirect(".");
String referer = req.getHeader("Referer"); if(referer==null) referer="."; rsp.sendRedirect(referer);
public void doBuild( StaplerRequest req, StaplerResponse rsp ) throws IOException { getParent().getQueue().add(this); rsp.sendRedirect("."); }
String cmd = DESCRIPTOR.getShell()+" -xe "+script.getRemote();
String[] cmd = new String[] { DESCRIPTOR.getShell(),"-xe",script.getRemote()};
public boolean perform(Build build, Launcher launcher, BuildListener listener) { Project proj = build.getProject(); FilePath ws = proj.getWorkspace(); FilePath script=null; try { try { script = ws.createTempFile("hudson","sh"); Writer w = new FileWriter(script.getLocal()); w.write(command); w.close(); } catch (IOException e) { Util.displayIOException(e,listener); e.printStackTrace( listener.fatalError("Unable to produce a script file") ); return false; } String cmd = DESCRIPTOR.getShell()+" -xe "+script.getRemote(); listener.getLogger().println("$ "+cmd); int r = 0; try { r = launcher.launch(cmd,build.getEnvVars(),listener.getLogger(),ws).join(); } catch (IOException e) { Util.displayIOException(e,listener); e.printStackTrace( listener.fatalError("command execution failed") ); } return r==0; } finally { if(script!=null) script.delete(); } }
listener.getLogger().println("$ "+cmd); int r = 0;
int r;
public boolean perform(Build build, Launcher launcher, BuildListener listener) { Project proj = build.getProject(); FilePath ws = proj.getWorkspace(); FilePath script=null; try { try { script = ws.createTempFile("hudson","sh"); Writer w = new FileWriter(script.getLocal()); w.write(command); w.close(); } catch (IOException e) { Util.displayIOException(e,listener); e.printStackTrace( listener.fatalError("Unable to produce a script file") ); return false; } String cmd = DESCRIPTOR.getShell()+" -xe "+script.getRemote(); listener.getLogger().println("$ "+cmd); int r = 0; try { r = launcher.launch(cmd,build.getEnvVars(),listener.getLogger(),ws).join(); } catch (IOException e) { Util.displayIOException(e,listener); e.printStackTrace( listener.fatalError("command execution failed") ); } return r==0; } finally { if(script!=null) script.delete(); } }
r = -1;
public boolean perform(Build build, Launcher launcher, BuildListener listener) { Project proj = build.getProject(); FilePath ws = proj.getWorkspace(); FilePath script=null; try { try { script = ws.createTempFile("hudson","sh"); Writer w = new FileWriter(script.getLocal()); w.write(command); w.close(); } catch (IOException e) { Util.displayIOException(e,listener); e.printStackTrace( listener.fatalError("Unable to produce a script file") ); return false; } String cmd = DESCRIPTOR.getShell()+" -xe "+script.getRemote(); listener.getLogger().println("$ "+cmd); int r = 0; try { r = launcher.launch(cmd,build.getEnvVars(),listener.getLogger(),ws).join(); } catch (IOException e) { Util.displayIOException(e,listener); e.printStackTrace( listener.fatalError("command execution failed") ); } return r==0; } finally { if(script!=null) script.delete(); } }
MacroFunction complex = new MacroFunction("complex",2,"x+i*y",globalDJep); globalDJep.addFunction("complex",complex);
MacroFunction complex = new MacroFunction("macrocomplex",2,"x+i*y",globalDJep); globalDJep.addFunction("macrocomplex",complex);
boolean addStandardDiffRules() { try { addDiffRule(new MacroDiffRules(globalDJep,"sin","cos(x)")); addDiffRule(new MacroDiffRules(globalDJep,"cos","-sin(x)")); addDiffRule(new MacroDiffRules(globalDJep,"tan","1/((cos(x))^2)")); MacroFunction sec = new MacroFunction("sec",1,"1/cos(x)",globalDJep); globalDJep.addFunction("sec",sec); MacroFunction cosec = new MacroFunction("cosec",1,"1/sin(x)",globalDJep); globalDJep.addFunction("cosec",cosec); MacroFunction cot = new MacroFunction("cot",1,"1/tan(x)",globalDJep); globalDJep.addFunction("cot",cot); addDiffRule(new MacroDiffRules(globalDJep,"sec","sec(x) * tan(x)")); addDiffRule(new MacroDiffRules(globalDJep,"cosec","-cosec(x) * cot(x)")); addDiffRule(new MacroDiffRules(globalDJep,"cot","-(cosec(x))^2")); addDiffRule(new MacroDiffRules(globalDJep,"asin","1/(sqrt(1-x^2))")); addDiffRule(new MacroDiffRules(globalDJep,"acos","-1/(sqrt(1-x^2))")); addDiffRule(new MacroDiffRules(globalDJep,"atan","1/(1+x^2)")); addDiffRule(new MacroDiffRules(globalDJep,"sinh","cosh(x)")); addDiffRule(new MacroDiffRules(globalDJep,"cosh","sinh(x)")); addDiffRule(new MacroDiffRules(globalDJep,"tanh","1-(tanh(x))^2")); addDiffRule(new MacroDiffRules(globalDJep,"asinh","1/(sqrt(1+x^2))")); addDiffRule(new MacroDiffRules(globalDJep,"acosh","1/(sqrt(x^2-1))")); addDiffRule(new MacroDiffRules(globalDJep,"atanh","1/(1-x^2)")); addDiffRule(new MacroDiffRules(globalDJep,"sqrt","1/(2 (sqrt(x)))")); globalDJep.addFunction("exp",new Exp()); addDiffRule(new MacroDiffRules(globalDJep,"exp","exp(x)"));// globalDJep.addFunction("pow",new Pow());// addDiffRule(new MacroDiffRules(globalDJep,"pow","y*(pow(x,y-1))","(ln(x)) (pow(x,y))")); addDiffRule(new MacroDiffRules(globalDJep,"ln","1/x")); addDiffRule(new MacroDiffRules(globalDJep,"log", // -> (1/ln(10)) /x = log(e) / x but don't know if e exists globalDJep.getNodeFactory().buildOperatorNode(globalDJep.getOperatorSet().getDivide(), globalDJep.getNodeFactory().buildConstantNode( globalDJep.getTreeUtils().getNumber(1/Math.log(10.0))), globalDJep.getNodeFactory().buildVariableNode(globalDJep.getSymbolTable().makeVarIfNeeded("x"))))); // TODO problems here with using a global variable (x) in an essentially local context addDiffRule(new MacroDiffRules(globalDJep,"abs","abs(x)/x")); addDiffRule(new MacroDiffRules(globalDJep,"angle","y/(x^2+y^2)","-x/(x^2+y^2)")); addDiffRule(new MacroDiffRules(globalDJep,"mod","1","0")); addDiffRule(new PassThroughDiffRule(globalDJep,"sum")); addDiffRule(new PassThroughDiffRule(globalDJep,"re")); addDiffRule(new PassThroughDiffRule(globalDJep,"im")); addDiffRule(new PassThroughDiffRule(globalDJep,"rand")); MacroFunction complex = new MacroFunction("complex",2,"x+i*y",globalDJep); globalDJep.addFunction("complex",complex); addDiffRule(new MacroFunctionDiffRules(globalDJep,complex)); /* addDiffRule(new PassThroughDiffRule("\"<\"",globalDJep.getOperatorSet().getLT().getPFMC())); addDiffRule(new PassThroughDiffRule("\">\"",new Comparative(1))); addDiffRule(new PassThroughDiffRule("\"<=\"",new Comparative(2))); addDiffRule(new PassThroughDiffRule("\">=\"",new Comparative(3))); addDiffRule(new PassThroughDiffRule("\"!=\"",new Comparative(4))); addDiffRule(new PassThroughDiffRule("\"==\"",new Comparative(5)));*/ // addDiffRule(new DiffDiffRule(this,"diff")); // TODO do we want to add eval here?// addDiffRule(new EvalDiffRule(this,"eval",eval)); //addDiffRule(new PassThroughDiffRule("\"&&\"")); //addDiffRule(new PassThroughDiffRule("\"||\"")); //addDiffRule(new PassThroughDiffRule("\"!\"")); // also consider if, min, max, sgn, dot, cross, //addDiffRule(new MacroDiffRules(this,"sgn","0")); return true; } catch(ParseException e) { System.err.println(e.getMessage()); return false; } }
return super.getFailCount() + (getStatus()==Status.PASS ? 0 : 1);
if(considerTestAsTestObject) return super.getFailCount() + (getStatus()==Status.PASS ? 0 : 1); else { if (super.getTotalCount() != 0) return super.getFailCount(); else return (getStatus() == Status.PASS ? 0 : 1); }
public int getFailCount() { return super.getFailCount() + (getStatus()==Status.PASS ? 0 : 1); }
return super.getTotalCount()+1;
if(considerTestAsTestObject) return super.getTotalCount()+1; else { if(super.getTotalCount() != 0) return super.getTotalCount(); else return 1; }
public int getTotalCount() { return super.getTotalCount()+1; }
setUnits("gr");
public Misc() { setName("");; setCost(0); setDescription(""); }
Map<String,String> previousRevisions = new HashMap<String,String>(); { File file = getRevisionFile(build.getPreviousBuild()); if(!file.exists()) return createEmptyChangeLog(changelogFile,listener, "log"); BufferedReader br = new BufferedReader(new FileReader(file)); String line; while((line=br.readLine())!=null) { int index = line.indexOf('/'); if(index<0) { logger.println("Unable to parse the line: "+line); continue; } previousRevisions.put(line.substring(0,index), line.substring(index+1)); } }
Map<String,String> previousRevisions = parseRevisionFile(build.getPreviousBuild());
public boolean calcChangeLog(Build build, File changelogFile, Launcher launcher, BuildListener listener) throws IOException { if(build.getPreviousBuild()==null) { // nothing to compare against return createEmptyChangeLog(changelogFile, listener, "log"); } PrintStream logger = listener.getLogger(); Map<String,String> previousRevisions = new HashMap<String,String>(); // module -> revision {// read the revision file of the last build File file = getRevisionFile(build.getPreviousBuild()); if(!file.exists()) // nothing to compare against return createEmptyChangeLog(changelogFile,listener, "log"); BufferedReader br = new BufferedReader(new FileReader(file)); String line; while((line=br.readLine())!=null) { int index = line.indexOf('/'); if(index<0) { logger.println("Unable to parse the line: "+line); continue; // invalid line? } previousRevisions.put(line.substring(0,index), line.substring(index+1)); } } Map env = createEnvVarMap(); for( String module : getModuleDirNames() ) { String prevRev = previousRevisions.get(module); if(prevRev==null) { logger.println("no revision recorded for "+module+" in the previous build"); continue; } String cmd = DESCRIPTOR.getSvnExe()+" log -v --xml --non-interactive -r "+prevRev+":BASE "+module; OutputStream os = new BufferedOutputStream(new FileOutputStream(changelogFile)); try { int r = launcher.launch(cmd,env,os,build.getProject().getWorkspace()).join(); if(r!=0) { listener.fatalError("revision check failed"); return false; } } finally { os.close(); } } return true; }
private File getRevisionFile(Build build) {
private static File getRevisionFile(Build build) {
private File getRevisionFile(Build build) { return new File(build.getRootDir(),"revision.txt"); }
if (param1 instanceof Number) { if (param2 instanceof Number) {
if (param1 instanceof Complex) { if (param2 instanceof Complex) return add((Complex)param1, (Complex)param2); else if (param2 instanceof Number) return add((Complex)param1, (Number)param2); } else if (param1 instanceof Number) { if (param2 instanceof Complex) return add((Complex)param2, (Number)param1); else if (param2 instanceof Number)
public Object add(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) { return add((Number)param1, (Number)param2); } else if (param2 instanceof Complex) { return add((Complex)param2, (Number)param1); } } else if (param1 instanceof Complex) { if (param2 instanceof Number) { return add((Complex)param1, (Number)param2); } else if (param2 instanceof Complex) { return add((Complex)param1, (Complex)param2); } } else if ((param1 instanceof String) && (param2 instanceof String)) { return (String)param1 + (String)param2; } throw new ParseException("Invalid parameter type"); }
} else if (param2 instanceof Complex) { return add((Complex)param2, (Number)param1); } } else if (param1 instanceof Complex) { if (param2 instanceof Number) { return add((Complex)param1, (Number)param2); } else if (param2 instanceof Complex) { return add((Complex)param1, (Complex)param2); } } else if ((param1 instanceof String) && (param2 instanceof String)) {
} else if ((param1 instanceof String) && (param2 instanceof String)) {
public Object add(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) { return add((Number)param1, (Number)param2); } else if (param2 instanceof Complex) { return add((Complex)param2, (Number)param1); } } else if (param1 instanceof Complex) { if (param2 instanceof Number) { return add((Complex)param1, (Number)param2); } else if (param2 instanceof Complex) { return add((Complex)param1, (Complex)param2); } } else if ((param1 instanceof String) && (param2 instanceof String)) { return (String)param1 + (String)param2; } throw new ParseException("Invalid parameter type"); }
if (!u.equals(getCurrentEntity())) {
if (!u.getEntity().equals(getCurrentEntity())) {
public List<Entity> getEntities() { List<Entity> entityList = new ArrayList<Entity>(); if (logger.isDebugEnabled()) { logger.debug("Current entity is: "+getCurrentEntity()); } for (User u: getUsers()) { if (!u.equals(getCurrentEntity())) { entityList.add(u.getEntity()); if (logger.isDebugEnabled()) { logger.debug("Added to entity list: "+u.getEntity()); } } } return entityList; }
Node n = j.parse("zap * wow");
j.parse("zap * wow");
public void testUndeclared() throws Exception { j.setAllowUndeclared(false); try { Node n = j.parse("zap * wow"); fail("Should have found undeclared error"); } catch(ParseException e) { System.out.println("Error caught: "+e.getMessage()); } try { j.setVarValue("foo",new Double(5.0)); fail("Should have found a null pointer exception"); } catch(NullPointerException e) { System.out.println("Error caught: "+e.getClass().getName()+": "+e.getMessage()); } }
JButton closeBtn = new JButton( GUIRegistry.getInstance().getIconFactory().getIcon("Close") );
JButton closeBtn = new JButton( tab.getTabAction( SearchTab.FILTER_PANEL_TOGGLE_ACTION) ); closeBtn.setText(null); closeBtn.setIcon( GUIRegistry.getInstance().getIconFactory().getIcon( "Close") );
public SearchFilterPanel( SearchTab tab ) { super(); searchTab = tab; setBorder( BorderFactory.createLineBorder( PhexColors.getBoxPanelBorderColor() ) ); setBackground( UIManager.getDefaults().getColor("window") ); CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout( "p, fill:p:grow", // columns "d, fill:d:grow"); //rows PanelBuilder panelBuilder = new PanelBuilder( layout, this ); topLayoutPanel = new JPanel(); topLayoutPanel.setOpaque(false); layout = new FormLayout( "4dlu, p, fill:8dlu:grow, p, 4dlu", // columns "2dlu, p, 2dlu"); //rows PanelBuilder topBuilder = new PanelBuilder( layout, topLayoutPanel ); JLabel titelLabel = new JLabel( Localizer.getString( "SearchTab_SearchFilterOptions" ) ); Font currentFont = titelLabel.getFont(); Font enlargedFont = currentFont.deriveFont( Font.BOLD, currentFont.getSize() + 2 ); titelLabel.setFont( enlargedFont ); topBuilder.add( titelLabel, cc.xy(2, 2) ); JButton closeBtn = new JButton( GUIRegistry.getInstance().getIconFactory().getIcon("Close") ); closeBtn.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) ); closeBtn.setBorder( GUIUtils.ROLLOVER_BUTTON_BORDER ); closeBtn.setRolloverEnabled( true ); closeBtn.setOpaque(false); topBuilder.add( closeBtn, cc.xy(4, 2) ); panelBuilder.add( topLayoutPanel, cc.xywh( 1, 1, 2, 1 ) ); leftLayoutPanel = new JPanel(); leftLayoutPanel.setBackground(getBackground()); leftLayoutPanel.setOpaque(false); layout = new FormLayout( "4dlu, p, 0dlu", // columns "23px, d, 0dlu, d, 23px"); //rows PanelBuilder leftBuilder = new PanelBuilder( layout, leftLayoutPanel ); ButtonGroup leftBtnGroup = new ButtonGroup(); quickFilterBtn = new JToggleButton( Localizer.getString( "SearchTab_QuickFilter" ), GUIRegistry.getInstance().getIconFactory().getIcon("Filter") ); quickFilterBtn.setBorder( new CompoundBorder( BorderFactory.createMatteBorder(2, 2, 1, 0, getBackground()), new EmptyBorder( 5, 7, 5, 11) ) ); leftBtnGroup.add(quickFilterBtn); updateLeftBtnProps(quickFilterBtn); leftBuilder.add( quickFilterBtn, cc.xy(2, 2) ); quickFilterBtn.addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e ) { activateQuickFilterPanel( ); } }); filterListBtn = new JToggleButton( Localizer.getString( "SearchTab_FilterRules" ), IconFactory.EMPTY_IMAGE_16 ); filterListBtn.setBorder( new CompoundBorder( BorderFactory.createMatteBorder(1, 2, 2, 0, getBackground()), new EmptyBorder( 5, 7, 5, 11) ) ); leftBtnGroup.add(filterListBtn); updateLeftBtnProps(filterListBtn); leftBuilder.add( filterListBtn, cc.xy(2, 4) ); filterListBtn.addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e ) { activateFilterListPanel( ); } }); panelBuilder.add( leftLayoutPanel, cc.xywh( 1, 2, 1, 1 ) ); quickFilterPanel = new QuickFilterPanel(); filterListPanel = new FilterListPanel(); filterContentPanel = new JPanel( new BorderLayout() ); filterContentPanel.setOpaque(false); panelBuilder.add( filterContentPanel, cc.xywh( 2, 2, 1, 1 ) ); quickFilterBtn.doClick(); }
numZeros = SacTimeSeries.swapBytes((short)dis.readUnsignedShort()); numPoles = SacTimeSeries.swapBytes((short)dis.readUnsignedShort());
numZeros = SacTimeSeries.swapBytes(dis.readShort()); numPoles = SacTimeSeries.swapBytes(dis.readShort());
public PSNPolesAndZeros(DataInputStream data) throws IOException{ dis = data; numZeros = SacTimeSeries.swapBytes((short)dis.readUnsignedShort()); numPoles = SacTimeSeries.swapBytes((short)dis.readUnsignedShort()); zeros = new double[numZeros][2]; for (int i = 0; i < numZeros; i++) { for (int j = 0; j < 2; j++) { zeros[i][j] = SacTimeSeries.swapBytes(dis.readDouble()); } } poles = new double[numPoles][2]; for (int i = 0; i < numZeros; i++) { for (int j = 0; j < 2; j++) { poles[i][j] = SacTimeSeries.swapBytes(dis.readDouble()); } } }
if ( shareFile.getURN() == null ) { return new Integer(0); }
public Object getValueAt(int row, int col) { if ( displayDirectory == null ) { return ""; } if ( row >= displayDirectryFiles.length ) { fireTableRowsDeleted( row, row ); return ""; } ShareFile shareFile = sharedFilesService.getShareFileByFile( displayDirectryFiles[row] ); if ( shareFile == null ) { switch ( col ) { case FILE_MODEL_INDEX: return displayDirectryFiles[row]; case DIRECTORY_MODEL_INDEX: return displayDirectryFiles[row].getParent(); case SIZE_MODEL_INDEX: return new Long( displayDirectryFiles[row].length() ); case SEARCH_COUNT_MODEL_INDEX: case UPLOAD_COUNT_MODEL_INDEX: case ALT_LOC_COUNT_MODEL_INDEX: return null; case SHA1_MODEL_INDEX: case THEX_MODEL_INDEX: return ""; } } else { switch ( col ) { case FILE_MODEL_INDEX: return shareFile; case DIRECTORY_MODEL_INDEX: return shareFile.getSystemFile().getParent(); case SIZE_MODEL_INDEX: return shareFile.getFileSizeObject(); case SEARCH_COUNT_MODEL_INDEX: return new Integer( shareFile.getSearchCount() ); case UPLOAD_COUNT_MODEL_INDEX: return new Integer( shareFile.getUploadCount() ); case ALT_LOC_COUNT_MODEL_INDEX: return new Integer( shareFile.getAltLocContainer().getSize() ); case SHA1_MODEL_INDEX: return shareFile.getSHA1(); case THEX_MODEL_INDEX: ShareFileThexData thexData = shareFile.getThexData(false); return thexData != null ? thexData.getRootHash() : ""; } } return ""; }
logger.debug("Loaded property: "+value);
logger.debug("Loaded property: " + getValue()+" set from id="+id);
protected void setAsText(String id, Class clazz) { if (logger.isDebugEnabled()) { logger.debug("Loaded "+clazz.getName()+" property editor"); } try { Serializable key = resolveId(id); Object value = getHibernateTemplate().load(clazz, key); super.setValue(value); if (logger.isDebugEnabled()) { logger.debug("Loaded property: "+value); } } catch (Exception e) { super.setValue(null); } }
jButton2 = new JButton(); mainToolBar.add(jButton2); jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource(
findButton = new JButton(); mainToolBar.add(findButton); findButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource(
private void initGUI() { try { // restore the saved size and location: this.setSize(preferences.getIProperty("winWidth"), preferences.getIProperty("winHeight")); this.setLocation(preferences.getIProperty("winX"), preferences.getIProperty("winY")); imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/sb2.gif"); icon = new ImageIcon(imgURL); this.setIconImage(icon.getImage()); this.setTitle("StrangeBrew " + version); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.9, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; pnlDetailsLayout.columnWidths = new int[]{7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; pnlDetailsLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; pnlDetailsLayout.rowHeights = new int[]{7, 7, 7, 7, 7, 7, 7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { brewerNameText = new JTextField(); pnlDetails.add(brewerNameText, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); brewerNameText.setPreferredSize(new java.awt.Dimension(69, 20)); brewerNameText.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); lblEffic.setPreferredSize(new java.awt.Dimension(31, 14)); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); lblAtten.setPreferredSize(new java.awt.Dimension(34, 14)); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints(7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints(7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { //txtDate = new JFormattedTextField(); txtDate = new DatePicker(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); // txtDate.setText("Date"); txtDate.setPreferredSize(new java.awt.Dimension(73, 20)); txtDate.setDateStyle(DateFormat.SHORT); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); // Install the custom key selection manager cmbStyle.setKeySelectionManager(new SBKeySelectionManager()); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.setPreferredSize(new java.awt.Dimension(190, 20)); } { preBoilText = new JFormattedTextField(); pnlDetails.add(preBoilText, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); preBoilText.setText("Pre Boil"); preBoilText.setPreferredSize(new java.awt.Dimension(37, 20)); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.setPreferredSize(new java.awt.Dimension(46, 20)); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); spnEffic.setPreferredSize(new java.awt.Dimension(53, 18)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); spnAtten.setPreferredSize(new java.awt.Dimension(49, 20)); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); spnOG.setPreferredSize(new java.awt.Dimension(67, 18)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.setPreferredSize(new java.awt.Dimension(69, 20)); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints(8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints(8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints(8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints(7, 4, 3, 2, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); // txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.setLineWrap(true); txtComments.setPreferredSize(new java.awt.Dimension(263, 40)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); // Install the custom key selection manager cmbYeast.setKeySelectionManager(new SBKeySelectionManager()); pnlDetails.add(cmbYeast, new GridBagConstraints(1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.setPreferredSize(new java.awt.Dimension(193, 20)); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.setPreferredSize(new java.awt.Dimension(22, 20)); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.setPreferredSize(new java.awt.Dimension(23, 20)); } { alcMethodComboModel = new DefaultComboBoxModel(new String[]{"Volume", "Weight"}); alcMethodCombo = new JComboBox(alcMethodComboModel); pnlDetails.add(alcMethodCombo, new GridBagConstraints(9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(71, 20)); } { ibuMethodComboModel = new DefaultComboBoxModel(new String[]{"Tinseth", "Garetz", "Rager"}); ibuMethodCombo = new JComboBox(ibuMethodComboModel); pnlDetails.add(ibuMethodCombo, new GridBagConstraints(9, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(72, 20)); } { colourMethodComboModel = new DefaultComboBoxModel(new String[]{"SRM", "EBC"}); colourMethodCombo = new JComboBox(colourMethodComboModel); pnlDetails.add(colourMethodCombo, new GridBagConstraints(9, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(52, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); mainToolBar = new JToolBar(); getContentPane().add(mainToolBar, BorderLayout.NORTH); mainToolBar.setFloatable(false); mainToolBar.setRollover(true); saveButton = new JButton(); mainToolBar.add(saveButton); saveButton.setMnemonic(java.awt.event.KeyEvent.VK_S); saveButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/save.gif"))); saveButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); jButton2 = new JButton(); mainToolBar.add(jButton2); jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/find.gif"))); final JFrame owner = this; jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(297, 20)); } } evapMethodCombo = new JComboBox(); pnlDetails.add(evapMethodCombo, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapMethodCombo.setModel(evapMethodComboModel); evapMethodCombo.setPreferredSize(new java.awt.Dimension(64, 20)); colourPanel = new JPanel(); pnlDetails.add(colourPanel, new GridBagConstraints(9, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); colourPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); colourPanel.setPreferredSize(new java.awt.Dimension(93, 32)); } { SBNotifier sbn = new SBNotifier(); stylePanel = new StylePanel(sbn); jTabbedPane1.addTab("Style", null, stylePanel, null); miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); dilutionPanel = new DilutionPanel(); jTabbedPane1.addTab("Dilution", null, dilutionPanel, null); mashPanel = new MashPanel(myRecipe); jTabbedPane1.addTab("Mash", null, mashPanel, null); waterPanel = new WaterPanel(sbn); jTabbedPane1.addTab("Water", null, waterPanel, null); costPanel = new CostPanel(); jTabbedPane1.addTab("Cost", null, costPanel, null); // SBNotifier sbn = new SBNotifier(); settingsPanel = new SettingsPanel(sbn); jTabbedPane1.addTab("Settings", null, settingsPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { maltTableModel = new MaltTableModel(this); maltTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, maltTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane1.setViewportView(maltTable); maltTable.setModel(maltTableModel); // maltTable.setAutoCreateColumnsFromModel(false); maltTable.getTableHeader().setReorderingAllowed(false); TableColumn maltColumn = maltTable.getColumnModel().getColumn(2); // set up malt list combo maltComboBox = new JComboBox(); ComboBoxEditor editor = maltComboBox.getEditor(); editor.getEditorComponent().addKeyListener(new KeyAdapter(){ public void keyPressed(KeyEvent evt){ // TODO: handle keypress } }); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt amount editor amountEditor = new SBCellEditor(new JTextField()); maltColumn = maltTable.getColumnModel().getColumn(3); maltColumn.setCellEditor(amountEditor); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(4); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"S", "M", "Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); // set up the units combobox maltTotalUnitsComboBox = new JComboBox(); maltTotalUnitsComboModel = new ComboModel(); maltTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltTotalUnitsComboBox.setModel(maltTotalUnitsComboModel); TableColumn t = tblMaltTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(maltTotalUnitsComboBox)); maltTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) maltTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setMaltUnits(u); displayRecipe(); } } }); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(592, 27)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(386, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); maltTable.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = maltTable.getSelectedRow(); myRecipe.delMalt(i); maltTable.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); // set up the units combobox hopsTotalUnitsComboBox = new JComboBox(); hopsTotalUnitsComboModel = new ComboModel(); hopsTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsTotalUnitsComboBox.setModel(hopsTotalUnitsComboModel); TableColumn t = tblHopsTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(hopsTotalUnitsComboBox)); hopsTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe(); } } }); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { hopsTableModel = new HopsTableModel(this); hopsTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, hopsTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane2.setViewportView(hopsTable); hopsTable.setModel(hopsTableModel); hopsTable.getTableHeader().setReorderingAllowed(false); TableColumn hopColumn = hopsTable.getColumnModel().getColumn(0); hopComboBox = new JComboBox(); // Install the custom key selection manager hopComboBox.setKeySelectionManager(new SBKeySelectionManager()); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); // set up hop units combo hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = hopsTable.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); // set up hop type combo String[] forms = {"Leaf", "Pellet", "Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = hopsTable.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String[] add = {"Boil", "FWH", "Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = hopsTable.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(413, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); hopsTable.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = hopsTable.getSelectedRow(); myRecipe.delHop(i); hopsTable.updateUI(); displayRecipe(); } } }); } } } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanelLayout.setHgap(2); statusPanelLayout.setVgap(2); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { fileNamePanel = new JPanel(); statusPanel.add(fileNamePanel); fileNamePanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); fileNamePanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { ibuMethodPanel = new JPanel(); statusPanel.add(ibuMethodPanel); ibuMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { ibuMethodLabel = new JLabel(); ibuMethodPanel.add(ibuMethodLabel); ibuMethodLabel.setText("IBU Method:"); ibuMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { alcMethodPanel = new JPanel(); statusPanel.add(alcMethodPanel); alcMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { alcMethodLabel = new JLabel(); alcMethodPanel.add(alcMethodLabel); alcMethodLabel.setText("Alc Method:"); alcMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { fileMenu = new JMenu(); jMenuBar1.add(fileMenu); fileMenu.setText("File"); { newFileMenuItem = new JMenuItem(); fileMenu.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); fileMenu.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_O, ActionEvent.CTRL_MASK)); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/find.gif"); icon = new ImageIcon(imgURL); findFileMenuItem = new JMenuItem("Find", icon); findFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_F, ActionEvent.CTRL_MASK)); fileMenu.add(findFileMenuItem); final JFrame owner = this; findFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // open the find dialog FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/save.gif"); icon = new ImageIcon(imgURL); saveMenuItem = new JMenuItem("Save", icon); fileMenu.add(saveMenuItem); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_S, ActionEvent.CTRL_MASK)); saveMenuItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/saveas.gif"); icon = new ImageIcon(imgURL); saveAsMenuItem = new JMenuItem("Save As ...", icon); fileMenu.add(saveAsMenuItem); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAs(); } }); } { exportMenu = new JMenu(); fileMenu.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file, "recipeToHtml.xslt", null); } catch (Exception e) { showError(e); } } else { Debug.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } } }); } } { JMenuItem clipboardMenuItem = new JMenuItem("Copy to Clipboard"); fileMenu.add(clipboardMenuItem); clipboardMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Copy current recipe to clipboard Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s); } }); JMenuItem printMenuItem = new JMenuItem("Print..."); fileMenu.add(printMenuItem); final JFrame owner = this; printMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true); } }); } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); final JFrame owner = this; exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuTools = new JMenu(); jMenuBar1.add(mnuTools); mnuTools.setText("Tools"); { final JFrame owner = this; JMenuItem scalRecipeMenuItem = new JMenuItem(); mnuTools.add(scalRecipeMenuItem); scalRecipeMenuItem.setText("Resize / Convert Recipe..."); scalRecipeMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_R, ActionEvent.CTRL_MASK)); scalRecipeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); } }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); maltPercentMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_M, ActionEvent.CTRL_MASK)); maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); } }); JMenuItem refractometerMenuItem = new JMenuItem(); mnuTools.add(refractometerMenuItem); refractometerMenuItem.setText("Refractometer Utility..."); refractometerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { RefractometerDialog refract = new RefractometerDialog(owner); refract.setModal(true); refract.setVisible(true); } }); JMenuItem extractPotentialMenuItem = new JMenuItem(); mnuTools.add(extractPotentialMenuItem); extractPotentialMenuItem.setText("Extract Potential..."); extractPotentialMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PotentialExtractCalcDialog extCalc = new PotentialExtractCalcDialog(owner); extCalc.setModal(true); extCalc.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String urlString = SBStringUtils.getAppPath("help") + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner, version); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
jButton2.addActionListener(new ActionListener() {
findButton.addActionListener(new ActionListener() {
private void initGUI() { try { // restore the saved size and location: this.setSize(preferences.getIProperty("winWidth"), preferences.getIProperty("winHeight")); this.setLocation(preferences.getIProperty("winX"), preferences.getIProperty("winY")); imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/sb2.gif"); icon = new ImageIcon(imgURL); this.setIconImage(icon.getImage()); this.setTitle("StrangeBrew " + version); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.9, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; pnlDetailsLayout.columnWidths = new int[]{7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; pnlDetailsLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; pnlDetailsLayout.rowHeights = new int[]{7, 7, 7, 7, 7, 7, 7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { brewerNameText = new JTextField(); pnlDetails.add(brewerNameText, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); brewerNameText.setPreferredSize(new java.awt.Dimension(69, 20)); brewerNameText.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); lblEffic.setPreferredSize(new java.awt.Dimension(31, 14)); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); lblAtten.setPreferredSize(new java.awt.Dimension(34, 14)); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints(7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints(7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { //txtDate = new JFormattedTextField(); txtDate = new DatePicker(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); // txtDate.setText("Date"); txtDate.setPreferredSize(new java.awt.Dimension(73, 20)); txtDate.setDateStyle(DateFormat.SHORT); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); // Install the custom key selection manager cmbStyle.setKeySelectionManager(new SBKeySelectionManager()); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.setPreferredSize(new java.awt.Dimension(190, 20)); } { preBoilText = new JFormattedTextField(); pnlDetails.add(preBoilText, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); preBoilText.setText("Pre Boil"); preBoilText.setPreferredSize(new java.awt.Dimension(37, 20)); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.setPreferredSize(new java.awt.Dimension(46, 20)); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); spnEffic.setPreferredSize(new java.awt.Dimension(53, 18)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); spnAtten.setPreferredSize(new java.awt.Dimension(49, 20)); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); spnOG.setPreferredSize(new java.awt.Dimension(67, 18)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.setPreferredSize(new java.awt.Dimension(69, 20)); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints(8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints(8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints(8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints(7, 4, 3, 2, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); // txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.setLineWrap(true); txtComments.setPreferredSize(new java.awt.Dimension(263, 40)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); // Install the custom key selection manager cmbYeast.setKeySelectionManager(new SBKeySelectionManager()); pnlDetails.add(cmbYeast, new GridBagConstraints(1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.setPreferredSize(new java.awt.Dimension(193, 20)); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.setPreferredSize(new java.awt.Dimension(22, 20)); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.setPreferredSize(new java.awt.Dimension(23, 20)); } { alcMethodComboModel = new DefaultComboBoxModel(new String[]{"Volume", "Weight"}); alcMethodCombo = new JComboBox(alcMethodComboModel); pnlDetails.add(alcMethodCombo, new GridBagConstraints(9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(71, 20)); } { ibuMethodComboModel = new DefaultComboBoxModel(new String[]{"Tinseth", "Garetz", "Rager"}); ibuMethodCombo = new JComboBox(ibuMethodComboModel); pnlDetails.add(ibuMethodCombo, new GridBagConstraints(9, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(72, 20)); } { colourMethodComboModel = new DefaultComboBoxModel(new String[]{"SRM", "EBC"}); colourMethodCombo = new JComboBox(colourMethodComboModel); pnlDetails.add(colourMethodCombo, new GridBagConstraints(9, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(52, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); mainToolBar = new JToolBar(); getContentPane().add(mainToolBar, BorderLayout.NORTH); mainToolBar.setFloatable(false); mainToolBar.setRollover(true); saveButton = new JButton(); mainToolBar.add(saveButton); saveButton.setMnemonic(java.awt.event.KeyEvent.VK_S); saveButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/save.gif"))); saveButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); jButton2 = new JButton(); mainToolBar.add(jButton2); jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/find.gif"))); final JFrame owner = this; jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(297, 20)); } } evapMethodCombo = new JComboBox(); pnlDetails.add(evapMethodCombo, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapMethodCombo.setModel(evapMethodComboModel); evapMethodCombo.setPreferredSize(new java.awt.Dimension(64, 20)); colourPanel = new JPanel(); pnlDetails.add(colourPanel, new GridBagConstraints(9, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); colourPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); colourPanel.setPreferredSize(new java.awt.Dimension(93, 32)); } { SBNotifier sbn = new SBNotifier(); stylePanel = new StylePanel(sbn); jTabbedPane1.addTab("Style", null, stylePanel, null); miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); dilutionPanel = new DilutionPanel(); jTabbedPane1.addTab("Dilution", null, dilutionPanel, null); mashPanel = new MashPanel(myRecipe); jTabbedPane1.addTab("Mash", null, mashPanel, null); waterPanel = new WaterPanel(sbn); jTabbedPane1.addTab("Water", null, waterPanel, null); costPanel = new CostPanel(); jTabbedPane1.addTab("Cost", null, costPanel, null); // SBNotifier sbn = new SBNotifier(); settingsPanel = new SettingsPanel(sbn); jTabbedPane1.addTab("Settings", null, settingsPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { maltTableModel = new MaltTableModel(this); maltTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, maltTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane1.setViewportView(maltTable); maltTable.setModel(maltTableModel); // maltTable.setAutoCreateColumnsFromModel(false); maltTable.getTableHeader().setReorderingAllowed(false); TableColumn maltColumn = maltTable.getColumnModel().getColumn(2); // set up malt list combo maltComboBox = new JComboBox(); ComboBoxEditor editor = maltComboBox.getEditor(); editor.getEditorComponent().addKeyListener(new KeyAdapter(){ public void keyPressed(KeyEvent evt){ // TODO: handle keypress } }); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt amount editor amountEditor = new SBCellEditor(new JTextField()); maltColumn = maltTable.getColumnModel().getColumn(3); maltColumn.setCellEditor(amountEditor); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(4); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"S", "M", "Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); // set up the units combobox maltTotalUnitsComboBox = new JComboBox(); maltTotalUnitsComboModel = new ComboModel(); maltTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltTotalUnitsComboBox.setModel(maltTotalUnitsComboModel); TableColumn t = tblMaltTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(maltTotalUnitsComboBox)); maltTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) maltTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setMaltUnits(u); displayRecipe(); } } }); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(592, 27)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(386, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); maltTable.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = maltTable.getSelectedRow(); myRecipe.delMalt(i); maltTable.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); // set up the units combobox hopsTotalUnitsComboBox = new JComboBox(); hopsTotalUnitsComboModel = new ComboModel(); hopsTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsTotalUnitsComboBox.setModel(hopsTotalUnitsComboModel); TableColumn t = tblHopsTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(hopsTotalUnitsComboBox)); hopsTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe(); } } }); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { hopsTableModel = new HopsTableModel(this); hopsTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, hopsTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane2.setViewportView(hopsTable); hopsTable.setModel(hopsTableModel); hopsTable.getTableHeader().setReorderingAllowed(false); TableColumn hopColumn = hopsTable.getColumnModel().getColumn(0); hopComboBox = new JComboBox(); // Install the custom key selection manager hopComboBox.setKeySelectionManager(new SBKeySelectionManager()); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); // set up hop units combo hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = hopsTable.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); // set up hop type combo String[] forms = {"Leaf", "Pellet", "Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = hopsTable.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String[] add = {"Boil", "FWH", "Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = hopsTable.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(413, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); hopsTable.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = hopsTable.getSelectedRow(); myRecipe.delHop(i); hopsTable.updateUI(); displayRecipe(); } } }); } } } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanelLayout.setHgap(2); statusPanelLayout.setVgap(2); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { fileNamePanel = new JPanel(); statusPanel.add(fileNamePanel); fileNamePanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); fileNamePanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { ibuMethodPanel = new JPanel(); statusPanel.add(ibuMethodPanel); ibuMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { ibuMethodLabel = new JLabel(); ibuMethodPanel.add(ibuMethodLabel); ibuMethodLabel.setText("IBU Method:"); ibuMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { alcMethodPanel = new JPanel(); statusPanel.add(alcMethodPanel); alcMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { alcMethodLabel = new JLabel(); alcMethodPanel.add(alcMethodLabel); alcMethodLabel.setText("Alc Method:"); alcMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { fileMenu = new JMenu(); jMenuBar1.add(fileMenu); fileMenu.setText("File"); { newFileMenuItem = new JMenuItem(); fileMenu.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); fileMenu.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_O, ActionEvent.CTRL_MASK)); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/find.gif"); icon = new ImageIcon(imgURL); findFileMenuItem = new JMenuItem("Find", icon); findFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_F, ActionEvent.CTRL_MASK)); fileMenu.add(findFileMenuItem); final JFrame owner = this; findFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // open the find dialog FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/save.gif"); icon = new ImageIcon(imgURL); saveMenuItem = new JMenuItem("Save", icon); fileMenu.add(saveMenuItem); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_S, ActionEvent.CTRL_MASK)); saveMenuItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/saveas.gif"); icon = new ImageIcon(imgURL); saveAsMenuItem = new JMenuItem("Save As ...", icon); fileMenu.add(saveAsMenuItem); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAs(); } }); } { exportMenu = new JMenu(); fileMenu.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file, "recipeToHtml.xslt", null); } catch (Exception e) { showError(e); } } else { Debug.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } } }); } } { JMenuItem clipboardMenuItem = new JMenuItem("Copy to Clipboard"); fileMenu.add(clipboardMenuItem); clipboardMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Copy current recipe to clipboard Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s); } }); JMenuItem printMenuItem = new JMenuItem("Print..."); fileMenu.add(printMenuItem); final JFrame owner = this; printMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true); } }); } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); final JFrame owner = this; exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuTools = new JMenu(); jMenuBar1.add(mnuTools); mnuTools.setText("Tools"); { final JFrame owner = this; JMenuItem scalRecipeMenuItem = new JMenuItem(); mnuTools.add(scalRecipeMenuItem); scalRecipeMenuItem.setText("Resize / Convert Recipe..."); scalRecipeMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_R, ActionEvent.CTRL_MASK)); scalRecipeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); } }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); maltPercentMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_M, ActionEvent.CTRL_MASK)); maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); } }); JMenuItem refractometerMenuItem = new JMenuItem(); mnuTools.add(refractometerMenuItem); refractometerMenuItem.setText("Refractometer Utility..."); refractometerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { RefractometerDialog refract = new RefractometerDialog(owner); refract.setModal(true); refract.setVisible(true); } }); JMenuItem extractPotentialMenuItem = new JMenuItem(); mnuTools.add(extractPotentialMenuItem); extractPotentialMenuItem.setText("Extract Potential..."); extractPotentialMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PotentialExtractCalcDialog extCalc = new PotentialExtractCalcDialog(owner); extCalc.setModal(true); extCalc.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String urlString = SBStringUtils.getAppPath("help") + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner, version); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
JButton printButton = new JButton(); mainToolBar.add(printButton); printButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/print.gif"))); printButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true); } });
private void initGUI() { try { // restore the saved size and location: this.setSize(preferences.getIProperty("winWidth"), preferences.getIProperty("winHeight")); this.setLocation(preferences.getIProperty("winX"), preferences.getIProperty("winY")); imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/sb2.gif"); icon = new ImageIcon(imgURL); this.setIconImage(icon.getImage()); this.setTitle("StrangeBrew " + version); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.9, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; pnlDetailsLayout.columnWidths = new int[]{7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; pnlDetailsLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; pnlDetailsLayout.rowHeights = new int[]{7, 7, 7, 7, 7, 7, 7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { brewerNameText = new JTextField(); pnlDetails.add(brewerNameText, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); brewerNameText.setPreferredSize(new java.awt.Dimension(69, 20)); brewerNameText.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); lblEffic.setPreferredSize(new java.awt.Dimension(31, 14)); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); lblAtten.setPreferredSize(new java.awt.Dimension(34, 14)); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints(7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints(7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { //txtDate = new JFormattedTextField(); txtDate = new DatePicker(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); // txtDate.setText("Date"); txtDate.setPreferredSize(new java.awt.Dimension(73, 20)); txtDate.setDateStyle(DateFormat.SHORT); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); // Install the custom key selection manager cmbStyle.setKeySelectionManager(new SBKeySelectionManager()); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.setPreferredSize(new java.awt.Dimension(190, 20)); } { preBoilText = new JFormattedTextField(); pnlDetails.add(preBoilText, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); preBoilText.setText("Pre Boil"); preBoilText.setPreferredSize(new java.awt.Dimension(37, 20)); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.setPreferredSize(new java.awt.Dimension(46, 20)); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); spnEffic.setPreferredSize(new java.awt.Dimension(53, 18)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); spnAtten.setPreferredSize(new java.awt.Dimension(49, 20)); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); spnOG.setPreferredSize(new java.awt.Dimension(67, 18)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.setPreferredSize(new java.awt.Dimension(69, 20)); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints(8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints(8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints(8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints(7, 4, 3, 2, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); // txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.setLineWrap(true); txtComments.setPreferredSize(new java.awt.Dimension(263, 40)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); // Install the custom key selection manager cmbYeast.setKeySelectionManager(new SBKeySelectionManager()); pnlDetails.add(cmbYeast, new GridBagConstraints(1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.setPreferredSize(new java.awt.Dimension(193, 20)); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.setPreferredSize(new java.awt.Dimension(22, 20)); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.setPreferredSize(new java.awt.Dimension(23, 20)); } { alcMethodComboModel = new DefaultComboBoxModel(new String[]{"Volume", "Weight"}); alcMethodCombo = new JComboBox(alcMethodComboModel); pnlDetails.add(alcMethodCombo, new GridBagConstraints(9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(71, 20)); } { ibuMethodComboModel = new DefaultComboBoxModel(new String[]{"Tinseth", "Garetz", "Rager"}); ibuMethodCombo = new JComboBox(ibuMethodComboModel); pnlDetails.add(ibuMethodCombo, new GridBagConstraints(9, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(72, 20)); } { colourMethodComboModel = new DefaultComboBoxModel(new String[]{"SRM", "EBC"}); colourMethodCombo = new JComboBox(colourMethodComboModel); pnlDetails.add(colourMethodCombo, new GridBagConstraints(9, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(52, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); mainToolBar = new JToolBar(); getContentPane().add(mainToolBar, BorderLayout.NORTH); mainToolBar.setFloatable(false); mainToolBar.setRollover(true); saveButton = new JButton(); mainToolBar.add(saveButton); saveButton.setMnemonic(java.awt.event.KeyEvent.VK_S); saveButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/save.gif"))); saveButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); jButton2 = new JButton(); mainToolBar.add(jButton2); jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/find.gif"))); final JFrame owner = this; jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(297, 20)); } } evapMethodCombo = new JComboBox(); pnlDetails.add(evapMethodCombo, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapMethodCombo.setModel(evapMethodComboModel); evapMethodCombo.setPreferredSize(new java.awt.Dimension(64, 20)); colourPanel = new JPanel(); pnlDetails.add(colourPanel, new GridBagConstraints(9, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); colourPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); colourPanel.setPreferredSize(new java.awt.Dimension(93, 32)); } { SBNotifier sbn = new SBNotifier(); stylePanel = new StylePanel(sbn); jTabbedPane1.addTab("Style", null, stylePanel, null); miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); dilutionPanel = new DilutionPanel(); jTabbedPane1.addTab("Dilution", null, dilutionPanel, null); mashPanel = new MashPanel(myRecipe); jTabbedPane1.addTab("Mash", null, mashPanel, null); waterPanel = new WaterPanel(sbn); jTabbedPane1.addTab("Water", null, waterPanel, null); costPanel = new CostPanel(); jTabbedPane1.addTab("Cost", null, costPanel, null); // SBNotifier sbn = new SBNotifier(); settingsPanel = new SettingsPanel(sbn); jTabbedPane1.addTab("Settings", null, settingsPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { maltTableModel = new MaltTableModel(this); maltTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, maltTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane1.setViewportView(maltTable); maltTable.setModel(maltTableModel); // maltTable.setAutoCreateColumnsFromModel(false); maltTable.getTableHeader().setReorderingAllowed(false); TableColumn maltColumn = maltTable.getColumnModel().getColumn(2); // set up malt list combo maltComboBox = new JComboBox(); ComboBoxEditor editor = maltComboBox.getEditor(); editor.getEditorComponent().addKeyListener(new KeyAdapter(){ public void keyPressed(KeyEvent evt){ // TODO: handle keypress } }); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt amount editor amountEditor = new SBCellEditor(new JTextField()); maltColumn = maltTable.getColumnModel().getColumn(3); maltColumn.setCellEditor(amountEditor); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(4); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"S", "M", "Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); // set up the units combobox maltTotalUnitsComboBox = new JComboBox(); maltTotalUnitsComboModel = new ComboModel(); maltTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltTotalUnitsComboBox.setModel(maltTotalUnitsComboModel); TableColumn t = tblMaltTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(maltTotalUnitsComboBox)); maltTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) maltTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setMaltUnits(u); displayRecipe(); } } }); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(592, 27)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(386, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); maltTable.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = maltTable.getSelectedRow(); myRecipe.delMalt(i); maltTable.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); // set up the units combobox hopsTotalUnitsComboBox = new JComboBox(); hopsTotalUnitsComboModel = new ComboModel(); hopsTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsTotalUnitsComboBox.setModel(hopsTotalUnitsComboModel); TableColumn t = tblHopsTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(hopsTotalUnitsComboBox)); hopsTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe(); } } }); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { hopsTableModel = new HopsTableModel(this); hopsTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, hopsTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane2.setViewportView(hopsTable); hopsTable.setModel(hopsTableModel); hopsTable.getTableHeader().setReorderingAllowed(false); TableColumn hopColumn = hopsTable.getColumnModel().getColumn(0); hopComboBox = new JComboBox(); // Install the custom key selection manager hopComboBox.setKeySelectionManager(new SBKeySelectionManager()); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); // set up hop units combo hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = hopsTable.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); // set up hop type combo String[] forms = {"Leaf", "Pellet", "Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = hopsTable.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String[] add = {"Boil", "FWH", "Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = hopsTable.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(413, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); hopsTable.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = hopsTable.getSelectedRow(); myRecipe.delHop(i); hopsTable.updateUI(); displayRecipe(); } } }); } } } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanelLayout.setHgap(2); statusPanelLayout.setVgap(2); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { fileNamePanel = new JPanel(); statusPanel.add(fileNamePanel); fileNamePanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); fileNamePanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { ibuMethodPanel = new JPanel(); statusPanel.add(ibuMethodPanel); ibuMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { ibuMethodLabel = new JLabel(); ibuMethodPanel.add(ibuMethodLabel); ibuMethodLabel.setText("IBU Method:"); ibuMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { alcMethodPanel = new JPanel(); statusPanel.add(alcMethodPanel); alcMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { alcMethodLabel = new JLabel(); alcMethodPanel.add(alcMethodLabel); alcMethodLabel.setText("Alc Method:"); alcMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { fileMenu = new JMenu(); jMenuBar1.add(fileMenu); fileMenu.setText("File"); { newFileMenuItem = new JMenuItem(); fileMenu.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); fileMenu.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_O, ActionEvent.CTRL_MASK)); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/find.gif"); icon = new ImageIcon(imgURL); findFileMenuItem = new JMenuItem("Find", icon); findFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_F, ActionEvent.CTRL_MASK)); fileMenu.add(findFileMenuItem); final JFrame owner = this; findFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // open the find dialog FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/save.gif"); icon = new ImageIcon(imgURL); saveMenuItem = new JMenuItem("Save", icon); fileMenu.add(saveMenuItem); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_S, ActionEvent.CTRL_MASK)); saveMenuItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/saveas.gif"); icon = new ImageIcon(imgURL); saveAsMenuItem = new JMenuItem("Save As ...", icon); fileMenu.add(saveAsMenuItem); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAs(); } }); } { exportMenu = new JMenu(); fileMenu.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file, "recipeToHtml.xslt", null); } catch (Exception e) { showError(e); } } else { Debug.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } } }); } } { JMenuItem clipboardMenuItem = new JMenuItem("Copy to Clipboard"); fileMenu.add(clipboardMenuItem); clipboardMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Copy current recipe to clipboard Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s); } }); JMenuItem printMenuItem = new JMenuItem("Print..."); fileMenu.add(printMenuItem); final JFrame owner = this; printMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true); } }); } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); final JFrame owner = this; exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuTools = new JMenu(); jMenuBar1.add(mnuTools); mnuTools.setText("Tools"); { final JFrame owner = this; JMenuItem scalRecipeMenuItem = new JMenuItem(); mnuTools.add(scalRecipeMenuItem); scalRecipeMenuItem.setText("Resize / Convert Recipe..."); scalRecipeMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_R, ActionEvent.CTRL_MASK)); scalRecipeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); } }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); maltPercentMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_M, ActionEvent.CTRL_MASK)); maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); } }); JMenuItem refractometerMenuItem = new JMenuItem(); mnuTools.add(refractometerMenuItem); refractometerMenuItem.setText("Refractometer Utility..."); refractometerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { RefractometerDialog refract = new RefractometerDialog(owner); refract.setModal(true); refract.setVisible(true); } }); JMenuItem extractPotentialMenuItem = new JMenuItem(); mnuTools.add(extractPotentialMenuItem); extractPotentialMenuItem.setText("Extract Potential..."); extractPotentialMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PotentialExtractCalcDialog extCalc = new PotentialExtractCalcDialog(owner); extCalc.setModal(true); extCalc.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String urlString = SBStringUtils.getAppPath("help") + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner, version); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); maltTable.updateUI(); displayRecipe(); }
String u = (String) maltTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setMaltUnits(u); displayRecipe();
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); maltTable.updateUI(); displayRecipe(); } }
}
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); maltTable.updateUI(); displayRecipe(); } }
int i = maltTable.getSelectedRow(); myRecipe.delMalt(i);
Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f);
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = maltTable.getSelectedRow(); myRecipe.delMalt(i); maltTable.updateUI(); displayRecipe(); } }
String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe();
if (myRecipe != null) { int i = maltTable.getSelectedRow(); myRecipe.delMalt(i); maltTable.updateUI(); displayRecipe(); }
public void actionPerformed(ActionEvent evt) { String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe(); } }
}
public void actionPerformed(ActionEvent evt) { String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe(); } }
int i = hopsTable.getSelectedRow(); myRecipe.delHop(i);
Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h);
public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = hopsTable.getSelectedRow(); myRecipe.delHop(i); hopsTable.updateUI(); displayRecipe(); } }
myRecipe = new Recipe(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe(); }
if (myRecipe != null) { int i = hopsTable.getSelectedRow(); myRecipe.delHop(i); hopsTable.updateUI(); displayRecipe(); } }
public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe(); }
String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); }
myRecipe = new Recipe(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe();
public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } }
FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true);
String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); }
public void actionPerformed(ActionEvent evt) { // open the find dialog FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); }
saveFile(evt); }
FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); }
public void actionPerformed(ActionEvent evt) { saveFile(evt); }
saveAs(); }
saveFile(evt); }
public void actionPerformed(ActionEvent evt) { saveAs(); }
String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); try { saveAsHTML(file, "recipeToHtml.xslt", null); } catch (Exception e) { showError(e); } } else { Debug.print("Save command cancelled by user.\n"); } }
saveAs(); }
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file, "recipeToHtml.xslt", null); } catch (Exception e) { showError(e); } } else { Debug.print("Save command cancelled by user.\n"); } }
String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text");
String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML");
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } }
+ ".txt"));
+ ".html"));
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } }
FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close();
saveAsHTML(file, "recipeToHtml.xslt", null);
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } }
Debug.print("Export text command cancelled by user.\n");
Debug.print("Save command cancelled by user.\n");
public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } }
Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s); }
String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } }
public void actionPerformed(ActionEvent evt) { // Copy current recipe to clipboard Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s); }
PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true);
Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s);
public void actionPerformed(ActionEvent evt) { PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true); }
processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0);
PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true);
public void actionPerformed(ActionEvent evt) { // exit program processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0); }
PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true);
processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0);
public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); }
ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true);
PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true);
public void actionPerformed(ActionEvent evt) { ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); }
MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true);
ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true);
public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); }
RefractometerDialog refract = new RefractometerDialog(owner); refract.setModal(true); refract.setVisible(true);
MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true);
public void actionPerformed(ActionEvent evt) { RefractometerDialog refract = new RefractometerDialog(owner); refract.setModal(true); refract.setVisible(true); }
PotentialExtractCalcDialog extCalc = new PotentialExtractCalcDialog(owner); extCalc.setModal(true); extCalc.setVisible(true);
RefractometerDialog refract = new RefractometerDialog(owner); refract.setModal(true); refract.setVisible(true);
public void actionPerformed(ActionEvent evt) { PotentialExtractCalcDialog extCalc = new PotentialExtractCalcDialog(owner); extCalc.setModal(true); extCalc.setVisible(true); }
String urlString = SBStringUtils.getAppPath("help") + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { e.printStackTrace(); }
PotentialExtractCalcDialog extCalc = new PotentialExtractCalcDialog(owner); extCalc.setModal(true); extCalc.setVisible(true);
public void actionPerformed(ActionEvent evt) { String urlString = SBStringUtils.getAppPath("help") + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
aboutDlg = new AboutDialog(owner, version); aboutDlg.setVisible(true);
String urlString = SBStringUtils.getAppPath("help") + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { e.printStackTrace(); }
public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner, version); aboutDlg.setVisible(true); }
String slash = System.getProperty("file.separator"); currentDir = new java.io.File("."); try { currentDir = new File(currentDir.getCanonicalPath() + slash + "recipes"); } catch (IOException e) { e.printStackTrace(); }
currentDir = new File(SBStringUtils.getAppPath("recipes"));
public FindDialog(JFrame frame) { super(frame); recipes = new ArrayList(); files = new ArrayList(); inst = (StrangeSwing) frame; String slash = System.getProperty("file.separator"); currentDir = new java.io.File("."); try { currentDir = new File(currentDir.getCanonicalPath() + slash + "recipes"); } catch (IOException e) { e.printStackTrace(); } initGUI(); dirLocationText.setText(currentDir.getAbsolutePath()); loadRecipes(currentDir); }
if (param instanceof Number)
if (param instanceof Complex) { return ((Complex)param).cos(); } else if (param instanceof Number)
public Object cos(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.cos(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).cos(); } throw new ParseException("Invalid parameter type"); }
} else if (param instanceof Complex) { return ((Complex)param).cos();
public Object cos(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.cos(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).cos(); } throw new ParseException("Invalid parameter type"); }
public String visualizeSearchStatus( Search search )
public static String visualizeSearchStatus( Search search )
public String visualizeSearchStatus( Search search ) { return null; }
return null;
if ( search instanceof BrowseHostResults ) { BrowseHostResults br = (BrowseHostResults) search; switch ( br.getBrowseHostStatus() ) { case BrowseHostResults.INITIALIZING: return Localizer.getString("BrowseHost_Initializing"); case BrowseHostResults.CONNECTING: return Localizer.getString("BrowseHost_Connecting"); case BrowseHostResults.FETCHING: return Localizer.getString("BrowseHost_Fetching"); case BrowseHostResults.FINISHED: return Localizer.getString("BrowseHost_Finished"); case BrowseHostResults.CONNECTION_ERROR: return Localizer.getString("BrowseHost_ConnectionError"); case BrowseHostResults.BROWSE_HOST_ERROR: return Localizer.getString("BrowseHost_BrowseHostError"); default: return "Unknown: " + br.getBrowseHostStatus(); } } else { if (search.isSearching()) { return Localizer.getString("Searching"); } else { return Localizer.getString("Search_Stopped"); } }
public String visualizeSearchStatus( Search search ) { return null; }
if (param instanceof Number)
if (param instanceof Complex) { return ((Complex)param).asin(); } else if (param instanceof Number)
public Object asin(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.asin(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).asin(); } throw new ParseException("Invalid parameter type"); }
} else if (param instanceof Complex) { return ((Complex)param).asin();
public Object asin(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.asin(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).asin(); } throw new ParseException("Invalid parameter type"); }
public UserLog createAndPersistUserLog(User user, Date date) { UserLog userLog = new UserLog(); userLog.setUser(user); userLog.setLastLogin(date); merge(userLog); return userLog;
public UserLog createAndPersistUserLog(User user) { return createAndPersistUserLog(user, new Date());
public UserLog createAndPersistUserLog(User user, Date date) { UserLog userLog = new UserLog(); userLog.setUser(user); userLog.setLastLogin(date); merge(userLog); return userLog; }
Date lastLogin = (Date) findUnique(LASTUSERLOGDATE_QUERY, principal);
Date lastLogin = findLastIdentityLogDate(principal);
public UserLog findLastUserLog(String principal) { try { // two different queries to grant compatibility with all databases Date lastLogin = (Date) findUnique(LASTUSERLOGDATE_QUERY, principal); List<UserLog> userLogList = (ArrayList<UserLog>) find(LASTUSERLOG_QUERY, principal, lastLogin ); if (logger.isDebugEnabled()) { for (UserLog ul: userLogList) { logger.debug("Found UserLog(s) with principal "+principal+"[" +ul.getUser().getIdentity().getPrincipal()+"]: "+ul.getUser()+" - "+ul.getLastLogin()); } } if (userLogList.size()>0) { return userLogList.get(0); } return null; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Exception "+e.toString()); } throw new DataRetrievalFailureException("Unable to find UserLogs for principal: "+principal); } }
if (param instanceof Number) { return new Double(Math.exp(((Number)param).doubleValue())); } else if (param instanceof Complex)
if (param instanceof Complex)
public Object exp(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.exp(((Number)param).doubleValue())); } else if (param instanceof Complex) { Complex z = (Complex) param; double x = z.re(); double y = z.im(); double mod = Math.exp(x); return new Complex(mod*Math.cos(y),mod*Math.sin(y)); } throw new ParseException("Invalid parameter type"); }
else if (param instanceof Number) { return new Double(Math.exp(((Number)param).doubleValue())); }
public Object exp(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.exp(((Number)param).doubleValue())); } else if (param instanceof Complex) { Complex z = (Complex) param; double x = z.re(); double y = z.im(); double mod = Math.exp(x); return new Complex(mod*Math.cos(y),mod*Math.sin(y)); } throw new ParseException("Invalid parameter type"); }
rsp.sendRedirect(req.getContextPath());
rsp.sendRedirect(req.getContextPath()+"/");
public synchronized void doLoginEntry( StaplerRequest req, StaplerResponse rsp ) throws IOException { rsp.sendRedirect(req.getContextPath()); }
rsp.sendRedirect(req.getContextPath());
rsp.sendRedirect(req.getContextPath()+"/");
public synchronized void doLogout( StaplerRequest req, StaplerResponse rsp ) throws IOException { HttpSession session = req.getSession(false); if(session!=null) session.invalidate(); rsp.sendRedirect(req.getContextPath()); }
rsp.sendRedirect(req.getContextPath());
rsp.sendRedirect(req.getContextPath()+"/");
public synchronized void doReload( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; load(); rsp.sendRedirect(req.getContextPath()); }
int index = ((Double) param2.getEle(0)).intValue()-1;
int index = ((Number) param2.getEle(0)).intValue()-1;
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI param1,MatrixValueI param2) throws ParseException {// Number num = (Number) rhs.getEle(0);// res.setEle(0,lhs.getEle(num.intValue()-1)); if(param1 instanceof MVector) { if(param2 instanceof Scaler) { int index = ((Double) param2.getEle(0)).intValue()-1; Object val = ((MVector) param1).getEle(index); res.setEle(0,val); } else throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); res.setEle(0,val); } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } else throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); return res; }
Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1);
Number d1 = (Number) vec.getEle(0); Number d2 = (Number) vec.getEle(1);
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI param1,MatrixValueI param2) throws ParseException {// Number num = (Number) rhs.getEle(0);// res.setEle(0,lhs.getEle(num.intValue()-1)); if(param1 instanceof MVector) { if(param2 instanceof Scaler) { int index = ((Double) param2.getEle(0)).intValue()-1; Object val = ((MVector) param1).getEle(index); res.setEle(0,val); } else throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); res.setEle(0,val); } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } else throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); return res; }
if(param2 instanceof Double)
if(param2 instanceof Number)
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Double) { Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1);
Object val = ((MVector) param1).getEle(((Number) param2).intValue()-1);
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Double) { Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1);
Number d1 = (Number) vec.getEle(0); Number d2 = (Number) vec.getEle(1);
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Double) { Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
String path = getPath(); File inputFile = new File(path + getSep() + type + ".ini");
String path = SBStringUtils.getAppPath("ini"); File inputFile = new File(path + type + ".ini");
private void loadProperties() { try { String path = getPath(); File inputFile = new File(path + getSep() + type + ".ini"); if (inputFile.exists()){ props.load(new FileInputStream(inputFile)); Debug.print(type + ".ini file read: " + inputFile.getAbsolutePath() +". Contents:"); } } catch (Exception e) { System.out.println(e); } }
String path = getPath(); Debug.print("Storing props: " + path); FileOutputStream out = new FileOutputStream(path + "\\" + type +".ini");
String path = SBStringUtils.getAppPath("ini"); Debug.print("Storing props: " + path); FileOutputStream out = new FileOutputStream(path + type +".ini");
public void saveProperties() { try{ String path = getPath(); Debug.print("Storing props: " + path); FileOutputStream out = new FileOutputStream(path + "\\" + type +".ini"); props.store(out, "/* properties updated */"); } catch (Exception e) { System.out.println(e); } }
super( Localizer.getString( "AdvancedSearchFilter" ), IconFactory.EMPTY_IMAGE_16, Localizer.getString( "TTTAdvancedSearchFilter" ) );
super( Localizer.getString( "SearchTab_EditFilterRules" ), null, Localizer.getString( "SearchTab_TTTEditFilterRules" ) );
public AdvancedFilterAction() { super( Localizer.getString( "AdvancedSearchFilter" ), IconFactory.EMPTY_IMAGE_16, Localizer.getString( "TTTAdvancedSearchFilter" ) ); refreshActionState(); }
POperator op = (POperator) node; if(!this.op.equals(op)) return false; if(args.length != op.args.length)
POperator nodeOp = (POperator) node; if(!this.op.equals(nodeOp)) return false; if(args.length != nodeOp.args.length)
public boolean equals(PNodeI node) { if(!(node instanceof POperator)) return false; POperator op = (POperator) node; if(!this.op.equals(op)) return false; if(args.length != op.args.length) return false; for(int i=0;i<args.length;++i) if(!args[i].equals(op.args[i])) return false; return true; }
if(!args[i].equals(op.args[i])) return false;
if(!args[i].equals(nodeOp.args[i])) return false;
public boolean equals(PNodeI node) { if(!(node instanceof POperator)) return false; POperator op = (POperator) node; if(!this.op.equals(op)) return false; if(args.length != op.args.length) return false; for(int i=0;i<args.length;++i) if(!args[i].equals(op.args[i])) return false; return true; }
} catch (FileNotFoundException e) {
} catch (Exception e) {
private String checkFileType(File f) { if (f.getPath().endsWith(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines if (f.getPath().endsWith(".qbrew") || (f.getPath().endsWith(".xml"))) { try { FileReader in = new FileReader(f); BufferedReader inb = new BufferedReader(in); String c; int i = 0; while ((c = inb.readLine()) != null && i < 10) { if (c.indexOf("BeerXML Format") > -1) return "beerxml"; if (c.indexOf("STRANGEBREWRECIPE") > -1) return "sb"; if (c.indexOf("generator=\"qbrew\"") > -1) return "qbrew"; i++; } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return ""; }
} catch (IOException e) { e.printStackTrace(); }
}
private String checkFileType(File f) { if (f.getPath().endsWith(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines if (f.getPath().endsWith(".qbrew") || (f.getPath().endsWith(".xml"))) { try { FileReader in = new FileReader(f); BufferedReader inb = new BufferedReader(in); String c; int i = 0; while ((c = inb.readLine()) != null && i < 10) { if (c.indexOf("BeerXML Format") > -1) return "beerxml"; if (c.indexOf("STRANGEBREWRECIPE") > -1) return "sb"; if (c.indexOf("generator=\"qbrew\"") > -1) return "qbrew"; i++; } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return ""; }