rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
public DrawableSeismogram(JComponent parent, DataSetSeismogram seis, Color color){ this(parent, seis, color, seis.toString()); | public DrawableSeismogram(JComponent parent, DataSetSeismogram seis){ this(parent, seis, Color.blue); | public DrawableSeismogram(JComponent parent, DataSetSeismogram seis, Color color){ this(parent, seis, color, seis.toString()); } |
jobNames.add(job.getName()); owner.save(); | if(job!=null) { jobNames.add(job.getName()); owner.save(); } | public Job doCreateJob(StaplerRequest req, StaplerResponse rsp) throws IOException { Job job = owner.doCreateJob(req, rsp); jobNames.add(job.getName()); owner.save(); return job; } |
rsp.sendRedirect(path); | rsp.sendRedirect(URLEncoder.encode(path,"UTF-8")); | protected final void serveFile(StaplerRequest req, StaplerResponse rsp, File root, String icon, boolean serveDirIndex) throws IOException, ServletException { if(req.getQueryString()!=null) { String path = req.getParameter("path"); if(path!=null) { rsp.sendRedirect(path); return; } } String path = req.getRestOfPath(); if(path.length()==0) path = "/"; if(path.indexOf("..")!=-1 || path.length()<1) { // don't serve anything other than files in the artifacts dir rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } File f = new File(root,path.substring(1)); boolean isFingerprint=false; if(f.getName().equals("*fingerprint*")) { f = f.getParentFile(); isFingerprint = true; } if(!f.exists()) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if(f.isDirectory()) { if(!req.getRequestURL().toString().endsWith("/")) { rsp.sendRedirect(req.getRequestURL().append('/').toString()); return; } if(serveDirIndex) { req.setAttribute("it",this); List<Path> parentPaths = buildParentPath(path); req.setAttribute("parentPath",parentPaths); req.setAttribute("topPath", parentPaths.isEmpty() ? "." : repeat("../",parentPaths.size())); req.setAttribute("files",buildChildPathList(f)); req.setAttribute("icon",icon); req.getView(this,"dir.jsp").forward(req,rsp); return; } else { f = new File(f,"index.html"); } } FileInputStream in = new FileInputStream(f); try { if(isFingerprint) { Hudson hudson = Hudson.getInstance(); rsp.forward(hudson.getFingerprint(hudson.getDigestOf(in)),"/",req); } else { // serve the file String contentType = req.getServletContext().getMimeType(f.getPath()); rsp.setContentType(contentType); rsp.setContentLength((int)f.length()); byte[] buf = new byte[1024]; int len; while((len=in.read(buf))>0) rsp.getOutputStream().write(buf,0,len); } } finally { in.close(); } } |
rsp.sendRedirect(req.getRequestURL().append('/').toString()); | rsp.sendRedirect2(req.getRequestURL().append('/').toString()); | protected final void serveFile(StaplerRequest req, StaplerResponse rsp, File root, String icon, boolean serveDirIndex) throws IOException, ServletException { if(req.getQueryString()!=null) { String path = req.getParameter("path"); if(path!=null) { rsp.sendRedirect(path); return; } } String path = req.getRestOfPath(); if(path.length()==0) path = "/"; if(path.indexOf("..")!=-1 || path.length()<1) { // don't serve anything other than files in the artifacts dir rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } File f = new File(root,path.substring(1)); boolean isFingerprint=false; if(f.getName().equals("*fingerprint*")) { f = f.getParentFile(); isFingerprint = true; } if(!f.exists()) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if(f.isDirectory()) { if(!req.getRequestURL().toString().endsWith("/")) { rsp.sendRedirect(req.getRequestURL().append('/').toString()); return; } if(serveDirIndex) { req.setAttribute("it",this); List<Path> parentPaths = buildParentPath(path); req.setAttribute("parentPath",parentPaths); req.setAttribute("topPath", parentPaths.isEmpty() ? "." : repeat("../",parentPaths.size())); req.setAttribute("files",buildChildPathList(f)); req.setAttribute("icon",icon); req.getView(this,"dir.jsp").forward(req,rsp); return; } else { f = new File(f,"index.html"); } } FileInputStream in = new FileInputStream(f); try { if(isFingerprint) { Hudson hudson = Hudson.getInstance(); rsp.forward(hudson.getFingerprint(hudson.getDigestOf(in)),"/",req); } else { // serve the file String contentType = req.getServletContext().getMimeType(f.getPath()); rsp.setContentType(contentType); rsp.setContentLength((int)f.length()); byte[] buf = new byte[1024]; int len; while((len=in.read(buf))>0) rsp.getOutputStream().write(buf,0,len); } } finally { in.close(); } } |
h2.setCost(h.getCostPerU()); | private void addListeners(){ txtName.addActionListener(this); txtName.addFocusListener(this); brewerNameText.addFocusListener(this); brewerNameText.addActionListener(this); txtDate.addFocusListener(this); txtDate.addActionListener(this); txtPreBoil.addFocusListener(this); txtPreBoil.addActionListener(this); boilMinText.addFocusListener(this); boilMinText.addActionListener(this); evapText.addFocusListener(this); evapText.addActionListener(this); cmbStyle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel.getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); stylePanel.setStyle(s); } cmbStyle.setToolTipText(SBStringUtils.multiLineToolTip(50, s .getDescription())); } }); postBoilText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); postBoilText.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPostBoil(Double.parseDouble(postBoilText.getText() .toString())); displayRecipe(); } }); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel.getSelectedItem(); if (myRecipe != null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } String st = SBStringUtils.multiLineToolTip(40, y .getDescription()); cmbYeast.setToolTipText(st); } }); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { // also sets postboil units: myRecipe.setVolUnits(q); displayRecipe(); } } }); alcMethodCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); ibuMethodCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); colourMethodCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); evapMethodCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); maltComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = maltTable.getSelectedRow(); if (myRecipe != null && i != -1 ) { Fermentable f2 = myRecipe.getFermentable(i); if (f2 != null){ f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); f2.setDescription(f.getDescription()); f2.setMashed(f.getMashed()); f2.setSteep(f.getSteep()); f2.setCost(f.getCostPerU()); } } } }); maltUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbMaltUnitsModel.getSelectedItem(); int i = maltTable.getSelectedRow(); if (myRecipe != null && i != -1) { Fermentable f2 = myRecipe.getFermentable(i); if (f2 != null){ f2.setUnitsFull(u); myRecipe.calcMaltTotals(); displayRecipe(); } } } }); hopComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = hopsTable.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } }); hopsUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) cmbHopsUnitsModel.getSelectedItem(); int i = hopsTable.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h = myRecipe.getHop(i); h.setUnitsFull(u); myRecipe.calcHopsTotals(); // tblHops.updateUI(); displayRecipe(); } } }); } |
|
h2.setCost(h.getCostPerU()); | public void actionPerformed(ActionEvent evt) { Hop h = (Hop) cmbHopsModel.getSelectedItem(); int i = hopsTable.getSelectedRow(); if (myRecipe != null && i != -1) { Hop h2 = myRecipe.getHop(i); h2.setAlpha(h.getAlpha()); h2.setDescription(h.getDescription()); } } |
|
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); } | private void initGUI() { try { this.setSize(600, 532); 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); { 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); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); } } { 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(); 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)); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); 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)); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.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(); 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(58, 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(59, 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(44, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); 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)); } { 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(); 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(0); // set up malt list combo maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"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); } } { 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(55, 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); } { 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(); 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(58, 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.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); // ImportXml imp = new ImportXml(file.toString(), "recipe"); // myRecipe = imp.handler.getRecipe(); myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { findFileMenuItem = new JMenuItem(); findFileMenuItem.setText("Find"); 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.setVisible(true); } }); } { saveMenuItem = new JMenuItem(); fileMenu.add(saveMenuItem); saveMenuItem.setText("Save"); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int choice = 1; if (currentFile != null) { File file = currentFile; //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); Debug.print("Saved: " + file.getAbsoluteFile()); currentFile = file; } catch (Exception e) { showError(e); } } // prompt to save if not already saved else { choice = JOptionPane.showConfirmDialog(null, "File not saved. Do you wish to save it?", "File note saved", JOptionPane.YES_NO_OPTION); } if (choice == 0) { // same as save as: saveAs(); } } }); } { saveAsMenuItem = new JMenuItem(); fileMenu.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. Debug.print(myRecipe.toXML()); 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); } 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"); } } }); } } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program 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"); {// mashManagerMenuItem = new JMenuItem();// mnuTools.add(mashManagerMenuItem);// mashManagerMenuItem.setText("Mash Manager...");// mashManagerMenuItem.addActionListener(new ActionListener() {// public void actionPerformed(ActionEvent evt) {// mashMgr = new MashManager(myRecipe);// mashMgr.setVisible(true);// }// }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); final JFrame owner = this; maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.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) { } }); } { 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(); } } |
|
exitMenuItem.setText("Exit"); | exitMenuItem.setText("Exit"); final JFrame owner = this; | private void initGUI() { try { this.setSize(600, 532); 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); { 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); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); } } { 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(); 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)); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); 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)); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.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(); 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(58, 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(59, 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(44, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); 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)); } { 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(); 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(0); // set up malt list combo maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"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); } } { 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(55, 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); } { 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(); 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(58, 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.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); // ImportXml imp = new ImportXml(file.toString(), "recipe"); // myRecipe = imp.handler.getRecipe(); myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { findFileMenuItem = new JMenuItem(); findFileMenuItem.setText("Find"); 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.setVisible(true); } }); } { saveMenuItem = new JMenuItem(); fileMenu.add(saveMenuItem); saveMenuItem.setText("Save"); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int choice = 1; if (currentFile != null) { File file = currentFile; //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); Debug.print("Saved: " + file.getAbsoluteFile()); currentFile = file; } catch (Exception e) { showError(e); } } // prompt to save if not already saved else { choice = JOptionPane.showConfirmDialog(null, "File not saved. Do you wish to save it?", "File note saved", JOptionPane.YES_NO_OPTION); } if (choice == 0) { // same as save as: saveAs(); } } }); } { saveAsMenuItem = new JMenuItem(); fileMenu.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. Debug.print(myRecipe.toXML()); 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); } 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"); } } }); } } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program 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"); {// mashManagerMenuItem = new JMenuItem();// mnuTools.add(mashManagerMenuItem);// mashManagerMenuItem.setText("Mash Manager...");// mashManagerMenuItem.addActionListener(new ActionListener() {// public void actionPerformed(ActionEvent evt) {// mashMgr = new MashManager(myRecipe);// mashMgr.setVisible(true);// }// }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); final JFrame owner = this; maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.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) { } }); } { 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(); } } |
processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); | private void initGUI() { try { this.setSize(600, 532); 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); { 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); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(179, 20)); } } { 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(); 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)); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); 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)); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.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(); 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(58, 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(59, 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.NONE, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(44, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); 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)); } { 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(); 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(0); // set up malt list combo maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"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); } } { 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(55, 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); } { 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(); 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(58, 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.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); // ImportXml imp = new ImportXml(file.toString(), "recipe"); // myRecipe = imp.handler.getRecipe(); myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { findFileMenuItem = new JMenuItem(); findFileMenuItem.setText("Find"); 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.setVisible(true); } }); } { saveMenuItem = new JMenuItem(); fileMenu.add(saveMenuItem); saveMenuItem.setText("Save"); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int choice = 1; if (currentFile != null) { File file = currentFile; //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toXML()); out.close(); Debug.print("Saved: " + file.getAbsoluteFile()); currentFile = file; } catch (Exception e) { showError(e); } } // prompt to save if not already saved else { choice = JOptionPane.showConfirmDialog(null, "File not saved. Do you wish to save it?", "File note saved", JOptionPane.YES_NO_OPTION); } if (choice == 0) { // same as save as: saveAs(); } } }); } { saveAsMenuItem = new JMenuItem(); fileMenu.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. Debug.print(myRecipe.toXML()); 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); } 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"); } } }); } } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program 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"); {// mashManagerMenuItem = new JMenuItem();// mnuTools.add(mashManagerMenuItem);// mashManagerMenuItem.setText("Mash Manager...");// mashManagerMenuItem.addActionListener(new ActionListener() {// public void actionPerformed(ActionEvent evt) {// mashMgr = new MashManager(myRecipe);// mashMgr.setVisible(true);// }// }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); final JFrame owner = this; maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.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) { } }); } { 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 (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); } | 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); // ImportXml imp = new ImportXml(file.toString(), "recipe"); // myRecipe = imp.handler.getRecipe(); myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } |
|
processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); | public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } |
|
return "alreadyTagged.jsp"; | return "alreadyTagged.jelly"; | private synchronized String chooseAction() { if(tagName!=null) return "alreadyTagged.jsp"; if(workerThread!=null) return "inProgress.jsp"; return "tagForm.jsp"; } |
return "inProgress.jsp"; return "tagForm.jsp"; | return "inProgress.jelly"; return "tagForm.jelly"; | private synchronized String chooseAction() { if(tagName!=null) return "alreadyTagged.jsp"; if(workerThread!=null) return "inProgress.jsp"; return "tagForm.jsp"; } |
public int writeRelationships(Collection tables, boolean includeImplied, LineWriter out) throws IOException { | public WriteStats writeRelationships(Table table, boolean includeImplied, boolean twoDegreesOfSeparation, LineWriter out) throws IOException { Set tablesWritten = new HashSet(); WriteStats stats = new WriteStats(); boolean[] wroteImplied = new boolean[1]; | public int writeRelationships(Collection tables, boolean includeImplied, LineWriter out) throws IOException { DotTableFormatter formatter = new DotTableFormatter(); int numWritten = 0; writeDotHeader(includeImplied ? "allRelationshipsGraph" : "realRelationshipsGraph", out); Iterator iter = tables.iterator(); while (iter.hasNext()) { Table table = (Table)iter.next(); if (!table.isOrphan(includeImplied)) { formatter.writeNode(table, "tables/", true, false, false, out); ++numWritten; } } Set relationships = new TreeSet(); iter = tables.iterator(); while (iter.hasNext()) relationships.addAll(formatter.getRelationships((Table)iter.next(), includeImplied)); iter = relationships.iterator(); while (iter.hasNext()) out.writeln(iter.next().toString()); out.writeln("}"); return numWritten; } |
int numWritten = 0; writeDotHeader(includeImplied ? "allRelationshipsGraph" : "realRelationshipsGraph", out); | public int writeRelationships(Collection tables, boolean includeImplied, LineWriter out) throws IOException { DotTableFormatter formatter = new DotTableFormatter(); int numWritten = 0; writeDotHeader(includeImplied ? "allRelationshipsGraph" : "realRelationshipsGraph", out); Iterator iter = tables.iterator(); while (iter.hasNext()) { Table table = (Table)iter.next(); if (!table.isOrphan(includeImplied)) { formatter.writeNode(table, "tables/", true, false, false, out); ++numWritten; } } Set relationships = new TreeSet(); iter = tables.iterator(); while (iter.hasNext()) relationships.addAll(formatter.getRelationships((Table)iter.next(), includeImplied)); iter = relationships.iterator(); while (iter.hasNext()) out.writeln(iter.next().toString()); out.writeln("}"); return numWritten; } |
|
Iterator iter = tables.iterator(); | writeDotHeader(includeImplied ? "impliedTwoDegreesRelationshipsGraph" : (twoDegreesOfSeparation ? "twoDegreesRelationshipsGraph" : "oneDegreeRelationshipsGraph"), out); | public int writeRelationships(Collection tables, boolean includeImplied, LineWriter out) throws IOException { DotTableFormatter formatter = new DotTableFormatter(); int numWritten = 0; writeDotHeader(includeImplied ? "allRelationshipsGraph" : "realRelationshipsGraph", out); Iterator iter = tables.iterator(); while (iter.hasNext()) { Table table = (Table)iter.next(); if (!table.isOrphan(includeImplied)) { formatter.writeNode(table, "tables/", true, false, false, out); ++numWritten; } } Set relationships = new TreeSet(); iter = tables.iterator(); while (iter.hasNext()) relationships.addAll(formatter.getRelationships((Table)iter.next(), includeImplied)); iter = relationships.iterator(); while (iter.hasNext()) out.writeln(iter.next().toString()); out.writeln("}"); return numWritten; } |
Table table = (Table)iter.next(); if (!table.isOrphan(includeImplied)) { formatter.writeNode(table, "tables/", true, false, false, out); ++numWritten; | Table relatedTable = (Table)iter.next(); if (!tablesWritten.add(relatedTable)) continue; formatter.writeNode(relatedTable, "", true, false, false, out); stats.wroteTable(relatedTable); relationships.addAll(formatter.getRelationships(relatedTable, table, includeImplied)); } if (twoDegreesOfSeparation) { iter = relatedTables.iterator(); while (iter.hasNext()) { Table relatedTable = (Table)iter.next(); Set cousins = getImmediateRelatives(relatedTable, includeImplied, wroteImplied); Iterator cousinsIter = cousins.iterator(); while (cousinsIter.hasNext()) { Table cousin = (Table)cousinsIter.next(); if (!tablesWritten.add(cousin)) continue; relationships.addAll(formatter.getRelationships(cousin, relatedTable, includeImplied)); formatter.writeNode(cousin, "", false, false, false, out); stats.wroteTable(cousin); } | public int writeRelationships(Collection tables, boolean includeImplied, LineWriter out) throws IOException { DotTableFormatter formatter = new DotTableFormatter(); int numWritten = 0; writeDotHeader(includeImplied ? "allRelationshipsGraph" : "realRelationshipsGraph", out); Iterator iter = tables.iterator(); while (iter.hasNext()) { Table table = (Table)iter.next(); if (!table.isOrphan(includeImplied)) { formatter.writeNode(table, "tables/", true, false, false, out); ++numWritten; } } Set relationships = new TreeSet(); iter = tables.iterator(); while (iter.hasNext()) relationships.addAll(formatter.getRelationships((Table)iter.next(), includeImplied)); iter = relationships.iterator(); while (iter.hasNext()) out.writeln(iter.next().toString()); out.writeln("}"); return numWritten; } |
Set relationships = new TreeSet(); iter = tables.iterator(); while (iter.hasNext()) relationships.addAll(formatter.getRelationships((Table)iter.next(), includeImplied)); iter = relationships.iterator(); | iter = new TreeSet(relationships).iterator(); | public int writeRelationships(Collection tables, boolean includeImplied, LineWriter out) throws IOException { DotTableFormatter formatter = new DotTableFormatter(); int numWritten = 0; writeDotHeader(includeImplied ? "allRelationshipsGraph" : "realRelationshipsGraph", out); Iterator iter = tables.iterator(); while (iter.hasNext()) { Table table = (Table)iter.next(); if (!table.isOrphan(includeImplied)) { formatter.writeNode(table, "tables/", true, false, false, out); ++numWritten; } } Set relationships = new TreeSet(); iter = tables.iterator(); while (iter.hasNext()) relationships.addAll(formatter.getRelationships((Table)iter.next(), includeImplied)); iter = relationships.iterator(); while (iter.hasNext()) out.writeln(iter.next().toString()); out.writeln("}"); return numWritten; } |
return numWritten; | stats.setWroteImplied(wroteImplied[0]); return stats; | public int writeRelationships(Collection tables, boolean includeImplied, LineWriter out) throws IOException { DotTableFormatter formatter = new DotTableFormatter(); int numWritten = 0; writeDotHeader(includeImplied ? "allRelationshipsGraph" : "realRelationshipsGraph", out); Iterator iter = tables.iterator(); while (iter.hasNext()) { Table table = (Table)iter.next(); if (!table.isOrphan(includeImplied)) { formatter.writeNode(table, "tables/", true, false, false, out); ++numWritten; } } Set relationships = new TreeSet(); iter = tables.iterator(); while (iter.hasNext()) relationships.addAll(formatter.getRelationships((Table)iter.next(), includeImplied)); iter = relationships.iterator(); while (iter.hasNext()) out.writeln(iter.next().toString()); out.writeln("}"); return numWritten; } |
else if (qName.equalsIgnoreCase("NAME") && currentList.equalsIgnoreCase("DETAILS")) { r.setName(buffer); buffer=""; } | public void endElement(String namespaceURI, String sName, // simple name String qName // qualified name ) throws SAXException { if (importType == "STRANGEBREW") { if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("FERMENTABLES")) { r.addMalt(m); m = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("HOPS")) { h.setDescription(descrBuf); descrBuf = ""; r.addHop(h); h = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("MISC")) { misc.setDescription(descrBuf); descrBuf = ""; r.addMisc(misc); misc = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("NOTES")) { r.addNote(note); note = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("MASH")) { r.mash.addStep(type, startTemp, endTemp, "F", method, minutes, rampMin); } // there's a problem with having two elements named "NOTES" : else if (qName.equalsIgnoreCase("FERMENTABLS") || qName.equalsIgnoreCase("HOPS") || qName.equalsIgnoreCase("DETAILS") || qName.equalsIgnoreCase("MISC") || (qName.equalsIgnoreCase("NOTES") && !currentList.equalsIgnoreCase("DETAILS")) ) { currentList = ""; } } else if (importType == "QBREW"){ if (qName.equalsIgnoreCase("GRAIN")){ r.addMalt(m); m = null; } else if (qName.equalsIgnoreCase("HOP")){ r.addHop(h); h = null; } else if (qName.equalsIgnoreCase("title")){ r.setName(buffer); buffer = ""; } } } |
|
r.setName(s); | buffer = buffer + s; | void sbCharacters(String s){ if (currentList.equals("FERMENTABLES")) { if (currentElement.equalsIgnoreCase("MALT")) { m.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { m.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("POINTS")) { m.setPppg(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("COSTLB")) { m.setCost( s ); } else if (currentElement.equalsIgnoreCase("UNITS")) { m.setUnits(s); } else if (currentElement.equalsIgnoreCase("LOV")) { m.setLov(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { m.setDescription(s); } } else if (currentList.equalsIgnoreCase("HOPS")) { if (currentElement.equalsIgnoreCase("HOP")) { h.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { h.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("ALPHA")) { h.setAlpha(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("UNITS")) { h.setUnits(s); } else if (currentElement.equalsIgnoreCase("FORM")) { h.setType(s); } else if (currentElement.equalsIgnoreCase("COSTOZ")) { h.setCost( s ); } else if (currentElement.equalsIgnoreCase("ADD")) { h.setAdd(s); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { descrBuf = descrBuf + s; } else if (currentElement.equalsIgnoreCase("TIME")) { h.setMinutes(Integer.parseInt(s)); } } else if (currentList.equalsIgnoreCase("MISC")) { if (currentElement.equalsIgnoreCase("NAME")) { misc.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { misc.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("UNITS")) { misc.setUnits(s); } else if (currentElement.equalsIgnoreCase("COMMENTS")) { misc.setComments(s); } else if (currentElement.equalsIgnoreCase("COST_PER_U")) { // misc.setCost( Double.parseDouble(s) ); } else if (currentElement.equalsIgnoreCase("ADD")) { h.setAdd(s); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { descrBuf = descrBuf + s; } else if (currentElement.equalsIgnoreCase("TIME")) { misc.setTime(Integer.parseInt(s)); } else if (currentElement.equalsIgnoreCase("STAGE")) { misc.setStage(s); } } else if (currentList.equalsIgnoreCase("NOTES")) { if (currentElement.equalsIgnoreCase("DATE")) { DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); try { Date d = df.parse(s); note.setDate(d); } catch(ParseException e) { System.out.println("Unable to parse " + s); } } else if (currentElement.equalsIgnoreCase("TYPE")) { note.setType(s); } else if (currentElement.equalsIgnoreCase("NOTE")) { note.setNote(s); } } else if (currentList.equalsIgnoreCase("MASH")) { if (currentElement.equalsIgnoreCase("TYPE")) { type = s; } else if (currentElement.equalsIgnoreCase("TEMP")) { startTemp = Double.parseDouble(s); } else if (currentElement.equalsIgnoreCase("METHOD")) { method = s; } else if (currentElement.equalsIgnoreCase("MIN")) { minutes = Integer.parseInt(s); } else if (currentElement.equalsIgnoreCase("END_TEMP")) { endTemp = Double.parseDouble(s); } else if (currentElement.equalsIgnoreCase("RAMP_MIN")) { rampMin = Integer.parseInt(s); } } else if (currentList.equalsIgnoreCase("DETAILS")) { if (currentElement.equalsIgnoreCase("NAME")) { r.setName(s); } else if (currentElement.equalsIgnoreCase("EFFICIENCY")) { r.setEfficiency(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("ATTENUATION")) { r.setAttenuation(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("PRESIZE")) { r.setPreBoil(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("SIZE")) { r.setPostBoil(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("SIZE_UNITS")) { r.setPreBoilVolUnits(s); r.setPostBoilVolUnits(s); } else if (currentElement.equalsIgnoreCase("STYLE")) { r.setStyle(s); } else if (currentElement.equalsIgnoreCase("BOIL_TIME")) { r.setBoilMinutes(Integer.parseInt(s)); } else if (currentElement.equalsIgnoreCase("HOPS_UNITS")) { r.setHopsUnits(s); } else if (currentElement.equalsIgnoreCase("MALT_UNITS")) { r.setMaltUnits(s); } else if (currentElement.equalsIgnoreCase("MASH_RATIO")) { r.setMashRatio(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("MASH_RATIO_U")) { r.setMashRatioU(s); } else if (currentElement.equalsIgnoreCase("BREWER")) { r.setBrewer(s); } else if (currentElement.equalsIgnoreCase("MASH")) { r.setMashed(Boolean.valueOf(s).booleanValue()); } else if (currentElement.equalsIgnoreCase("YEAST")) { r.setYeastName(s); } else if (currentElement.equalsIgnoreCase("RECIPE_DATE")) { DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); try { Date d = df.parse(s); r.setCreated(d); } catch(ParseException e) { System.out.println("Unable to parse " + s); } // These are SBJ1.0 Extensions: } else if (currentElement.equalsIgnoreCase("ALC_METHOD")) { r.setAlcMethod(s); } else if (currentElement.equalsIgnoreCase("IBU_METHOD")) { r.setIBUMethod(s); } else if (currentElement.equalsIgnoreCase("COLOUR_METHOD")) { r.setColourMethod(s); } } else s = ""; } |
String cmd = DESCRIPTOR.getSvnExe()+" info "+subject; | String cmd = DESCRIPTOR.getSvnExe()+" info --xml "+subject; | public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); throw new IOException("revision check failed"); } SvnInfo info = new SvnInfo(); BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); String line; while((line=br.readLine())!=null) { if(line.startsWith("Revision:")) { info.revision = Integer.parseInt( line.substring("Revision: ".length()).trim()); } if(line.startsWith("URL:")) { info.url = line.substring("URL: ".length()).trim(); } } if(!info.isComplete()) throw new IOException("no revision in the svn info output"); return info; } |
BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); String line; while((line=br.readLine())!=null) { if(line.startsWith("Revision:")) { info.revision = Integer.parseInt( line.substring("Revision: ".length()).trim()); } if(line.startsWith("URL:")) { info.url = line.substring("URL: ".length()).trim(); } | Digester digester = new Digester(); digester.push(info); digester.addBeanPropertySetter("info/entry/url"); digester.addSetProperties("info/entry","revision","revision"); try { digester.parse(new ByteArrayInputStream(baos.toByteArray())); } catch (SAXException e) { listener.getLogger().write(baos.toByteArray()); e.printStackTrace(listener.fatalError("Failed to parse Subversion output")); throw new IOException("Unabled to parse svn info output"); | public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); throw new IOException("revision check failed"); } SvnInfo info = new SvnInfo(); BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); String line; while((line=br.readLine())!=null) { if(line.startsWith("Revision:")) { info.revision = Integer.parseInt( line.substring("Revision: ".length()).trim()); } if(line.startsWith("URL:")) { info.url = line.substring("URL: ".length()).trim(); } } if(!info.isComplete()) throw new IOException("no revision in the svn info output"); return info; } |
throw new IOException("no revision in the svn info output"); | throw new IOException("No revision in the svn info output"); | public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); throw new IOException("revision check failed"); } SvnInfo info = new SvnInfo(); BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); String line; while((line=br.readLine())!=null) { if(line.startsWith("Revision:")) { info.revision = Integer.parseInt( line.substring("Revision: ".length()).trim()); } if(line.startsWith("URL:")) { info.url = line.substring("URL: ".length()).trim(); } } if(!info.isComplete()) throw new IOException("no revision in the svn info output"); return info; } |
public SeismogramIterator(String name, LocalSeismogramImpl[] seismograms, MicroSecondTimeRange timeRange){ this.name = name; if(seismograms.length > 0){ LocalSeismogramImpl[] seis = this.seismograms = DisplayUtils.sortByDate(seismograms); MicroSecondDate startTime = seis[0].getBeginTime(); MicroSecondDate endTime = seis[seis.length - 1].getEndTime(); TimeInterval samplingInterval = seis[0].getSampling().getPeriod(); sampling = seis[0].getSampling(); seisTimeRange = new MicroSecondTimeRange(startTime, endTime); addToIterateList(seis[0], 0, seis[0].getNumPoints()); for(int i = 1; i < seis.length; i++){ LocalSeismogramImpl current = seis[i]; LocalSeismogramImpl prev = seis[i-1]; if(DisplayUtils.areOverlapping(prev,current)){ MicroSecondDate currentStartTime = prev.getEndTime().add(samplingInterval); MicroSecondDate currentEndTime = current.getEndTime(); MicroSecondTimeRange currentTR = new MicroSecondTimeRange(currentStartTime, currentEndTime); int[] points = DisplayUtils.getSeisPoints(current, currentTR); addToIterateList(current, points[0], current.getNumPoints()); }else if(DisplayUtils.areContiguous(prev, current)){ addToIterateList(current, 0, current.getNumPoints()); }else{ TimeInterval difference = current.getBeginTime().difference(prev.getEndTime()); TimeInterval convSampling = (TimeInterval)samplingInterval.convertTo(UnitImpl.MICROSECOND); double gapPoints = difference.divideBy(convSampling).getValue(); addToIterateList(new Gap((int)gapPoints), 0, (int)gapPoints); addToIterateList(current, 0, current.getNumPoints()); } } setTimeRange(timeRange); }else{ this.seismograms = seismograms; this.timeRange = DisplayUtils.ZERO_TIME; this.seisTimeRange = DisplayUtils.ZERO_TIME; } | public SeismogramIterator(String name, LocalSeismogramImpl[] seismograms){ this(name, seismograms, DisplayUtils.getFullTime(seismograms)); | public SeismogramIterator(String name, LocalSeismogramImpl[] seismograms, MicroSecondTimeRange timeRange){ this.name = name; if(seismograms.length > 0){ LocalSeismogramImpl[] seis = this.seismograms = DisplayUtils.sortByDate(seismograms); MicroSecondDate startTime = seis[0].getBeginTime(); MicroSecondDate endTime = seis[seis.length - 1].getEndTime(); TimeInterval samplingInterval = seis[0].getSampling().getPeriod(); sampling = seis[0].getSampling(); seisTimeRange = new MicroSecondTimeRange(startTime, endTime); addToIterateList(seis[0], 0, seis[0].getNumPoints()); for(int i = 1; i < seis.length; i++){ LocalSeismogramImpl current = seis[i]; LocalSeismogramImpl prev = seis[i-1]; if(DisplayUtils.areOverlapping(prev,current)){ MicroSecondDate currentStartTime = prev.getEndTime().add(samplingInterval); MicroSecondDate currentEndTime = current.getEndTime(); MicroSecondTimeRange currentTR = new MicroSecondTimeRange(currentStartTime, currentEndTime); int[] points = DisplayUtils.getSeisPoints(current, currentTR); addToIterateList(current, points[0], current.getNumPoints()); }else if(DisplayUtils.areContiguous(prev, current)){ addToIterateList(current, 0, current.getNumPoints()); }else{//are seperated TimeInterval difference = current.getBeginTime().difference(prev.getEndTime()); TimeInterval convSampling = (TimeInterval)samplingInterval.convertTo(UnitImpl.MICROSECOND); double gapPoints = difference.divideBy(convSampling).getValue(); addToIterateList(new Gap((int)gapPoints), 0, (int)gapPoints); addToIterateList(current, 0, current.getNumPoints()); } } setTimeRange(timeRange); }else{ this.seismograms = seismograms; this.timeRange = DisplayUtils.ZERO_TIME; this.seisTimeRange = DisplayUtils.ZERO_TIME; } } |
System.out.println(this + " getting value at"); | public QuantityImpl getValueAt(int position){ try{ System.out.println(this + " getting value at"); Object[] seisAndPoint = getSeisAtWithInternal(position); LocalSeismogramImpl seis = (LocalSeismogramImpl)seisAndPoint[0]; Integer point = (Integer)seisAndPoint[1]; return seis.getValueAt(point.intValue()); }catch(CodecException e){ GlobalExceptionHandler.handleStatic(e); } return null; } |
|
} catch (Exception e) { e.printStackTrace(); System.err.println( "Native SQLite not found, falling back to Nested SQLite"); } | } catch (Exception e) { } | public Conn(String url, String filename) throws SQLException { // TODO: library variable to explicitly control load type // attempt to use the Native library first try { Class nativedb = Class.forName("org.sqlite.NativeDB"); if (((Boolean)nativedb.getDeclaredMethod("load", null) .invoke(null, null)).booleanValue()) db = (DB)nativedb.newInstance(); } catch (Exception e) { e.printStackTrace(); System.err.println( "Native SQLite not found, falling back to Nested SQLite"); } // load nested library if (db == null) { try { db = (DB)Class.forName("org.sqlite.NestedDB").newInstance(); } catch (Exception e) { throw new SQLException("no SQLite library found"); } } this.url = url; db.open(filename); setTimeout(3000); } |
R first = m.get(m.firstKey()); | private R update(TreeMap<Integer, R> m, Integer key, R value) { R r = m.put(key, value); SortedMap<Integer,R> head = m.headMap(key); if(!head.isEmpty()) { R prev = m.get(head.lastKey()); value.nextBuild = prev.nextBuild; value.previousBuild = prev; if(value.nextBuild!=null) value.nextBuild.previousBuild = value; prev.nextBuild=value; } else { if(!m.isEmpty()) { R first = m.get(m.firstKey()); value.nextBuild = first; value.previousBuild = null; first.previousBuild = value; } } return r; } |
|
UnitImpl realWorldUnit = ur.getUnit(); float sensitivity = 1.0f; if(realWorldUnit.equals(UnitImpl.COUNT)){ | UnitRangeImpl out = ur; if(ur.getUnit().isConvertableTo(UnitImpl.COUNT)){ | public static UnitRangeImpl getRealWorldUnitRange(UnitRangeImpl ur, DataSetSeismogram seismo) { UnitImpl realWorldUnit = ur.getUnit(); // this is the constant to divide by to get real worl units (not counts) float sensitivity = 1.0f; if(realWorldUnit.equals(UnitImpl.COUNT)){ Object responseObj = seismo.getAuxillaryData(StdAuxillaryDataNames.RESPONSE); if (responseObj != null && responseObj instanceof Response) { Response response = (Response)responseObj; realWorldUnit = (UnitImpl)response.stages[0].input_units; sensitivity = response.the_sensitivity.sensitivity_factor; } } // logger.debug("sensitivity is "+sensitivity+" to get to "+realWorldUnit); UnitRangeImpl out = new UnitRangeImpl(ur.getMinValue()/sensitivity, ur.getMaxValue()/sensitivity, realWorldUnit); return getBestForDisplay(out); } |
realWorldUnit = (UnitImpl)response.stages[0].input_units; sensitivity = response.the_sensitivity.sensitivity_factor; | UnitImpl realWorldUnit = (UnitImpl)response.stages[0].input_units; float sensitivity = response.the_sensitivity.sensitivity_factor; out = new UnitRangeImpl(ur.getMinValue()/sensitivity, ur.getMaxValue()/sensitivity, realWorldUnit); | public static UnitRangeImpl getRealWorldUnitRange(UnitRangeImpl ur, DataSetSeismogram seismo) { UnitImpl realWorldUnit = ur.getUnit(); // this is the constant to divide by to get real worl units (not counts) float sensitivity = 1.0f; if(realWorldUnit.equals(UnitImpl.COUNT)){ Object responseObj = seismo.getAuxillaryData(StdAuxillaryDataNames.RESPONSE); if (responseObj != null && responseObj instanceof Response) { Response response = (Response)responseObj; realWorldUnit = (UnitImpl)response.stages[0].input_units; sensitivity = response.the_sensitivity.sensitivity_factor; } } // logger.debug("sensitivity is "+sensitivity+" to get to "+realWorldUnit); UnitRangeImpl out = new UnitRangeImpl(ur.getMinValue()/sensitivity, ur.getMaxValue()/sensitivity, realWorldUnit); return getBestForDisplay(out); } |
UnitRangeImpl out = new UnitRangeImpl(ur.getMinValue()/sensitivity, ur.getMaxValue()/sensitivity, realWorldUnit); | public static UnitRangeImpl getRealWorldUnitRange(UnitRangeImpl ur, DataSetSeismogram seismo) { UnitImpl realWorldUnit = ur.getUnit(); // this is the constant to divide by to get real worl units (not counts) float sensitivity = 1.0f; if(realWorldUnit.equals(UnitImpl.COUNT)){ Object responseObj = seismo.getAuxillaryData(StdAuxillaryDataNames.RESPONSE); if (responseObj != null && responseObj instanceof Response) { Response response = (Response)responseObj; realWorldUnit = (UnitImpl)response.stages[0].input_units; sensitivity = response.the_sensitivity.sensitivity_factor; } } // logger.debug("sensitivity is "+sensitivity+" to get to "+realWorldUnit); UnitRangeImpl out = new UnitRangeImpl(ur.getMinValue()/sensitivity, ur.getMaxValue()/sensitivity, realWorldUnit); return getBestForDisplay(out); } |
|
final void powN(int n){ | final void powN(short n){ | final void powN(int n){ double r = stack[--sp]; switch(n){ case 0: r = 1.0; break; case 1: break; case 2: r *= r; break; case 3: r *= r*r; break; case 4: r *= r*r*r; break; case 5: r *= r*r*r*r; break; default: r = Math.pow(r,n); break; } stack[sp++] = r; } |
r = Math.pow(r,n); break; | { short bitMask = n; double evenPower = r; double result; if ( (bitMask & 1) != 0 ) result = r; else result = 1; bitMask >>>= 1; while ( bitMask != 0 ) { evenPower *= evenPower; if ( (bitMask & 1) != 0 ) result *= evenPower; bitMask >>>= 1; } r = result; } | final void powN(int n){ double r = stack[--sp]; switch(n){ case 0: r = 1.0; break; case 1: break; case 2: r *= r; break; case 3: r *= r*r; break; case 4: r *= r*r*r; break; case 5: r *= r*r*r*r; break; default: r = Math.pow(r,n); break; } stack[sp++] = r; } |
case FUN2: binaryFunction(aux1); break; case FUN3: trianaryFunction(aux1); break; case FUN4: quarteraryFunction(aux1); break; case POWN: scalerStore.powN(aux1); break; case RECIP: scalerStore.recroprical(); break; | public final double evaluate(RpCommandList comList) { scalerStore.reset(); // Now actually process the commands int num = comList.getNumCommands(); for(short commandNum=0;commandNum<num;++commandNum) { RpCommand command = comList.commands[commandNum]; short aux1 = command.aux1; switch(command.command) { case CONST: scalerStore.stack[scalerStore.sp++]=constVals[aux1]; break; case VAR: scalerStore.stack[scalerStore.sp++]=scalerStore.vars[aux1]; break; case ADD: scalerStore.add(); break; case SUB: scalerStore.sub(); break; case MUL: scalerStore.mulS(); break; case DIV: scalerStore.div(); break; case MOD: scalerStore.mod(); break; case POW: scalerStore.pow(); break; case AND: scalerStore.and(); break; case OR: scalerStore.or(); break; case NOT: scalerStore.not(); break; case LT: scalerStore.lt(); break; case LE: scalerStore.le(); break; case GT: scalerStore.gt(); break; case GE: scalerStore.ge(); break; case NE: scalerStore.neq(); break; case EQ: scalerStore.eq(); break; case ASSIGN: scalerStore.assign(aux1); break; case FUN: unitaryFunction(aux1); break; case UMINUS: scalerStore.uminus(); break; } } return scalerStore.stack[--scalerStore.sp]; } |
|
case ATAN2: return "atan2"; case IF: return "if"; | public String getFunction(short ref) { switch(ref) { case SIN: return "sin"; case COS: return "cos"; case TAN: return "tan"; case ASIN: return "asin"; case ACOS: return "acos"; case ATAN: return "atan"; case SINH: return "sinh"; case COSH: return "cosh"; case TANH: return "tanh"; case ASINH: return "asinh"; case ACOSH: return "acosh"; case ATANH: return "atanh"; case ABS: return "abs"; case EXP: return "exp"; case LOG: return "log"; case LN: return "ln"; case SQRT: return "sqrt"; case SEC: return "sec"; case COSEC: return "cosec"; case COT: return "cot"; } return null; } |
|
for(int i=0;i<param2.getDim().numEles();++i) | for(int i=0;i<param1.getDim().numEles();++i) | public MatrixValueI calcValue(MatrixValueI res,MatrixValueI param1,MatrixValueI param2) throws ParseException { if(param1 instanceof Scaler) { if(param2 instanceof Scaler) { // Scaler * Scaler -> Scaler res.setEle(0,super.mul(param1.getEle(0),param2.getEle(0))); } else if(param2 instanceof MVector) { // Scaler * Vector -> Vector for(int i=0;i<param2.getDim().getFirstDim();++i) res.setEle(i,super.mul(param1.getEle(0),param2.getEle(i))); } else if(param2 instanceof Matrix) // Scaler * Matrix -> Matrix { Matrix r = (Matrix) param2; Matrix mres = (Matrix) res; for(int i=0;i<r.getNumRows();++i) for(int j=0;j<r.getNumCols();++j) mres.setEle(i,j,super.mul(param1.getEle(0),r.getEle(i,j))); } else { // Tensor res for(int i=0;i<param2.getDim().numEles();++i) res.setEle(i,super.mul(param1.getEle(0),param2.getEle(i))); } } else if(param1 instanceof MVector) { if(param2 instanceof Scaler) // Vector * Scaler -> Vector { for(int i=0;i<param1.getDim().getFirstDim();++i) res.setEle(i,super.mul(param1.getEle(i),param2.getEle(0))); } else if(param2 instanceof MVector) // Vector * Vector -> Matrix { Matrix mat = (Matrix) res; for(int i=0;i<param1.getDim().getFirstDim();++i) for(int j=0;j<param2.getDim().getFirstDim();++j) mat.setEle(i,j,super.mul(param1.getEle(i),param2.getEle(j))); } else if(param2 instanceof Matrix) // Vector * Matrix -> Vector { MVector lhs = (MVector) param1; Matrix rhs = (Matrix) param2; if(lhs.getNumEles() != rhs.getNumRows()) throw new ParseException("Multiply Matrix , Vector: Miss match in sizes ("+lhs.getNumEles()+","+rhs.getNumRows()+")!"); for(int i=0;i<rhs.getNumCols();++i) { Object val = super.mul(lhs.getEle(0),rhs.getEle(0,i)); for(int j=1;j<rhs.getNumRows();++j) val = add.add(val, super.mul(lhs.getEle(j),rhs.getEle(j,i))); res.setEle(i,val); } } else { throw new ParseException("Sorry I don't know how to multiply a vector by a tensor"); } } else if(param1 instanceof Matrix) { if(param2 instanceof Scaler) // Matrix * Scaler -> Matrix { Matrix l = (Matrix) param1; Matrix mres = (Matrix) res; for(int i=0;i<l.getNumRows();++i) for(int j=0;j<l.getNumCols();++j) mres.setEle(i,j,super.mul(l.getEle(i,j),param2.getEle(0))); } else if(param2 instanceof MVector) // Matrix * Vector -> Vector { Matrix lhs = (Matrix) param1; MVector rhs = (MVector) param2; if(lhs.getNumCols() != rhs.getNumEles()) throw new ParseException("Mat * Vec: Miss match in sizes ("+lhs.getNumCols()+","+rhs.getNumEles()+") when trying to add vectors!"); for(int i=0;i<lhs.getNumRows();++i) { Object val = super.mul(lhs.getEle(i,0),rhs.getEle(0)); for(int j=1;j<lhs.getNumCols();++j) val = add.add(val,super.mul(lhs.getEle(i,j),rhs.getEle(j))); res.setEle(i,val); } } else if(param2 instanceof Matrix) // Matrix * Matrix -> Matrix { Matrix lhs = (Matrix) param1; Matrix rhs = (Matrix) param2; Matrix mres = (Matrix) res; if(lhs.getNumCols() != rhs.getNumRows()) throw new ParseException("Multiply matrix,matrix: Miss match in number of dims ("+lhs.getNumCols()+","+rhs.getNumRows()+")!"); int lnr = lhs.getNumRows(); int lnc = lhs.getNumCols(); int rnc = rhs.getNumCols(); Object ldata[][] = lhs.getEles(); Object rdata[][] = rhs.getEles(); Object resdata[][] = mres.getEles(); for(int i=0;i<lnr;++i) for(int j=0;j<rnc;++j) { Object val = mul(ldata[i][0],rdata[0][j]); for(int k=1;k<lnc;++k) val = add.add(val, mul(ldata[i][k],rdata[k][j])); resdata[i][j] = val; } } else // Tensor res throw new ParseException("Sorry I don't know how to multiply a matrix by a tensor"); } else { if(param2 instanceof Scaler) { for(int i=0;i<param2.getDim().numEles();++i) res.setEle(i,super.mul(param1.getEle(i),param2.getEle(0))); } else throw new ParseException("Sorry I don't know how to multiply a tensor by a vector"); } return res; } |
if (param instanceof Number) | if (param instanceof Complex) { return ((Complex)param).acosh(); } else if (param instanceof Number) | public Object acosh(Object param) throws ParseException { if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.acosh(); } else if (param instanceof Complex) { return ((Complex)param).acosh(); } throw new ParseException("Invalid parameter type"); } |
else if (param instanceof Complex) { return ((Complex)param).acosh(); } | public Object acosh(Object param) throws ParseException { if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.acosh(); } else if (param instanceof Complex) { return ((Complex)param).acosh(); } throw new ParseException("Invalid parameter type"); } |
|
int i = n / rows; int j = n % rows; | int i = n / cols; int j = n % cols; | public Object getEle(int n) { int i = n / rows; int j = n % rows; return data[i][j]; } |
int i = n / rows; int j = n % rows; | int i = n / cols; int j = n % cols; | public void setEle(int n,Object value) { int i = n / rows; int j = n % rows; data[i][j] = value; } |
JSpinner maltSpin = new JSpinner(); maltColumn.setCellEditor(new SpinnerEditor()); | SpinnerNumberModel spnMaltAmntModel = new SpinnerNumberModel(1.00,0.00,9999.00,0.25 ); maltColumn.setCellEditor(new SpinnerEditor(spnMaltAmntModel)); | private void initGUI() { try { this.setSize(520, 532); 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.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { 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); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName .setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setName(txtName.getText()); } }); } } { 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}; pnlDetailsLayout.columnWidths = new int[]{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); { 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:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtBrewer.setText("Brewer"); txtBrewer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setBrewer(txtBrewer.getText()); } }); } { 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:"); } { lblMash = new JLabel(); pnlDetails.add(lblMash, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMash.setText("Mash:"); } { 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:"); } { 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:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(3, 2, 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(3, 3, 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(5, 0, 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(5, 2, 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(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JTextField(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 2, 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.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel .getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPreBoil(Double .parseDouble(txtPreBoil.getText() .toString())); displayRecipe(); } }); } { txtPostBoil = new JFormattedTextField(); pnlDetails.add(txtPostBoil, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPostBoil.setText("Post Boil"); txtPostBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out .println("txtPostBoil.actionPerformed, event=" + evt); myRecipe.setPostBoil(Double .parseDouble(txtPostBoil.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 3, 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.#")); } { 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.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(4, 2, 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")); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(4, 3, 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.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( 6, 0, 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(6, 1, 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( 6, 2, 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( 3, 5, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); 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(); pnlDetails.add(cmbYeast, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel .getSelectedItem(); if (myRecipe!= null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } } }); } { ComboBoxModel cmbSizeUnitsModel = new DefaultComboBoxModel( new String[]{"Item One", "Item Two"}); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[] {0.1,0.1,0.1,0.1}; jPanel2Layout1.columnWidths = new int[] {7,7,7,7}; jPanel2Layout1.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1}; jPanel2Layout1.rowHeights = new int[] {7,7,7,7,7,7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",0,12), new java.awt.Color(0,0,0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } } { 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(); FlowLayout pnlMaltLayout = new FlowLayout(); 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); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(); jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); // TableColumn column = null; TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up spin editor for amount maltColumn = tblMalt.getColumnModel().getColumn(1); JSpinner maltSpin = new JSpinner(); maltColumn.setCellEditor(new SpinnerEditor()); for (int i = 0; i < tblMalt.getColumnCount(); i++) { TableColumn column; column = tblMalt.getColumnModel() .getColumn(i); if (i == 0) { column.setPreferredWidth(100); } else { column.setPreferredWidth(50); } } maltComboBox .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt .getSelectedRow(); if (myRecipe != null) { Fermentable f2 = (Fermentable) myRecipe .getFermentablesList() .get(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); } } }); } } { tblMaltTotalsModel = new DefaultTableModel( new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); } } { 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[]{ "Column 1", "Column 2"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); tblHops.setModel(tblHopsModel); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); } } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem .addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String path = getClass() .getProtectionDomain() .getCodeSource().getLocation() .toString().substring(6) + "\\"; JFileChooser fc = new JFileChooser(path); // Show open dialog; this method does // not return until the dialog is closed int returnVal = fc .showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file .toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash .setMaltWeight(myRecipe .getTotalMashLbs()); myRecipe.mash.calcMashSchedule(); displayRecipe(); } else { System.out .print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toText()); } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu .addActionListener(new ActionListener() { public void actionPerformed ( ActionEvent evt) { try{ saveAsHTML(); } catch (Exception e){ } } }); } } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } } |
BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); | private void initGUI() { try { this.setSize(520, 532); 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.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { 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); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName .setPreferredSize(new java.awt.Dimension(179, 20)); txtName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setName(txtName.getText()); } }); } } { 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}; pnlDetailsLayout.columnWidths = new int[]{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); { 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:"); } { txtBrewer = new JTextField(); pnlDetails.add(txtBrewer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtBrewer.setText("Brewer"); txtBrewer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setBrewer(txtBrewer.getText()); } }); } { 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:"); } { lblMash = new JLabel(); pnlDetails.add(lblMash, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMash.setText("Mash:"); } { 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:"); } { 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:"); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(3, 2, 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(3, 3, 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(5, 0, 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(5, 2, 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(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { txtDate = new JTextField(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtDate.setText("Date"); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 2, 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.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Style s = (Style) cmbStyleModel .getSelectedItem(); if (myRecipe != null && s != myRecipe.getStyleObj()) { myRecipe.setStyle(s); } } }); } { txtPreBoil = new JFormattedTextField(); pnlDetails.add(txtPreBoil, new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPreBoil.setText("Pre Boil"); txtPreBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { myRecipe.setPreBoil(Double .parseDouble(txtPreBoil.getText() .toString())); displayRecipe(); } }); } { txtPostBoil = new JFormattedTextField(); pnlDetails.add(txtPostBoil, new GridBagConstraints( 1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); txtPostBoil.setText("Post Boil"); txtPostBoil.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out .println("txtPostBoil.actionPerformed, event=" + evt); myRecipe.setPostBoil(Double .parseDouble(txtPostBoil.getText() .toString())); displayRecipe(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints( 3, 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.#")); } { 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.#")); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(4, 2, 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")); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel( 1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(4, 3, 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.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( 6, 0, 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(6, 1, 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( 6, 2, 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( 3, 5, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); 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(); pnlDetails.add(cmbYeast, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets( 0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Yeast y = (Yeast) cmbYeastModel .getSelectedItem(); if (myRecipe!= null && y != myRecipe.getYeastObj()) { myRecipe.setYeast(y); } } }); } { ComboBoxModel cmbSizeUnitsModel = new DefaultComboBoxModel( new String[]{"Item One", "Item Two"}); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } } { pnlStyle = new JPanel(); FlowLayout pnlStyleLayout = new FlowLayout(); pnlStyle.setLayout(pnlStyleLayout); jTabbedPane1.addTab("Style", null, pnlStyle, null); { lblStyle2 = new JLabel(); pnlStyle.add(lblStyle2); lblStyle2.setText("Style:"); } { ComboBoxModel cmbStyle2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); cmbStyle2 = new JComboBox(); pnlStyle.add(cmbStyle2); cmbStyle2.setModel(cmbStyle2Model); } { jPanel2 = new JPanel(); GridBagLayout jPanel2Layout1 = new GridBagLayout(); jPanel2Layout1.columnWeights = new double[] {0.1,0.1,0.1,0.1}; jPanel2Layout1.columnWidths = new int[] {7,7,7,7}; jPanel2Layout1.rowWeights = new double[] {0.1,0.1,0.1,0.1,0.1,0.1}; jPanel2Layout1.rowHeights = new int[] {7,7,7,7,7,7}; jPanel2.setPreferredSize(new java.awt.Dimension(179, 120)); jPanel2.setLayout(jPanel2Layout1); pnlStyle.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false), "Recipe Conformance:", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog",0,12), new java.awt.Color(0,0,0))); { jLabel5 = new JLabel(); jPanel2.add(jLabel5, new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("OG:"); jLabel5.setBounds(74, 3, 60, 30); } { jLabel1 = new JLabel(); jPanel2.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); GridLayout jLabel1Layout = new GridLayout(1, 1); jLabel1.setLayout(jLabel1Layout); jLabel1.setText("Low:"); } { jLabel2 = new JLabel(); jPanel2.add(jLabel2, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Recipe:"); } { jLabel3 = new JLabel(); jPanel2.add(jLabel3, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("High:"); } { jLabel4 = new JLabel(); jPanel2.add(jLabel4, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("IBU:"); } { jLabel6 = new JLabel(); jPanel2.add(jLabel6, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Colour:"); } { jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("ABV:"); } } { jScrollPane3 = new JScrollPane(); pnlStyle.add(jScrollPane3); { txaStyles = new JTextArea(); jScrollPane3.setViewportView(txaStyles); txaStyles.setText("Matched Styles"); } } { sldMatch = new JSlider(); pnlStyle.add(sldMatch); } } } { 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(); FlowLayout pnlMaltLayout = new FlowLayout(); 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); { tblMaltModel = new MaltTableModel(this); tblMalt = new JTable(); jScrollPane1.setViewportView(tblMalt); tblMalt.setModel(tblMaltModel); // TableColumn column = null; TableColumn maltColumn = tblMalt.getColumnModel().getColumn(0); JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up spin editor for amount maltColumn = tblMalt.getColumnModel().getColumn(1); JSpinner maltSpin = new JSpinner(); maltColumn.setCellEditor(new SpinnerEditor()); for (int i = 0; i < tblMalt.getColumnCount(); i++) { TableColumn column; column = tblMalt.getColumnModel() .getColumn(i); if (i == 0) { column.setPreferredWidth(100); } else { column.setPreferredWidth(50); } } maltComboBox .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent evt) { Fermentable f = (Fermentable) cmbMaltModel .getSelectedItem(); int i = tblMalt .getSelectedRow(); if (myRecipe != null) { Fermentable f2 = (Fermentable) myRecipe .getFermentablesList() .get(i); f2.setLov(f.getLov()); f2.setPppg(f.getPppg()); } } }); } } { tblMaltTotalsModel = new DefaultTableModel( new String[][]{{""}}, new String[]{"Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); } } { 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[]{ "Column 1", "Column 2"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { tblHopsModel = new HopsTableModel(this); tblHops = new JTable(); jScrollPane2.setViewportView(tblHops); BorderLayout tblHopsLayout = new BorderLayout(); tblHops.setLayout(tblHopsLayout); tblHops.setModel(tblHopsModel); TableColumn hopColumn = tblHops.getColumnModel().getColumn(0); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); } } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { newFileMenuItem = new JMenuItem(); jMenu3.add(newFileMenuItem); newFileMenuItem.setText("New"); } { openFileMenuItem = new JMenuItem(); jMenu3.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem .addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String path = getClass() .getProtectionDomain() .getCodeSource().getLocation() .toString().substring(6) + "\\"; JFileChooser fc = new JFileChooser(path); // Show open dialog; this method does // not return until the dialog is closed int returnVal = fc .showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); System.out.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file .toString()); myRecipe = imp.handler.getRecipe(); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash .setMaltWeight(myRecipe .getTotalMashLbs()); myRecipe.mash.calcMashSchedule(); displayRecipe(); } else { System.out .print("Open command cancelled by user.\n"); } } }); } { saveMenuItem = new JMenuItem(); jMenu3.add(saveMenuItem); saveMenuItem.setText("Save"); } { saveAsMenuItem = new JMenuItem(); jMenu3.add(saveAsMenuItem); saveAsMenuItem.setText("Save As ..."); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. System.out.print(myRecipe.toText()); } }); } { exportMenu = new JMenu(); jMenu3.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu .addActionListener(new ActionListener() { public void actionPerformed ( ActionEvent evt) { try{ saveAsHTML(); } catch (Exception e){ } } }); } } { closeFileMenuItem = new JMenuItem(); jMenu3.add(closeFileMenuItem); closeFileMenuItem.setText("Close"); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } } } } catch (Exception e) { e.printStackTrace(); } } |
|
if(r!=0) | if(r!=0) { listener.getLogger().write(baos.toByteArray()); | public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) throw new IOException("revision check failed"); SvnInfo info = new SvnInfo(); BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); String line; while((line=br.readLine())!=null) { if(line.startsWith("Revision:")) { info.revision = Integer.parseInt( line.substring("Revision: ".length()).trim()); } if(line.startsWith("URL:")) { info.url = line.substring("URL: ".length()).trim(); } } if(!info.isComplete()) throw new IOException("no revision in the svn info output"); return info; } |
} | public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) throw new IOException("revision check failed"); SvnInfo info = new SvnInfo(); BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); String line; while((line=br.readLine())!=null) { if(line.startsWith("Revision:")) { info.revision = Integer.parseInt( line.substring("Revision: ".length()).trim()); } if(line.startsWith("URL:")) { info.url = line.substring("URL: ".length()).trim(); } } if(!info.isComplete()) throw new IOException("no revision in the svn info output"); return info; } |
|
Map env = createEnvVarMap(); | Map env = createEnvVarMap(false); | private Map<String,SvnInfo> buildRevisionMap(FilePath workspace, TaskListener listener) throws IOException { PrintStream logger = listener.getLogger(); Map<String/*module name*/,SvnInfo> revisions = new HashMap<String,SvnInfo>(); Map env = createEnvVarMap(); // invoke the "svn info" for( String module : getModuleDirNames() ) { // parse the output SvnInfo info = SvnInfo.parse(module,env,workspace,listener); revisions.put(module,info); logger.println("Revision:"+info.revision); } return revisions; } |
Map env = createEnvVarMap(); | Map env = createEnvVarMap(true); | private 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,Integer> previousRevisions = parseRevisionFile(build.getPreviousBuild()); Map env = createEnvVarMap(); for( String module : getModuleDirNames() ) { Integer 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+1)+":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; } |
Map env = createEnvVarMap(); | Map env = createEnvVarMap(false); | public boolean pollChanges(Project project, Launcher launcher, FilePath workspace, TaskListener listener) throws IOException { // current workspace revision Map<String,SvnInfo> wsRev = buildRevisionMap(workspace,listener); Map env = createEnvVarMap(); // check the corresponding remote revision for (SvnInfo localInfo : wsRev.values()) { SvnInfo remoteInfo = SvnInfo.parse(localInfo.url,env,workspace,listener); if(remoteInfo.revision > localInfo.revision) return true; // change found } return false; // no change } |
colourPanel.setBackground(Recipe.calcRGB(1, myRecipe.getSrm(), | colourPanel.setBackground(Recipe.calcRGB(1, colour, | public void displayRecipe() { if (myRecipe == null) return; txtName.setText(myRecipe.getName()); brewerNameText.setText(myRecipe.getBrewer()); txtPreBoil.setValue(new Double(myRecipe.getPreBoilVol(myRecipe.getVolUnits()))); lblSizeUnits.setText(myRecipe.getVolUnits()); postBoilText.setValue(new Double(myRecipe.getPostBoilVol(myRecipe.getVolUnits()))); boilMinText.setText(SBStringUtils.df0.format(myRecipe.getBoilMinutes())); evapText.setText(SBStringUtils.df1.format(myRecipe.getEvap())); spnEffic.setValue(new Double(myRecipe.getEfficiency())); spnAtten.setValue(new Double(myRecipe.getAttenuation())); spnOG.setValue(new Double(myRecipe.getEstOg())); spnFG.setValue(new Double(myRecipe.getEstFg())); txtComments.setText(myRecipe.getComments()); lblIBUvalue.setText(SBStringUtils.df1.format(myRecipe.getIbu())); lblColourValue.setText(SBStringUtils.df1.format(myRecipe.getSrm())); lblAlcValue.setText(SBStringUtils.df1.format(myRecipe.getAlcohol())); txtDate.setText(dateFormat1.format(myRecipe.getCreated().getTime())); Costs = SBStringUtils.myNF.format(myRecipe.getTotalMaltCost()); tblMaltTotalsModel.setDataVector(new String[][]{{"Totals:", "" + SBStringUtils.df1.format(myRecipe.getTotalMalt()), myRecipe.getMaltUnits(), "" + SBStringUtils.df3.format(myRecipe.getEstOg()), "" + SBStringUtils.df1.format(myRecipe.getSrm()), Costs, "100"}}, new String[]{"", "", "", "", "", "", ""}); Costs = SBStringUtils.myNF.format(myRecipe.getTotalHopsCost()); tblHopsTotalsModel.setDataVector(new String[][]{{"Totals:", "", "", "" + SBStringUtils.df1.format(myRecipe.getTotalHops()), myRecipe.getHopUnits(), "", "", "" + SBStringUtils.df1.format(myRecipe.getIbu()), Costs}}, new String[]{"", "", "", "", "", "", "", "", ""}); String fileName = "not saved"; if (currentFile != null) { fileName = currentFile.getName(); } fileNameLabel.setText("File: " + fileName); ibuMethodLabel.setText("IBU method: " + myRecipe.getIBUMethod()); alcMethodLabel.setText("Alc method: " + myRecipe.getAlcMethod()); if (preferences.getProperty("optRGBMethod").equals("1")) colourPanel.setBackground(Recipe.calcRGB(1, myRecipe.getSrm(), preferences.getIProperty("optRed"), preferences.getIProperty("optGreen"), preferences.getIProperty("optBlue"), preferences.getIProperty("optAlpha"))); else colourPanel.setBackground(Recipe.calcRGB(2, myRecipe.getSrm(), preferences.getIProperty("optRed"), preferences.getIProperty("optGreen"), preferences.getIProperty("optBlue"), preferences.getIProperty("optAlpha"))); stylePanel.setStyleData(); costPanel.displayCost(); } |
colourPanel.setBackground(Recipe.calcRGB(2, myRecipe.getSrm(), | colourPanel.setBackground(Recipe.calcRGB(2, colour, | public void displayRecipe() { if (myRecipe == null) return; txtName.setText(myRecipe.getName()); brewerNameText.setText(myRecipe.getBrewer()); txtPreBoil.setValue(new Double(myRecipe.getPreBoilVol(myRecipe.getVolUnits()))); lblSizeUnits.setText(myRecipe.getVolUnits()); postBoilText.setValue(new Double(myRecipe.getPostBoilVol(myRecipe.getVolUnits()))); boilMinText.setText(SBStringUtils.df0.format(myRecipe.getBoilMinutes())); evapText.setText(SBStringUtils.df1.format(myRecipe.getEvap())); spnEffic.setValue(new Double(myRecipe.getEfficiency())); spnAtten.setValue(new Double(myRecipe.getAttenuation())); spnOG.setValue(new Double(myRecipe.getEstOg())); spnFG.setValue(new Double(myRecipe.getEstFg())); txtComments.setText(myRecipe.getComments()); lblIBUvalue.setText(SBStringUtils.df1.format(myRecipe.getIbu())); lblColourValue.setText(SBStringUtils.df1.format(myRecipe.getSrm())); lblAlcValue.setText(SBStringUtils.df1.format(myRecipe.getAlcohol())); txtDate.setText(dateFormat1.format(myRecipe.getCreated().getTime())); Costs = SBStringUtils.myNF.format(myRecipe.getTotalMaltCost()); tblMaltTotalsModel.setDataVector(new String[][]{{"Totals:", "" + SBStringUtils.df1.format(myRecipe.getTotalMalt()), myRecipe.getMaltUnits(), "" + SBStringUtils.df3.format(myRecipe.getEstOg()), "" + SBStringUtils.df1.format(myRecipe.getSrm()), Costs, "100"}}, new String[]{"", "", "", "", "", "", ""}); Costs = SBStringUtils.myNF.format(myRecipe.getTotalHopsCost()); tblHopsTotalsModel.setDataVector(new String[][]{{"Totals:", "", "", "" + SBStringUtils.df1.format(myRecipe.getTotalHops()), myRecipe.getHopUnits(), "", "", "" + SBStringUtils.df1.format(myRecipe.getIbu()), Costs}}, new String[]{"", "", "", "", "", "", "", "", ""}); String fileName = "not saved"; if (currentFile != null) { fileName = currentFile.getName(); } fileNameLabel.setText("File: " + fileName); ibuMethodLabel.setText("IBU method: " + myRecipe.getIBUMethod()); alcMethodLabel.setText("Alc method: " + myRecipe.getAlcMethod()); if (preferences.getProperty("optRGBMethod").equals("1")) colourPanel.setBackground(Recipe.calcRGB(1, myRecipe.getSrm(), preferences.getIProperty("optRed"), preferences.getIProperty("optGreen"), preferences.getIProperty("optBlue"), preferences.getIProperty("optAlpha"))); else colourPanel.setBackground(Recipe.calcRGB(2, myRecipe.getSrm(), preferences.getIProperty("optRed"), preferences.getIProperty("optGreen"), preferences.getIProperty("optBlue"), preferences.getIProperty("optAlpha"))); stylePanel.setStyleData(); costPanel.displayCost(); } |
exploreFileBtn.setIcon( iconPack.getIcon("Download.Overview.Explore") ); | if ( exploreFileBtn != null ) { exploreFileBtn.setIcon( iconPack.getIcon("Download.Overview.Explore") ); } | private void setupIcons() { IconPack iconPack = GUIRegistry.getInstance().getPlafIconPack(); defProgressIcon = iconPack.getIcon( "Download.Overview.Progress" ); twinkleProgressIcon = iconPack.getIcon( "Download.Overview.ProgressAni" ); progressIconLabel.setIcon( defProgressIcon ); exploreFileBtn.setIcon( iconPack.getIcon("Download.Overview.Explore") ); } |
return success(); | return error(); | public Event nonUnique(RequestContext context) { IdentityForm form = doGetForm(context); //TODO non unique identity return success(); } |
symTab = null; | public EvaluatorVisitor() { debug = false; errorList = null; stack = new Stack(); } |
|
public Object getValue(Node topNode, Vector errorList_in, SymbolTable symTab_in) throws Exception { | public Object getValue(Node topNode, Vector errorList_in, SymbolTable symTab_in) throws Exception { if (topNode == null) { throw new IllegalArgumentException( "topNode parameter is null"); } if (symTab_in == null) { throw new IllegalArgumentException( "symTab_in parameter is null"); } | public Object getValue(Node topNode, Vector errorList_in, SymbolTable symTab_in) throws Exception { errorList = errorList_in; symTab = symTab_in; if (topNode == null) { throw new Exception( "EvaluatorVisitor.getValue(): topNode parameter is null"); } errorFlag = false; // evaluate by letting the top node accept the visitor topNode.jjtAccept(this, null); // something is wrong if not exactly one item remains on the stack // or if the error flag has been set if (errorFlag || stack.size() != 1) { throw new Exception( "EvaluatorVisitor.getValue(): Error during evaluation"); } // return the value of the expression return stack.pop(); } |
if (topNode == null) { throw new Exception( "EvaluatorVisitor.getValue(): topNode parameter is null"); } | errorFlag = false; | public Object getValue(Node topNode, Vector errorList_in, SymbolTable symTab_in) throws Exception { errorList = errorList_in; symTab = symTab_in; if (topNode == null) { throw new Exception( "EvaluatorVisitor.getValue(): topNode parameter is null"); } errorFlag = false; // evaluate by letting the top node accept the visitor topNode.jjtAccept(this, null); // something is wrong if not exactly one item remains on the stack // or if the error flag has been set if (errorFlag || stack.size() != 1) { throw new Exception( "EvaluatorVisitor.getValue(): Error during evaluation"); } // return the value of the expression return stack.pop(); } |
errorFlag = false; | public Object getValue(Node topNode, Vector errorList_in, SymbolTable symTab_in) throws Exception { errorList = errorList_in; symTab = symTab_in; if (topNode == null) { throw new Exception( "EvaluatorVisitor.getValue(): topNode parameter is null"); } errorFlag = false; // evaluate by letting the top node accept the visitor topNode.jjtAccept(this, null); // something is wrong if not exactly one item remains on the stack // or if the error flag has been set if (errorFlag || stack.size() != 1) { throw new Exception( "EvaluatorVisitor.getValue(): Error during evaluation"); } // return the value of the expression return stack.pop(); } |
|
public QueryResponseMsg( MsgHeader header, byte[] aBody ) throws InvalidMessageException | public QueryResponseMsg( MsgHeader header, GUID clientID, DestAddress aHostAddress, int speed, QueryResponseRecord records[] ) | public QueryResponseMsg( MsgHeader header, byte[] aBody ) throws InvalidMessageException { super( header ); getHeader().setPayloadType(MsgHeader.QUERY_HIT_PAYLOAD); body = aBody; header.setDataLength( body.length ); // validate port int port = IOUtil.unsignedShort2Int( IOUtil.deserializeShortLE( body, 1 ) ); destAddress = new DefaultDestAddress( getHostIP(), port ); if ( !destAddress.isValidAddress() ) { throw new InvalidMessageException( "Invalid address: " + destAddress ); } isParsed = false; } |
body = aBody; header.setDataLength( body.length ); | remoteClientID = clientID; destAddress = aHostAddress; remoteHostSpeed = speed; this.records = records; | public QueryResponseMsg( MsgHeader header, byte[] aBody ) throws InvalidMessageException { super( header ); getHeader().setPayloadType(MsgHeader.QUERY_HIT_PAYLOAD); body = aBody; header.setDataLength( body.length ); // validate port int port = IOUtil.unsignedShort2Int( IOUtil.deserializeShortLE( body, 1 ) ); destAddress = new DefaultDestAddress( getHostIP(), port ); if ( !destAddress.isValidAddress() ) { throw new InvalidMessageException( "Invalid address: " + destAddress ); } isParsed = false; } |
int port = IOUtil.unsignedShort2Int( IOUtil.deserializeShortLE( body, 1 ) ); destAddress = new DefaultDestAddress( getHostIP(), port ); if ( !destAddress.isValidAddress() ) | pushProxyAddresses = HostManager.getInstance(). getNetworkHostsContainer().getPushProxies(); boolean isPushNeeded; if ( NetworkManager.getInstance().hasConnectedIncoming() ) | public QueryResponseMsg( MsgHeader header, byte[] aBody ) throws InvalidMessageException { super( header ); getHeader().setPayloadType(MsgHeader.QUERY_HIT_PAYLOAD); body = aBody; header.setDataLength( body.length ); // validate port int port = IOUtil.unsignedShort2Int( IOUtil.deserializeShortLE( body, 1 ) ); destAddress = new DefaultDestAddress( getHostIP(), port ); if ( !destAddress.isValidAddress() ) { throw new InvalidMessageException( "Invalid address: " + destAddress ); } isParsed = false; } |
throw new InvalidMessageException( "Invalid address: " + destAddress ); | isPushNeeded = false; pushNeededFlag = QHD_FALSE_FLAG; | public QueryResponseMsg( MsgHeader header, byte[] aBody ) throws InvalidMessageException { super( header ); getHeader().setPayloadType(MsgHeader.QUERY_HIT_PAYLOAD); body = aBody; header.setDataLength( body.length ); // validate port int port = IOUtil.unsignedShort2Int( IOUtil.deserializeShortLE( body, 1 ) ); destAddress = new DefaultDestAddress( getHostIP(), port ); if ( !destAddress.isValidAddress() ) { throw new InvalidMessageException( "Invalid address: " + destAddress ); } isParsed = false; } |
isParsed = false; | else { isPushNeeded = true; pushNeededFlag = QHD_TRUE_FLAG; } boolean isServerBusy = UploadManager.getInstance().isHostBusy(); try { buildBody( isPushNeeded, isServerBusy ); } catch (IOException e) { NLogger.error(NLoggerNames.MESSAGE_ENCODE_DECODE, e, e); } getHeader().setDataLength( body.length ); isParsed = true; | public QueryResponseMsg( MsgHeader header, byte[] aBody ) throws InvalidMessageException { super( header ); getHeader().setPayloadType(MsgHeader.QUERY_HIT_PAYLOAD); body = aBody; header.setDataLength( body.length ); // validate port int port = IOUtil.unsignedShort2Int( IOUtil.deserializeShortLE( body, 1 ) ); destAddress = new DefaultDestAddress( getHostIP(), port ); if ( !destAddress.isValidAddress() ) { throw new InvalidMessageException( "Invalid address: " + destAddress ); } isParsed = false; } |
public boolean mkdirs() { return local.mkdirs(); | public void mkdirs() throws IOException { if(!local.mkdirs()) throw new IOException("Failed to mkdirs: "+local); | public boolean mkdirs() { return local.mkdirs(); } |
if ((param1 instanceof Complex) && (param2 instanceof Complex)) | Object res=null; switch(id) | public void run(Stack inStack) throws ParseException { checkStack(inStack);// check the stack Object param2 = inStack.pop(); Object param1 = inStack.pop(); if ((param1 instanceof Complex) && (param2 instanceof Complex)) { int r; switch (id) { case NE: r = ((Complex)param1).equals((Complex)param2,tolerance) ? 0 : 1; break; case EQ: r = ((Complex)param1).equals((Complex)param2,tolerance) ? 1 : 0; break; default: throw new ParseException("Relational operator type error"); } inStack.push(new Double(r));//push the result on the inStack } else if ((param1 instanceof Number) && (param2 instanceof Number)) { double x = ((Number)param1).doubleValue(); double y = ((Number)param2).doubleValue(); int r; switch (id) { case LT: r = (x<y) ? 1 : 0; break; case GT: r = (x>y) ? 1 : 0; break; case LE: r = (x<=y) ? 1 : 0; break; case GE: r = (x>=y) ? 1 : 0; break; case NE: r = (x!=y) ? 1 : 0; break; case EQ: r = (x==y) ? 1 : 0; break; default: throw new ParseException("Unknown relational operator"); } inStack.push(new Double(r));//push the result on the inStack } else if ((param1 instanceof String) && (param2 instanceof String)) { int r; switch (id) { case NE: r = ((String)param1).equals((String)param2) ? 0 : 1; break; case EQ: r = ((String)param1).equals((String)param2) ? 1 : 0; break; default: throw new ParseException("Relational operator type error"); } inStack.push(new Double(r));//push the result on the inStack } else { throw new ParseException("Invalid parameter type"); } return; } |
int r; switch (id) { case NE: r = ((Complex)param1).equals((Complex)param2,tolerance) ? 0 : 1; break; case EQ: r = ((Complex)param1).equals((Complex)param2,tolerance) ? 1 : 0; break; default: throw new ParseException("Relational operator type error"); } inStack.push(new Double(r)); | case LT: res = lt(param1,param2); break; case GT: res = gt(param1,param2); break; case LE: res = le(param1,param2); break; case GE: res = ge(param1,param2); break; case NE: res = ne(param1,param2); break; case EQ: res = eq(param1,param2); break; | public void run(Stack inStack) throws ParseException { checkStack(inStack);// check the stack Object param2 = inStack.pop(); Object param1 = inStack.pop(); if ((param1 instanceof Complex) && (param2 instanceof Complex)) { int r; switch (id) { case NE: r = ((Complex)param1).equals((Complex)param2,tolerance) ? 0 : 1; break; case EQ: r = ((Complex)param1).equals((Complex)param2,tolerance) ? 1 : 0; break; default: throw new ParseException("Relational operator type error"); } inStack.push(new Double(r));//push the result on the inStack } else if ((param1 instanceof Number) && (param2 instanceof Number)) { double x = ((Number)param1).doubleValue(); double y = ((Number)param2).doubleValue(); int r; switch (id) { case LT: r = (x<y) ? 1 : 0; break; case GT: r = (x>y) ? 1 : 0; break; case LE: r = (x<=y) ? 1 : 0; break; case GE: r = (x>=y) ? 1 : 0; break; case NE: r = (x!=y) ? 1 : 0; break; case EQ: r = (x==y) ? 1 : 0; break; default: throw new ParseException("Unknown relational operator"); } inStack.push(new Double(r));//push the result on the inStack } else if ((param1 instanceof String) && (param2 instanceof String)) { int r; switch (id) { case NE: r = ((String)param1).equals((String)param2) ? 0 : 1; break; case EQ: r = ((String)param1).equals((String)param2) ? 1 : 0; break; default: throw new ParseException("Relational operator type error"); } inStack.push(new Double(r));//push the result on the inStack } else { throw new ParseException("Invalid parameter type"); } return; } |
else if ((param1 instanceof Number) && (param2 instanceof Number)) { double x = ((Number)param1).doubleValue(); double y = ((Number)param2).doubleValue(); int r; switch (id) { case LT: r = (x<y) ? 1 : 0; break; case GT: r = (x>y) ? 1 : 0; break; case LE: r = (x<=y) ? 1 : 0; break; case GE: r = (x>=y) ? 1 : 0; break; case NE: r = (x!=y) ? 1 : 0; break; case EQ: r = (x==y) ? 1 : 0; break; default: throw new ParseException("Unknown relational operator"); } inStack.push(new Double(r)); } else if ((param1 instanceof String) && (param2 instanceof String)) { int r; switch (id) { case NE: r = ((String)param1).equals((String)param2) ? 0 : 1; break; case EQ: r = ((String)param1).equals((String)param2) ? 1 : 0; break; default: throw new ParseException("Relational operator type error"); } inStack.push(new Double(r)); } else { throw new ParseException("Invalid parameter type"); } return; | inStack.push(res); | public void run(Stack inStack) throws ParseException { checkStack(inStack);// check the stack Object param2 = inStack.pop(); Object param1 = inStack.pop(); if ((param1 instanceof Complex) && (param2 instanceof Complex)) { int r; switch (id) { case NE: r = ((Complex)param1).equals((Complex)param2,tolerance) ? 0 : 1; break; case EQ: r = ((Complex)param1).equals((Complex)param2,tolerance) ? 1 : 0; break; default: throw new ParseException("Relational operator type error"); } inStack.push(new Double(r));//push the result on the inStack } else if ((param1 instanceof Number) && (param2 instanceof Number)) { double x = ((Number)param1).doubleValue(); double y = ((Number)param2).doubleValue(); int r; switch (id) { case LT: r = (x<y) ? 1 : 0; break; case GT: r = (x>y) ? 1 : 0; break; case LE: r = (x<=y) ? 1 : 0; break; case GE: r = (x>=y) ? 1 : 0; break; case NE: r = (x!=y) ? 1 : 0; break; case EQ: r = (x==y) ? 1 : 0; break; default: throw new ParseException("Unknown relational operator"); } inStack.push(new Double(r));//push the result on the inStack } else if ((param1 instanceof String) && (param2 instanceof String)) { int r; switch (id) { case NE: r = ((String)param1).equals((String)param2) ? 0 : 1; break; case EQ: r = ((String)param1).equals((String)param2) ? 1 : 0; break; default: throw new ParseException("Relational operator type error"); } inStack.push(new Double(r));//push the result on the inStack } else { throw new ParseException("Invalid parameter type"); } return; } |
public synchronized SeismogramIterator getIterator(MicroSecondTimeRange timeRange){ if(softIterator != null){ SeismogramIterator it = (SeismogramIterator)softIterator.get(); if(!changed && it != null){ if(it.getTimeRange().equals(timeRange)){ return it; }else if(timeRange != null){ it.setTimeRange(timeRange); return it; } } } changed = false; SeismogramIterator it = new SeismogramIterator(seismogram.getName(), getSeismograms(), timeRange); softIterator = new SoftReference(it); return it; | public synchronized SeismogramIterator getIterator(){ return getIterator(DisplayUtils.getFullTime(getSeismograms())); | public synchronized SeismogramIterator getIterator(MicroSecondTimeRange timeRange){ //logger.debug("Getting Iterator"); if(softIterator != null){ SeismogramIterator it = (SeismogramIterator)softIterator.get(); if(!changed && it != null){ if(it.getTimeRange().equals(timeRange)){ return it; }else if(timeRange != null){ it.setTimeRange(timeRange); return it; } } } changed = false; SeismogramIterator it = new SeismogramIterator(seismogram.getName(), getSeismograms(), timeRange); softIterator = new SoftReference(it); return it; } |
return new Double(SBStringUtils.df1.format(data .getMaltAmountAs(row, data.getMaltUnits(row)))); | return SBStringUtils.df1.format(data .getMaltAmountAs(row, data.getMaltUnits(row))); | public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : return data.getMaltName(row); case 1 : return new Double(SBStringUtils.df1.format(data .getMaltAmountAs(row, data.getMaltUnits(row)))); case 2 : return data.getMaltUnits(row); case 3 : return new Double(SBStringUtils.df3.format(data.getMaltPppg(row))); case 4 : return new Double(SBStringUtils.df0.format(data.getMaltLov(row))); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.df1.format(new Double(data.getMaltPercent(row))); } } catch (Exception e) { }; return ""; } |
return new Double(SBStringUtils.df3.format(data.getMaltPppg(row))); | return SBStringUtils.df3.format(data.getMaltPppg(row)); | public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : return data.getMaltName(row); case 1 : return new Double(SBStringUtils.df1.format(data .getMaltAmountAs(row, data.getMaltUnits(row)))); case 2 : return data.getMaltUnits(row); case 3 : return new Double(SBStringUtils.df3.format(data.getMaltPppg(row))); case 4 : return new Double(SBStringUtils.df0.format(data.getMaltLov(row))); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.df1.format(new Double(data.getMaltPercent(row))); } } catch (Exception e) { }; return ""; } |
return new Double(SBStringUtils.df0.format(data.getMaltLov(row))); | return SBStringUtils.df0.format(data.getMaltLov(row)); | public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : return data.getMaltName(row); case 1 : return new Double(SBStringUtils.df1.format(data .getMaltAmountAs(row, data.getMaltUnits(row)))); case 2 : return data.getMaltUnits(row); case 3 : return new Double(SBStringUtils.df3.format(data.getMaltPppg(row))); case 4 : return new Double(SBStringUtils.df0.format(data.getMaltLov(row))); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.df1.format(new Double(data.getMaltPercent(row))); } } catch (Exception e) { }; return ""; } |
QueryResponseRecord rec; ArrayList newHitList = new ArrayList( ); int recordCount = msg.getRecordCount(); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); | QueryResponseRecord[] records = msg.getMsgRecords(); ArrayList<RemoteFile> newHitList = new ArrayList<RemoteFile>( records.length ); for (int i = 0; i < records.length; i++) { | public void processResponse( QueryResponseMsg msg ) { SwarmingManager swarmingMgr = SwarmingManager.getInstance(); long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; ArrayList newHitList = new ArrayList( ); int recordCount = msg.getRecordCount(); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); if( ServiceManager.sCfg.enableHitSnooping ) { snoopDownloadCandidates( swarmingMgr, qhHost, rec ); } if ( searchFilter != null ) { monitorPassiveSearch( qhHost, rec, newHitList ); } } // for // if something was added... if ( newHitList.size() > 0 ) { RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } } |
snoopDownloadCandidates( swarmingMgr, qhHost, rec ); | snoopDownloadCandidates( swarmingMgr, qhHost, records[i] ); | public void processResponse( QueryResponseMsg msg ) { SwarmingManager swarmingMgr = SwarmingManager.getInstance(); long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; ArrayList newHitList = new ArrayList( ); int recordCount = msg.getRecordCount(); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); if( ServiceManager.sCfg.enableHitSnooping ) { snoopDownloadCandidates( swarmingMgr, qhHost, rec ); } if ( searchFilter != null ) { monitorPassiveSearch( qhHost, rec, newHitList ); } } // for // if something was added... if ( newHitList.size() > 0 ) { RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } } |
monitorPassiveSearch( qhHost, rec, newHitList ); | monitorPassiveSearch( qhHost, records[i], newHitList ); | public void processResponse( QueryResponseMsg msg ) { SwarmingManager swarmingMgr = SwarmingManager.getInstance(); long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; ArrayList newHitList = new ArrayList( ); int recordCount = msg.getRecordCount(); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); if( ServiceManager.sCfg.enableHitSnooping ) { snoopDownloadCandidates( swarmingMgr, qhHost, rec ); } if ( searchFilter != null ) { monitorPassiveSearch( qhHost, rec, newHitList ); } } // for // if something was added... if ( newHitList.size() > 0 ) { RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } } |
if (param1 instanceof Number) | if (param1 instanceof Complex) | public Object mul(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return mul((Number)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param2, (Number)param1); else if (param2 instanceof Vector) return mul((Vector)param2, (Number)param1); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return mul((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return mul((Vector)param2, (Complex)param1); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return mul((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); } |
if (param2 instanceof Number) return mul((Number)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param2, (Number)param1); else if (param2 instanceof Vector) return mul((Vector)param2, (Number)param1); } else if (param1 instanceof Complex) { if (param2 instanceof Number) | if (param2 instanceof Complex) return mul((Complex)param1, (Complex)param2); else if (param2 instanceof Number) | public Object mul(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return mul((Number)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param2, (Number)param1); else if (param2 instanceof Vector) return mul((Vector)param2, (Number)param1); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return mul((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return mul((Vector)param2, (Complex)param1); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return mul((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); } |
else if (param2 instanceof Complex) return mul((Complex)param1, (Complex)param2); | public Object mul(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return mul((Number)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param2, (Number)param1); else if (param2 instanceof Vector) return mul((Vector)param2, (Number)param1); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return mul((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return mul((Vector)param2, (Complex)param1); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return mul((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); } |
|
if (param2 instanceof Number) | if (param2 instanceof Complex) return mul((Vector)param1, (Complex)param2); else if (param2 instanceof Number) | public Object mul(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return mul((Number)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param2, (Number)param1); else if (param2 instanceof Vector) return mul((Vector)param2, (Number)param1); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return mul((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return mul((Vector)param2, (Complex)param1); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return mul((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); } |
else if (param2 instanceof Complex) return mul((Vector)param1, (Complex)param2); | public Object mul(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return mul((Number)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param2, (Number)param1); else if (param2 instanceof Vector) return mul((Vector)param2, (Number)param1); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return mul((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return mul((Vector)param2, (Complex)param1); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return mul((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return mul((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); } |
|
public SWDownloadCandidate(DestAddress address, URI downloadUri, SWDownloadFile file) throws URIException | public SWDownloadCandidate( RemoteFile remoteFile, SWDownloadFile aDownloadFile ) | public SWDownloadCandidate(DestAddress address, URI downloadUri, SWDownloadFile file) throws URIException { availableScopeList = null; downloadFile = file; fileName = URLUtil.getPathQueryFromUri( downloadUri ); this.downloadURI = downloadUri; resourceURN = URLUtil.getQueryURN( downloadUri ); guid = null; vendor = null; isPushNeeded = false; // assume chat is supported but we dont know... isChatSupported = true; hostAddress = address; status = CandidateStatus.WAITING; lastTransferRateBPS = 0; totalDownloadSize = 0; lastConnectionTime = 0; } |
downloadFile = file; fileName = URLUtil.getPathQueryFromUri( downloadUri ); this.downloadURI = downloadUri; resourceURN = URLUtil.getQueryURN( downloadUri ); guid = null; vendor = null; isPushNeeded = false; isChatSupported = true; hostAddress = address; | downloadFile = aDownloadFile; fileIndex = remoteFile.getFileIndex(); fileName = remoteFile.getFilename(); resourceURN = remoteFile.getURN(); guid = remoteFile.getRemoteClientID(); QueryHitHost qhHost = remoteFile.getQueryHitHost(); vendor = qhHost.getVendor(); isPushNeeded = qhHost.isPushNeeded(); hostAddress = remoteFile.getHostAddress(); isChatSupported = qhHost.isChatSupported(); pushProxyAddresses = qhHost.getPushProxyAddresses(); | public SWDownloadCandidate(DestAddress address, URI downloadUri, SWDownloadFile file) throws URIException { availableScopeList = null; downloadFile = file; fileName = URLUtil.getPathQueryFromUri( downloadUri ); this.downloadURI = downloadUri; resourceURN = URLUtil.getQueryURN( downloadUri ); guid = null; vendor = null; isPushNeeded = false; // assume chat is supported but we dont know... isChatSupported = true; hostAddress = address; status = CandidateStatus.WAITING; lastTransferRateBPS = 0; totalDownloadSize = 0; lastConnectionTime = 0; } |
Object getService() { | Object getService(Object bindObject) { | Object getService() { synchronized (tracking) { if (tracking.isEmpty()) { return null; } return getService((ServiceReference) tracking.get(0)); } } |
return getService((ServiceReference) tracking.get(0)); | return getService(bindObject, (ServiceReference) tracking.get(0)); | Object getService() { synchronized (tracking) { if (tracking.isEmpty()) { return null; } return getService((ServiceReference) tracking.get(0)); } } |
if (cached != null) { objects.put(ref, cached); | } else { Object tmp = ref.getProperty(Constants.SERVICE_RANKING); int refInt = (tmp instanceof Integer) ? ((Integer) tmp) .intValue() : 0; Long refId = (Long) ref.getProperty(Constants.SERVICE_ID); int i = 0; for (int n = tracking.size(); i < n; i++) { ServiceReference challenger = (ServiceReference) tracking .get(i); tmp = challenger.getProperty(Constants.SERVICE_RANKING); int challengerInt = (tmp instanceof Integer) ? ((Integer) tmp) .intValue() : 0; if (challengerInt < refInt) { break; } else if (challengerInt == refInt) { Long challengerId = (Long) challenger .getProperty(Constants.SERVICE_ID); if (refId.compareTo(challengerId) < 0) { break; } } | private void includeService(ServiceReference ref, Object cached) { synchronized (tracking) { if (tracking.isEmpty()) { tracking.add(0, ref); if (cached != null) { objects.put(ref, cached); } return; } Object tmp = ref.getProperty(Constants.SERVICE_RANKING); int refInt = (tmp instanceof Integer) ? ((Integer) tmp).intValue() : 0; Long refId = (Long) ref.getProperty(Constants.SERVICE_ID); int i = 0; for (int n = tracking.size(); i < n; i++) { ServiceReference challenger = (ServiceReference) tracking .get(i); tmp = challenger.getProperty(Constants.SERVICE_RANKING); int challengerInt = (tmp instanceof Integer) ? ((Integer) tmp) .intValue() : 0; if (challengerInt < refInt) { break; } else if (challengerInt == refInt) { Long challengerId = (Long) challenger .getProperty(Constants.SERVICE_ID); if (refId.compareTo(challengerId) < 0) { break; } } } tracking.add(i, ref); objects.put(ref, cached); } } |
return; | tracking.add(i, ref); | private void includeService(ServiceReference ref, Object cached) { synchronized (tracking) { if (tracking.isEmpty()) { tracking.add(0, ref); if (cached != null) { objects.put(ref, cached); } return; } Object tmp = ref.getProperty(Constants.SERVICE_RANKING); int refInt = (tmp instanceof Integer) ? ((Integer) tmp).intValue() : 0; Long refId = (Long) ref.getProperty(Constants.SERVICE_ID); int i = 0; for (int n = tracking.size(); i < n; i++) { ServiceReference challenger = (ServiceReference) tracking .get(i); tmp = challenger.getProperty(Constants.SERVICE_RANKING); int challengerInt = (tmp instanceof Integer) ? ((Integer) tmp) .intValue() : 0; if (challengerInt < refInt) { break; } else if (challengerInt == refInt) { Long challengerId = (Long) challenger .getProperty(Constants.SERVICE_ID); if (refId.compareTo(challengerId) < 0) { break; } } } tracking.add(i, ref); objects.put(ref, cached); } } |
Object tmp = ref.getProperty(Constants.SERVICE_RANKING); int refInt = (tmp instanceof Integer) ? ((Integer) tmp).intValue() : 0; Long refId = (Long) ref.getProperty(Constants.SERVICE_ID); int i = 0; for (int n = tracking.size(); i < n; i++) { ServiceReference challenger = (ServiceReference) tracking .get(i); tmp = challenger.getProperty(Constants.SERVICE_RANKING); int challengerInt = (tmp instanceof Integer) ? ((Integer) tmp) .intValue() : 0; if (challengerInt < refInt) { break; } else if (challengerInt == refInt) { Long challengerId = (Long) challenger .getProperty(Constants.SERVICE_ID); if (refId.compareTo(challengerId) < 0) { break; } } | if (cached != null) { objects.put(ref, cached); | private void includeService(ServiceReference ref, Object cached) { synchronized (tracking) { if (tracking.isEmpty()) { tracking.add(0, ref); if (cached != null) { objects.put(ref, cached); } return; } Object tmp = ref.getProperty(Constants.SERVICE_RANKING); int refInt = (tmp instanceof Integer) ? ((Integer) tmp).intValue() : 0; Long refId = (Long) ref.getProperty(Constants.SERVICE_ID); int i = 0; for (int n = tracking.size(); i < n; i++) { ServiceReference challenger = (ServiceReference) tracking .get(i); tmp = challenger.getProperty(Constants.SERVICE_RANKING); int challengerInt = (tmp instanceof Integer) ? ((Integer) tmp) .intValue() : 0; if (challengerInt < refInt) { break; } else if (challengerInt == refInt) { Long challengerId = (Long) challenger .getProperty(Constants.SERVICE_ID); if (refId.compareTo(challengerId) < 0) { break; } } } tracking.add(i, ref); objects.put(ref, cached); } } |
tracking.add(i, ref); objects.put(ref, cached); | private void includeService(ServiceReference ref, Object cached) { synchronized (tracking) { if (tracking.isEmpty()) { tracking.add(0, ref); if (cached != null) { objects.put(ref, cached); } return; } Object tmp = ref.getProperty(Constants.SERVICE_RANKING); int refInt = (tmp instanceof Integer) ? ((Integer) tmp).intValue() : 0; Long refId = (Long) ref.getProperty(Constants.SERVICE_ID); int i = 0; for (int n = tracking.size(); i < n; i++) { ServiceReference challenger = (ServiceReference) tracking .get(i); tmp = challenger.getProperty(Constants.SERVICE_RANKING); int challengerInt = (tmp instanceof Integer) ? ((Integer) tmp) .intValue() : 0; if (challengerInt < refInt) { break; } else if (challengerInt == refInt) { Long challengerId = (Long) challenger .getProperty(Constants.SERVICE_ID); if (refId.compareTo(challengerId) < 0) { break; } } } tracking.add(i, ref); objects.put(ref, cached); } } |
|
.getProperty(org.bamja.core.impl.Constants.DUPLEX_REFERENCE); | .getProperty(org.bamja.core.impl.Constants.DUPLEX_REFERENCES); | public void serviceChanged(ServiceEvent event) { ServiceReference ref = event.getServiceReference(); ArrayList<DuplexReference> duplexRefList = (ArrayList) ref .getProperty(org.bamja.core.impl.Constants.DUPLEX_REFERENCE); if (duplexRefList != null) { Class implClass = this.config.getImplementationClass(); ArrayList<String> classes = new ArrayList<String>(); for (Class superClass = implClass; superClass != null; superClass = superClass .getSuperclass()) { classes.add(superClass.getName()); } for (Class c : implClass.getInterfaces()) { classes.add(c.getName()); } for (DuplexReference duplexRef : duplexRefList) { if (!classes.contains(duplexRef.getInterfaceName()) && !duplexRef.isOptional()) { return; } } } switch (event.getType()) { case ServiceEvent.REGISTERED: { Object cache = null; try { cache = addingService(ref); } catch (Throwable e) { } includeService(ref, cache); addedService(ref, cache); // Should be safe to throw the exception } break; case ServiceEvent.UNREGISTERING: { synchronized (tracking) { if (!tracking.contains(ref)) { // in this case we have removed this reference from the // tracker. return; } } Object object = objects.get(ref); try { removingService(ref, object); } catch (Throwable ignored) { } excludeService(ref); removedService(ref, object); } } } |
ArrayList<String> classes = new ArrayList<String>(); | if (implClass == null) return; ArrayList<String> allClassnames = new ArrayList<String>(); | public void serviceChanged(ServiceEvent event) { ServiceReference ref = event.getServiceReference(); ArrayList<DuplexReference> duplexRefList = (ArrayList) ref .getProperty(org.bamja.core.impl.Constants.DUPLEX_REFERENCE); if (duplexRefList != null) { Class implClass = this.config.getImplementationClass(); ArrayList<String> classes = new ArrayList<String>(); for (Class superClass = implClass; superClass != null; superClass = superClass .getSuperclass()) { classes.add(superClass.getName()); } for (Class c : implClass.getInterfaces()) { classes.add(c.getName()); } for (DuplexReference duplexRef : duplexRefList) { if (!classes.contains(duplexRef.getInterfaceName()) && !duplexRef.isOptional()) { return; } } } switch (event.getType()) { case ServiceEvent.REGISTERED: { Object cache = null; try { cache = addingService(ref); } catch (Throwable e) { } includeService(ref, cache); addedService(ref, cache); // Should be safe to throw the exception } break; case ServiceEvent.UNREGISTERING: { synchronized (tracking) { if (!tracking.contains(ref)) { // in this case we have removed this reference from the // tracker. return; } } Object object = objects.get(ref); try { removingService(ref, object); } catch (Throwable ignored) { } excludeService(ref); removedService(ref, object); } } } |
classes.add(superClass.getName()); } for (Class c : implClass.getInterfaces()) { classes.add(c.getName()); | allClassnames.add(superClass.getName()); scanInterfaces(superClass, allClassnames); | public void serviceChanged(ServiceEvent event) { ServiceReference ref = event.getServiceReference(); ArrayList<DuplexReference> duplexRefList = (ArrayList) ref .getProperty(org.bamja.core.impl.Constants.DUPLEX_REFERENCE); if (duplexRefList != null) { Class implClass = this.config.getImplementationClass(); ArrayList<String> classes = new ArrayList<String>(); for (Class superClass = implClass; superClass != null; superClass = superClass .getSuperclass()) { classes.add(superClass.getName()); } for (Class c : implClass.getInterfaces()) { classes.add(c.getName()); } for (DuplexReference duplexRef : duplexRefList) { if (!classes.contains(duplexRef.getInterfaceName()) && !duplexRef.isOptional()) { return; } } } switch (event.getType()) { case ServiceEvent.REGISTERED: { Object cache = null; try { cache = addingService(ref); } catch (Throwable e) { } includeService(ref, cache); addedService(ref, cache); // Should be safe to throw the exception } break; case ServiceEvent.UNREGISTERING: { synchronized (tracking) { if (!tracking.contains(ref)) { // in this case we have removed this reference from the // tracker. return; } } Object object = objects.get(ref); try { removingService(ref, object); } catch (Throwable ignored) { } excludeService(ref); removedService(ref, object); } } } |
if (!classes.contains(duplexRef.getInterfaceName()) | if (!allClassnames.contains(duplexRef.getInterfaceName()) | public void serviceChanged(ServiceEvent event) { ServiceReference ref = event.getServiceReference(); ArrayList<DuplexReference> duplexRefList = (ArrayList) ref .getProperty(org.bamja.core.impl.Constants.DUPLEX_REFERENCE); if (duplexRefList != null) { Class implClass = this.config.getImplementationClass(); ArrayList<String> classes = new ArrayList<String>(); for (Class superClass = implClass; superClass != null; superClass = superClass .getSuperclass()) { classes.add(superClass.getName()); } for (Class c : implClass.getInterfaces()) { classes.add(c.getName()); } for (DuplexReference duplexRef : duplexRefList) { if (!classes.contains(duplexRef.getInterfaceName()) && !duplexRef.isOptional()) { return; } } } switch (event.getType()) { case ServiceEvent.REGISTERED: { Object cache = null; try { cache = addingService(ref); } catch (Throwable e) { } includeService(ref, cache); addedService(ref, cache); // Should be safe to throw the exception } break; case ServiceEvent.UNREGISTERING: { synchronized (tracking) { if (!tracking.contains(ref)) { // in this case we have removed this reference from the // tracker. return; } } Object object = objects.get(ref); try { removingService(ref, object); } catch (Throwable ignored) { } excludeService(ref); removedService(ref, object); } } } |
for (Project p : blockedProjects) { | Iterator<Project> itr = blockedProjects.iterator(); while(itr.hasNext()) { Project p = itr.next(); | private synchronized void maintain() { for (Project p : blockedProjects) { Build lastBuild = p.getLastBuild(); if (lastBuild == null || !lastBuild.isBuilding()) { // ready to be executed blockedProjects.remove(p); buildables.add(p); } } while(!queue.isEmpty()) { Item top = peek(); if(!top.timestamp.before(new GregorianCalendar())) return; // finished moving all ready items from queue Build lastBuild = top.project.getLastBuild(); if(lastBuild==null || !lastBuild.isBuilding()) { // ready to be executed immediately queue.remove(top); buildables.add(top.project); } // this can't be built know because another build is in progress // set this project aside. queue.remove(top); blockedProjects.add(top.project); } } |
blockedProjects.remove(p); | itr.remove(); | private synchronized void maintain() { for (Project p : blockedProjects) { Build lastBuild = p.getLastBuild(); if (lastBuild == null || !lastBuild.isBuilding()) { // ready to be executed blockedProjects.remove(p); buildables.add(p); } } while(!queue.isEmpty()) { Item top = peek(); if(!top.timestamp.before(new GregorianCalendar())) return; // finished moving all ready items from queue Build lastBuild = top.project.getLastBuild(); if(lastBuild==null || !lastBuild.isBuilding()) { // ready to be executed immediately queue.remove(top); buildables.add(top.project); } // this can't be built know because another build is in progress // set this project aside. queue.remove(top); blockedProjects.add(top.project); } } |
queue.remove(top); blockedProjects.add(top.project); | private synchronized void maintain() { for (Project p : blockedProjects) { Build lastBuild = p.getLastBuild(); if (lastBuild == null || !lastBuild.isBuilding()) { // ready to be executed blockedProjects.remove(p); buildables.add(p); } } while(!queue.isEmpty()) { Item top = peek(); if(!top.timestamp.before(new GregorianCalendar())) return; // finished moving all ready items from queue Build lastBuild = top.project.getLastBuild(); if(lastBuild==null || !lastBuild.isBuilding()) { // ready to be executed immediately queue.remove(top); buildables.add(top.project); } // this can't be built know because another build is in progress // set this project aside. queue.remove(top); blockedProjects.add(top.project); } } |
|
LargeText text = new LargeText(getLogFile(),completed); | File logFile = getLogFile(); if(!logFile.exists()) { rsp.addHeader("X-Text-Size","0"); rsp.addHeader("X-More-Data","true"); return; } LargeText text = new LargeText(logFile,completed); | public void doProgressiveLog( StaplerRequest req, StaplerResponse rsp) throws IOException { rsp.setContentType("text/plain"); rsp.setCharacterEncoding("UTF-8"); rsp.setStatus(HttpServletResponse.SC_OK); boolean completed = !isBuilding(); LargeText text = new LargeText(getLogFile(),completed); long start = 0; String s = req.getParameter("start"); if(s!=null) start = Long.parseLong(s); CharSpool spool = new CharSpool(); long r = text.writeLogTo(start,spool); rsp.addHeader("X-Text-Size",String.valueOf(r)); if(!completed) rsp.addHeader("X-More-Data","true"); spool.writeTo(rsp.getWriter()); } |
this.bc = bc; | Activator.bc = bc; | public void start(BundleContext bc) throws Exception { this.bc = bc; log = new LogRef(bc); SCR.init(bc); } |
r.put(p,getDownstreamRelationship(p)); | if(p.isFingerprintConfigured()) r.put(p,getDownstreamRelationship(p)); | public Map<Project,RangeSet> getDownstreamBuilds() { Map<Project,RangeSet> r = new HashMap<Project,RangeSet>(); for (Project p : getParent().getDownstreamProjects()) { r.put(p,getDownstreamRelationship(p)); } return r; } |
res.setDim(Dimensions.ONE); | res.setDim(calcDim(name,pfmc,arguments)); | public ASTFunNode buildFunctionNode(String name,PostfixMathCommandI pfmc,Node[] arguments) throws ParseException { ASTMFunNode res = new ASTMFunNode(ParserTreeConstants.JJTFUNNODE); res.setFunction(name,pfmc); copyChildren(res,arguments); // TODO whats the dim? res.setDim(Dimensions.ONE); return res; } |
public void shaleTime(double shift, double scale, DataSetSeismogram[] seismos){ this.shift += shift * this.scale; this.scale *= scale; time = time.shale(shift, scale); for(int i = 0; i < seismos.length; i++){ seismoTimes.put(seismos[i], time); } fireTimeEvent(); | public void shaleTime(double shift, double scale){ shaleTime(shift, scale, getSeismograms()); | public void shaleTime(double shift, double scale, DataSetSeismogram[] seismos){ this.shift += shift * this.scale; this.scale *= scale; time = time.shale(shift, scale); for(int i = 0; i < seismos.length; i++){ seismoTimes.put(seismos[i], time); } fireTimeEvent(); } |
while(r!=null && r.getResult()!=null && (r.isBuilding() || r.getResult().isWorseThan(Result.UNSTABLE))) | while(r!=null && r.getResult()==null && (r.isBuilding() || r.getResult().isWorseThan(Result.UNSTABLE))) | public synchronized RunT getLastSuccessfulBuild() { RunT r = getLastBuild(); // temporary hack till we figure out what's causing this bug while(r!=null && r.getResult()!=null && (r.isBuilding() || r.getResult().isWorseThan(Result.UNSTABLE))) r=r.getPreviousBuild(); return r; } |
MicroSecondDate now = new MicroSecondDate(); | MicroSecondDate now = new MicroSecondDate().add(offset); | public void startTimer() { if (timer == null) { timer = new javax.swing.Timer((int)update.convertTo(UnitImpl.MILLISECOND).value, new ActionListener() { public void actionPerformed(ActionEvent e) { if (beginTime != null && speed != 0) { MicroSecondDate now = new MicroSecondDate(); TimeInterval timeInterval = new TimeInterval(lastDate, now); timeInterval = timeInterval.add(offset); width = (TimeInterval)timeInterval.multiplyBy(speed); lastDate = now; setAllBeginTime(beginTime.add(width)); updateTimeSyncListeners(); System.out.println("Timer: updateTimeSyncListeners() speed="+speed); } // end of if (beginTime != null) } }); timer.setCoalesce(true); timer.start(); } } |
timeInterval = timeInterval.add(offset); | public void startTimer() { if (timer == null) { timer = new javax.swing.Timer((int)update.convertTo(UnitImpl.MILLISECOND).value, new ActionListener() { public void actionPerformed(ActionEvent e) { if (beginTime != null && speed != 0) { MicroSecondDate now = new MicroSecondDate(); TimeInterval timeInterval = new TimeInterval(lastDate, now); timeInterval = timeInterval.add(offset); width = (TimeInterval)timeInterval.multiplyBy(speed); lastDate = now; setAllBeginTime(beginTime.add(width)); updateTimeSyncListeners(); System.out.println("Timer: updateTimeSyncListeners() speed="+speed); } // end of if (beginTime != null) } }); timer.setCoalesce(true); timer.start(); } } |
|
MicroSecondDate now = new MicroSecondDate(); | MicroSecondDate now = new MicroSecondDate().add(offset); | public void actionPerformed(ActionEvent e) { if (beginTime != null && speed != 0) { MicroSecondDate now = new MicroSecondDate(); TimeInterval timeInterval = new TimeInterval(lastDate, now); timeInterval = timeInterval.add(offset); width = (TimeInterval)timeInterval.multiplyBy(speed); lastDate = now; setAllBeginTime(beginTime.add(width)); updateTimeSyncListeners(); System.out.println("Timer: updateTimeSyncListeners() speed="+speed); } // end of if (beginTime != null) } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.