rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
myParent.setRecipe(imp.handler.getRecipe()); | try { Recipe recipe = imp.handler.getRecipe(); if (recipe != null) { myParent.setRecipe(recipe); } else { System.out.println("Recipe is null for some reason."); } } catch(Exception e) { System.out.print("Problem loading "); System.out.println(myContents.getOpenFilename()); } | public void execute() { if (myContents.getQuitItem().isSelected()) { myContents.quit(); } if (myContents.getOpenItem().isSelected()) { ImportXml imp = new ImportXml(myContents.getOpenFilename()); myParent.setRecipe(imp.handler.getRecipe()); } } |
if (NewSwingApp.DEBUG){ | /* if (NewSwingApp.DEBUG){ | public void setValueAt(Object value, int row, int col) { Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : m.setName(value.toString()); if (NewSwingApp.DEBUG){ System.out.println("value is:" + value); } case 1 : m.setAmount(Double.parseDouble(value.toString())); case 2 : m.setUnits(value.toString()); case 3 : m.setPppg(Double.parseDouble(value.toString())); case 4 : m.setLov(Double.parseDouble(value.toString())); case 5 : m.setCost(Double.parseDouble(value.toString())); case 6 : m.setPercent(Double.parseDouble(value.toString())); } } catch (Exception e) { }; fireTableCellUpdated(row, col); } |
} | }*/ | public void setValueAt(Object value, int row, int col) { Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : m.setName(value.toString()); if (NewSwingApp.DEBUG){ System.out.println("value is:" + value); } case 1 : m.setAmount(Double.parseDouble(value.toString())); case 2 : m.setUnits(value.toString()); case 3 : m.setPppg(Double.parseDouble(value.toString())); case 4 : m.setLov(Double.parseDouble(value.toString())); case 5 : m.setCost(Double.parseDouble(value.toString())); case 6 : m.setPercent(Double.parseDouble(value.toString())); } } catch (Exception e) { }; fireTableCellUpdated(row, col); } |
return new SQETestResultPublisher(req.getParameter("sqetest_includes")); | return new SQETestResultPublisher(req.getParameter("sqetest_includes"),(req.getParameter("sqetest_testobject")!=null)); | public Publisher newInstance(StaplerRequest req) { return new SQETestResultPublisher(req.getParameter("sqetest_includes")); } |
public SQETestResultPublisher(String includes) { | public SQETestResultPublisher(String includes, boolean considerTestAsTestObject) { | public SQETestResultPublisher(String includes) { this.includes = includes; } |
this.considerTestAsTestObject = considerTestAsTestObject; | public SQETestResultPublisher(String includes) { this.includes = includes; } |
|
SQETestAction action = new SQETestAction(build, ds, listener); | SQETestAction action = new SQETestAction(build, ds, listener, considerTestAsTestObject); | public boolean perform(Build build, Launcher launcher, BuildListener listener) { FileSet fs = new FileSet(); org.apache.tools.ant.Project p = new org.apache.tools.ant.Project(); fs.setProject(p); fs.setDir(build.getProject().getWorkspace().getLocal()); fs.setIncludes(includes); DirectoryScanner ds = fs.getDirectoryScanner(p); if(ds.getIncludedFiles().length==0) { listener.getLogger().println("No SQE test report files wer efound. Configuration error?"); // no test result. Most likely a configuration error or fatal problem build.setResult(Result.FAILURE); } SQETestAction action = new SQETestAction(build, ds, listener); build.getActions().add(action); Report r = action.getResult(); if(r.getTotalCount()==0) { listener.getLogger().println("Test reports were found but none of them are new. Did tests run?"); // no test result. Most likely a configuration error or fatal problem build.setResult(Result.FAILURE); } if(r.getFailCount()>0) build.setResult(Result.UNSTABLE); return true; } |
case 2 : return data.getNoteNote(row); | public Object getValueAt(int row, int col) { try { switch (col) { case 0 : return SBStringUtils.dateFormatShort.format(data.getNoteDate(row)); case 1 : return data.getNoteType(row); case 2 : return data.getNoteNote(row); } } catch (Exception e) { }; return ""; } |
|
case 2 : data.setNoteNote(row, value.toString()); break; | public void setValueAt(Object value, int row, int col) { try { switch (col) { case 0 : try { Date d = SBStringUtils.dateFormatShort.parse(value.toString()); data.setNoteDate(row, d); } catch (ParseException e) { System.out.println("Unable to parse " + value.toString()); } break; case 1 : data.setNoteType(row, value.toString()); break; case 2 : data.setNoteNote(row, value.toString()); break; } } catch (Exception e) { }; fireTableCellUpdated(row, col); fireTableDataChanged(); } |
|
noteColumn.setCellEditor(new DefaultCellEditor(typeComboBox)); notesTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = notesTable.getSelectedRow(); noteTextArea.setText(myRecipe.getNoteNote(i)); } }); | noteColumn.setCellEditor(new DefaultCellEditor(typeComboBox)); | private void initGUI() { try { BoxLayout thisLayout = new BoxLayout(this, javax.swing.BoxLayout.X_AXIS); this.setLayout(thisLayout); setPreferredSize(new Dimension(400, 300)); { tablePanel = new JPanel(); BoxLayout tablePanelLayout = new BoxLayout(tablePanel, javax.swing.BoxLayout.Y_AXIS); tablePanel.setLayout(tablePanelLayout); this.add(tablePanel); { notesTableScroll = new JScrollPane(); tablePanel.add(notesTableScroll); notesTableScroll.setPreferredSize(new java.awt.Dimension(235, 264)); { notesTableModel = new NotesTableModel(myRecipe); notesTable = new JTable(); notesTableScroll.setViewportView(notesTable); notesTable.setModel(notesTableModel); // set up type combo String[] types = {"Planning", "Brewed", "Fermentation", "Racked", "Conditioned", "Kegged", "Bottled", "Tasting", "Contest"}; JComboBox typeComboBox = new JComboBox(types); TableColumn noteColumn = notesTable.getColumnModel().getColumn(1); noteColumn.setCellEditor(new DefaultCellEditor(typeComboBox)); notesTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = notesTable.getSelectedRow(); noteTextArea.setText(myRecipe.getNoteNote(i)); } }); // set up the date picker DateEditor dateEditor = new DateEditor(); noteColumn = notesTable.getColumnModel().getColumn(0); noteColumn.setCellEditor(dateEditor); } } { buttonsPanel = new JPanel(); tablePanel.add(buttonsPanel); FlowLayout buttonsPanelLayout = new FlowLayout(); buttonsPanelLayout.setAlignment(FlowLayout.LEFT); buttonsPanel.setLayout(buttonsPanelLayout); { addNoteButton = new JButton(); buttonsPanel.add(addNoteButton); addNoteButton.setText("+"); addNoteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Note n = new Note(); myRecipe.addNote(n); notesTable.updateUI(); } } }); } { delNoteButton = new JButton(); buttonsPanel.add(delNoteButton); delNoteButton.setText("-"); delNoteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = notesTable.getSelectedRow(); myRecipe.delNote(i); notesTable.updateUI(); } } }); } } } { notePanel = new JPanel(); BoxLayout notePanelLayout = new BoxLayout(notePanel, javax.swing.BoxLayout.Y_AXIS); notePanel.setLayout(notePanelLayout); this.add(notePanel); notePanel.setBorder(BorderFactory.createTitledBorder("Note:")); { noteScroll = new JScrollPane(); notePanel.add(noteScroll); { noteTextArea = new JTextArea(); noteScroll.setViewportView(noteTextArea); noteTextArea.setWrapStyleWord(true); noteTextArea.setLineWrap(true); noteTextArea.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (selectedRow > -1 && !noteTextArea.getText().equals( myRecipe.getNoteNote(selectedRow))) { myRecipe.setNoteNote(selectedRow, noteTextArea.getText()); } } }); noteTextArea.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { selectedRow = notesTable.getSelectedRow(); } }); } } } } catch (Exception e) { e.printStackTrace(); } } |
if (selectedRow > -1 && !noteTextArea.getText().equals( myRecipe.getNoteNote(selectedRow))) { | selectedRow = notesTable.getSelectedRow(); if (selectedRow > -1) { | private void initGUI() { try { BoxLayout thisLayout = new BoxLayout(this, javax.swing.BoxLayout.X_AXIS); this.setLayout(thisLayout); setPreferredSize(new Dimension(400, 300)); { tablePanel = new JPanel(); BoxLayout tablePanelLayout = new BoxLayout(tablePanel, javax.swing.BoxLayout.Y_AXIS); tablePanel.setLayout(tablePanelLayout); this.add(tablePanel); { notesTableScroll = new JScrollPane(); tablePanel.add(notesTableScroll); notesTableScroll.setPreferredSize(new java.awt.Dimension(235, 264)); { notesTableModel = new NotesTableModel(myRecipe); notesTable = new JTable(); notesTableScroll.setViewportView(notesTable); notesTable.setModel(notesTableModel); // set up type combo String[] types = {"Planning", "Brewed", "Fermentation", "Racked", "Conditioned", "Kegged", "Bottled", "Tasting", "Contest"}; JComboBox typeComboBox = new JComboBox(types); TableColumn noteColumn = notesTable.getColumnModel().getColumn(1); noteColumn.setCellEditor(new DefaultCellEditor(typeComboBox)); notesTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = notesTable.getSelectedRow(); noteTextArea.setText(myRecipe.getNoteNote(i)); } }); // set up the date picker DateEditor dateEditor = new DateEditor(); noteColumn = notesTable.getColumnModel().getColumn(0); noteColumn.setCellEditor(dateEditor); } } { buttonsPanel = new JPanel(); tablePanel.add(buttonsPanel); FlowLayout buttonsPanelLayout = new FlowLayout(); buttonsPanelLayout.setAlignment(FlowLayout.LEFT); buttonsPanel.setLayout(buttonsPanelLayout); { addNoteButton = new JButton(); buttonsPanel.add(addNoteButton); addNoteButton.setText("+"); addNoteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Note n = new Note(); myRecipe.addNote(n); notesTable.updateUI(); } } }); } { delNoteButton = new JButton(); buttonsPanel.add(delNoteButton); delNoteButton.setText("-"); delNoteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = notesTable.getSelectedRow(); myRecipe.delNote(i); notesTable.updateUI(); } } }); } } } { notePanel = new JPanel(); BoxLayout notePanelLayout = new BoxLayout(notePanel, javax.swing.BoxLayout.Y_AXIS); notePanel.setLayout(notePanelLayout); this.add(notePanel); notePanel.setBorder(BorderFactory.createTitledBorder("Note:")); { noteScroll = new JScrollPane(); notePanel.add(noteScroll); { noteTextArea = new JTextArea(); noteScroll.setViewportView(noteTextArea); noteTextArea.setWrapStyleWord(true); noteTextArea.setLineWrap(true); noteTextArea.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (selectedRow > -1 && !noteTextArea.getText().equals( myRecipe.getNoteNote(selectedRow))) { myRecipe.setNoteNote(selectedRow, noteTextArea.getText()); } } }); noteTextArea.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { selectedRow = notesTable.getSelectedRow(); } }); } } } } catch (Exception e) { e.printStackTrace(); } } |
}); noteTextArea.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { selectedRow = notesTable.getSelectedRow(); } }); | }); | private void initGUI() { try { BoxLayout thisLayout = new BoxLayout(this, javax.swing.BoxLayout.X_AXIS); this.setLayout(thisLayout); setPreferredSize(new Dimension(400, 300)); { tablePanel = new JPanel(); BoxLayout tablePanelLayout = new BoxLayout(tablePanel, javax.swing.BoxLayout.Y_AXIS); tablePanel.setLayout(tablePanelLayout); this.add(tablePanel); { notesTableScroll = new JScrollPane(); tablePanel.add(notesTableScroll); notesTableScroll.setPreferredSize(new java.awt.Dimension(235, 264)); { notesTableModel = new NotesTableModel(myRecipe); notesTable = new JTable(); notesTableScroll.setViewportView(notesTable); notesTable.setModel(notesTableModel); // set up type combo String[] types = {"Planning", "Brewed", "Fermentation", "Racked", "Conditioned", "Kegged", "Bottled", "Tasting", "Contest"}; JComboBox typeComboBox = new JComboBox(types); TableColumn noteColumn = notesTable.getColumnModel().getColumn(1); noteColumn.setCellEditor(new DefaultCellEditor(typeComboBox)); notesTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = notesTable.getSelectedRow(); noteTextArea.setText(myRecipe.getNoteNote(i)); } }); // set up the date picker DateEditor dateEditor = new DateEditor(); noteColumn = notesTable.getColumnModel().getColumn(0); noteColumn.setCellEditor(dateEditor); } } { buttonsPanel = new JPanel(); tablePanel.add(buttonsPanel); FlowLayout buttonsPanelLayout = new FlowLayout(); buttonsPanelLayout.setAlignment(FlowLayout.LEFT); buttonsPanel.setLayout(buttonsPanelLayout); { addNoteButton = new JButton(); buttonsPanel.add(addNoteButton); addNoteButton.setText("+"); addNoteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Note n = new Note(); myRecipe.addNote(n); notesTable.updateUI(); } } }); } { delNoteButton = new JButton(); buttonsPanel.add(delNoteButton); delNoteButton.setText("-"); delNoteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = notesTable.getSelectedRow(); myRecipe.delNote(i); notesTable.updateUI(); } } }); } } } { notePanel = new JPanel(); BoxLayout notePanelLayout = new BoxLayout(notePanel, javax.swing.BoxLayout.Y_AXIS); notePanel.setLayout(notePanelLayout); this.add(notePanel); notePanel.setBorder(BorderFactory.createTitledBorder("Note:")); { noteScroll = new JScrollPane(); notePanel.add(noteScroll); { noteTextArea = new JTextArea(); noteScroll.setViewportView(noteTextArea); noteTextArea.setWrapStyleWord(true); noteTextArea.setLineWrap(true); noteTextArea.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (selectedRow > -1 && !noteTextArea.getText().equals( myRecipe.getNoteNote(selectedRow))) { myRecipe.setNoteNote(selectedRow, noteTextArea.getText()); } } }); noteTextArea.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { selectedRow = notesTable.getSelectedRow(); } }); } } } } catch (Exception e) { e.printStackTrace(); } } |
if (selectedRow > -1 && !noteTextArea.getText().equals( myRecipe.getNoteNote(selectedRow))) { | selectedRow = notesTable.getSelectedRow(); if (selectedRow > -1) { | public void focusLost(FocusEvent evt) { if (selectedRow > -1 && !noteTextArea.getText().equals( myRecipe.getNoteNote(selectedRow))) { myRecipe.setNoteNote(selectedRow, noteTextArea.getText()); } } |
internalTimeConfig.setDisplayInterval(new TimeInterval(selectionBegin, currentInternal.getEndTime())); internalTimeConfig.setAllBeginTime(selectionBegin); | System.out.println(selectionBegin + " " + currentInternal.getEndTime()); internalTimeConfig.set(selectionBegin, new TimeInterval(selectionBegin, currentInternal.getEndTime())); | public void adjustRange(MicroSecondDate selectionBegin, MicroSecondDate selectionEnd){ MicroSecondTimeRange currentInternal = internalTimeConfig.getTimeRange(); double timeWidth = externalTimeConfig.getTimeRange().getInterval().getValue(); if(released == true){ double beginDistance = Math.abs(currentInternal.getBeginTime().getMicroSecondTime() - selectionEnd.getMicroSecondTime())/timeWidth; double endDistance = Math.abs(currentInternal.getEndTime().getMicroSecondTime() - selectionBegin.getMicroSecondTime())/timeWidth; if(beginDistance < endDistance) selectedBegin = true; else selectedBegin = false; released = false; }else if(selectionBegin.getMicroSecondTime() > currentInternal.getEndTime().getMicroSecondTime() || selectionEnd.getMicroSecondTime() < currentInternal.getBeginTime().getMicroSecondTime()){ selectedBegin = !selectedBegin; } if(selectedBegin){ internalTimeConfig.setDisplayInterval(new TimeInterval(selectionBegin, currentInternal.getEndTime())); internalTimeConfig.setAllBeginTime(selectionBegin); repaintParents(); }else{ internalTimeConfig.setDisplayInterval(new TimeInterval(currentInternal.getBeginTime(), selectionEnd)); repaintParents(); } } |
println("'group Z'\tintegers (arbitary precision)"); | println("'group Z'\tintegers (arbitrary precision)"); | public void printHelp() { super.printHelp(); println("'group'\tprints the current group"); println("'group G'\tchanges underlying group to G"); println("'group Z'\tintegers (arbitary precision)"); println("'group Q'\trationals"); println("'group R'\treals, represented as Doubles."); println("'group R 3'\treals reprecented as BigDecimals with 3 decimal places"); println("'group P 3'\tpermutation group on three symbols"); println("\t[1,3,2]+[3,2,1] -> (3,1,2)"); println("'group Zn 5'\tintegers modulo 5"); println("'group Qu'\tQuartonians"); println("'extend x'\textends current group by adding symbol x, i.e. a free group"); println("\tsuch a group can be considered as the ring of polynomials"); println("\tsimplification happens automatically"); println("'extend t a b c'\talgebraic extensions generated by t"); println("\twhere t is a root of the polynomial a t^2 + b t +c=0"); println("\te.g group extend t 1 0 1 gives complex numbers, t^2+1=0."); println("\tfor these groups there is a natural mapping to complex numbers and complex result is also printed."); println("'setRootVal t re im'\tsets the value of free variable 't' in a free group to complex number re+i im"); } |
println("'group R 3'\treals reprecented as BigDecimals with 3 decimal places"); | println("'group R 3'\treals represented as BigDecimals with 3 decimal places"); | public void printHelp() { super.printHelp(); println("'group'\tprints the current group"); println("'group G'\tchanges underlying group to G"); println("'group Z'\tintegers (arbitary precision)"); println("'group Q'\trationals"); println("'group R'\treals, represented as Doubles."); println("'group R 3'\treals reprecented as BigDecimals with 3 decimal places"); println("'group P 3'\tpermutation group on three symbols"); println("\t[1,3,2]+[3,2,1] -> (3,1,2)"); println("'group Zn 5'\tintegers modulo 5"); println("'group Qu'\tQuartonians"); println("'extend x'\textends current group by adding symbol x, i.e. a free group"); println("\tsuch a group can be considered as the ring of polynomials"); println("\tsimplification happens automatically"); println("'extend t a b c'\talgebraic extensions generated by t"); println("\twhere t is a root of the polynomial a t^2 + b t +c=0"); println("\te.g group extend t 1 0 1 gives complex numbers, t^2+1=0."); println("\tfor these groups there is a natural mapping to complex numbers and complex result is also printed."); println("'setRootVal t re im'\tsets the value of free variable 't' in a free group to complex number re+i im"); } |
println("'group Qu'\tQuartonians"); | println("'group Qu'\tQuarternions"); | public void printHelp() { super.printHelp(); println("'group'\tprints the current group"); println("'group G'\tchanges underlying group to G"); println("'group Z'\tintegers (arbitary precision)"); println("'group Q'\trationals"); println("'group R'\treals, represented as Doubles."); println("'group R 3'\treals reprecented as BigDecimals with 3 decimal places"); println("'group P 3'\tpermutation group on three symbols"); println("\t[1,3,2]+[3,2,1] -> (3,1,2)"); println("'group Zn 5'\tintegers modulo 5"); println("'group Qu'\tQuartonians"); println("'extend x'\textends current group by adding symbol x, i.e. a free group"); println("\tsuch a group can be considered as the ring of polynomials"); println("\tsimplification happens automatically"); println("'extend t a b c'\talgebraic extensions generated by t"); println("\twhere t is a root of the polynomial a t^2 + b t +c=0"); println("\te.g group extend t 1 0 1 gives complex numbers, t^2+1=0."); println("\tfor these groups there is a natural mapping to complex numbers and complex result is also printed."); println("'setRootVal t re im'\tsets the value of free variable 't' in a free group to complex number re+i im"); } |
initialise(new Quartonians()); | initialise(new Quaternions()); | public boolean testSpecialCommands(String command) { GroupJep gj = (GroupJep) j; if(!super.testSpecialCommands(command)) return false; String words[] = split(command); if(words.length==0) return true; if(words[0].equals("group")) { if(words.length == 1) { } else if(words[1].equals("Z")) { initialise(new Integers()); } else if(words[1].equals("Q")) { initialise(new Rationals()); } else if(words[1].equals("R") && words.length == 3) { initialise(new BigReals( Integer.parseInt(words[2]), BigDecimal.ROUND_HALF_EVEN )); } else if(words[1].equals("R") && words.length == 2) { initialise(new Reals()); } else if(words[1].equals("P") && words.length == 3) { initialise(new PermutationGroup( Integer.parseInt(words[2])) ); } else if(words[1].equals("Zn") && words.length == 3) { initialise(new Zn(new BigInteger(words[2]))); } else if(words[1].equals("Qu")) { initialise(new Quartonians()); } else { println("invalid group spec "+command); return false; } printGroup(); return false; } if(words[0].equals("extend")) { RingI ring = (RingI) gj.getGroup(); if(words.length < 2) println("extend must have at least one argument"); else if(words.length == 2) /* Add a free variable */ { initialise(new ExtendedFreeGroup(ring, words[1])); } else /* extend by an algebraic number */ { int deg = words.length-3; Number coeffs[] = new Number[deg+1]; for(int i=0;i<=deg;++i) coeffs[i] = ring.valueOf(words[words.length-i-1]); Polynomial p1 = new Polynomial(ring,words[1],coeffs); initialise(new AlgebraicExtension(ring, p1)); } printGroup(); return false; } if(words[0].equals("setRootVal")) { String symbol = words[1]; Complex val = new Complex(Double.parseDouble(words[2]),Double.parseDouble(words[3])); GroupI g = gj.getGroup(); if(g instanceof FreeGroup) { boolean flag = ((FreeGroup) g).setRootVal(symbol,val); if(!flag) println("Failed to set root value, could not find symbol"); } return false; } return true; } |
nextUpdate = System.currentTimeMillis()+1000; reload(); | if(!reloadingInProgress) { reloadingInProgress = true; synchronized(reloadQueue) { reloadQueue.add(this); reloadQueue.notify(); } } | protected synchronized SortedMap<String,ExternalRun> _getRuns() { if(nextUpdate<System.currentTimeMillis()) { nextUpdate = System.currentTimeMillis()+1000; reload(); } return runs; } |
runs = new TreeMap<String,ExternalRun>(reverseComparator); | TreeMap<String,ExternalRun> runs = new TreeMap<String,ExternalRun>(reverseComparator); | private void reload() { runs = new TreeMap<String,ExternalRun>(reverseComparator); File[] subdirs = getBuildDir().listFiles(new FileFilter() { public boolean accept(File subdir) { return subdir.isDirectory(); } }); Arrays.sort(subdirs,fileComparator); ExternalRun lastBuild = null; for( File dir : subdirs ) { try { ExternalRun b = new ExternalRun(this,dir,lastBuild); lastBuild = b; runs.put( b.getId(), b ); } catch (IOException e) { e.printStackTrace(); try { Util.deleteRecursive(dir); } catch (IOException e1) { e1.printStackTrace(); // but ignore } } } } |
synchronized(this) { this.runs = runs; reloadingInProgress = false; nextUpdate = System.currentTimeMillis()+1000; } | private void reload() { runs = new TreeMap<String,ExternalRun>(reverseComparator); File[] subdirs = getBuildDir().listFiles(new FileFilter() { public boolean accept(File subdir) { return subdir.isDirectory(); } }); Arrays.sort(subdirs,fileComparator); ExternalRun lastBuild = null; for( File dir : subdirs ) { try { ExternalRun b = new ExternalRun(this,dir,lastBuild); lastBuild = b; runs.put( b.getId(), b ); } catch (IOException e) { e.printStackTrace(); try { Util.deleteRecursive(dir); } catch (IOException e1) { e1.printStackTrace(); // but ignore } } } } |
|
ImportXml imp = new ImportXml(myContents.getOpenFilename()); try { | String myFile = myContents.getOpenFilename(); if (myFile != "/") { ImportXml imp = new ImportXml(myFile); | public void execute() { if (myContents.getQuitItem().isSelected()) { myContents.quit(); } if (myContents.getOpenItem().isSelected()) { ImportXml imp = new ImportXml(myContents.getOpenFilename()); try { Recipe recipe = imp.handler.getRecipe(); if (recipe != null) { myParent.setRecipe(recipe); } else { System.out.println("Recipe is null for some reason."); } } catch(Exception e) { System.out.print("Problem loading "); System.out.println(myContents.getOpenFilename()); } } } |
if (recipe != null) { myParent.setRecipe(recipe); } else { System.out.println("Recipe is null for some reason."); } } catch(Exception e) { System.out.print("Problem loading "); System.out.println(myContents.getOpenFilename()); | myParent.setRecipe(recipe); | public void execute() { if (myContents.getQuitItem().isSelected()) { myContents.quit(); } if (myContents.getOpenItem().isSelected()) { ImportXml imp = new ImportXml(myContents.getOpenFilename()); try { Recipe recipe = imp.handler.getRecipe(); if (recipe != null) { myParent.setRecipe(recipe); } else { System.out.println("Recipe is null for some reason."); } } catch(Exception e) { System.out.print("Problem loading "); System.out.println(myContents.getOpenFilename()); } } } |
task.setBranch(branch); | private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); final StringWriter errorOutput = new StringWriter(); final boolean[] hadError = new boolean[1]; ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) { hadError[0] = true; errorOutput.write(msg); errorOutput.write('\n'); } } }; task.setProject(new org.apache.tools.ant.Project()); File baseDir = build.getProject().getWorkspace().getLocal(); task.setDir(baseDir); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) { // if the directory doesn't exist, cvs changelog will die, so filter them out. // this means we'll lose the log of those changes for (String filePath : changedFiles) { if(new File(baseDir,filePath).getParentFile().exists()) task.addFile(filePath); } } else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); if(hadError[0]) { // non-fatal error must have occurred, such as cvs changelog parsing error.s listener.getLogger().print(errorOutput); } return true; } catch( BuildException e ) { // capture output from the task for diagnosis listener.getLogger().print(errorOutput); // then report an error e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } } |
|
plottDb = new JDBCPlottable(); | plottDb = new JDBCPlottable(new ConnectionCreator(new String[] {}).createConnection(), "HSQL"); | public void setUp() throws SQLException { data = createFullDayPlottable(); plottDb = new JDBCPlottable(); } |
seisIterator = container.getIterator(); seisWAV = new FissuresToWAV(seisIterator, 200); | seisWAV = new FissuresToWAV(container, 200); | public SoundPlay(SeismogramDisplay display, SeismogramContainer container){ this.display = display; this.container = container; seisIterator = container.getIterator(); seisWAV = new FissuresToWAV(seisIterator, 200); SeismogramDisplay.getMouseForwarder().addPermMouseListener(this); SeismogramDisplay.getMouseMotionForwarder().addMouseMotionListener(this); } |
seisIterator.setTimeRange(timeEvent.getTime(container.getDataSetSeismogram())); | container.getIterator().setTimeRange(timeEvent.getTime(container.getDataSetSeismogram())); | public void mouseClicked(MouseEvent e){ if(intersects(e)){ System.out.println("This should be playing something..."); sendToWAV(); seisIterator.setTimeRange(timeEvent.getTime(container.getDataSetSeismogram())); seisWAV.play(); } } |
public static List<Resource> createAndPersistResourceList(HibernateTemplate hibernateTemplate, int i, int e, int p) { List<Resource> resourceList = createResourceList(i, e, p); | public static List<ResourceGroup> createAndPersistResourceList(HibernateTemplate hibernateTemplate, int i, int e, int p) { List<ResourceGroup> resourceList = createResourceList(i, e, p); | public static List<Resource> createAndPersistResourceList(HibernateTemplate hibernateTemplate, int i, int e, int p) { List<Resource> resourceList = createResourceList(i, e, p); hibernateTemplate.saveOrUpdateAll(resourceList); hibernateTemplate.flush(); hibernateTemplate.clear(); return resourceList; } |
public static List<Resource> createResourceList(int size, int entityListSize, int parentListSize) { | public static List<ResourceGroup> createResourceList(int size, int entityListSize, int parentListSize) { | public static List<Resource> createResourceList(int size, int entityListSize, int parentListSize) { List<ResourceGroup> resourceGroupList = createResourceGroupList(size, entityListSize, parentListSize); List<Resource> resourceList = new ArrayList<Resource>(); for (ResourceGroup g: resourceGroupList) { for (int i=0;i<size;i++) { resourceList.add(ResourceCreatorImpl.resourceFactory(g, generateKey(20, i), null)); } } return resourceList; } |
List<Resource> resourceList = new ArrayList<Resource>(); | List<ResourceGroup> resourceList = new ArrayList<ResourceGroup>(); | public static List<Resource> createResourceList(int size, int entityListSize, int parentListSize) { List<ResourceGroup> resourceGroupList = createResourceGroupList(size, entityListSize, parentListSize); List<Resource> resourceList = new ArrayList<Resource>(); for (ResourceGroup g: resourceGroupList) { for (int i=0;i<size;i++) { resourceList.add(ResourceCreatorImpl.resourceFactory(g, generateKey(20, i), null)); } } return resourceList; } |
resourceList.add(ResourceCreatorImpl.resourceFactory(g, generateKey(20, i), null)); | resourceList.add(ResourceCreatorImpl.resourceFactory(g, generateKey(20, intValue++), null)); | public static List<Resource> createResourceList(int size, int entityListSize, int parentListSize) { List<ResourceGroup> resourceGroupList = createResourceGroupList(size, entityListSize, parentListSize); List<Resource> resourceList = new ArrayList<Resource>(); for (ResourceGroup g: resourceGroupList) { for (int i=0;i<size;i++) { resourceList.add(ResourceCreatorImpl.resourceFactory(g, generateKey(20, i), null)); } } return resourceList; } |
securityMgr.createIPAccessRule( Localizer.getString( "UserBanned" ), true, IPAccessRule.SINGLE_ADDRESS, ip.getHostIP(), null, false, expiryDate, true ); | byte res = securityMgr.controlHostIPAccess( ip.getHostIP() ); if (res == PhexSecurityManager.ACCESS_GRANTED) { securityMgr.createIPAccessRule( Localizer.getString( "UserBanned" ), true, IPAccessRule.SINGLE_ADDRESS, ip.getHostIP(), null, false, expiryDate, true ); } | private static void banHosts( DestAddress[] addresses, ExpiryDate expiryDate ) { PhexSecurityManager securityMgr = PhexSecurityManager.getInstance(); for ( int i = 0; i < addresses.length; i++ ) { IpAddress ip = addresses[i].getIpAddress(); if ( ip == null ) { continue; } securityMgr.createIPAccessRule( Localizer.getString( "UserBanned" ), true, IPAccessRule.SINGLE_ADDRESS, ip.getHostIP(), null, false, expiryDate, true ); } } |
else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); | throw new ParseException("Too many children "+nchild+" for "+node+"\n"); | public Node differentiate(ASTFunNode node,String var,Node [] children,Node [] dchildren,DJep djep) throws ParseException { XOperatorSet op = (XOperatorSet) djep.getOperatorSet(); NodeFactory nf = djep.getNodeFactory(); int nchild = node.jjtGetNumChildren(); if(nchild==2) return nf.buildOperatorNode(op.getDivide(), nf.buildOperatorNode(op.getSubtract(), nf.buildOperatorNode(op.getMultiply(), dchildren[0], djep.deepCopy(children[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[0]), dchildren[1])), nf.buildOperatorNode(op.getMultiply(), djep.deepCopy(children[1]), djep.deepCopy(children[1]))); else throw new ParseException("Too many children "+nchild+" for "+node+"\n"); } |
if(line.startsWith(cvsroot)) | int portIndex = line.indexOf(":2401/"); String line2 = ""; if(portIndex>=0) line2 = line.substring(0,portIndex+1)+line.substring(portIndex+5); if(line.startsWith(cvsroot) || line.startsWith(cvsroot2) || line2.startsWith(cvsroot2)) | private boolean scanCvsPassFile(File passfile, String cvsroot) throws IOException { cvsroot += ' '; BufferedReader in = new BufferedReader(new FileReader(passfile)); try { String line; while((line=in.readLine())!=null) { if(line.startsWith(cvsroot)) return true; } return false; } finally { in.close(); } } |
myRecipe.setPostBoilVolUnits(q); | 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.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)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { 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.addFocusListener(this); brewerNameText.addActionListener(this); 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:"); } { 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(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.addFocusListener(this); txtDate.addActionListener(this); } { 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.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())); } }); } { 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.addFocusListener(this); txtPreBoil.addActionListener(this); } { 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.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(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints(6, 3, 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)); } { 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(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)); } { 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.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( 6, 4, 4, 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.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.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); } }); } { 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); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); myRecipe.setPreBoilVolUnits(q); displayRecipe(); } } }); } { 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.addFocusListener(this); boilMinText.addActionListener(this); } { 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.addFocusListener(this); evapText.addActionListener(this); } { 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.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); } { 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.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); } { 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.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); } } { 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); } } { 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 JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); 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()); } } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); 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(); } } } }); } } { 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(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 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); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); 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()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = hopsTable.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); 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(); } } }); // 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(70, 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(); 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"}; String desc = "StrangBrew and QBrew recipes"; sbFileFilter saveFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(saveFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); 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) { // TODO: handle io exception } } // 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) { // TODO: handle io exception } } 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) { // TODO: handle io exception } } 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); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { 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); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } } |
|
maltTable.setAutoCreateColumnsFromModel(false); | 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.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)); txtName.addActionListener(this); txtName.addFocusListener(this); } } { 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.addFocusListener(this); brewerNameText.addActionListener(this); 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:"); } { 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(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.addFocusListener(this); txtDate.addActionListener(this); } { 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.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())); } }); } { 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.addFocusListener(this); txtPreBoil.addActionListener(this); } { 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.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(); } }); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints(6, 3, 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)); } { 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(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)); } { 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.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( 6, 4, 4, 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.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.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); } }); } { 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); cmbSizeUnits.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); myRecipe.setPreBoilVolUnits(q); displayRecipe(); } } }); } { 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.addFocusListener(this); boilMinText.addActionListener(this); } { 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.addFocusListener(this); evapText.addActionListener(this); } { 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.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); } { 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.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); } { 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.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { recipeSettingsActionPerformed(evt); } }); } } { 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); } } { 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 JComboBox maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); 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()); } } } }); // set up malt units combo JComboBox maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(2); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); 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(); } } } }); } } { 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(390, 34)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(140, 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); JComboBox hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); 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()); } } }); // set up hop units combo JComboBox hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = hopsTable.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); 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(); } } }); // 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(70, 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(); 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"}; String desc = "StrangBrew and QBrew recipes"; sbFileFilter saveFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(saveFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); ImportXml imp = new ImportXml(file.toString()); myRecipe = imp.handler.getRecipe(); 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) { // TODO: handle io exception } } // 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) { // TODO: handle io exception } } 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) { // TODO: handle io exception } } 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); } } { mnuView = new JMenu(); jMenuBar1.add(mnuView); mnuView.setText("View"); { mashManagerMenuItem = new JMenuItem(); mnuView.add(mashManagerMenuItem); mashManagerMenuItem.setText("Mash Manager..."); mashManagerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mashMgr = new MashManager(myRecipe); mashMgr.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); } { 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); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } } |
|
myRecipe.setPostBoilVolUnits(q); | public void actionPerformed(ActionEvent evt) { String q = (String) cmbSizeUnits.getSelectedItem(); if (myRecipe != null && q != myRecipe.getVolUnits()) { myRecipe.setPostBoilVolUnits(q); myRecipe.setPreBoilVolUnits(q); displayRecipe(); } } |
|
view.init(); | public static void main(String[] args) { Recipe myRecipe = new Recipe(); if (args.length != 1) { System.err.println("Usage: filename or --gui"); System.exit(1); } else if (args[0].equals("--gui")) { MainView view = new SWTMainView(); view.init(); MainController controller = new MainController(view, myRecipe); controller.execute(); } else { // this is copied from the ImportXml main method // import an xml file, and write a bunch of stuff about it // Dont't know how to get the recipe returned from this thing, though // Use an instance of the ImportXml as the SAX event handler ImportXml imp = new ImportXml(args[0]); myRecipe = imp.handler.getRecipe(); } myRecipe.testRecipe(); } |
|
if ( !isSearching ) | switch ( browseHostStatus ) | public int getProgress() { if ( !isSearching ) { return 100; } else { return 0; } } |
else { return 0; } | public int getProgress() { if ( !isSearching ) { return 100; } else { return 0; } } |
|
browseHostError = BROWSE_HOST_ERROR; | browseHostStatus = BROWSE_HOST_ERROR; | public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } |
browseHostError = CONNECTION_ERROR; | browseHostStatus = CONNECTION_ERROR; | public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } |
shapeTypes.addElement(new ShapeType(shapeType.getID(), shapeType.getPluralNaming(), false)); | shapeTypes.addElement(new ShapeType(shapeType.getID(), shapeType.getPluralNaming(), as.getTopicProperty(shapeType, PROPERTY_COLOR), false)); | private void initShapeTypes(Session session) { Vector st = ((CityMapTopic) as.getLiveTopic(getCityMap(session))).getShapeTypes(); // ### ugly System.out.println(">>> there are " + st.size() + " shape types:"); Vector shapeTypes = new Vector(); for (int i = 0; i < st.size(); i++) { TypeTopic shapeType = (TypeTopic) as.getLiveTopic((BaseTopic) st.elementAt(i)); shapeTypes.addElement(new ShapeType(shapeType.getID(), shapeType.getPluralNaming(), false)); // isSelected=false System.out.println(" > " + shapeType.getName()); } session.setAttribute("shapeTypes", shapeTypes); } |
System.out.println(">>> shape size: " + width + "x" + height); | Dimension size = new Dimension(width, height); | private void updateShapes(Session session) { try { Vector shapes = new Vector(); Vector shapeTypes = getShapeTypes(session); String mapID = getCityMap(session).getID(); // for all shape types ... Enumeration e = shapeTypes.elements(); while (e.hasMoreElements()) { ShapeType shapeType = (ShapeType) e.nextElement(); // if type is selected ... if (shapeType.isSelected) { // ... query all shapes and add Shape objects to the "shapes" vector Vector shapeTopics = cm.getViewTopics(mapID, 1, shapeType.typeID); Enumeration e2 = shapeTopics.elements(); while (e2.hasMoreElements()) { PresentableTopic shapeTopic = (PresentableTopic) e2.nextElement(); String icon = as.getLiveTopic(shapeTopic).getIconfile(); // --- load shape image and calculate position --- String url = as.getCorporateWebBaseURL() + FILESERVER_ICONS_PATH + icon; // Note 1: Toolkit.getImage() is used here instead of createImage() in order to utilize // the Toolkits caching mechanism // Note 2: ImageIcon is a kluge to make sure the image is fully loaded before we proceed Image image = new ImageIcon(Toolkit.getDefaultToolkit().getImage(new URL(url))).getImage(); int width = image.getWidth(null); int height = image.getHeight(null); System.out.println(">>> shape size: " + width + "x" + height); Point point = shapeTopic.getGeometry(); point.translate(-width / 2, -height / 2); // shapes.addElement(new Shape(url, point)); // ### involve icon size } } } session.setAttribute("shapes", shapes); System.out.println("> \"shapes\" stored in session: " + shapes.size() + " shapes"); } catch (Throwable e) { System.out.println("*** BrowseServlet.updateShapes(): " + e); } } |
shapes.addElement(new Shape(url, point)); | shapes.addElement(new Shape(url, point, size)); | private void updateShapes(Session session) { try { Vector shapes = new Vector(); Vector shapeTypes = getShapeTypes(session); String mapID = getCityMap(session).getID(); // for all shape types ... Enumeration e = shapeTypes.elements(); while (e.hasMoreElements()) { ShapeType shapeType = (ShapeType) e.nextElement(); // if type is selected ... if (shapeType.isSelected) { // ... query all shapes and add Shape objects to the "shapes" vector Vector shapeTopics = cm.getViewTopics(mapID, 1, shapeType.typeID); Enumeration e2 = shapeTopics.elements(); while (e2.hasMoreElements()) { PresentableTopic shapeTopic = (PresentableTopic) e2.nextElement(); String icon = as.getLiveTopic(shapeTopic).getIconfile(); // --- load shape image and calculate position --- String url = as.getCorporateWebBaseURL() + FILESERVER_ICONS_PATH + icon; // Note 1: Toolkit.getImage() is used here instead of createImage() in order to utilize // the Toolkits caching mechanism // Note 2: ImageIcon is a kluge to make sure the image is fully loaded before we proceed Image image = new ImageIcon(Toolkit.getDefaultToolkit().getImage(new URL(url))).getImage(); int width = image.getWidth(null); int height = image.getHeight(null); System.out.println(">>> shape size: " + width + "x" + height); Point point = shapeTopic.getGeometry(); point.translate(-width / 2, -height / 2); // shapes.addElement(new Shape(url, point)); // ### involve icon size } } } session.setAttribute("shapes", shapes); System.out.println("> \"shapes\" stored in session: " + shapes.size() + " shapes"); } catch (Throwable e) { System.out.println("*** BrowseServlet.updateShapes(): " + e); } } |
return "job/"+name+'/'; | try { return "job/"+ URLEncoder.encode(name,"UTF-8")+'/'; } catch (UnsupportedEncodingException e) { throw new Error(e); } | public String getUrl() { return "job/"+name+'/'; } |
creator.getCurrentSelection().setDisplay(selectionDisplay.addDisplay(first, tr, first.getName() + " " + | creator.getCurrentSelection().setDisplay(selectionDisplay.addDisplay(first, tr, creator.getName() + "." + | public void createSelectionDisplay(BasicSeismogramDisplay creator){ if(selectionDisplay == null){ logger.debug("creating selection display"); selectionWindow = new JDialog(); //selectionWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); selectionWindow.setSize(400, 220); JToolBar infoBar = new JToolBar(); infoBar.add(new FilterSelection(selectionDisplay)); infoBar.setFloatable(false); selectionWindow.getContentPane().add(infoBar, BorderLayout.SOUTH); Iterator e = creator.getSeismograms().iterator(); TimeConfigRegistrar tr = creator.getCurrentSelection().getInternalConfig(); LocalSeismogramImpl first = ((LocalSeismogramImpl)e.next()); AmpConfigRegistrar ar = new AmpConfigRegistrar(new OffsetMeanAmpConfig(first, tr.getTimeRange((LocalSeismogram)first))); ar.visibleAmpCalc(tr); selectionDisplay = new VerticalSeismogramDisplay(mouseForwarder, motionForwarder); creator.getCurrentSelection().setDisplay(selectionDisplay.addDisplay(first, tr, creator.getName() + "." + creator.getCurrentSelection().getColor())); while(e.hasNext()){ selectionDisplay.addSeismogram(((LocalSeismogramImpl)e.next()), 0); } selectionWindow.getContentPane().add(selectionDisplay); Toolkit tk = Toolkit.getDefaultToolkit(); selectionWindow.setLocation(tk.getScreenSize().width, tk.getScreenSize().height - selectionDisplays * 250); selectionDisplays++; selectionWindow.setVisible(true); }else{ logger.debug("adding another selection"); Iterator e = creator.getSeismograms().iterator(); TimeConfigRegistrar tr = creator.getCurrentSelection().getInternalConfig(); LocalSeismogramImpl first = ((LocalSeismogramImpl)e.next()); AmpConfigRegistrar ar = new AmpConfigRegistrar(new OffsetMeanAmpConfig(first, tr.getTimeRange((LocalSeismogram)first))); ar.visibleAmpCalc(tr); creator.getCurrentSelection().setDisplay(selectionDisplay.addDisplay(first, tr, first.getName() + " " + creator.getCurrentSelection().getColor())); while(e.hasNext()){ selectionDisplay.addSeismogram(((LocalSeismogramImpl)e.next()), 0); } } } |
assertEquals(str, sym.getText().asNativeText().javaValue); | assertEquals(str, sym.base_getText().asNativeText().javaValue); | private void compareSymbol(String str, ATSymbol sym) { try { assertEquals(str, sym.getText().asNativeText().javaValue); } catch (XTypeMismatch e) { fail(e.getMessage()); } } |
public static final AGSymbol alloc(String javaRepresentation) { return alloc(NATText.atValue(javaRepresentation)); | public static final AGSymbol alloc(ATText txt) { AGSymbol existing = (AGSymbol) _STRINGPOOL_.get(txt); if (existing == null) { existing = new AGSymbol(txt); _STRINGPOOL_.put(txt, existing); } return existing; | public static final AGSymbol alloc(String javaRepresentation) { return alloc(NATText.atValue(javaRepresentation)); } |
if (!(candidate instanceof DateProperty)) { return false; } | public boolean matches(Property candidate) { // XXX later return true; } |
|
guard = op.getOperationGuard(); | guard = "["+op.getOperationGuard()+"]"; | private NFA<Object, String> createNFA(Protocol protocol){ EList states = protocol.getStates(); provervisual.State initState = null; HashSet <Object>finalStates = new HashSet<Object>(); HashSet <Object>actionStates = new HashSet<Object>(); for(Iterator i = states.iterator(); i.hasNext();){ Object element = i.next(); provervisual.State state = (provervisual.State) element; if(state instanceof InitialState){ initState = state; }else if(state instanceof FinalState){ finalStates.add(state); }else{ actionStates.add(element); } } EList operations = protocol.getOperations(); Map<Object, List<Pair<Object, String>>> node2arcs = this.<Object, String> makeNode2Arcs(); for(Iterator i = operations.iterator(); i.hasNext();){ Operation op = (Operation) i.next() ; String guard = ""; if(op.getOperationGuard() != null) guard = op.getOperationGuard(); addTrans(node2arcs, op.getStartState(), "<"+op.getOperationAbbrev()+ "["+guard+"]>", op.getEndState() ); } NFA<Object, String> nfa = makeNFA(initState, new HashSet<Object>(finalStates), node2arcs); return nfa; } |
"["+guard+"]>", op.getEndState() ); | guard+">", op.getEndState() ); | private NFA<Object, String> createNFA(Protocol protocol){ EList states = protocol.getStates(); provervisual.State initState = null; HashSet <Object>finalStates = new HashSet<Object>(); HashSet <Object>actionStates = new HashSet<Object>(); for(Iterator i = states.iterator(); i.hasNext();){ Object element = i.next(); provervisual.State state = (provervisual.State) element; if(state instanceof InitialState){ initState = state; }else if(state instanceof FinalState){ finalStates.add(state); }else{ actionStates.add(element); } } EList operations = protocol.getOperations(); Map<Object, List<Pair<Object, String>>> node2arcs = this.<Object, String> makeNode2Arcs(); for(Iterator i = operations.iterator(); i.hasNext();){ Operation op = (Operation) i.next() ; String guard = ""; if(op.getOperationGuard() != null) guard = op.getOperationGuard(); addTrans(node2arcs, op.getStartState(), "<"+op.getOperationAbbrev()+ "["+guard+"]>", op.getEndState() ); } NFA<Object, String> nfa = makeNFA(initState, new HashSet<Object>(finalStates), node2arcs); return nfa; } |
if(args.length > 0) { | if(args.length > 2) { | public static void main(String[] args) { BasicConfigurator.configure(); OpenMap om; if(args.length > 0) { om = new OpenMap("edu/sc/seis/fissuresUtil/data/maps/dcwpo-browse", "edu/sc/seis/mapData", args[0]); } else { om = new OpenMap("edu/sc/seis/fissuresUtil/data/maps/dcwpo-browse", "edu/sc/seis/mapData"); } EventLayer evLayer = new EventLayer(om.getMapBean(), new DepthEventColorizer()); om.setEventLayer(evLayer); evLayer.eventDataChanged(new EQDataEvent(MockEventAccessOperations.createEvents())); StationLayer staLayer = new StationLayer(); om.setStationLayer(staLayer); Station sta = MockStation.createStation(); Station other = MockStation.createOtherStation(); staLayer.stationDataChanged(new StationDataEvent(new Station[] {sta})); staLayer.stationAvailabiltyChanged(new AvailableStationDataEvent(sta, AvailableStationDataEvent.UP)); staLayer.stationDataChanged(new StationDataEvent(new Station[] {other})); staLayer.stationAvailabiltyChanged(new AvailableStationDataEvent(other, AvailableStationDataEvent.DOWN)); JFrame frame = new JFrame("OpenMap Test"); frame.addWindowListener(new Closer()); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(om); frame.setSize(640, 480); frame.show(); } |
"edu/sc/seis/mapData", args[0]); | "edu/sc/seis/mapData", args[2]); | public static void main(String[] args) { BasicConfigurator.configure(); OpenMap om; if(args.length > 0) { om = new OpenMap("edu/sc/seis/fissuresUtil/data/maps/dcwpo-browse", "edu/sc/seis/mapData", args[0]); } else { om = new OpenMap("edu/sc/seis/fissuresUtil/data/maps/dcwpo-browse", "edu/sc/seis/mapData"); } EventLayer evLayer = new EventLayer(om.getMapBean(), new DepthEventColorizer()); om.setEventLayer(evLayer); evLayer.eventDataChanged(new EQDataEvent(MockEventAccessOperations.createEvents())); StationLayer staLayer = new StationLayer(); om.setStationLayer(staLayer); Station sta = MockStation.createStation(); Station other = MockStation.createOtherStation(); staLayer.stationDataChanged(new StationDataEvent(new Station[] {sta})); staLayer.stationAvailabiltyChanged(new AvailableStationDataEvent(sta, AvailableStationDataEvent.UP)); staLayer.stationDataChanged(new StationDataEvent(new Station[] {other})); staLayer.stationAvailabiltyChanged(new AvailableStationDataEvent(other, AvailableStationDataEvent.DOWN)); JFrame frame = new JFrame("OpenMap Test"); frame.addWindowListener(new Closer()); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(om); frame.setSize(640, 480); frame.show(); } |
handle("An uncaught exception has occured. Please report this to [email protected]", thrown); | handle("An uncaught exception has occured.", thrown); | public static void handle(Throwable thrown) { handle("An uncaught exception has occured. Please report this to [email protected]", thrown); } |
System.out.println("ZoomListener: " + zl); | public void addZoomListener(ZoomListener zl){ System.out.println("ZoomListener: " + zl); listenerList.add(ZoomListener.class, zl); } |
|
public char asChar() throws XIllegalArgument { | public char asChar() throws XTypeMismatch { | public char asChar() throws XIllegalArgument { if (javaValue.length() == 1) { return javaValue.charAt(0); } else { throw new XIllegalArgument("Expected a character, given a string: " + javaValue); } } |
throw new XIllegalArgument("Expected a character, given a string: " + javaValue); | throw new XTypeMismatch(Character.class, this); | public char asChar() throws XIllegalArgument { if (javaValue.length() == 1) { return javaValue.charAt(0); } else { throw new XIllegalArgument("Expected a character, given a string: " + javaValue); } } |
setFillPaint(Color.BLUE); | setFillPaint(STATION); | public OMStation(Station stat){ super(stat.my_location.latitude, stat.my_location.longitude, xPoints, yPoints, OMPoly.COORDMODE_ORIGIN); station = stat; setFillPaint(Color.BLUE); setLinePaint(Color.BLACK); generate(getProjection()); } |
setFillPaint(Color.BLUE); | setFillPaint(STATION); | public void deselect(){ setFillPaint(Color.BLUE); selected = false; } |
events = svci.findEventsByName(cdURI.getCal(), entityName); | events = getSvci().findEventsByName(cdURI.getCal(), entityName); | public void init(boolean content) throws WebdavIntfException { if (!content) { return; } try { if ((eventInfo == null) && exists) { String entityName = cdURI.getEntityName(); if (entityName == null) { return; } if (debug) { debugMsg("SEARCH: compNode retrieve event on path " + cdURI.getCal().getPath() + " with name " + entityName); } if (events == null) { events = svci.findEventsByName(cdURI.getCal(), entityName); } if ((events == null) || (events.size() == 0)) { exists = false; } else { if (events.size() == 1) { /* Non recurring or no overrides */ eventInfo = (EventInfo)events.iterator().next(); } else { /* Find the master */ // XXX Check the guids here? Iterator it = events.iterator(); while (it.hasNext()) { EventInfo ei = (EventInfo)it.next(); if (ei.getEvent().getRecurring()) { eventInfo = ei; } } if (eventInfo == null) { throw new WebdavIntfException("Missing master for " + cdURI); } } } } if (eventInfo != null) { BwEvent event = eventInfo.getEvent(); creDate = event.getCreated(); lastmodDate = event.getLastmod(); } name = cdURI.getEntityName(); } catch (WebdavIntfException wie) { throw wie; } catch (Throwable t) { throw new WebdavIntfException(t); } } |
public EventInfo(BwEvent event) { setEvent(event); | public EventInfo() { | public EventInfo(BwEvent event) { setEvent(event); } |
fisName = new FissuresNamingServiceImpl(orb); | fisName = new FissuresNamingService(orb); | public static void init(String[] args) { Properties props = initProperties(args); /* Check for properties on the command line and load them if they exist. */ /** Configure log4j, not required for DHI, but is useful. */ BasicConfigurator.configure(); logger.info("Logging configured"); /* Initialize the ORB. This must be done before the corba system can * be used. Parameters passed in via the args and props configure the * ORB. Consult the docummentation for your orb for more information. */ orb = (org.omg.CORBA_2_3.ORB)org.omg.CORBA.ORB.init(args, props); logger.info("orb initialized, class="+orb.getClass().getName()); /* Valuetypes are corba objects that are sent "over the wire" and need * a factory to handle the unmarshalling on the client side, so that the * correct object is created locally. The AllVTFactory.register method * registers factories for all of the IDL defined valuetypes found in * the fissuresImpl package. */ AllVTFactory vt = new AllVTFactory(); vt.register(orb); logger.info("register valuetype factories"); /* Here we pick a name server to connect to. These are two choices for * the IRIS DMC and USC SCEPP, others may exist. Port 6371 are used by * both USC and the DMC, but this is not required.*/ fisName = new FissuresNamingServiceImpl(orb); logger.info("create fisName helper with orb"); //fisName.setNameServiceCorbaLoc("corbaloc:iiop:dmc.iris.washington.edu:6371/NameService"); fisName.setNameServiceCorbaLoc("corbaloc:iiop:pooh.seis.sc.edu:6371/NameService"); //try { NamingContext nc = fisName.getNameService(); logger.info("got fis name service"); } |
public FissuresNamingServiceImpl(org.omg.CORBA_2_3.ORB orb) throws InvalidName { org.omg.CORBA.Object obj = null; obj = orb.resolve_initial_references("NameService"); namingContext = NamingContextExtHelper.narrow(obj); | public FissuresNamingServiceImpl (java.util.Properties props) throws InvalidName { this.props = props; String[] args = new String[0]; orb = (org.omg.CORBA_2_3.ORB)org.omg.CORBA.ORB.init(args, props); AllVTFactory vt = new AllVTFactory(); vt.register(orb); org.omg.CORBA.Object rootObj = orb.resolve_initial_references("NameService"); if (rootObj == null) { logger.info("Name service object is null!"); return; } namingContext = NamingContextExtHelper.narrow(rootObj); logger.info("got Name context"); | public FissuresNamingServiceImpl(org.omg.CORBA_2_3.ORB orb) throws InvalidName { org.omg.CORBA.Object obj = null; obj = orb.resolve_initial_references("NameService"); namingContext = NamingContextExtHelper.narrow(obj); } |
PlottableDC plottabledc = PlottableDCHelper.narrow(getPlottableDC(dns, objectname)); | PlottableDC plottabledc = PlottableDCHelper.narrow(getPlottableDCObject(dns, objectname)); | public PlottableDC getPlottableDC(String dns, String objectname) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName { PlottableDC plottabledc = PlottableDCHelper.narrow(getPlottableDC(dns, objectname)); return plottabledc; } |
int maxTry = 2; for(int i = 0; i < 2; i++) { | int maxTry = 1; for(int i = 0; i <= maxTry; i++) { | public org.omg.CORBA.Object resolve(String dns, String interfacename, String objectname) throws NotFound, CannotProceed, InvalidName, org.omg.CORBA.ORBPackage.InvalidName { dns = appendKindNames(dns); if(interfacename != null && interfacename.length() != 0) { dns = dns + "/" + interfacename + ".interface"; } if(objectname != null && objectname.length() != 0) { dns = dns + "/" + objectname + ".object" + getVersion(); } logger.info("the final dns resolved is " + dns); // try 2 times in case of an exception int maxTry = 2; for(int i = 0; i < 2; i++) { try { NameComponent[] names = getNameService().to_name(dns); //return resolveBySteps(names); // for debugging return getNameService().resolve(names); } catch(org.omg.CORBA.SystemException e) { logger.info("retry=" + i + " " + e); if(i == maxTry) { throw e; } } catch(NotFound nfe) { logger.info("retry=" + i + "NOT FOUND Exception caught while resolving name context and the name not found is " + nfe.rest_of_name[0].id); if(i == maxTry) { throw nfe; } } catch(InvalidName ine) { logger.info("retry=" + i + "INVALID NAME Exception caught while resolving name context", ine); if(i == maxTry) { throw ine; } } catch(CannotProceed cpe) { logger.info("retry=" + i + "CANNOT PROCEED Exception caught while resolving dns name context"); if(i == maxTry) { throw cpe; } } } throw new RuntimeException("This code should never happen"); } |
Iterator e = seismos.keySet().iterator(); while(e.hasNext()){ timeConfig.setBeginTime((DataSetSeismogram)e.next(), b); } | timeConfig.setAllBeginTime(b); | public void setAllBeginTime(MicroSecondDate b){ Iterator e = seismos.keySet().iterator(); while(e.hasNext()){ timeConfig.setBeginTime((DataSetSeismogram)e.next(), b); } } |
semanticHint = UMLVisualIDRegistry.getType(org.eclipse.uml2.diagram.profile.edit.parts.Profile2EditPart.VISUAL_ID); | semanticHint = UMLVisualIDRegistry.getType(Profile2EditPart.VISUAL_ID); | protected void decorateView(View containerView, View view, IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) { if (semanticHint == null) { semanticHint = UMLVisualIDRegistry.getType(org.eclipse.uml2.diagram.profile.edit.parts.Profile2EditPart.VISUAL_ID); view.setType(semanticHint); } super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted); if (!ProfileEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(containerView))) { EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$ shortcutAnnotation.getDetails().put("modelID", ProfileEditPart.MODEL_ID); //$NON-NLS-1$ view.getEAnnotations().add(shortcutAnnotation); } getViewService().createNode(semanticAdapter, view, UMLVisualIDRegistry.getType(ProfileNode_profileEditPart.VISUAL_ID), ViewUtil.APPEND, true, getPreferencesHint()); getViewService().createNode(semanticAdapter, view, UMLVisualIDRegistry.getType(ProfileNameEditPart.VISUAL_ID), ViewUtil.APPEND, true, getPreferencesHint()); getViewService().createNode(semanticAdapter, view, UMLVisualIDRegistry.getType(ProfileContentsEditPart.VISUAL_ID), ViewUtil.APPEND, true, getPreferencesHint()); } |
if(meanDiff == this.ampRange.getMaxValue()) | if(meanDiff >= this.ampRange.getMaxValue() - 1) | public void removeSeismogram(LocalSeismogram aSeis){ MicroSecondTimeRange calcIntv; if(this.timeConfig == null) calcIntv = new MicroSecondTimeRange(((LocalSeismogramImpl)aSeis).getBeginTime(), ((LocalSeismogramImpl)aSeis).getEndTime()); else calcIntv = timeConfig.getTimeRange(aSeis); if(seismos.contains(aSeis)){ LocalSeismogramImpl seis = (LocalSeismogramImpl)aSeis; int beginIndex = SeisPlotUtil.getPixel(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), calcIntv.getBeginTime()); if (beginIndex < 0) beginIndex = 0; if (beginIndex > seis.getNumPoints()) beginIndex = seis.getNumPoints(); int endIndex = SeisPlotUtil.getPixel(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), calcIntv.getEndTime()); if (endIndex < 0) endIndex = 0; if (endIndex > seis.getNumPoints()) endIndex = seis.getNumPoints(); if (endIndex == beginIndex) { seismos.remove(aSeis); return; } try { double min = seis.getMinValue(beginIndex, endIndex).getValue(); double max = seis.getMaxValue(beginIndex, endIndex).getValue(); double mean = seis.getMeanValue(beginIndex, endIndex).getValue(); double meanDiff = (Math.abs(mean - min) > Math.abs(mean - max) ? Math.abs(mean - min) : Math.abs(mean - max)); if(meanDiff == this.ampRange.getMaxValue()) this.ampRange = null; } catch (Exception e) { this.ampRange = null; } seismos.remove(aSeis); if(ampRange == null){ Iterator e = seismos.iterator(); while(e.hasNext()) this.getAmpRange(((LocalSeismogram)e.next()), calcIntv); this.updateAmpSyncListeners(); } } } |
logger.debug("recalculating amp range as defining seismogram was removed"); | public void removeSeismogram(LocalSeismogram aSeis){ MicroSecondTimeRange calcIntv; if(this.timeConfig == null) calcIntv = new MicroSecondTimeRange(((LocalSeismogramImpl)aSeis).getBeginTime(), ((LocalSeismogramImpl)aSeis).getEndTime()); else calcIntv = timeConfig.getTimeRange(aSeis); if(seismos.contains(aSeis)){ LocalSeismogramImpl seis = (LocalSeismogramImpl)aSeis; int beginIndex = SeisPlotUtil.getPixel(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), calcIntv.getBeginTime()); if (beginIndex < 0) beginIndex = 0; if (beginIndex > seis.getNumPoints()) beginIndex = seis.getNumPoints(); int endIndex = SeisPlotUtil.getPixel(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), calcIntv.getEndTime()); if (endIndex < 0) endIndex = 0; if (endIndex > seis.getNumPoints()) endIndex = seis.getNumPoints(); if (endIndex == beginIndex) { seismos.remove(aSeis); return; } try { double min = seis.getMinValue(beginIndex, endIndex).getValue(); double max = seis.getMaxValue(beginIndex, endIndex).getValue(); double mean = seis.getMeanValue(beginIndex, endIndex).getValue(); double meanDiff = (Math.abs(mean - min) > Math.abs(mean - max) ? Math.abs(mean - min) : Math.abs(mean - max)); if(meanDiff == this.ampRange.getMaxValue()) this.ampRange = null; } catch (Exception e) { this.ampRange = null; } seismos.remove(aSeis); if(ampRange == null){ Iterator e = seismos.iterator(); while(e.hasNext()) this.getAmpRange(((LocalSeismogram)e.next()), calcIntv); this.updateAmpSyncListeners(); } } } |
|
public DateTime(Object instant, DateTimeZone zone) { super(instant, zone); | public DateTime() { super(); | public DateTime(Object instant, DateTimeZone zone) { super(instant, zone); } |
return super.meta_select(receiver, selector); | Method[] choices = Symbiosis.getMethods(wrappedObject_.getClass(), jSelector, false); if (choices.length > 0) { return new JavaMethod(this, wrappedObject_, choices); } else { return super.meta_select(receiver, selector); } | public ATObject meta_select(ATObject receiver, ATSymbol selector) throws InterpreterException { String jSelector = Reflection.upSelector(selector); try { return Symbiosis.readField(wrappedObject_, wrappedObject_.getClass(), jSelector); } catch (XUndefinedField e) { return super.meta_select(receiver, selector); } } |
return super.meta_select(receiver, selector); | Method[] choices = Symbiosis.getMethods(wrappedClass_, jSelector, true); if (choices.length > 0) { return new JavaMethod(this, null, choices); } else { return super.meta_select(receiver, selector); } | public ATObject meta_select(ATObject receiver, ATSymbol selector) throws InterpreterException { String jSelector = Reflection.upSelector(selector); try { return Symbiosis.readField(null, wrappedClass_, jSelector); } catch (XUndefinedField e) { return super.meta_select(receiver, selector); } } |
sorter.remove(display.getName()); | sorter.remove(display.getSeismograms()[0].toString()); | public boolean removeDisplay(BasicSeismogramDisplay display){ if(basicDisplays.contains(display)){ if(basicDisplays.size() == 1){ this.removeAll(); return true; } super.remove(display); basicDisplays.remove(display); sorter.remove(display.getName()); ((BasicSeismogramDisplay)basicDisplays.getFirst()).addTopTimeBorder(); ((BasicSeismogramDisplay)basicDisplays.getLast()).addBottomTimeBorder(); super.revalidate(); display.destroy(); repaint(); return true; } return false; } |
href = href.substring(href.indexOf("file:")+1); | href = href.substring(href.indexOf("file:")+5); | public static void insertParameterRef(Element paramRef, String name, String href, Object value) { // write(href, value); //Element paramRef = doc.createElement("parameterRef"); paramRef.setAttribute("name", name); paramRef.setAttributeNS(xlinkNS,"xlink:type", "type/xml"); if(href.startsWith("file:")) { href = href.substring(href.indexOf("file:")+1); } href.replace(' ', '_'); paramRef.setAttributeNS(xlinkNS, "xlink:href", href); if(!(value instanceof String)) { paramRef.setAttribute("objectType", getObjectType(value)); } /* try { DocumentBuilderFactory factory = DocumentBuilderFactory.getInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); } catch(Exception e) { e.printStackTrace(); }*/ } |
href.replace(' ', '_'); | href = href.replace(' ', '_'); | public static void insertParameterRef(Element paramRef, String name, String href, Object value) { // write(href, value); //Element paramRef = doc.createElement("parameterRef"); paramRef.setAttribute("name", name); paramRef.setAttributeNS(xlinkNS,"xlink:type", "type/xml"); if(href.startsWith("file:")) { href = href.substring(href.indexOf("file:")+1); } href.replace(' ', '_'); paramRef.setAttributeNS(xlinkNS, "xlink:href", href); if(!(value instanceof String)) { paramRef.setAttribute("objectType", getObjectType(value)); } /* try { DocumentBuilderFactory factory = DocumentBuilderFactory.getInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); } catch(Exception e) { e.printStackTrace(); }*/ } |
public static void insert(Element element, Channel channel) { | public static void insert(XMLStreamWriter writer, Channel channel) throws XMLStreamException{ writer.writeStartElement("id"); XMLChannelId.insert(writer, channel.get_id()); XMLUtil.writeEndElementWithNewLine(writer); | public static void insert(Element element, Channel channel) { Document doc = element.getOwnerDocument(); Element id = doc.createElement("id"); XMLChannelId.insert(id, channel.get_id()); element.appendChild(id); element.appendChild(XMLUtil.createTextElement(doc, "name", channel.name)); Element an_orientation = doc.createElement("an_orientation"); XMLOrientation.insert(an_orientation, channel.an_orientation); element.appendChild(an_orientation); Element sampling_info = doc.createElement("sampling_info"); XMLSampling.insert(sampling_info, channel.sampling_info); element.appendChild(sampling_info); Element effective_time = doc.createElement("effective_time"); XMLTimeRange.insert(effective_time, channel.effective_time); element.appendChild(effective_time); Element my_site = doc.createElement("my_site"); XMLSite.insert(my_site, channel.my_site); element.appendChild(my_site); } |
Document doc = element.getOwnerDocument(); | XMLUtil.writeTextElement(writer, "name", channel.name); | public static void insert(Element element, Channel channel) { Document doc = element.getOwnerDocument(); Element id = doc.createElement("id"); XMLChannelId.insert(id, channel.get_id()); element.appendChild(id); element.appendChild(XMLUtil.createTextElement(doc, "name", channel.name)); Element an_orientation = doc.createElement("an_orientation"); XMLOrientation.insert(an_orientation, channel.an_orientation); element.appendChild(an_orientation); Element sampling_info = doc.createElement("sampling_info"); XMLSampling.insert(sampling_info, channel.sampling_info); element.appendChild(sampling_info); Element effective_time = doc.createElement("effective_time"); XMLTimeRange.insert(effective_time, channel.effective_time); element.appendChild(effective_time); Element my_site = doc.createElement("my_site"); XMLSite.insert(my_site, channel.my_site); element.appendChild(my_site); } |
Element id = doc.createElement("id"); XMLChannelId.insert(id, channel.get_id()); element.appendChild(id); | writer.writeStartElement("an_orientation"); XMLOrientation.insert(writer, channel.an_orientation); XMLUtil.writeEndElementWithNewLine(writer); | public static void insert(Element element, Channel channel) { Document doc = element.getOwnerDocument(); Element id = doc.createElement("id"); XMLChannelId.insert(id, channel.get_id()); element.appendChild(id); element.appendChild(XMLUtil.createTextElement(doc, "name", channel.name)); Element an_orientation = doc.createElement("an_orientation"); XMLOrientation.insert(an_orientation, channel.an_orientation); element.appendChild(an_orientation); Element sampling_info = doc.createElement("sampling_info"); XMLSampling.insert(sampling_info, channel.sampling_info); element.appendChild(sampling_info); Element effective_time = doc.createElement("effective_time"); XMLTimeRange.insert(effective_time, channel.effective_time); element.appendChild(effective_time); Element my_site = doc.createElement("my_site"); XMLSite.insert(my_site, channel.my_site); element.appendChild(my_site); } |
element.appendChild(XMLUtil.createTextElement(doc, "name", channel.name)); | writer.writeStartElement("sampling_info"); XMLSampling.insert(writer, channel.sampling_info); XMLUtil.writeEndElementWithNewLine(writer); | public static void insert(Element element, Channel channel) { Document doc = element.getOwnerDocument(); Element id = doc.createElement("id"); XMLChannelId.insert(id, channel.get_id()); element.appendChild(id); element.appendChild(XMLUtil.createTextElement(doc, "name", channel.name)); Element an_orientation = doc.createElement("an_orientation"); XMLOrientation.insert(an_orientation, channel.an_orientation); element.appendChild(an_orientation); Element sampling_info = doc.createElement("sampling_info"); XMLSampling.insert(sampling_info, channel.sampling_info); element.appendChild(sampling_info); Element effective_time = doc.createElement("effective_time"); XMLTimeRange.insert(effective_time, channel.effective_time); element.appendChild(effective_time); Element my_site = doc.createElement("my_site"); XMLSite.insert(my_site, channel.my_site); element.appendChild(my_site); } |
Element an_orientation = doc.createElement("an_orientation"); XMLOrientation.insert(an_orientation, channel.an_orientation); element.appendChild(an_orientation); | writer.writeStartElement("effective_time"); XMLTimeRange.insert(writer, channel.effective_time); XMLUtil.writeEndElementWithNewLine(writer); | public static void insert(Element element, Channel channel) { Document doc = element.getOwnerDocument(); Element id = doc.createElement("id"); XMLChannelId.insert(id, channel.get_id()); element.appendChild(id); element.appendChild(XMLUtil.createTextElement(doc, "name", channel.name)); Element an_orientation = doc.createElement("an_orientation"); XMLOrientation.insert(an_orientation, channel.an_orientation); element.appendChild(an_orientation); Element sampling_info = doc.createElement("sampling_info"); XMLSampling.insert(sampling_info, channel.sampling_info); element.appendChild(sampling_info); Element effective_time = doc.createElement("effective_time"); XMLTimeRange.insert(effective_time, channel.effective_time); element.appendChild(effective_time); Element my_site = doc.createElement("my_site"); XMLSite.insert(my_site, channel.my_site); element.appendChild(my_site); } |
Element sampling_info = doc.createElement("sampling_info"); XMLSampling.insert(sampling_info, channel.sampling_info); element.appendChild(sampling_info); Element effective_time = doc.createElement("effective_time"); XMLTimeRange.insert(effective_time, channel.effective_time); element.appendChild(effective_time); Element my_site = doc.createElement("my_site"); XMLSite.insert(my_site, channel.my_site); element.appendChild(my_site); | writer.writeStartElement("my_site"); XMLSite.insert(writer, channel.my_site); XMLUtil.writeEndElementWithNewLine(writer); | public static void insert(Element element, Channel channel) { Document doc = element.getOwnerDocument(); Element id = doc.createElement("id"); XMLChannelId.insert(id, channel.get_id()); element.appendChild(id); element.appendChild(XMLUtil.createTextElement(doc, "name", channel.name)); Element an_orientation = doc.createElement("an_orientation"); XMLOrientation.insert(an_orientation, channel.an_orientation); element.appendChild(an_orientation); Element sampling_info = doc.createElement("sampling_info"); XMLSampling.insert(sampling_info, channel.sampling_info); element.appendChild(sampling_info); Element effective_time = doc.createElement("effective_time"); XMLTimeRange.insert(effective_time, channel.effective_time); element.appendChild(effective_time); Element my_site = doc.createElement("my_site"); XMLSite.insert(my_site, channel.my_site); element.appendChild(my_site); } |
GenericCommandExecute.execute(command); | FileOutputStream fos = new FileOutputStream(psFilename, true); try { GenericCommandExecute.execute(command, new StringReader(""), fos, System.err); } finally { fos.close(); } | public static void close(String psFilename, String projection, String region) throws InterruptedException, IOException { String command = "psxy /dev/null -V -J" + projection + " -R" + region + " -O"; GenericCommandExecute.execute(command); } |
addPoints("/Volumes/heff/oliverpa/gmtTest/world.ps", | addPoints("world.ps", | public static void main(String[] args) { try { double[][] points = { {-180, 90}, {-135, 67.5}, {-90, 45}, {-45, 22.5}, {0, 0}}; addPoints("/Volumes/heff/oliverpa/gmtTest/world.ps", "Kf166/10i", "-14/346/-90/90", "t0.4", "0/0/255", "5/255", points); double[][] morePoints = { {45, -22.5, 0.7}, {90, -45, 0.5}, {135, -67.5, 0.4}, {180, -90, 1.0}}; addPoints("/Volumes/heff/oliverpa/gmtTest/world.ps", "Kf166/10i", "-14/346/-90/90", "ci", null, "12/255/0/0", morePoints); } catch(Exception e) { e.printStackTrace(); } } //private static Logger logger = Logger.getLogger(PSXYExecute.class); |
close("world.ps", "Kf166/10i", "-14/346/-90/90"); | public static void main(String[] args) { try { double[][] points = { {-180, 90}, {-135, 67.5}, {-90, 45}, {-45, 22.5}, {0, 0}}; addPoints("/Volumes/heff/oliverpa/gmtTest/world.ps", "Kf166/10i", "-14/346/-90/90", "t0.4", "0/0/255", "5/255", points); double[][] morePoints = { {45, -22.5, 0.7}, {90, -45, 0.5}, {135, -67.5, 0.4}, {180, -90, 1.0}}; addPoints("/Volumes/heff/oliverpa/gmtTest/world.ps", "Kf166/10i", "-14/346/-90/90", "ci", null, "12/255/0/0", morePoints); } catch(Exception e) { e.printStackTrace(); } } //private static Logger logger = Logger.getLogger(PSXYExecute.class); |
|
public static int execute(String command, Reader stdin, OutputStream stdout, OutputStream stderr) throws InterruptedException, | public static int execute(String command) throws InterruptedException, | public static int execute(String command, Reader stdin, OutputStream stdout, OutputStream stderr) throws InterruptedException, IOException { Runtime rt = Runtime.getRuntime(); System.out.println("executing command: " + command); Process proc = rt.exec(command); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdout)); BufferedWriter inWriter = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())); BufferedReader errReader = new BufferedReader(new InputStreamReader(proc.getErrorStream())); BufferedWriter errWriter = new BufferedWriter(new OutputStreamWriter(stderr)); StreamPump pump = new StreamPump(reader, writer, false); pump.setName("stdout"); StreamPump errPump = new StreamPump(errReader, errWriter, false); errPump.setName("stderr"); StreamPump stdInPump = new StreamPump(new BufferedReader(stdin), inWriter, true); stdInPump.setName("stdin"); pump.start(); stdInPump.start(); errPump.start(); int exitVal = proc.waitFor(); //waiting for finish of StreamPump runs synchronized(pump) {} synchronized(stdInPump) {} synchronized(errPump) {} System.out.println("command returned exit value " + exitVal); if(!pump.hasCompleted() || !errPump.hasCompleted()) { throw new IllegalStateException("Pumps must complete"); } return exitVal; } |
Runtime rt = Runtime.getRuntime(); System.out.println("executing command: " + command); Process proc = rt.exec(command); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdout)); BufferedWriter inWriter = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())); BufferedReader errReader = new BufferedReader(new InputStreamReader(proc.getErrorStream())); BufferedWriter errWriter = new BufferedWriter(new OutputStreamWriter(stderr)); StreamPump pump = new StreamPump(reader, writer, false); pump.setName("stdout"); StreamPump errPump = new StreamPump(errReader, errWriter, false); errPump.setName("stderr"); StreamPump stdInPump = new StreamPump(new BufferedReader(stdin), inWriter, true); stdInPump.setName("stdin"); pump.start(); stdInPump.start(); errPump.start(); int exitVal = proc.waitFor(); synchronized(pump) {} synchronized(stdInPump) {} synchronized(errPump) {} System.out.println("command returned exit value " + exitVal); if(!pump.hasCompleted() || !errPump.hasCompleted()) { throw new IllegalStateException("Pumps must complete"); } return exitVal; | return execute(command, new StringReader(""), System.out, System.err); | public static int execute(String command, Reader stdin, OutputStream stdout, OutputStream stderr) throws InterruptedException, IOException { Runtime rt = Runtime.getRuntime(); System.out.println("executing command: " + command); Process proc = rt.exec(command); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdout)); BufferedWriter inWriter = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())); BufferedReader errReader = new BufferedReader(new InputStreamReader(proc.getErrorStream())); BufferedWriter errWriter = new BufferedWriter(new OutputStreamWriter(stderr)); StreamPump pump = new StreamPump(reader, writer, false); pump.setName("stdout"); StreamPump errPump = new StreamPump(errReader, errWriter, false); errPump.setName("stderr"); StreamPump stdInPump = new StreamPump(new BufferedReader(stdin), inWriter, true); stdInPump.setName("stdin"); pump.start(); stdInPump.start(); errPump.start(); int exitVal = proc.waitFor(); //waiting for finish of StreamPump runs synchronized(pump) {} synchronized(stdInPump) {} synchronized(errPump) {} System.out.println("command returned exit value " + exitVal); if(!pump.hasCompleted() || !errPump.hasCompleted()) { throw new IllegalStateException("Pumps must complete"); } return exitVal; } |
public JDBCQuantity(Connection conn) throws SQLException{ this(new JDBCUnit(conn), conn); | public JDBCQuantity()throws SQLException{ this(ConnMgr.createConnection()); | public JDBCQuantity(Connection conn) throws SQLException{ this(new JDBCUnit(conn), conn); } |
if (cal.getChildren().size() > 0) { form.getErr().emit("org.bedework.client.error.calendar.referenced"); return "inUse"; } | public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { if (form.getGuest()) { return "noAccess"; // First line of defence } BwCalendar cal = form.getCalendar(); int delResult = form.fetchSvci().deleteCalendar(cal); if (delResult == 2) { form.getErr().emit("org.bedework.client.error.calendar.referenced"); return "inUse"; } if (delResult == 1) { form.getErr().emit("org.bedework.client.error.nosuchcalendar", cal.getId()); return "notFound"; } form.getMsg().emit("org.bedework.client.message.calendar.deleted"); return "continue"; } |
|
Main.getMainFrame().scoreSheet.resetUsedRowsHack(); | public void setMode(int mode) { if (mode <= Main.MODE_IN_LOBBY) { gameBoardData.init(); scoreSheetCaptionData.init(); scoreSheetHoteltypeData.init(); Main.getMainFrame().scoreSheet.resetUsedRowsHack(); } if (mode < Main.MODE_IN_LOBBY) { userListPresenter.init(); } } |
|
Main.getMainFrame().setComponentsBounds(); | public void sync(ScoreSheetCaptionData sscd, ScoreSheetHoteltypeData sshtd) { makeOnlyUsedRowsVisible(sscd); for (int y=0; y<10; ++y) { for (int x=0; x<10; ++x) { boolean repaint = false; Object caption = sscd.getCaption(x, y); if (scoreSheetCaptionData.getCaption(x, y) != caption) { scoreSheetCaptionData.setCaption(x, y, caption); if (caption == null) { caption = 0; } if (caption.getClass() == Integer.class) { if (((Integer)caption) == 0) { if (x >= 1 && x <= 7) { if (y >= 1 && y <= 6) { caption = " "; } else if (y >= 8 && y <= 9) { caption = "-"; } } } if (x >= 8 && x <= 9 && y >= 1 && y <= 6) { caption = (Integer)caption * 100; } } scoreSheet[y][x].setText(caption.toString()); repaint = true; } int hoteltype = sshtd.getHoteltype(x, y); if (scoreSheetHoteltypeData.getHoteltype(x, y) != hoteltype) { scoreSheetHoteltypeData.setHoteltype(x, y, hoteltype); scoreSheet[y][x].setBackgroundColor(Util.hoteltypeToColor(hoteltype)); repaint = true; } if (repaint) { scoreSheet[y][x].repaint(); } } } } |
|
graphics2d.drawString(string, xc - offsetX, yc - offsetY); | AttributedString as = new AttributedString(string); as.addAttribute(TextAttribute.FONT, graphics2d.getFont()); boolean isHyperlink = (this.getIdea().getUrl().length() > 0); if (isHyperlink) { as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); } graphics2d.drawString(as.getIterator(), xc - offsetX, yc - offsetY); | void drawString(Graphics2D graphics2d, String string, Point p, int alignment, double orientation, boolean editing, IdeaMap map) { double orient = orientation % Math.PI; if (orient > (Math.PI / 2.0)) { orient -= Math.PI; } if (orient < (-Math.PI / 2.0)) { orient += Math.PI; } int xc = p.x; int yc = p.y; AffineTransform transform = graphics2d.getTransform(); transform(graphics2d, orient, xc, yc); FontMetrics fm = graphics2d.getFontMetrics(); double realTextWidth = fm.stringWidth(string); double realTextHeight = fm.getHeight() - fm.getDescent(); int offsetX = (int) (realTextWidth * (double) (alignment % 3) / 2.0); int offsetY = (int) (-realTextHeight * (double) (alignment / 3) / 2.0); if (!editing) { if ((graphics2d != null) && (string != null)) { graphics2d.drawString(string, xc - offsetX, yc - offsetY); } } else { Graphics2D g2d = (Graphics2D)graphics2d.create(xc - offsetX - 5, yc + offsetY - 5, (int) realTextWidth + 10, (int) realTextHeight + 10); map.getTextField().paint(g2d); g2d.dispose(); } graphics2d.setTransform(transform); } |
public BranchView(Idea anIdea) { super(anIdea); | public BranchView() { this(null); | public BranchView(Idea anIdea) { super(anIdea); } |
public MutablePeriod(Object period, PeriodType type) { super(period, type, null); | public MutablePeriod() { super(0L, null, null); | public MutablePeriod(Object period, PeriodType type) { super(period, type, null); } |
public int sort(LocalSeismogramImpl seismo){ String name = seismo.getName(); int i = 0; while(i < names.size() && ((String)names.get(i)).compareToIgnoreCase(name) < 0){ i++; } names.add(i, seismo.getName()); return i; | public int sort(LocalSeismogramImpl seismo, String name){ names.add(name); return names.size(); | public int sort(LocalSeismogramImpl seismo){ String name = seismo.getName(); int i = 0; while(i < names.size() && ((String)names.get(i)).compareToIgnoreCase(name) < 0){ i++; } names.add(i, seismo.getName()); return i; } |
public DataSetSeismogram(RequestFilter rf, DataCenterOperations dco) { this(rf, dco, null); | public DataSetSeismogram() { this.dssDataListeners = new LinkedList(); this.rfChangeListeners = new LinkedList(); | public DataSetSeismogram(RequestFilter rf, DataCenterOperations dco) { this(rf, dco, null); } |
Vector headers = null; Vector cont = null; | Collection headers = null; Collection cont = null; | Req(String user, String pw, String testFileName) throws Throwable { this.user = user; this.pw = pw; FileReader frdr = null; try { File testFile = new File(testFileName); frdr = new FileReader(testFile); LineNumberReader lnr = new LineNumberReader(frdr); Vector headers = null; Vector cont = null; do { String ln = lnr.readLine(); if (ln == null) { break; } if (ln.trim().length() == 0) { continue; } if (cont != null) { /* swallow remaining as content */ cont.add(ln); } else if ((description == null) && (ln.startsWith(descHdr))) { /* DESCRIPTION */ description = ln.substring(descHdr.length()); } else if (ln.startsWith(exprespHdr)) { /* EXPECT-RESPONSE */ expectedResp = Integer.parseInt(ln.substring(exprespHdr.length())); } else if ((method == null) && (ln.startsWith(methHdr))) { /* METHOD */ method = ln.substring(methHdr.length()); } else if (ln.startsWith(authHdr)) { /* AUTH */ auth = "true".equals(ln.substring(authHdr.length())); } else if ((url == null) && (ln.startsWith(urlHdr))) { /* URL */ url = ln.substring(urlHdr.length()); } else if (ln.startsWith(hdrHdr)) { /* HEADER */ if (headers == null) { headers = new Vector(); } String hdr = ln.substring(hdrHdr.length()); int colonPos = hdr.indexOf(": "); if (colonPos < 0) { throw new Exception("Bad header in test data file " + testFileName); } headers.add(new Header(hdr.substring(0, colonPos), hdr.substring(colonPos + 2))); } else if ((contentType == null) && (ln.startsWith(ctypeHdr))) { /* CONTENTTYPE */ contentType = ln.substring(ctypeHdr.length()); } else if (ln.startsWith(contFileHdr)) { /* CONTENTFILE */ fromFile = true; contentFileName = ln.substring(contFileHdr.length()); File contentFile = new File(contentFileName); if (!contentFile.isAbsolute()) { contentFileName = testFile.getParentFile().getAbsolutePath() + "/" + contentFileName; } System.out.println("Load content from file " + contentFileName); } else if (!fromFile && ln.startsWith(contHdr)) { /* CONTENT */ if (cont == null) { cont = new Vector(); } } else { throw new Exception("Bad test data file " + testFileName); } } while (true); if (headers != null) { hdrs = (Header[])headers.toArray(new Header[headers.size()]); } if (cont != null) { content = (String[])cont.toArray(new String[cont.size()]); } } finally { if (frdr != null) { try { frdr.close(); } catch (Throwable t) {} } } } |
headers = new Vector(); | headers = new ArrayList(); | Req(String user, String pw, String testFileName) throws Throwable { this.user = user; this.pw = pw; FileReader frdr = null; try { File testFile = new File(testFileName); frdr = new FileReader(testFile); LineNumberReader lnr = new LineNumberReader(frdr); Vector headers = null; Vector cont = null; do { String ln = lnr.readLine(); if (ln == null) { break; } if (ln.trim().length() == 0) { continue; } if (cont != null) { /* swallow remaining as content */ cont.add(ln); } else if ((description == null) && (ln.startsWith(descHdr))) { /* DESCRIPTION */ description = ln.substring(descHdr.length()); } else if (ln.startsWith(exprespHdr)) { /* EXPECT-RESPONSE */ expectedResp = Integer.parseInt(ln.substring(exprespHdr.length())); } else if ((method == null) && (ln.startsWith(methHdr))) { /* METHOD */ method = ln.substring(methHdr.length()); } else if (ln.startsWith(authHdr)) { /* AUTH */ auth = "true".equals(ln.substring(authHdr.length())); } else if ((url == null) && (ln.startsWith(urlHdr))) { /* URL */ url = ln.substring(urlHdr.length()); } else if (ln.startsWith(hdrHdr)) { /* HEADER */ if (headers == null) { headers = new Vector(); } String hdr = ln.substring(hdrHdr.length()); int colonPos = hdr.indexOf(": "); if (colonPos < 0) { throw new Exception("Bad header in test data file " + testFileName); } headers.add(new Header(hdr.substring(0, colonPos), hdr.substring(colonPos + 2))); } else if ((contentType == null) && (ln.startsWith(ctypeHdr))) { /* CONTENTTYPE */ contentType = ln.substring(ctypeHdr.length()); } else if (ln.startsWith(contFileHdr)) { /* CONTENTFILE */ fromFile = true; contentFileName = ln.substring(contFileHdr.length()); File contentFile = new File(contentFileName); if (!contentFile.isAbsolute()) { contentFileName = testFile.getParentFile().getAbsolutePath() + "/" + contentFileName; } System.out.println("Load content from file " + contentFileName); } else if (!fromFile && ln.startsWith(contHdr)) { /* CONTENT */ if (cont == null) { cont = new Vector(); } } else { throw new Exception("Bad test data file " + testFileName); } } while (true); if (headers != null) { hdrs = (Header[])headers.toArray(new Header[headers.size()]); } if (cont != null) { content = (String[])cont.toArray(new String[cont.size()]); } } finally { if (frdr != null) { try { frdr.close(); } catch (Throwable t) {} } } } |
cont = new Vector(); | cont = new ArrayList(); | Req(String user, String pw, String testFileName) throws Throwable { this.user = user; this.pw = pw; FileReader frdr = null; try { File testFile = new File(testFileName); frdr = new FileReader(testFile); LineNumberReader lnr = new LineNumberReader(frdr); Vector headers = null; Vector cont = null; do { String ln = lnr.readLine(); if (ln == null) { break; } if (ln.trim().length() == 0) { continue; } if (cont != null) { /* swallow remaining as content */ cont.add(ln); } else if ((description == null) && (ln.startsWith(descHdr))) { /* DESCRIPTION */ description = ln.substring(descHdr.length()); } else if (ln.startsWith(exprespHdr)) { /* EXPECT-RESPONSE */ expectedResp = Integer.parseInt(ln.substring(exprespHdr.length())); } else if ((method == null) && (ln.startsWith(methHdr))) { /* METHOD */ method = ln.substring(methHdr.length()); } else if (ln.startsWith(authHdr)) { /* AUTH */ auth = "true".equals(ln.substring(authHdr.length())); } else if ((url == null) && (ln.startsWith(urlHdr))) { /* URL */ url = ln.substring(urlHdr.length()); } else if (ln.startsWith(hdrHdr)) { /* HEADER */ if (headers == null) { headers = new Vector(); } String hdr = ln.substring(hdrHdr.length()); int colonPos = hdr.indexOf(": "); if (colonPos < 0) { throw new Exception("Bad header in test data file " + testFileName); } headers.add(new Header(hdr.substring(0, colonPos), hdr.substring(colonPos + 2))); } else if ((contentType == null) && (ln.startsWith(ctypeHdr))) { /* CONTENTTYPE */ contentType = ln.substring(ctypeHdr.length()); } else if (ln.startsWith(contFileHdr)) { /* CONTENTFILE */ fromFile = true; contentFileName = ln.substring(contFileHdr.length()); File contentFile = new File(contentFileName); if (!contentFile.isAbsolute()) { contentFileName = testFile.getParentFile().getAbsolutePath() + "/" + contentFileName; } System.out.println("Load content from file " + contentFileName); } else if (!fromFile && ln.startsWith(contHdr)) { /* CONTENT */ if (cont == null) { cont = new Vector(); } } else { throw new Exception("Bad test data file " + testFileName); } } while (true); if (headers != null) { hdrs = (Header[])headers.toArray(new Header[headers.size()]); } if (cont != null) { content = (String[])cont.toArray(new String[cont.size()]); } } finally { if (frdr != null) { try { frdr.close(); } catch (Throwable t) {} } } } |
public int sendRequest(String method, String url, String user, String pw, Header[] hdrs, String contentType, int contentLen, byte[] content) throws Throwable { client.setMethodName(method, url); HttpMethod meth = client.getMethod(); if (user != null) { String upw = user + ":" + pw; meth.setRequestHeader("Authorization", "Basic " + new String(new BASE64Encoder().encode (upw.getBytes()))); } if (hdrs != null) { for (int i = 0; i < hdrs.length; i++) { meth.setRequestHeader(hdrs[i]); } } if (contentType == null) { contentType = "text/xml"; } if (content != null) { client.setContent(content, contentType); } status = client.execute(); return status; | public int sendRequest(String method, String url, Header[] hdrs, String contentType, int contentLen, byte[] content) throws Throwable { return sendRequest(method, url, null, null, hdrs, contentType, contentLen, content); | public int sendRequest(String method, String url, String user, String pw, Header[] hdrs, String contentType, int contentLen, byte[] content) throws Throwable { client.setMethodName(method, url); HttpMethod meth = client.getMethod(); if (user != null) { String upw = user + ":" + pw; meth.setRequestHeader("Authorization", "Basic " + new String(new BASE64Encoder().encode (upw.getBytes()))); } if (hdrs != null) { for (int i = 0; i < hdrs.length; i++) { meth.setRequestHeader(hdrs[i]); } } if (contentType == null) { contentType = "text/xml"; } if (content != null) { client.setContent(content, contentType); } status = client.execute(); return status; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.