rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
for(int i=numberOfParameters-1;i>0;) vars[i].setValue(stack.pop());
for(int i=numberOfParameters;i>0;--i) vars[i-1].setValue(stack.pop());
public void run(Stack stack) throws ParseException { if(numberOfParameters == 0) {} else if(numberOfParameters == 1) vars[0].setValue(stack.pop()); else if(numberOfParameters == 2) { vars[1].setValue(stack.pop()); vars[0].setValue(stack.pop()); } else { for(int i=numberOfParameters-1;i>0;) vars[i].setValue(stack.pop()); } try { Object res = ev.getValue(topNode,mySymTab); stack.push(res); } catch(Exception e1) { throw new ParseException("MacroFunction eval: "+e1.getMessage()); } }
return new PrintWriter(out);
return new PrintWriter(new OutputStreamWriter(out),true);
public PrintWriter error(String msg) { out.println(msg); return new PrintWriter(out); }
if ((param1 instanceof Number) && (param2 instanceof Number)) { double x = ((Number)param1).doubleValue(); double y = ((Number)param2).doubleValue(); return (x==y); }
public boolean eq(Object param1, Object param2) throws ParseException { if ((param1 instanceof Complex) && (param2 instanceof Complex)) { return ((Complex)param1).equals((Complex)param2, tolerance); } if ((param1 instanceof Complex) && (param2 instanceof Double)) { return ((Complex)param1).equals(new Complex((Number)param2), tolerance); } if ((param2 instanceof Complex) && (param1 instanceof Double)) { return ((Complex)param2).equals(new Complex((Number)param1), tolerance); } // if we get to here, just use the equal function return param1.equals(param2); }
if ((param1 instanceof Number) && (param2 instanceof Number)) { double x = ((Number)param1).doubleValue(); double y = ((Number)param2).doubleValue(); return (x!=y); }
public boolean ne(Object param1, Object param2) throws ParseException { if ((param1 instanceof Complex) && (param2 instanceof Complex)) { return !((Complex)param1).equals((Complex)param2, tolerance); } if ((param1 instanceof Complex) && (param2 instanceof Double)) { return !((Complex)param1).equals(new Complex((Number) param2), tolerance); } if ((param2 instanceof Complex) && (param1 instanceof Double)) { return !((Complex)param2).equals(new Complex((Number) param1), tolerance); } return !param1.equals(param2); }
for(int j=-1;j<=maxPrec;++j)
for(int jj=-1;jj<=maxPrec;++jj)
public void printOps() { println("Known operators"); Operator ops[] = j.getOperatorSet().getOperators(); int maxPrec = -1; for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()>maxPrec) maxPrec=((XOperator) ops[i]).getPrecedence(); for(int j=-1;j<=maxPrec;++j) for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()==j) println(((XOperator) ops[i]).toFullString()); }
if(((XOperator) ops[i]).getPrecedence()==j)
if(((XOperator) ops[i]).getPrecedence()==jj)
public void printOps() { println("Known operators"); Operator ops[] = j.getOperatorSet().getOperators(); int maxPrec = -1; for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()>maxPrec) maxPrec=((XOperator) ops[i]).getPrecedence(); for(int j=-1;j<=maxPrec;++j) for(int i=0;i<ops.length;++i) if(((XOperator) ops[i]).getPrecedence()==j) println(((XOperator) ops[i]).toFullString()); }
timeRegistrar = new TimeConfigRegistrar(); ampRegistrar = new AmpConfigRegistrar();
timeRegistrar = new TimeConfigRegistrar(new BoundedTimeConfig(timeRegistrar)); ampRegistrar = new AmpConfigRegistrar(new RMeanAmpConfig(ampRegistrar));
public BasicSeismogramDisplay(LocalSeismogram seis, String name, VerticalSeismogramDisplay parent){ timeRegistrar = new TimeConfigRegistrar(); ampRegistrar = new AmpConfigRegistrar(); initializeDisplay(seis, name, parent); }
parent.removeAll(me);
parent.removeAll();
public void removeAll(MouseEvent me){ logger.debug("remove all called"); parent.removeAll(me); }
public void remove(){ display.remove(); }
public void remove(){ if(display != null) display.remove(); }
public void remove(){ display.remove(); }
if (param instanceof Number) {
if (param instanceof Complex) return new Double(((Complex)param).re()); else if (param instanceof Number)
public Number re(Object param) throws ParseException { if (param instanceof Number) { return ((Number)param); } else if (param instanceof Complex) { return new Double(((Complex)param).re()); } throw new ParseException("Invalid parameter type"); }
} else if (param instanceof Complex) { return new Double(((Complex)param).re()); }
public Number re(Object param) throws ParseException { if (param instanceof Number) { return ((Number)param); } else if (param instanceof Complex) { return new Double(((Complex)param).re()); } throw new ParseException("Invalid parameter type"); }
validatePrincipal(user.getCredential(), errors);
public void validate(Object obj, Errors errors) { if (obj==null) { errors.reject("user.error.nullpointer", "Null user received"); } else { User user = (User) obj; validatePrincipal(user.getCredential(), errors); } }
j.dv.printDiffRules();
j.getDifferentationVisitor().printDiffRules();
private String getCommand() throws IOException { String s; if (br == null) return null; if ( (s = br.readLine()) == null) return null; if( s.equals("rules")) { j.dv.printDiffRules(); System.out.println("dJEPdx - Enter q to quit, rules to print the differentation rules,\ndiff(x^2,x) to differentiate,\neval(x^y,x,2,y,3) to evaluate"); System.out.print(prompt); return getCommand(); } if (s.equals("q") || s.equals("quit") || s.equals("exit")) return null; return s; }
j.dv.addStandardDiffRules();
j.addStandardDiffRules();
public void initialise() { j = new DJep(); j.addStandardConstants(); j.addStandardFunctions(); j.addComplex(); j.setAllowUndeclared(true); j.setAllowAssignment(true); j.setImplicitMul(true); j.dv.addStandardDiffRules(); //j.setTraverse(true); }
Node processed = j.commandv.process(node,j);
Node processed = j.preprocess(node);
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
j.pv.setFullBrackets(true);
j.getPrintVisitor().setFullBrackets(true);
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
j.pv.setFullBrackets(false);
j.getPrintVisitor().setFullBrackets(false);
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
((DSymbolTable) j.getSymbolTable()).print(j.pv);
((DSymbolTable) j.getSymbolTable()).print(j.getPrintVisitor());
public void processEquation(Node node) { try { System.out.print("fun:\t\t"); j.println(node); Node processed = j.commandv.process(node,j); System.out.print("Processed:\t"); j.println(processed); Node simp = j.simplify(processed); System.out.print("Simplified:\t"); j.println(simp); System.out.print("Full Brackets:\t"); j.pv.setFullBrackets(true); j.println(simp); j.pv.setFullBrackets(false); try { Object res = j.evaluate(simp); System.out.println("Value:\t"+res.toString()); } catch(Exception e2) { System.out.println("Value:\tnull "+e2.getMessage()); } // Node diff = dv.differentiate(simp,"x"); // System.out.print("dfun/dx:\t"); // bpv.println(diff); // simp = sv.simplify(diff); // System.out.print("Simplified:\t"); // bpv.println(simp); System.out.println("Variables"); ((DSymbolTable) j.getSymbolTable()).print(j.pv); } catch(ParseException e1) { System.out.println("Parse Error: "+e1.getMessage()); } catch(IllegalArgumentException e2) { System.out.println(e2.getMessage()); } catch(Exception e3) { System.out.println(e3.getMessage()); } }
updateTries ++; if ( updateTries > WINDOWS_PER_SECONDS * 2 ) { break; }
private void updateWindow( boolean blockTillAvailable ) { boolean wasInterrupted = false; long elapsedWindowMillis; long now; while ( true ) { now = System.currentTimeMillis(); elapsedWindowMillis = now - lastWindowTime; if (elapsedWindowMillis >= MILLIS_PER_WINDOW ) { // last window used up too many bytes... if ( bytesRemaining < 0 ) { bytesRemaining += bytesPerWindow; } else { bytesRemaining = bytesPerWindow; } lastWindowTime = now; if ( NLogger.isDebugEnabled( NLoggerNames.BANDWIDTH ) ) NLogger.debug(NLoggerNames.BANDWIDTH, "["+controllerName + "] Update new Window " + bytesPerWindow + " - Remaining: " + bytesRemaining + "."); } if ( !blockTillAvailable || bytesRemaining > 0 ) { break; } try { Thread.sleep( Math.max( MILLIS_PER_WINDOW - elapsedWindowMillis, 0 ) ); } catch (InterruptedException e) { wasInterrupted = true; break; } } if ( wasInterrupted ) {//reset interrupted Thread.currentThread().interrupt(); } }
if (param1 instanceof Number)
if (param1 instanceof Complex)
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
if (param2 instanceof Number)
if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Number) { if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Number)
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2);
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); }
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
if (param2 instanceof Number)
if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); else if (param2 instanceof Number)
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2);
public Object div(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) return div((Number)param1, (Number)param2); else if (param2 instanceof Complex) return div((Number)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Number)param1, (Vector)param2); } else if (param1 instanceof Complex) { if (param2 instanceof Number) return div((Complex)param1, (Number)param2); else if (param2 instanceof Complex) return div((Complex)param1, (Complex)param2); else if (param2 instanceof Vector) return div((Complex)param1, (Vector)param2); } else if (param1 instanceof Vector) { if (param2 instanceof Number) return div((Vector)param1, (Number)param2); else if (param2 instanceof Complex) return div((Vector)param1, (Complex)param2); } throw new ParseException("Invalid parameter type"); }
m.setCost(Double.parseDouble(value.toString()));
m.setCost(value.toString());
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())); break; case 2 : m.setUnits(value.toString()); break; case 3 : m.setPppg(Double.parseDouble(value.toString())); break; case 4 : m.setLov(Double.parseDouble(value.toString())); break; case 5 : m.setCost(Double.parseDouble(value.toString())); break; case 6 : m.setPercent(Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; fireTableCellUpdated(row, col); fireTableDataChanged(); app.myRecipe.calcMaltTotals(); app.displayRecipe(); }
for (int i = 1; i<=10; i++) {
for (int i = 1; i<=3; i++) {
private List<Entity> createEntities() { List<Entity> entities = new ArrayList<Entity>(); for (int i = 1; i<=10; i++) { Entity e = entityCreator.entityFactory(home, "ENTITY"+i); entities.add(e); } return entities; }
for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i);
for (int i = 1; i<numberOfIdentities; i++) { Identity c = userCreator.identityFactory("IDENTITY"+i, "ALIAS"+i); userDao.persistIdentity(c);
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i));
for (Identity i: identities) { User u = userCreator.userFactory(e, i); i.getUsers().add(u);
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) {
for (int j=0; j<=3;j++) {
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); }
logger.info("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date);
private List<User> populateUsersAndLogs(List<Entity> entities) { List<Identity> identities = new ArrayList<Identity>(); for (int i = 1; i<=3; i++) { Identity c = userCreator.identityFactory("CRED"+i, "ALIAS"+i); identities.add(c); } List<User> users = new ArrayList<User>(); for (Entity e: entities) { Random r = new Random(); int repeat1 = r.nextInt(2); for (int i=0; i<=repeat1;i++) { User u = userCreator.userFactory(e, identities.get(i)); userDao.persistUser(u); users.add(u); int repeat2 = r.nextInt(8); for (int j=0; j<=repeat2;j++) { Date date = randomDateGenerator(r); if (logger.isDebugEnabled()) { logger.debug("Repeat ("+i+", "+j+") UserLog to: "+u+" - "+date); } // there is a very small chance to have a duplicated date here ((UserDaoImpl) userDao).createAndPersistUserLog(u, date); } } } hibernateTemplate.flush(); return users; }
digester.addSetProperties("info/entry","revision","revision");
digester.addSetProperties("info/entry/commit","revision","revision");
public static SvnInfo parse(String subject, Map env, FilePath workspace, TaskListener listener) throws IOException { String cmd = DESCRIPTOR.getSvnExe()+" info --xml "+subject; listener.getLogger().println("$ "+cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int r = new Proc(cmd,env,baos,workspace.getLocal()).join(); if(r!=0) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); throw new IOException("revision check failed"); } SvnInfo info = new SvnInfo(); Digester digester = new Digester(); digester.push(info); digester.addBeanPropertySetter("info/entry/url"); digester.addSetProperties("info/entry","revision","revision"); // set attributes. in particular @revision try { digester.parse(new ByteArrayInputStream(baos.toByteArray())); } catch (SAXException e) { // failed. to allow user to diagnose the problem, send output to log listener.getLogger().write(baos.toByteArray()); e.printStackTrace(listener.fatalError("Failed to parse Subversion output")); throw new IOException("Unabled to parse svn info output"); } if(!info.isComplete()) throw new IOException("No revision in the svn info output"); return info; }
List<Home> homeList = hibernateTemplate.find("from Home");
List<Home> homeList = (ArrayList<Home>) hibernateTemplate.find("from Home");
public void testPersistDefaultEntitySuccess() { simpleCoreMgr.persistDefaultEntity(defaultEntity); hibernateTemplate.flush(); List<Home> homeList = hibernateTemplate.find("from Home"); assertEquals(1, homeList.size()); Home h = homeList.get(0); assertEquals (defaultEntity.getEntity().getHome(), h); List<Entity> entityList = hibernateTemplate.find("from Entity"); assertEquals(1, entityList.size()); Entity e = entityList.get(0); assertEquals(defaultEntity.getEntity(), e); }
List<Entity> entityList = hibernateTemplate.find("from Entity");
List<Entity> entityList = (ArrayList<Entity>) hibernateTemplate.find("from Entity");
public void testPersistDefaultEntitySuccess() { simpleCoreMgr.persistDefaultEntity(defaultEntity); hibernateTemplate.flush(); List<Home> homeList = hibernateTemplate.find("from Home"); assertEquals(1, homeList.size()); Home h = homeList.get(0); assertEquals (defaultEntity.getEntity().getHome(), h); List<Entity> entityList = hibernateTemplate.find("from Entity"); assertEquals(1, entityList.size()); Entity e = entityList.get(0); assertEquals(defaultEntity.getEntity(), e); }
int columnCount = tcm.getColumnCount();
int colCount = tcm.getColumnCount();
private void addColumnWidthListeners() { TableColumnModel mtcm = maltTable.getColumnModel(); TableColumnModel htcm = hopsTable.getColumnModel(); //: listener that watches the width of a column PropertyChangeListener mpcl = new PropertyChangeListener() { private int columnCount = maltTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = maltTable.getColumnModel(); TableColumnModel tcmt = tblMaltTotals.getColumnModel(); int colCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < colCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: listener that watches the width of a column PropertyChangeListener hpcl = new PropertyChangeListener() { private int columnCount = hopsTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: add the column width lister to each column for (Enumeration e = mtcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(mpcl); } //: add the column width lister to each column for (Enumeration e = htcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(hpcl); } }
for (int i = 0; i < columnCount; i++) {
for (int i = 0; i < colCount; i++) {
private void addColumnWidthListeners() { TableColumnModel mtcm = maltTable.getColumnModel(); TableColumnModel htcm = hopsTable.getColumnModel(); //: listener that watches the width of a column PropertyChangeListener mpcl = new PropertyChangeListener() { private int columnCount = maltTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = maltTable.getColumnModel(); TableColumnModel tcmt = tblMaltTotals.getColumnModel(); int colCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < colCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: listener that watches the width of a column PropertyChangeListener hpcl = new PropertyChangeListener() { private int columnCount = hopsTable.getColumnCount(); private int[] width = new int[columnCount]; public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } } }; //: add the column width lister to each column for (Enumeration e = mtcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(mpcl); } //: add the column width lister to each column for (Enumeration e = htcm.getColumns(); e.hasMoreElements();) { TableColumn tc = (TableColumn) e.nextElement(); tc.addPropertyChangeListener(hpcl); } }
int columnCount = tcm.getColumnCount();
int colCount = tcm.getColumnCount();
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } }
for (int i = 0; i < columnCount; i++) {
for (int i = 0; i < colCount; i++) {
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("preferredWidth")) { TableColumnModel tcm = hopsTable.getColumnModel(); TableColumnModel tcmt = tblHopsTotals.getColumnModel(); int columnCount = tcm.getColumnCount(); // for each column, get its width for (int i = 0; i < columnCount; i++) { tcmt.getColumn(i).setPreferredWidth(tcm.getColumn(i).getPreferredWidth()); } } }
stylePanel.setStyleData();
public void displayRecipe() { if (myRecipe == null) return; txtName.setText(myRecipe.getName()); brewerNameText.setText(myRecipe.getBrewer()); txtPreBoil.setValue(new Double(myRecipe.getPreBoilVol(myRecipe.getVolUnits()))); lblSizeUnits.setText(myRecipe.getVolUnits()); postBoilText.setValue(new Double(myRecipe.getPostBoilVol(myRecipe.getVolUnits()))); boilMinText.setText(SBStringUtils.df0.format(myRecipe.getBoilMinutes())); evapText.setText(SBStringUtils.df1.format(myRecipe.getEvap())); spnEffic.setValue(new Double(myRecipe.getEfficiency())); spnAtten.setValue(new Double(myRecipe.getAttenuation())); spnOG.setValue(new Double(myRecipe.getEstOg())); spnFG.setValue(new Double(myRecipe.getEstFg())); txtComments.setText(myRecipe.getComments()); lblIBUvalue.setText(SBStringUtils.df1.format(myRecipe.getIbu())); lblColourValue.setText(SBStringUtils.df1.format(myRecipe.getSrm())); lblAlcValue.setText(SBStringUtils.df1.format(myRecipe.getAlcohol())); txtDate.setText(dateFormat1.format(myRecipe.getCreated().getTime())); Costs = myNF.format(myRecipe.getTotalMaltCost()); tblMaltTotalsModel.setDataVector(new String[][]{{"Totals:", "" + SBStringUtils.df1.format(myRecipe.getTotalMalt()), myRecipe.getMaltUnits(), "" + SBStringUtils.df3.format(myRecipe.getEstOg()), "" + SBStringUtils.df1.format(myRecipe.getSrm()), Costs, "100"}}, new String[]{"", "", "", "", "", "", ""}); Costs = myNF.format(myRecipe.getTotalHopsCost()); tblHopsTotalsModel.setDataVector(new String[][]{{"Totals:", "", "", "" + SBStringUtils.df1.format(myRecipe.getTotalHops()), myRecipe.getHopUnits(), "", "", "" + SBStringUtils.df1.format(myRecipe.getIbu()), Costs}}, new String[]{"", "", "", "", "", "", "", "", ""}); String fileName = "not saved"; if (currentFile != null) { fileName = currentFile.getName(); } fileNameLabel.setText("File: " + fileName); ibuMethodLabel.setText("IBU method: " + myRecipe.getIBUMethod()); alcMethodLabel.setText("Alc method: " + myRecipe.getAlcMethod()); colourPanel.setBackground(Recipe.calcRGB(myRecipe.getSrm(), 8, 30, 20)); colourPanel2.setBackground(Recipe.calcRBG2(myRecipe.getSrm())); }
sb.append(SBStringUtils.xmlElement("VOLUME", getMashTotalVol(), 4));
sb.append(SBStringUtils.xmlElement("MASH_VOLUME", getMashTotalVol(), 4)); sb.append(SBStringUtils.xmlElement("MASH_RATIO", "" + mashRatio, 4)); sb.append(SBStringUtils.xmlElement("MASH_TIME", "" + totalTime, 4)); sb.append(SBStringUtils.xmlElement("MASH_TMP_U", "" + mashTempU, 4)); if (tempUnits.equals("C")) sb.append(SBStringUtils.xmlElement("MASH_TUNLOSS_TEMP", "" + (tunLossF/1.8), 4)); else sb.append(SBStringUtils.xmlElement("MASH_TUNLOSS_TEMP", "" + tunLossF, 4));
public String toXml() { StringBuffer sb = new StringBuffer(); sb.append(" <MASH>\n"); sb.append(SBStringUtils.xmlElement("VOLUME", getMashTotalVol(), 4)); for (int i = 0; i < steps.size(); i++) { MashStep st = (MashStep) steps.get(i); sb.append(" <ITEM>\n"); sb.append(" <TYPE>" + st.type + "</TYPE>\n"); sb.append(" <TEMP>" + st.startTemp + "</TEMP>\n"); if (tempUnits.equals("C")) sb.append(" <DISPL_TEMP>" + SBStringUtils.format(fToC(st.startTemp), 1) + "</DISPL_TEMP>\n"); else sb.append(" <DISPL_TEMP>" + st.startTemp + "</DISPL_TEMP>\n"); sb.append(" <END_TEMP>" + st.endTemp + "</END_TEMP>\n"); if (tempUnits.equals("C")) sb.append(" <DISPL_END_TEMP>" + SBStringUtils.format(fToC(st.endTemp), 1) + "</DISPL_END_TEMP>\n"); else sb.append(" <DISPL_END_TEMP>" + st.endTemp + "</DISPL_END_TEMP>\n"); sb.append(" <MIN>" + st.minutes + "</MIN>\n"); sb.append(" <RAMP_MIN>" + st.rampMin + "</RAMP_MIN>\n"); sb.append(" <METHOD>" + st.method + "</METHOD>\n"); sb.append(" <DIRECTIONS>" + st.directions + "</DIRECTIONS>\n"); sb.append(" </ITEM>\n"); } sb.append(" </MASH>\n"); return sb.toString(); }
"deploy/partner.xml"};
"deploy/core.xml"};
protected String[] getConfigLocations() { return new String[] { "deploy/dataSource.xml", "deploy/sessionFactory.xml", "deploy/support.xml", "deploy/transaction.xml", "deploy/partner.xml"}; }
return super.mul(param1,param2);
else return super.mul(param1,param2);
public Object dot(Object param1, Object param2) throws ParseException { if(param1 instanceof MVector && param2 instanceof MVector) return dot((MVector) param1,(MVector) param2); return super.mul(param1,param2); }
errorList.clear();
errorList.removeAllElements();
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.clear(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.add(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.add("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
errorList.add(((ParseException)e).getErrorInfo());
errorList.addElement(((ParseException)e).getErrorInfo());
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.clear(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.add(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.add("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
errorList.add("Syntax error");
errorList.addElement("Syntax error");
public void parseExpression(String expression_in) { Reader reader = new StringReader(expression_in); try { // try parsing errorList.clear(); topNode = parser.parseStream(reader, this); } catch (Throwable e) { // an exception was thrown, so there is no parse tree topNode = null; // check the type of error if (e instanceof ParseException) { // the ParseException object contains additional error // information errorList.add(((ParseException)e).getErrorInfo()); } else { // if the exception was not a ParseException, it was most // likely a syntax error if (debug) { System.out.println(e.getMessage()); e.printStackTrace(); } errorList.add("Syntax error"); } } // If traversing is enabled, print a dump of the tree to // standard output if (traverse && !hasError()) { ParserVisitor v = new ParserDumpVisitor(); topNode.jjtAccept(v, null); } }
public int getValue() {
public char getValue() {
public int getValue() { return value; }
UserGroup userGroup = userList.get((int) Math.random()*e*d);
IdentityFilter identityFilter = new IdentityFilter();
public void testFindIdentities() { // write list int e = 2; int d = 3; List<UserGroup> userList = AuthorizationTestSupport.createAndPersistUserGroupList(hibernateTemplate, e, d); assertEquals(e*d, userList.size()); UserGroup parent = AuthorizationTestSupport.createUserGroup(); parent.getIdentity().setPrincipal("USER"); for (UserGroup u:userList) { UserAssociation assoc = new UserAssociation(); assoc.setParent(parent); assoc.setChild(u); u.getParents().add(assoc); } // read UserGroup userGroup = userList.get((int) Math.random()*e*d);// assertEquals(identity, authenticationDao.findIdentityByPrincipal(identity.getPrincipal()));// IdentityFilter identityFilter = new IdentityFilter();// //// assertEquals(i, authenticationDao.findIdentityByCriteria(identityFilter, "").size());//// somente um parmetro//// // assertEquals(i, authenticationDao.findIdentityByCriteria(identityFilter).size());// //// assertEquals(identity, authenticationDao.findIdentityByCriteria("where identity.principal='"+identity.getPrincipal()+"' ").get(0));//// assertEquals(identity, authenticationDao.findIdentityByCriteria(identityFilter, "");// // assertEquals(identity, authenticationDao.findIdentityByCriteria(identityFilter)); }
List<Identity> identityList = authenticationDao.findIdentityByCriteria(identityFilter); assertEquals(e*d, identityList.size()); int index = (int) (Math.random()*e*d); System.out.println("INDEX "+index); Identity identity = identityList.get(index); UserGroup loaded = identity .getUsers() .iterator() .next() .getParents() .iterator() .next() .getParent(); assertEquals("USER", loaded.getIdentity().getPrincipal());
public void testFindIdentities() { // write list int e = 2; int d = 3; List<UserGroup> userList = AuthorizationTestSupport.createAndPersistUserGroupList(hibernateTemplate, e, d); assertEquals(e*d, userList.size()); UserGroup parent = AuthorizationTestSupport.createUserGroup(); parent.getIdentity().setPrincipal("USER"); for (UserGroup u:userList) { UserAssociation assoc = new UserAssociation(); assoc.setParent(parent); assoc.setChild(u); u.getParents().add(assoc); } // read UserGroup userGroup = userList.get((int) Math.random()*e*d);// assertEquals(identity, authenticationDao.findIdentityByPrincipal(identity.getPrincipal()));// IdentityFilter identityFilter = new IdentityFilter();// //// assertEquals(i, authenticationDao.findIdentityByCriteria(identityFilter, "").size());//// somente um parmetro//// // assertEquals(i, authenticationDao.findIdentityByCriteria(identityFilter).size());// //// assertEquals(identity, authenticationDao.findIdentityByCriteria("where identity.principal='"+identity.getPrincipal()+"' ").get(0));//// assertEquals(identity, authenticationDao.findIdentityByCriteria(identityFilter, "");// // assertEquals(identity, authenticationDao.findIdentityByCriteria(identityFilter)); }
else { Operator op = jep.getOperatorSet().getCross(); BinaryOperatorI bin = (BinaryOperatorI) op.getPFMC(); Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim); }
Operator op = jep.getOperatorSet().getCross(); BinaryOperatorI bin = (BinaryOperatorI) op.getPFMC(); Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim);
public MatrixNodeI preprocess( ASTFunNode node, MatrixPreprocessor visitor, MatrixJep jep, MatrixNodeFactory nf) throws ParseException { MatrixNodeI children[] = visitor.visitChildrenAsArray(node,null); if(node.jjtGetNumChildren()!=2) throw new ParseException("Operator "+node.getOperator().getName()+" must have two elements, it has "+children.length); Dimensions lhsDim = children[0].getDim(); Dimensions rhsDim = children[1].getDim(); if(rhsDim.equals(Dimensions.ONE)) { Dimensions dim = lhsDim; return (ASTMFunNode) nf.buildOperatorNode( node.getOperator(),children,dim); } else { Operator op = jep.getOperatorSet().getCross(); BinaryOperatorI bin = (BinaryOperatorI) op.getPFMC(); Dimensions dim = bin.calcDim(lhsDim,rhsDim); return (ASTMFunNode) nf.buildOperatorNode(op,children,dim); } }
if (param instanceof Number) {
if (param instanceof Complex) return new Double(((Complex)param).im()); else if (param instanceof Number)
public Number im(Object param) throws ParseException { if (param instanceof Number) { return new Double(0); } else if (param instanceof Complex) { return new Double(((Complex)param).im()); } throw new ParseException("Invalid parameter type"); }
} else if (param instanceof Complex) { return new Double(((Complex)param).im()); }
public Number im(Object param) throws ParseException { if (param instanceof Number) { return new Double(0); } else if (param instanceof Complex) { return new Double(((Complex)param).im()); } throw new ParseException("Invalid parameter type"); }
public boolean accept(File dir, String name) { return name.endsWith(".hudson-plugin"); } });
public boolean accept(File dir, String name) { return name.endsWith(".hpi") || name.endsWith(".hpl"); } });
public PluginManager(ServletContext context) { this.context = context; rootDir = new File(Hudson.getInstance().getRootDir(),"plugins"); if(!rootDir.exists()) rootDir.mkdirs(); File[] archives = rootDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".hudson-plugin"); } }); for( File arc : archives ) { try { PluginWrapper p = new PluginWrapper(this, arc); plugins.add(p); if(p.isActive()) activePlugins.add(p); } catch (IOException e) { System.err.println("Failed to load a plug-in "+arc); e.printStackTrace(); } } }
return name.endsWith(".hudson-plugin"); }
return name.endsWith(".hpi") || name.endsWith(".hpl"); }
public boolean accept(File dir, String name) { return name.endsWith(".hudson-plugin"); }
}else{ setUnitRange(event.getAmp()); }
}else setUnitRange(event.getAmp());
public void updateAmp(AmpEvent event){ if(event instanceof LazyAmpEvent){ ((LazyAmpEvent)event).addCalculateListener(this); }else{ setUnitRange(event.getAmp()); } }
bandwidthController.getAvailableByteCount( true );
bandwidthController.getAvailableByteCount( 1, true, true );
public void write(int b) throws IOException { // this call will always return at least 1 directly or after blocking. bandwidthController.getAvailableByteCount( true ); outStream.write(b); bandwidthController.markBytesUsed( 1 ); }
bandwidthController.markBytesUsed( 1 );
public void write(int b) throws IOException { // this call will always return at least 1 directly or after blocking. bandwidthController.getAvailableByteCount( true ); outStream.write(b); bandwidthController.markBytesUsed( 1 ); }
getParent().jobs.remove(name);
getParent().deleteJob(this);
public synchronized void doDoDelete( StaplerRequest req, StaplerResponse rsp ) throws IOException { Util.deleteRecursive(root); getParent().jobs.remove(name); rsp.sendRedirect(req.getContextPath()); }
scalRecipeMenuItem.setText("Scale Recipe...");
scalRecipeMenuItem.setText("Resize / Convert Recipe...");
private void initGUI() { try { // restore the saved size and location: this.setSize(preferences.getIProperty("winWidth"), preferences.getIProperty("winHeight")); this.setLocation(preferences.getIProperty("winX"), preferences.getIProperty("winY")); imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/sb2.gif"); icon = new ImageIcon(imgURL); this.setIconImage(icon.getImage()); this.setTitle("StrangeBrew " + version); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { System.exit(1); } }); { pnlMain = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.columnWeights = new double[]{0.1}; jPanel2Layout.columnWidths = new int[]{7}; jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.9, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7, 7}; pnlMain.setLayout(jPanel2Layout); this.getContentPane().add(pnlMain, BorderLayout.CENTER); { jTabbedPane1 = new JTabbedPane(); pnlMain.add(jTabbedPane1, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { pnlDetails = new JPanel(); GridBagLayout pnlDetailsLayout = new GridBagLayout(); pnlDetailsLayout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; pnlDetailsLayout.columnWidths = new int[]{7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; pnlDetailsLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; pnlDetailsLayout.rowHeights = new int[]{7, 7, 7, 7, 7, 7, 7}; pnlDetails.setLayout(pnlDetailsLayout); jTabbedPane1.addTab("Details", null, pnlDetails, null); pnlDetails.setPreferredSize(new java.awt.Dimension(20, 16)); { lblBrewer = new JLabel(); pnlDetails.add(lblBrewer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblBrewer.setText("Brewer:"); } { brewerNameText = new JTextField(); pnlDetails.add(brewerNameText, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); brewerNameText.setPreferredSize(new java.awt.Dimension(69, 20)); brewerNameText.setText("Brewer"); } { lblDate = new JLabel(); pnlDetails.add(lblDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDate.setText("Date:"); } { lblStyle = new JLabel(); pnlDetails.add(lblStyle, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblStyle.setText("Style:"); } { lblYeast = new JLabel(); pnlDetails.add(lblYeast, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblYeast.setText("Yeast:"); } { lblPreBoil = new JLabel(); pnlDetails.add(lblPreBoil, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPreBoil.setText("Pre boil:"); } { lblPostBoil = new JLabel(); pnlDetails.add(lblPostBoil, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblPostBoil.setText("Post boil:"); } { lblEffic = new JLabel(); pnlDetails.add(lblEffic, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblEffic.setText("Effic:"); lblEffic.setPreferredSize(new java.awt.Dimension(31, 14)); } { lblAtten = new JLabel(); pnlDetails.add(lblAtten, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAtten.setText("Atten:"); lblAtten.setPreferredSize(new java.awt.Dimension(34, 14)); } { lblOG = new JLabel(); pnlDetails.add(lblOG, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblOG.setText("OG:"); } { lblFG = new JLabel(); pnlDetails.add(lblFG, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFG.setText("FG:"); } { lblIBU = new JLabel(); pnlDetails.add(lblIBU, new GridBagConstraints(7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBU.setText("IBU:"); } { lblAlc = new JLabel(); pnlDetails.add(lblAlc, new GridBagConstraints(7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlc.setText("%Alc:"); } { lblColour = new JLabel(); pnlDetails.add(lblColour, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColour.setText("Colour:"); } { //txtDate = new JFormattedTextField(); txtDate = new DatePicker(); pnlDetails.add(txtDate, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); // txtDate.setText("Date"); txtDate.setPreferredSize(new java.awt.Dimension(73, 20)); txtDate.setDateStyle(DateFormat.SHORT); } { cmbStyleModel = new ComboModel(); cmbStyle = new JComboBox(); pnlDetails.add(cmbStyle, new GridBagConstraints(1, 2, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbStyle.setModel(cmbStyleModel); cmbStyle.setMaximumSize(new java.awt.Dimension(100, 32767)); cmbStyle.setPreferredSize(new java.awt.Dimension(190, 20)); } { preBoilText = new JFormattedTextField(); pnlDetails.add(preBoilText, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); preBoilText.setText("Pre Boil"); preBoilText.setPreferredSize(new java.awt.Dimension(37, 20)); } { postBoilText = new JFormattedTextField(); pnlDetails.add(postBoilText, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilText.setText("Post Boil"); postBoilText.setPreferredSize(new java.awt.Dimension(46, 20)); } { lblComments = new JLabel(); pnlDetails.add(lblComments, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblComments.setText("Comments:"); } { SpinnerNumberModel spnEfficModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnEffic = new JSpinner(); pnlDetails.add(spnEffic, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnEffic.setModel(spnEfficModel); spnEffic.setMaximumSize(new java.awt.Dimension(70, 32767)); spnEffic.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEfficiency(Double.parseDouble(spnEffic.getValue() .toString())); displayRecipe(); } }); spnEffic.setEditor(new JSpinner.NumberEditor(spnEffic, "00.#")); spnEffic.getEditor().setPreferredSize(new java.awt.Dimension(28, 16)); spnEffic.setPreferredSize(new java.awt.Dimension(53, 18)); } { SpinnerNumberModel spnAttenModel = new SpinnerNumberModel(75.0, 0.0, 100.0, 1.0); spnAtten = new JSpinner(); pnlDetails.add(spnAtten, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnAtten.setModel(spnAttenModel); spnAtten.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setAttenuation(Double.parseDouble(spnAtten.getValue() .toString())); displayRecipe(); } }); spnAtten.setEditor(new JSpinner.NumberEditor(spnAtten, "00.#")); spnAtten.setPreferredSize(new java.awt.Dimension(49, 20)); } { SpinnerNumberModel spnOgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnOG = new JSpinner(); pnlDetails.add(spnOG, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnOG.setModel(spnOgModel); spnOG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { myRecipe.setEstOg(Double.parseDouble(spnOG.getValue() .toString())); displayRecipe(); } }); spnOG.setEditor(new JSpinner.NumberEditor(spnOG, "0.000")); spnOG.getEditor().setPreferredSize(new java.awt.Dimension(20, 16)); spnOG.setPreferredSize(new java.awt.Dimension(67, 18)); } { SpinnerNumberModel spnFgModel = new SpinnerNumberModel(1.000, 0.900, 2.000, 0.001); spnFG = new JSpinner(); pnlDetails.add(spnFG, new GridBagConstraints(6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); spnFG.setModel(spnFgModel); spnFG.setEditor(new JSpinner.NumberEditor(spnFG, "0.000")); spnFG.setPreferredSize(new java.awt.Dimension(69, 20)); spnFG.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { // set the new FG, and update alc: myRecipe.setEstFg(Double.parseDouble(spnFG.getValue() .toString())); displayRecipe(); } }); } { lblIBUvalue = new JLabel(); pnlDetails.add(lblIBUvalue, new GridBagConstraints(8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblIBUvalue.setText("IBUs"); } { lblColourValue = new JLabel(); pnlDetails.add(lblColourValue, new GridBagConstraints(8, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblColourValue.setText("Colour"); } { lblAlcValue = new JLabel(); pnlDetails.add(lblAlcValue, new GridBagConstraints(8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblAlcValue.setText("Alc"); } { scpComments = new JScrollPane(); pnlDetails.add(scpComments, new GridBagConstraints(7, 4, 3, 2, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { txtComments = new JTextArea(); scpComments.setViewportView(txtComments); txtComments.setText("Comments"); txtComments.setWrapStyleWord(true); // txtComments.setPreferredSize(new java.awt.Dimension(117, 42)); txtComments.setLineWrap(true); txtComments.setPreferredSize(new java.awt.Dimension(263, 40)); txtComments.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if (!txtComments.getText().equals(myRecipe.getComments())) { myRecipe.setComments(txtComments.getText()); } } }); } } { cmbYeastModel = new ComboModel(); cmbYeast = new JComboBox(); pnlDetails.add(cmbYeast, new GridBagConstraints(1, 3, 5, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbYeast.setModel(cmbYeastModel); cmbYeast.setPreferredSize(new java.awt.Dimension(193, 20)); } { cmbSizeUnitsModel = new ComboModel(); cmbSizeUnits = new JComboBox(); pnlDetails.add(cmbSizeUnits, new GridBagConstraints(2, 4, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbSizeUnits.setModel(cmbSizeUnitsModel); } { lblSizeUnits = new JLabel(); pnlDetails.add(lblSizeUnits, new GridBagConstraints(2, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblSizeUnits.setText("Size Units"); } { boilTimeLable = new JLabel(); pnlDetails.add(boilTimeLable, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); boilTimeLable.setText("Boil Min:"); } { evapLabel = new JLabel(); pnlDetails.add(evapLabel, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapLabel.setText("Evap/hr:"); } { boilMinText = new JTextField(); pnlDetails.add(boilMinText, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilMinText.setText("60"); boilMinText.setPreferredSize(new java.awt.Dimension(22, 20)); } { evapText = new JTextField(); pnlDetails.add(evapText, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); evapText.setText("4"); evapText.setPreferredSize(new java.awt.Dimension(23, 20)); } { alcMethodComboModel = new DefaultComboBoxModel(new String[]{"Volume", "Weight"}); alcMethodCombo = new JComboBox(alcMethodComboModel); pnlDetails.add(alcMethodCombo, new GridBagConstraints(9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); alcMethodCombo.setPreferredSize(new java.awt.Dimension(58, 20)); } { ibuMethodComboModel = new DefaultComboBoxModel(new String[]{"Tinseth", "Garetz", "Rager"}); ibuMethodCombo = new JComboBox(ibuMethodComboModel); pnlDetails.add(ibuMethodCombo, new GridBagConstraints(9, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); ibuMethodCombo.setPreferredSize(new java.awt.Dimension(59, 20)); } { colourMethodComboModel = new DefaultComboBoxModel(new String[]{"SRM", "EBC"}); colourMethodCombo = new JComboBox(colourMethodComboModel); pnlDetails.add(colourMethodCombo, new GridBagConstraints(9, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); colourMethodCombo.setPreferredSize(new java.awt.Dimension(44, 20)); } ComboBoxModel evapMethodComboModel = new DefaultComboBoxModel(new String[] { "Constant", "Percent" }); { jPanel1 = new JPanel(); pnlMain.add(jPanel1, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1Layout.setAlignment(FlowLayout.LEFT); jPanel1.setLayout(jPanel1Layout); mainToolBar = new JToolBar(); getContentPane().add(mainToolBar, BorderLayout.NORTH); mainToolBar.setFloatable(false); mainToolBar.setRollover(true); saveButton = new JButton(); mainToolBar.add(saveButton); saveButton.setMnemonic(java.awt.event.KeyEvent.VK_S); saveButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/save.gif"))); saveButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); jButton2 = new JButton(); mainToolBar.add(jButton2); jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ca/strangebrew/icons/find.gif"))); final JFrame owner = this; jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); { lblName = new JLabel(); jPanel1.add(lblName); lblName.setText("Name:"); } { txtName = new JTextField(); jPanel1.add(txtName); txtName.setText("Name"); txtName.setPreferredSize(new java.awt.Dimension(297, 20)); } } evapMethodCombo = new JComboBox(); pnlDetails.add(evapMethodCombo, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); evapMethodCombo.setModel(evapMethodComboModel); evapMethodCombo.setPreferredSize(new java.awt.Dimension(64, 20)); colourPanel = new JPanel(); pnlDetails.add(colourPanel, new GridBagConstraints(9, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); colourPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); } { SBNotifier sbn = new SBNotifier(); stylePanel = new StylePanel(sbn); jTabbedPane1.addTab("Style", null, stylePanel, null); miscPanel = new MiscPanel(myRecipe); jTabbedPane1.addTab("Misc", null, miscPanel, null); notesPanel = new NotesPanel(); jTabbedPane1.addTab("Notes", null, notesPanel, null); dilutionPanel = new DilutionPanel(); jTabbedPane1.addTab("Dilution", null, dilutionPanel, null); mashPanel = new MashPanel(myRecipe); jTabbedPane1.addTab("Mash", null, mashPanel, null); waterPanel = new WaterPanel(); jTabbedPane1.addTab("Water", null, waterPanel, null); costPanel = new CostPanel(); jTabbedPane1.addTab("Cost", null, costPanel, null); // SBNotifier sbn = new SBNotifier(); settingsPanel = new SettingsPanel(sbn); jTabbedPane1.addTab("Settings", null, settingsPanel, null); } } { pnlTables = new JPanel(); BoxLayout pnlMaltsLayout = new BoxLayout(pnlTables, javax.swing.BoxLayout.Y_AXIS); pnlMain.add(pnlTables, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); pnlTables.setLayout(pnlMaltsLayout); { pnlMalt = new JPanel(); pnlTables.add(pnlMalt); BorderLayout pnlMaltLayout1 = new BorderLayout(); pnlMalt.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Fermentables", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlMalt.setLayout(pnlMaltLayout1); { jScrollPane1 = new JScrollPane(); pnlMalt.add(jScrollPane1, BorderLayout.CENTER); { maltTableModel = new MaltTableModel(this); maltTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, maltTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane1.setViewportView(maltTable); maltTable.setModel(maltTableModel); // maltTable.setAutoCreateColumnsFromModel(false); maltTable.getTableHeader().setReorderingAllowed(false); TableColumn maltColumn = maltTable.getColumnModel().getColumn(2); // set up malt list combo maltComboBox = new JComboBox(); cmbMaltModel = new ComboModel(); maltComboBox.setModel(cmbMaltModel); maltColumn.setCellEditor(new DefaultCellEditor(maltComboBox)); // set up malt amount editor amountEditor = new SBCellEditor(new JTextField()); maltColumn = maltTable.getColumnModel().getColumn(3); maltColumn.setCellEditor(amountEditor); // set up malt units combo maltUnitsComboBox = new JComboBox(); cmbMaltUnitsModel = new ComboModel(); maltUnitsComboBox.setModel(cmbMaltUnitsModel); maltColumn = maltTable.getColumnModel().getColumn(4); maltColumn.setCellEditor(new DefaultCellEditor(maltUnitsComboBox)); } } { tblMaltTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"S", "M", "Malt", "Amount", "Units", "Points", "Lov", "Cost/U", "%"}); tblMaltTotals = new JTable(); pnlMalt.add(tblMaltTotals, BorderLayout.SOUTH); tblMaltTotals.setModel(tblMaltTotalsModel); tblMaltTotals.getTableHeader().setEnabled(false); tblMaltTotals.setAutoCreateColumnsFromModel(false); // set up the units combobox maltTotalUnitsComboBox = new JComboBox(); maltTotalUnitsComboModel = new ComboModel(); maltTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); maltTotalUnitsComboBox.setModel(maltTotalUnitsComboModel); TableColumn t = tblMaltTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(maltTotalUnitsComboBox)); maltTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) maltTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setMaltUnits(u); displayRecipe(); } } }); } } { pnlMaltButtons = new JPanel(); pnlTables.add(pnlMaltButtons); FlowLayout pnlMaltButtonsLayout = new FlowLayout(); pnlMaltButtonsLayout.setAlignment(FlowLayout.LEFT); pnlMaltButtonsLayout.setVgap(0); pnlMaltButtons.setLayout(pnlMaltButtonsLayout); pnlMaltButtons.setPreferredSize(new java.awt.Dimension(592, 27)); { tlbMalt = new JToolBar(); pnlMaltButtons.add(tlbMalt); tlbMalt.setPreferredSize(new java.awt.Dimension(386, 20)); tlbMalt.setFloatable(false); { btnAddMalt = new JButton(); tlbMalt.add(btnAddMalt); btnAddMalt.setText("+"); btnAddMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Fermentable f = new Fermentable(myRecipe.getMaltUnits()); myRecipe.addMalt(f); maltTable.updateUI(); displayRecipe(); } } }); } { btnDelMalt = new JButton(); tlbMalt.add(btnDelMalt); btnDelMalt.setText("-"); btnDelMalt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = maltTable.getSelectedRow(); myRecipe.delMalt(i); maltTable.updateUI(); displayRecipe(); } } }); } } } { pnlHops = new JPanel(); BorderLayout pnlHopsLayout = new BorderLayout(); pnlHops.setBorder(BorderFactory.createTitledBorder(new LineBorder( new java.awt.Color(0, 0, 0), 1, false), "Hops", TitledBorder.LEADING, TitledBorder.TOP, new java.awt.Font("Dialog", 1, 12), new java.awt.Color(51, 51, 51))); pnlHops.setLayout(pnlHopsLayout); pnlTables.add(pnlHops); { tblHopsTotalsModel = new DefaultTableModel(new String[][]{{""}}, new String[]{"1", "2", "3", "4", "5", "6", "7", "8", "9"}); tblHopsTotals = new JTable(); pnlHops.add(tblHopsTotals, BorderLayout.SOUTH); tblHopsTotals.setModel(tblHopsTotalsModel); tblHopsTotals.setAutoCreateColumnsFromModel(false); // set up the units combobox hopsTotalUnitsComboBox = new JComboBox(); hopsTotalUnitsComboModel = new ComboModel(); hopsTotalUnitsComboModel.setList(new Quantity().getListofUnits("weight")); hopsTotalUnitsComboBox.setModel(hopsTotalUnitsComboModel); TableColumn t = tblHopsTotals.getColumnModel().getColumn(4); t.setCellEditor(new DefaultCellEditor(hopsTotalUnitsComboBox)); hopsTotalUnitsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String u = (String) hopsTotalUnitsComboModel.getSelectedItem(); if (myRecipe != null) { myRecipe.setHopsUnits(u); displayRecipe(); } } }); } { jScrollPane2 = new JScrollPane(); pnlHops.add(jScrollPane2, BorderLayout.CENTER); { hopsTableModel = new HopsTableModel(this); hopsTable = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, hopsTableModel .getDescriptionAt(rowIndex)); } }; jScrollPane2.setViewportView(hopsTable); hopsTable.setModel(hopsTableModel); hopsTable.getTableHeader().setReorderingAllowed(false); TableColumn hopColumn = hopsTable.getColumnModel().getColumn(0); hopComboBox = new JComboBox(); cmbHopsModel = new ComboModel(); hopComboBox.setModel(cmbHopsModel); hopColumn.setCellEditor(new DefaultCellEditor(hopComboBox)); // set up hop units combo hopsUnitsComboBox = new JComboBox(); cmbHopsUnitsModel = new ComboModel(); hopsUnitsComboBox.setModel(cmbHopsUnitsModel); hopColumn = hopsTable.getColumnModel().getColumn(4); hopColumn.setCellEditor(new DefaultCellEditor(hopsUnitsComboBox)); // set up hop type combo String[] forms = {"Leaf", "Pellet", "Plug"}; JComboBox hopsFormComboBox = new JComboBox(forms); hopColumn = hopsTable.getColumnModel().getColumn(1); hopColumn.setCellEditor(new DefaultCellEditor(hopsFormComboBox)); // set up hop add combo String[] add = {"Boil", "FWH", "Dry", "Mash"}; JComboBox hopsAddComboBox = new JComboBox(add); hopColumn = hopsTable.getColumnModel().getColumn(5); hopColumn.setCellEditor(new DefaultCellEditor(hopsAddComboBox)); } } } { pnlHopsButtons = new JPanel(); FlowLayout pnlHopsButtonsLayout = new FlowLayout(); pnlHopsButtonsLayout.setAlignment(FlowLayout.LEFT); pnlHopsButtonsLayout.setVgap(0); pnlHopsButtons.setLayout(pnlHopsButtonsLayout); pnlTables.add(pnlHopsButtons); pnlHopsButtons.setPreferredSize(new java.awt.Dimension(512, 16)); { tlbHops = new JToolBar(); pnlHopsButtons.add(tlbHops); tlbHops.setPreferredSize(new java.awt.Dimension(413, 19)); tlbHops.setFloatable(false); { btnAddHop = new JButton(); tlbHops.add(btnAddHop); btnAddHop.setText("+"); btnAddHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { Hop h = new Hop(myRecipe.getHopUnits()); myRecipe.addHop(h); hopsTable.updateUI(); displayRecipe(); } } }); } { btnDelHop = new JButton(); tlbHops.add(btnDelHop); btnDelHop.setText("-"); btnDelHop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (myRecipe != null) { int i = hopsTable.getSelectedRow(); myRecipe.delHop(i); hopsTable.updateUI(); displayRecipe(); } } }); } } } } { statusPanel = new JPanel(); FlowLayout statusPanelLayout = new FlowLayout(); statusPanelLayout.setAlignment(FlowLayout.LEFT); statusPanelLayout.setHgap(2); statusPanelLayout.setVgap(2); statusPanel.setLayout(statusPanelLayout); pnlMain.add(statusPanel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { fileNamePanel = new JPanel(); statusPanel.add(fileNamePanel); fileNamePanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { fileNameLabel = new JLabel(); fileNamePanel.add(fileNameLabel); fileNameLabel.setText("File Name"); fileNameLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { ibuMethodPanel = new JPanel(); statusPanel.add(ibuMethodPanel); ibuMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { ibuMethodLabel = new JLabel(); ibuMethodPanel.add(ibuMethodLabel); ibuMethodLabel.setText("IBU Method:"); ibuMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } { alcMethodPanel = new JPanel(); statusPanel.add(alcMethodPanel); alcMethodPanel.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); { alcMethodLabel = new JLabel(); alcMethodPanel.add(alcMethodLabel); alcMethodLabel.setText("Alc Method:"); alcMethodLabel.setFont(new java.awt.Font("Dialog", 1, 10)); } } } } { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { fileMenu = new JMenu(); jMenuBar1.add(fileMenu); fileMenu.setText("File"); { newFileMenuItem = new JMenuItem(); fileMenu.add(newFileMenuItem); newFileMenuItem.setText("New"); newFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // This is just a test right now to see that // stuff is changed. myRecipe = new Recipe(); myRecipe.setVersion(version); currentFile = null; attachRecipeData(); displayRecipe(); } }); } { openFileMenuItem = new JMenuItem(); fileMenu.add(openFileMenuItem); openFileMenuItem.setText("Open"); openFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_O, ActionEvent.CTRL_MASK)); openFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show open dialog; this method does // not return until the dialog is closed String[] ext = {"xml", "qbrew", "rec"}; String desc = "StrangBrew and importable formats"; sbFileFilter openFileFilter = new sbFileFilter(ext, desc); // fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(openFileFilter); int returnVal = fileChooser.showOpenDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Debug.print("Opening: " + file.getName() + ".\n"); OpenImport oi = new OpenImport(); myRecipe = oi.openFile(file); if (oi.getFileType().equals("")){ JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); } if (oi.getFileType().equals("beerxml")){ JOptionPane.showMessageDialog( null, "The file you've opened is in BeerXML format. It may contain \n" + "several recipes. Only the first recipe is opened. Use the Find \n" + "dialog to open other recipes in a BeerXML file.", "BeerXML!", JOptionPane.INFORMATION_MESSAGE); } myRecipe.setVersion(version); myRecipe.calcMaltTotals(); myRecipe.calcHopsTotals(); myRecipe.mash.calcMashSchedule(); checkIngredientsInDB(); attachRecipeData(); currentFile = file; displayRecipe(); } else { Debug.print("Open command cancelled by user.\n"); } } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/find.gif"); icon = new ImageIcon(imgURL); findFileMenuItem = new JMenuItem("Find", icon); findFileMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_F, ActionEvent.CTRL_MASK)); fileMenu.add(findFileMenuItem); final JFrame owner = this; findFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // open the find dialog FindDialog fd = new FindDialog(owner); fd.setModal(true); fd.setVisible(true); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/save.gif"); icon = new ImageIcon(imgURL); saveMenuItem = new JMenuItem("Save", icon); fileMenu.add(saveMenuItem); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_S, ActionEvent.CTRL_MASK)); saveMenuItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { saveFile(evt); } }); } { imgURL = getClass().getClassLoader().getResource("ca/strangebrew/icons/saveas.gif"); icon = new ImageIcon(imgURL); saveAsMenuItem = new JMenuItem("Save As ...", icon); fileMenu.add(saveAsMenuItem); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveAs(); } }); } { exportMenu = new JMenu(); fileMenu.add(exportMenu); exportMenu.setText("Export"); { exportHTMLmenu = new JMenuItem(); exportMenu.add(exportHTMLmenu); exportHTMLmenu.setText("HTML"); exportHTMLmenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"html", "htm"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "HTML"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".html")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { saveAsHTML(file, "recipeToHtml.xslt", null); } catch (Exception e) { showError(e); } } else { Debug.print("Save command cancelled by user.\n"); } } }); exportTextMenuItem = new JMenuItem(); exportMenu.add(exportTextMenuItem); exportTextMenuItem.setText("Text"); exportTextMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Show save dialog; this method does // not return until the dialog is closed String[] ext = {"txt"}; sbFileFilter saveFileFilter = new sbFileFilter(ext, "Text"); fileChooser.setFileFilter(saveFileFilter); fileChooser.setSelectedFile(new File(myRecipe.getName() + ".txt")); int returnVal = fileChooser.showSaveDialog(jMenuBar1); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); //This is where a real application would save the file. try { FileWriter out = new FileWriter(file); out.write(myRecipe.toText()); out.close(); } catch (Exception e) { showError(e); } } else { Debug.print("Export text command cancelled by user.\n"); } } }); } } { JMenuItem clipboardMenuItem = new JMenuItem("Copy to Clipboard"); fileMenu.add(clipboardMenuItem); clipboardMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Copy current recipe to clipboard Clipboard clipboard = getToolkit ().getSystemClipboard (); StringSelection s = new StringSelection(myRecipe.toText()); clipboard.setContents(s, s); } }); JMenuItem printMenuItem = new JMenuItem("Print..."); fileMenu.add(printMenuItem); final JFrame owner = this; printMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PrintDialog pd = new PrintDialog(owner); pd.setModal(true); pd.setVisible(true); } }); } { jSeparator2 = new JSeparator(); fileMenu.add(jSeparator2); } { exitMenuItem = new JMenuItem(); fileMenu.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); final JFrame owner = this; exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // exit program processWindowEvent(new WindowEvent(owner,WindowEvent.WINDOW_CLOSING)); System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { final JFrame owner = this; editPrefsMenuItem = new JMenuItem(); jMenu4.add(editPrefsMenuItem); editPrefsMenuItem.setText("Preferences..."); editPrefsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PreferencesDialog d = new PreferencesDialog(owner, preferences); d.setVisible(true); } }); } { jSeparator1 = new JSeparator(); jMenu4.add(jSeparator1); } { deleteMenuItem = new JMenuItem(); jMenu4.add(deleteMenuItem); deleteMenuItem.setText("Delete"); deleteMenuItem.setEnabled(false); } } { mnuTools = new JMenu(); jMenuBar1.add(mnuTools); mnuTools.setText("Tools"); { final JFrame owner = this; JMenuItem scalRecipeMenuItem = new JMenuItem(); mnuTools.add(scalRecipeMenuItem); scalRecipeMenuItem.setText("Scale Recipe..."); scalRecipeMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_R, ActionEvent.CTRL_MASK)); scalRecipeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ScaleRecipeDialog scaleRecipe = new ScaleRecipeDialog(owner); scaleRecipe.setModal(true); scaleRecipe.setVisible(true); } }); JMenuItem maltPercentMenuItem = new JMenuItem(); mnuTools.add(maltPercentMenuItem); maltPercentMenuItem.setText("Malt Percent..."); maltPercentMenuItem.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_M, ActionEvent.CTRL_MASK)); maltPercentMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MaltPercentDialog maltPercent = new MaltPercentDialog(owner); maltPercent.setModal(true); maltPercent.setVisible(true); } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("Help"); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String urlString = "file://" + appRoot + slash + "help" + slash + "index.html"; Debug.print(urlString); AbstractLogger logger = new SystemLogger(); BrowserLauncher launcher; try { launcher = new BrowserLauncher(logger); BrowserLauncherRunner runner = new BrowserLauncherRunner( launcher, urlString, null); Thread launcherThread = new Thread(runner); launcherThread.start(); } catch (BrowserLaunchingInitializingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperatingSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } { aboutMenuItem = new JMenuItem(); jMenu5.add(aboutMenuItem); aboutMenuItem.setText("About..."); final JFrame owner = this; aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutDlg = new AboutDialog(owner, version); aboutDlg.setVisible(true); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
QueryResponseRecord rec;
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++)
QueryResponseRecord[] records = msg.getMsgRecords(); ArrayList<RemoteFile> newHitList = new ArrayList<RemoteFile>( records.length ); for (int i = 0; i < records.length; i++)
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
rec = msg.getMsgRecord(i);
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo();
long fileSize = records[i].getFileSize(); String filename = records[i].getFilename(); URN urn = records[i].getURN(); int fileIndex = records[i].getFileIndex(); String metaData = records[i].getMetaData(); String pathInfo = records[i].getPathInfo();
public void processResponse( QueryResponseMsg msg ) { long speed = msg.getRemoteHostSpeed(); GUID rcID = msg.getRemoteClientID(); DestAddress address = msg.getDestAddress(); QueryHitHost qhHost = new QueryHitHost( rcID, address, speed ); qhHost.setQHDFlags( msg.getPushNeededFlag(), msg.getServerBusyFlag(), msg.getHasUploadedFlag(), msg.getUploadSpeedFlag() ); qhHost.setQueryResponseFields( msg ); QueryResponseRecord rec; RemoteFile rfile; int recordCount = msg.getRecordCount(); ArrayList newHitList = new ArrayList( recordCount ); for (int i = 0; i < recordCount; i++) { rec = msg.getMsgRecord(i); synchronized( this ) { long fileSize = rec.getFileSize(); String filename = rec.getFilename(); URN urn = rec.getURN(); int fileIndex = rec.getFileIndex(); String metaData = rec.getMetaData(); String pathInfo = rec.getPathInfo(); rfile = new RemoteFile( qhHost, fileIndex, filename, pathInfo, fileSize, urn, metaData, (short)100 ); searchResultHolder.addQueryHit( rfile ); newHitList.add( rfile ); } } // if something was added... if ( newHitList.size() > 0 ) { if ( queryEngine != null ) { queryEngine.incrementResultCount( msg.getUniqueResultCount() ); } RemoteFile[] newHits = new RemoteFile[ newHitList.size() ]; newHitList.toArray( newHits ); fireSearchHitsAdded( newHits ); } }
candidates[i].manualConnectionRetry();
if ( candidates[i] != null ) { candidates[i].manualConnectionRetry(); }
public void actionPerformed( ActionEvent e ) { SWDownloadCandidate[] candidates = getSelectedDownloadCandidates(); for ( int i = 0; i < candidates.length; i++ ) { candidates[i].manualConnectionRetry(); } }
MatrixValueI lhs,MatrixValueI rhs) throws ParseException
MatrixValueI param1,MatrixValueI param2) throws ParseException
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs,MatrixValueI rhs) throws ParseException { Number num = (Number) rhs.getEle(0); res.setEle(0,lhs.getEle(num.intValue()+1)); return res; }
Number num = (Number) rhs.getEle(0); res.setEle(0,lhs.getEle(num.intValue()+1));
if(param1 instanceof MVector) { if(param2 instanceof Scaler) { int index = ((Double) param2.getEle(0)).intValue()-1; Object val = ((MVector) param1).getEle(index); res.setEle(0,val); } else throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); res.setEle(0,val); } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } else throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString());
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs,MatrixValueI rhs) throws ParseException { Number num = (Number) rhs.getEle(0); res.setEle(0,lhs.getEle(num.intValue()+1)); return res; }
return data.getMaltSteep(row);
return new Boolean(data.getMaltSteep(row));
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0: // steep return data.getMaltSteep(row); case 1: // mash return data.getMaltMashed(row); case 2 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 3 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 4 : return data.getMaltUnits(row); case 5 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 6 : return SBStringUtils.format(data.getMaltLov(row), 0); case 7 : return new Double(data.getMaltCostPerU(row)); case 8 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
return data.getMaltMashed(row); case 2 : String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row);
return new Boolean (data.getMaltMashed(row)); case 2 : return data.getMaltName(row);
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0: // steep return data.getMaltSteep(row); case 1: // mash return data.getMaltMashed(row); case 2 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 3 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 4 : return data.getMaltUnits(row); case 5 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 6 : return SBStringUtils.format(data.getMaltLov(row), 0); case 7 : return new Double(data.getMaltCostPerU(row)); case 8 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.asinh();
double val = ((Number)param).doubleValue(); double res = Math.log(val+Math.sqrt(val*val+1)); return new Double(res);
public Object asinh(Object param) throws ParseException { if (param instanceof Complex) { return ((Complex)param).asinh(); } else if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.asinh(); } throw new ParseException("Invalid parameter type"); }
else { super.mouseReleased(e); }
public void mouseReleased(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) ) { AbstractButton b = (AbstractButton) e.getSource(); if ( b.isSelected() ) { int w = closeIcon.getIconWidth(); int h = closeIcon.getIconHeight(); int x = b.getWidth() - b.getInsets().right - w; int y = b.getHeight()/2 - h/2; Rectangle rec = new Rectangle( x, y, w, h ); if ( rec.contains(e.getX(), e.getY() ) ) { btn.searchTab.closeSearch( btn.search ); } else { super.mouseReleased(e); } } } }
if (myFile != "/") {
if (myFile != null) {
public void execute() { if (myContents.getQuitItem().isSelected()) { myContents.quit(); } if (myContents.getOpenItem().isSelected()) { String myFile = myContents.getOpenFilename(); if (myFile != "/") { ImportXml imp = new ImportXml(myFile); Recipe recipe = imp.handler.getRecipe(); myParent.setRecipe(recipe); } } }
req.setCharacterEncoding("UTF-8");
protected final void serveFile(StaplerRequest req, StaplerResponse rsp, File root, String icon, boolean serveDirIndex) throws IOException, ServletException { if(req.getQueryString()!=null) { String path = req.getParameter("path"); if(path!=null) { rsp.sendRedirect(URLEncoder.encode(path,"UTF-8")); return; } } String path = req.getRestOfPath(); if(path.length()==0) path = "/"; if(path.indexOf("..")!=-1 || path.length()<1) { // don't serve anything other than files in the artifacts dir rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } File f = new File(root,path.substring(1)); boolean isFingerprint=false; if(f.getName().equals("*fingerprint*")) { f = f.getParentFile(); isFingerprint = true; } if(!f.exists()) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if(f.isDirectory()) { if(!req.getRequestURL().toString().endsWith("/")) { rsp.sendRedirect2(req.getRequestURL().append('/').toString()); return; } if(serveDirIndex) { req.setAttribute("it",this); List<Path> parentPaths = buildParentPath(path); req.setAttribute("parentPath",parentPaths); req.setAttribute("topPath", parentPaths.isEmpty() ? "." : repeat("../",parentPaths.size())); req.setAttribute("files",buildChildPathList(f)); req.setAttribute("icon",icon); req.getView(this,"dir.jsp").forward(req,rsp); return; } else { f = new File(f,"index.html"); } } FileInputStream in = new FileInputStream(f); try { if(isFingerprint) { Hudson hudson = Hudson.getInstance(); rsp.forward(hudson.getFingerprint(hudson.getDigestOf(in)),"/",req); } else { // serve the file String contentType = req.getServletContext().getMimeType(f.getPath()); rsp.setContentType(contentType); rsp.setContentLength((int)f.length()); byte[] buf = new byte[1024]; int len; while((len=in.read(buf))>0) rsp.getOutputStream().write(buf,0,len); } } finally { in.close(); } }
cases.add(new CaseResult(e));
cases.add(new CaseResult(this,e));
SuiteResult(File xmlReport) throws DocumentException { Document result = new SAXReader().read(xmlReport); Element root = result.getRootElement(); name = root.attributeValue("name"); stdout = root.elementText("system-out"); stderr = root.elementText("system-err"); for (Element e : (List<Element>)root.elements("testcase")) { cases.add(new CaseResult(e)); } }
String v = req.getParameter("mailer_smtpServer");
String v = req.getParameter("mailer_smtp_server");
public boolean configure(HttpServletRequest req) { String v = req.getParameter("mailer_smtpServer"); if(v!=null && v.length()==0) v=null; getProperties().put("mail.smtp.host",v); getProperties().put("mail.admin.address",req.getParameter("mailer_admin_address")); save(); return super.configure(req); }
valueToStringTest("i*j","-1.0k");
valueToStringTest("i*j","-k");
public void testQuartonians() throws Exception { j = new GroupJep(new Quartonians()); j.addStandardConstants(); System.out.println(j.getGroup().toString()); valueToStringTest("i*j","-1.0k"); }
this.add(jPanel1, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
this.add(jPanel1, new GridBagConstraints(3, 1, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); jPanel1.setPreferredSize(new java.awt.Dimension(158, 230));
private void initGUI() { try { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.columnWeights = new double[]{0.3, 0.3}; thisLayout.columnWidths = new int[]{7, 7}; thisLayout.rowWeights = new double[]{0.1, 0.8, 0.1}; thisLayout.rowHeights = new int[]{7, 7, 7}; this.setLayout(thisLayout); { titlePanel = new JPanel(); FlowLayout titlePanelLayout = new FlowLayout(); titlePanelLayout.setAlignment(FlowLayout.LEFT); titlePanel.setLayout(titlePanelLayout); this.add(titlePanel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { titleLabel = new JLabel(); titlePanel.add(titleLabel); titleLabel.setText("Mash schedule for:"); titleLabel.setFont(new java.awt.Font("Dialog", 0, 12)); } { recipeNameLabel = new JLabel(); titlePanel.add(recipeNameLabel); recipeNameLabel.setText("Recipe Name"); } } { tablePanel = new JPanel(); BorderLayout pnlTableLayout = new BorderLayout(); tablePanel.setLayout(pnlTableLayout); this.add(tablePanel, new GridBagConstraints(0, 1, 2, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); tablePanel.setName(""); tablePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); { jScrollPane1 = new JScrollPane(); tablePanel.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(344, 145)); { mashModel = new MashTableModel(); tblMash = new JTable() { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); return SBStringUtils.multiLineToolTip(40, mashModel .getDirectionsAt(rowIndex)); } }; jScrollPane1.setViewportView(tblMash); tblMash.setModel(mashModel); tblMash.setAutoCreateColumnsFromModel(false); tblMash.getTableHeader().setReorderingAllowed(false); // set up type combo String[] types = {"acid", "gluten", "protein", "beta", "alpha", "mashout"}; JComboBox typesComboBox = new JComboBox(types); TableColumn mashColumn = tblMash.getColumnModel().getColumn(0); mashColumn.setCellEditor(new DefaultCellEditor(typesComboBox)); // set up method combo String[] methods = {"infusion", "decoction", "decoction thick", "decoction thin", "direct"}; JComboBox methodComboBox = new JComboBox(methods); mashColumn = tblMash.getColumnModel().getColumn(1); mashColumn.setCellEditor(new DefaultCellEditor(methodComboBox)); } } } jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); this.add(jPanel1, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); { settingsPanel = new JPanel(); jPanel1.add(settingsPanel, BorderLayout.CENTER); GridBagLayout settingsPanelLayout = new GridBagLayout(); settingsPanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; settingsPanelLayout.rowHeights = new int[]{7, 7, 7, 7}; settingsPanelLayout.columnWeights = new double[]{0.3, 0.1, 0.1}; settingsPanelLayout.columnWidths = new int[]{7, 7, 7}; settingsPanel.setLayout(settingsPanelLayout); settingsPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); settingsPanel.setPreferredSize(new java.awt.Dimension(172, 175)); jLabel15 = new JLabel(); settingsPanel.add(jLabel15, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel15.setText("Mash Ratio: 1:"); { ratioText = new JTextField(); settingsPanel.add(ratioText, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); ratioText.setText("1.25"); ratioText.addFocusListener(this); ratioText.addActionListener(this); } { ComboBoxModel ratioUnitsComboModel = new DefaultComboBoxModel(new String[]{ "qt/lb", "l/kg"}); this.setPreferredSize(new java.awt.Dimension(502, 276)); ratioUnitsCombo = new JComboBox(); settingsPanel.add(ratioUnitsCombo, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); ratioUnitsCombo.setModel(ratioUnitsComboModel); ratioUnitsCombo.addActionListener(this); } { grainTempText = new JTextField(); settingsPanel.add(grainTempText, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); grainTempText.setText("10"); grainTempText.addFocusListener(this); grainTempText.addActionListener(this); } { grainTempULabel = new JLabel(); settingsPanel.add(grainTempULabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grainTempULabel.setText("F"); } jLabel19 = new JLabel(); settingsPanel.add(jLabel19, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel19.setText("Grain Temp:"); boilTempTxt = new JTextField(); settingsPanel.add(boilTempTxt, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); boilTempTxt.setText("212"); jLabel20 = new JLabel(); settingsPanel.add(jLabel20, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel20.setText("Boil Temp:"); jLabel12 = new JLabel(); settingsPanel.add(jLabel12, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel12.setText("F"); { tunLossTxt = new JTextField(); settingsPanel.add(tunLossTxt, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); tunLossTxt.addFocusListener(this); tunLossTxt.addActionListener(this); } { tempLostULabel = new JLabel(); settingsPanel.add(tempLostULabel, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); tempLostULabel.setText("F"); } jLabel1 = new JLabel(); settingsPanel.add(jLabel1, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Temp Lost in Tun:"); { buttonsPanel = new JPanel(); tablePanel.add(buttonsPanel, BorderLayout.SOUTH); FlowLayout buttonsPanelLayout = new FlowLayout(); buttonsPanelLayout.setAlignment(FlowLayout.LEFT); buttonsPanel.setLayout(buttonsPanelLayout); buttonsPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); jToolBar1 = new JToolBar(); buttonsPanel.add(jToolBar1); jToolBar1.setFloatable(false); jToolBar1.setPreferredSize(new java.awt.Dimension(65, 18)); jLabel13 = new JLabel(); buttonsPanel.add(jLabel13); jLabel13.setText("Temp Units:"); { tempFrb = new JRadioButton(); buttonsPanel.add(tempFrb); tempFrb.setText("F"); tempFrb.addActionListener(this); } { tempCrb = new JRadioButton(); buttonsPanel.add(tempCrb); tempCrb.setText("C"); tempCrb.addActionListener(this); } tempBg = new ButtonGroup(); tempBg.add(tempFrb); tempBg.add(tempCrb); jLabel14 = new JLabel(); settingsPanel.add(jLabel14, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel14.setText("Vol Units:"); { delStepButton = new JButton(); jToolBar1.add(delStepButton); delStepButton.setText("-"); delStepButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { delStepButtonActionPerformed(evt); } }); } { addStepButton = new JButton(); jToolBar1.add(addStepButton); addStepButton.setText("+"); addStepButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { addStepButtonActionPerformed(evt); } }); } } { volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo = new JComboBox(); settingsPanel.add(volUnitsCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); volUnitsCombo.setModel(volUnitsComboModel); volUnitsCombo.addActionListener(this); } boilTempTxt.addFocusListener(this); boilTempTxt.addActionListener(this); } totalsPanel = new JPanel(); GridBagLayout totalsPanelLayout = new GridBagLayout(); totalsPanel.setLayout(totalsPanelLayout); jPanel1.add(totalsPanel, BorderLayout.SOUTH); jLabel16 = new JLabel(); totalMashLabel = new JLabel(); jLabel17 = new JLabel(); jLabel18 = new JLabel(); { totalTimeLabel = new JLabel(); totalTimeLabel.setText("Time"); } jLabel18.setText("Total Time:"); jLabel17.setText("Total Vol:"); totalsPanel .add(jLabel16, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); totalsPanel .add(totalMashLabel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); totalsPanel .add(jLabel17, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); totalsPanel .add(jLabel18, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); totalsPanel .add(totalTimeLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); { volLabel = new JLabel(); totalsPanel.add(volLabel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0)); volLabel.setText("10"); } jLabel16.setText("Total Weight:"); totalsPanelLayout.rowWeights = new double[]{0.1, 0.1, 0.1}; totalsPanelLayout.rowHeights = new int[]{7, 7, 7}; totalsPanelLayout.columnWeights = new double[]{0.1, 0.1}; totalsPanelLayout.columnWidths = new int[]{7, 7}; totalsPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); totalMashLabel.setText("10"); } catch (Exception e) { e.printStackTrace(); } }
String aString = new String(stringArray);
String aString = new String(PSNDataFile.chopToLength(stringArray));
public PSNVariableHeader(DataInputStream data, int length) throws IOException{ dis = data; for (int i = 0; i < length; i++) { //Sanity Check: this should be equal to 0x55 byte check = dis.readByte(); //System.out.println("Check: " + check); if (check != 0x55){ throw new IOException("file may not be a standard Type 4 PSN format"); } //read descriptor id byte id = dis.readByte(); int fieldLength = SacTimeSeries.swapBytes(dis.readInt()); //System.out.println("varHeader iteration " + i + ", id " + id + ", fieldLength " + fieldLength); switch (id) { case 0: if (fieldLength != 0){ throw new IOException("end of header has unread data"); } break; case 1: case 2: case 3: case 7: //entries.put(new Byte(id), readNullTerminatedString(dis, fieldLength)); byte[] stringArray = new byte[fieldLength]; dis.readFully(stringArray); String aString = new String(stringArray); entries.put(new Byte(id), aString); //System.out.println(aString); break; case 4: List eventInfoList; if (entries.containsKey(new Byte(id))){ eventInfoList = (ArrayList)entries.get(new Byte(id)); } else{ eventInfoList = new ArrayList(); } eventInfoList.add(new PSNEventInfo(dis)); entries.put(new Byte(id), eventInfoList); break; case 5: List phasePickList; if (hasPhasePicks()){ phasePickList = (ArrayList)entries.get(new Byte(id)); } else{ phasePickList = new ArrayList(); } phasePickList.add(new PSNPhasePick(dis)); entries.put(new Byte(id), phasePickList); break; case 11: entries.put(new Byte(id), new PSNSensorAmpAtoD(dis)); break; case 12: entries.put(new Byte(id), new PSNPolesAndZeros(dis)); break; default: dis.skip(fieldLength); break; } i+=(fieldLength + 5); } }
for( int i=builders.size()-1; i>=0; i-- ) { BuildStep b = builders.get(i);
for (BuildStep b : builders) {
public synchronized Map<BuildStepDescriptor,BuildStep> getBuilders() { Map<BuildStepDescriptor,BuildStep> m = new LinkedHashMap<BuildStepDescriptor,BuildStep>(); for( int i=builders.size()-1; i>=0; i-- ) { BuildStep b = builders.get(i); m.put(b.getDescriptor(),b); } return m; }
for( int i=publishers.size()-1; i>=0; i-- ) { BuildStep b = publishers.get(i);
for (BuildStep b : publishers) {
public synchronized Map<BuildStepDescriptor,BuildStep> getPublishers() { Map<BuildStepDescriptor,BuildStep> m = new LinkedHashMap<BuildStepDescriptor,BuildStep>(); for( int i=publishers.size()-1; i>=0; i-- ) { BuildStep b = publishers.get(i); m.put(b.getDescriptor(),b); } return m; }
else if (type.equals("ini")) path = appRoot + slash;
public static String getAppPath(String type){ String appRoot = ""; String path = ""; String slash = System.getProperty("file.separator"); try { appRoot = new File(".").getCanonicalPath(); } catch (Exception e){ e.printStackTrace(); } if (type.equals("data")) path = appRoot + slash + "src" + slash + "ca" + slash + "strangebrew" + slash + "data"; else if (type.equals("icons")) path = appRoot + slash + "src" + slash + "ca" + slash + "strangebrew" + slash + "icons"; else if (type.equals("recipes")) path = appRoot + slash + "recipes"; else if (type.equals("help")) path = "file://" + appRoot + slash + "help" + slash; else path = appRoot; return path; }
public Slave(String name, String command, String remoteFS, File localFS) {
public Slave(String name, String description, String command, String remoteFS, File localFS) {
public Slave(String name, String command, String remoteFS, File localFS) { this.name = name; this.command = command; this.remoteFS = remoteFS; this.localFS = localFS; }
this.description = description;
public Slave(String name, String command, String remoteFS, File localFS) { this.name = name; this.command = command; this.remoteFS = remoteFS; this.localFS = localFS; }
r.addAll(Arrays.asList(env));
for (String s : env) { int index =s.indexOf('='); r.add(s.substring(0,index)); r.add(s.substring(index+1)); }
public Launcher createLauncher(BuildListener listener) { return new Launcher(listener) { @Override public Proc launch(String[] cmd, String[] env, OutputStream out, FilePath workDir) throws IOException { return super.launch(prepend(cmd,env,workDir), env, null, out); } @Override public Proc launch(String[] cmd, String[] env, InputStream in, OutputStream out) throws IOException { return super.launch(prepend(cmd,env,CURRENT_DIR), env, in, out); } @Override public boolean isUnix() { // Err on Unix, since we expect that to be the common slaves return remoteFS.indexOf('\\')==-1; } private String[] prepend(String[] cmd, String[] env, FilePath workDir) { List<String> r = new ArrayList<String>(); r.addAll(Arrays.asList(getCommandTokens())); r.add("~/bin/slave"); r.add(workDir.getRemote()); r.addAll(Arrays.asList(env)); r.add("--"); r.addAll(Arrays.asList(cmd)); return r.toArray(new String[r.size()]); } }; }
r.addAll(Arrays.asList(env));
for (String s : env) { int index =s.indexOf('='); r.add(s.substring(0,index)); r.add(s.substring(index+1)); }
private String[] prepend(String[] cmd, String[] env, FilePath workDir) { List<String> r = new ArrayList<String>(); r.addAll(Arrays.asList(getCommandTokens())); r.add("~/bin/slave"); r.add(workDir.getRemote()); r.addAll(Arrays.asList(env)); r.add("--"); r.addAll(Arrays.asList(cmd)); return r.toArray(new String[r.size()]); }
searchStatusLbl = new JLabel(); searchBoxBuilder.add( searchStatusLbl, cc.xy( 4, 2 ) );
public SearchInfoBox( SearchControlPanel cp ) { super( Localizer.getString( "SearchTab_Information" ) ); controlPanel = cp; CellConstraints cc = new CellConstraints(); FormLayout boxLayout = new FormLayout( "6dlu, d, 2dlu, fill:p:grow, 6dlu", // columns "4dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu," + "p, 2dlu, p, 2dlu, p, 2dlu, p, 6dlu" ); // rows PanelBuilder searchBoxBuilder = new PanelBuilder( boxLayout, getContentPanel() ); JLabel label = searchBoxBuilder.addLabel( Localizer.getString( "SearchTab_Status" ), cc.xy( 2, 2 ) ); label.setToolTipText( Localizer.getString("SearchTab_TTTStatus") ); progressBar = new JProgressBar( 0, 100 ); progressBar.setToolTipText( Localizer.getString("SearchTab_TTTProgress") ); progressBar.setStringPainted(true); searchBoxBuilder.add( progressBar, cc.xywh( 2, 4, 3, 1 ) ); label = searchBoxBuilder.addLabel( Localizer.getString( "SearchTab_TotalResults" ), cc.xy( 2, 6 ) ); label.setToolTipText( Localizer.getString("SearchTab_TTTTotalResults") ); totalResultsLbl = new JLabel(); searchBoxBuilder.add( totalResultsLbl, cc.xy( 4, 6 ) ); label = searchBoxBuilder.addLabel( Localizer.getString( "SearchTab_DisplayedResults" ), cc.xy( 2, 8 ) ); label.setToolTipText( Localizer.getString("SearchTab_TTTDisplayedResults") ); displayedResultsLbl = new JLabel(); searchBoxBuilder.add( displayedResultsLbl, cc.xy( 4, 8 ) ); label = searchBoxBuilder.addLabel( Localizer.getString( "SearchTab_FilteredResults" ), cc.xy( 2, 10 ) ); label.setToolTipText( Localizer.getString("SearchTab_TTTFilteredResults") ); filteredResultsLbl = new JLabel(); searchBoxBuilder.add( filteredResultsLbl, cc.xy( 4, 10 ) ); updateDisplayTimer = new Timer( 2000, new ActionListener() { public void actionPerformed( ActionEvent e ) { try { updateDisplay(); } catch ( Throwable th ) { NLogger.error(SearchInfoBox.class, th, th); } } }); }
progressBar.setValue( displayedDataModel.getSearch().getProgress() );
progressBar.setValue( search.getProgress() );
private void updateDisplay() { if ( displayedDataModel != null ) { int total = displayedDataModel.getAllSearchResultCount(); int filtered = displayedDataModel.getFilteredElementCount(); progressBar.setValue( displayedDataModel.getSearch().getProgress() ); totalResultsLbl.setText( String.valueOf( total ) ); displayedResultsLbl.setText( String.valueOf( total - filtered ) ); filteredResultsLbl.setText( String.valueOf( filtered ) ); } else { progressBar.setValue(0); totalResultsLbl.setText(""); displayedResultsLbl.setText(""); filteredResultsLbl.setText(""); } }
searchStatusLbl.setText("");
private void updateDisplay() { if ( displayedDataModel != null ) { int total = displayedDataModel.getAllSearchResultCount(); int filtered = displayedDataModel.getFilteredElementCount(); progressBar.setValue( displayedDataModel.getSearch().getProgress() ); totalResultsLbl.setText( String.valueOf( total ) ); displayedResultsLbl.setText( String.valueOf( total - filtered ) ); filteredResultsLbl.setText( String.valueOf( filtered ) ); } else { progressBar.setValue(0); totalResultsLbl.setText(""); displayedResultsLbl.setText(""); filteredResultsLbl.setText(""); } }
v.jobNames.remove(oldName); v.jobNames.add(newName);
if(v.jobNames.remove(oldName)) v.jobNames.add(newName);
/*package*/ void onRenamed(Job job, String oldName, String newName) throws IOException { jobs.remove(oldName); jobs.put(newName,job); if(views!=null) { for (View v : views) { synchronized(v) { v.jobNames.remove(oldName); v.jobNames.add(newName); } } save(); } }
debug = false;
public EvaluatorVisitor() { debug = false; errorList = null; symTab = null; stack = new Stack(); }
public Object getValue(Node topNode, Vector errorList_in,
public synchronized Object getValue(Node topNode, Vector errorList_in,
public Object getValue(Node topNode, Vector errorList_in, SymbolTable symTab_in) throws Exception { // check if arguments are ok if (topNode == null) { throw new IllegalArgumentException( "topNode parameter is null"); } if (symTab_in == null) { throw new IllegalArgumentException( "symTab_in parameter is null"); } // set member vars errorList = errorList_in; symTab = symTab_in; errorFlag = false; // evaluate by letting the top node accept the visitor topNode.jjtAccept(this, null); // something is wrong if not exactly one item remains on the stack // or if the error flag has been set if (errorFlag || stack.size() != 1) { throw new Exception( "EvaluatorVisitor.getValue(): Error during evaluation"); } // return the value of the expression return stack.pop(); }
f.setMashed(s.trim().equalsIgnoreCase("true"));
f.setMashed(s.trim().equalsIgnoreCase("true")); } else if (currentList.equalsIgnoreCase("mash")){ if (currentElement.equalsIgnoreCase("type")) myRecipe.mash.setStepMethod(myRecipe.mash.getStepSize()-1, s.trim()); if (currentElement.equalsIgnoreCase("STEP_TIME")) myRecipe.mash.setStepMin(myRecipe.mash.getStepSize()-1, new Double(s.trim()).intValue()); if (currentElement.equalsIgnoreCase("STEP_TEMP")) myRecipe.mash.setStepStartTemp(myRecipe.mash.getStepSize()-1, Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("END_TEMP")) myRecipe.mash.setStepEndTemp(myRecipe.mash.getStepSize()-1, Double.parseDouble(s.trim())); } else if (currentList.equalsIgnoreCase("miscs")){ if (currentElement.equalsIgnoreCase("name")) m.setName(s.trim()); if (currentElement.equalsIgnoreCase("amount")) m.setAmountAs(Double.parseDouble(s.trim()), "kg"); if (currentElement.equalsIgnoreCase("use")) m.setStage(s.trim()); if (currentElement.equalsIgnoreCase("time")) m.setTime(new Double(s.trim()).intValue()); } else if (currentList.equalsIgnoreCase("yeast")){ if (currentElement.equalsIgnoreCase("name")) myRecipe.setYeastName(s.trim());
public void characters(char buf[], int offset, int len) throws SAXException { String s = new String(buf, offset, len); // we're inside a style: if (!s.trim().equals("")) { if (currentElement.equalsIgnoreCase("notes")) descrBuf += s; if (currentList.equalsIgnoreCase("hops")){ if (currentElement.equalsIgnoreCase("name")) h.setName(s.trim()); if (currentElement.equalsIgnoreCase("amount")) h.setAmountAs(Double.parseDouble(s.trim()), "kg"); if (currentElement.equalsIgnoreCase("form")) h.setType(s.trim()); if (currentElement.equalsIgnoreCase("hsi")) h.setStorage(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("alpha")) h.setAlpha(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("time")) h.setMinutes(new Double(s.trim()).intValue()); if (currentElement.equalsIgnoreCase("use")){ if (s.trim().equalsIgnoreCase("boil") || s.trim().equalsIgnoreCase("aroma")) h.setAdd("Boil"); if (s.trim().equalsIgnoreCase("dry hop")) h.setAdd("Dry"); if (s.trim().equalsIgnoreCase("first wort")) h.setAdd("FWH"); } } else if (currentList.equalsIgnoreCase("fermentables")){ if (currentElement.equalsIgnoreCase("name")) f.setName(s.trim()); if (currentElement.equalsIgnoreCase("amount")) f.setAmountAs(Double.parseDouble(s.trim()), "kg"); if (currentElement.equalsIgnoreCase("potential")) f.setPppg(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("color")) f.setLov(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("RECOMMEND_MASH")) f.setMashed(s.trim().equalsIgnoreCase("true")); } else if (currentList.equalsIgnoreCase("style")){ if (currentElement.equalsIgnoreCase("name")) myRecipe.setStyle(s.trim()); } else if (currentList.equalsIgnoreCase("recipe")){ if (currentElement.equalsIgnoreCase("name")) myRecipe.setName(s.trim()); if (currentElement.equalsIgnoreCase("brewer")) myRecipe.setBrewer(s.trim()); if (currentElement.equalsIgnoreCase("BATCH_SIZE")){ myRecipe.setPostBoil(Double.parseDouble(s.trim())); myRecipe.setVolUnits("l"); } if (currentElement.equalsIgnoreCase("BOIL_TIME")) myRecipe.setBoilMinutes(new Double(s.trim()).intValue()); if (currentElement.equalsIgnoreCase("EFFICIENCY")) myRecipe.setEfficiency(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("EFFICIENCY")) myRecipe.setEfficiency(Double.parseDouble(s.trim())); if (currentElement.equalsIgnoreCase("IBU_METHOD")) myRecipe.setIBUMethod(s.trim()); } } }
if (currentList.equalsIgnoreCase("miscs")) m.setDescription(descrBuf); if (currentList.equalsIgnoreCase("yeast")) myRecipe.getYeastObj().setDescription(descrBuf);
public void endElement(String namespaceURI, String sName, // simple name String qName // qualified name ) throws SAXException { if (qName.equalsIgnoreCase("recipe")){ newRecipe = false; numRecipes ++; recipes.add(myRecipe); } if (qName.equalsIgnoreCase("hops") || qName.equalsIgnoreCase("fermentables") || qName.equalsIgnoreCase("miscs") || qName.equalsIgnoreCase("yeasts") || qName.equalsIgnoreCase("waters") || qName.equalsIgnoreCase("style") || qName.equalsIgnoreCase("equipment") || qName.equalsIgnoreCase("mash")) { currentList = "recipe"; } if (qName.equalsIgnoreCase("hop")){ myRecipe.addHop(h); } if (qName.equalsIgnoreCase("fermentable")){ myRecipe.addMalt(f); } if (qName.equalsIgnoreCase("notes")){ if (currentList.equalsIgnoreCase("hops")) h.setDescription(descrBuf); if (currentList.equalsIgnoreCase("fermentables")) f.setDescription(descrBuf); } }
}
} if (eName.equalsIgnoreCase("MISC")){ m = new Misc(); } if (qName.equalsIgnoreCase("MASH_STEP")){ myRecipe.mash.addStep(); }
public void startElement(String namespaceURI, String lName, // local unit String qName, // qualified unit Attributes attrs) throws SAXException { String eName = lName; // element unit if ("".equals(eName)) eName = qName; // namespaceAware = false currentElement = eName; currentAttributes = attrs; if (eName.equalsIgnoreCase("recipe")){ newRecipe = true; myRecipe = new Recipe(); currentList = eName; } if (eName.equalsIgnoreCase("hops") || eName.equalsIgnoreCase("FERMENTABLES") || eName.equalsIgnoreCase("MISCS") || qName.equalsIgnoreCase("yeasts") || qName.equalsIgnoreCase("waters") || qName.equalsIgnoreCase("style") || qName.equalsIgnoreCase("equipment") || qName.equalsIgnoreCase("mash")){ currentList = eName; } if (eName.equalsIgnoreCase("hop")){ h = new Hop(); } if (eName.equalsIgnoreCase("FERMENTABLE")){ f = new Fermentable(); } if (eName.equalsIgnoreCase("notes")){ descrBuf = ""; } }
return "save.png";
return "save.gif";
public String getIconFileName() { return "save.png"; }
expect(hibernateTemplate.load(ExternalDocument.class, 5)).andReturn(loaded);
expect(hibernateTemplate.load(ExternalDocument.class, new Long(5))).andReturn(loaded);
public void testExternalDocument() { ExternalDocument loaded = new ExternalDocument(); loaded.setDocCode("TEST"); expect(hibernateTemplate.load(ExternalDocument.class, 5)).andReturn(loaded); replay(hibernateTemplate); ExternalDocumentForm externalDocumentForm = new ExternalDocumentForm(); BeanWrapper bw = new BeanWrapperImpl(externalDocumentForm); registrar.registerCustomEditors(bw); bw.setPropertyValue("externalDocument", "5"); verify(hibernateTemplate); assertSame(loaded, externalDocumentForm.getExternalDocument()); String docCode = ((ExternalDocument) bw.getPropertyValue("externalDocument")).getDocCode(); assertEquals("TEST", docCode); }
stations.clear();
public void initFrame(){ // setSize(new java.awt.Dimension (mywidth, myheight)); //setPreferredSize(new java.awt.Dimension (mywidth, myheight)); setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.fill = gbc.BOTH; gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 0; JLabel netLabel = new JLabel(bundle.getString("LABEL_NETWORKS")); JLabel staLabel = new JLabel(bundle.getString("LABEL_STATIONS")); JLabel siLabel = new JLabel(bundle.getString("LABEL_SITES")); JLabel orientationLabel = new JLabel(bundle.getString("LABEL_ORIENTATIONS")); JLabel chLabel = new JLabel(bundle.getString("LABEL_CHANNELS")); netLabel.setToolTipText(lnettip); staLabel.setToolTipText(lstatip); siLabel.setToolTipText(lsittip); chLabel.setToolTipText(lchatip); add(netLabel, gbc); gbc.gridx++; add(staLabel, gbc); gbc.gridx++; if (showSites) { add(siLabel, gbc); gbc.gridx++; } // end of if (showSites) add(orientationLabel, gbc); gbc.gridx++; add(chLabel, gbc); gbc.gridx++; gbc.gridy++; gbc.gridx = 0; gbc.weighty = 1.0; final ListCellRenderer renderer = new NameListCellRenderer(true); networkList = new JList(networks); networkList.setCellRenderer(renderer); networkList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); networkList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()){ return; } final NetworkAccess[] nets = getSelectedNetworks(); stations.clear(); Thread stationLoader = new Thread() { public void run() { try { for (int i=0; i<nets.length; i++) { Station[] newStations = nets[i].retrieve_stations(); logger.debug("got "+newStations.length+" stations"); for (int j=0; j<newStations.length; j++) { stations.addElement(newStations[j]); } logger.debug("finished adding stations"); } // end of for ((int i=0; i<nets.length; i++) } catch (Exception e) { edu.sc.seis.fissuresUtil.exceptionHandlerGUI.ExceptionHandlerGUI.handleException(e); } // end of try-catch } }; stationLoader.start(); } } ); JScrollPane scroller = new JScrollPane(networkList); add(scroller, gbc); gbc.gridx++; stationList = new JList(stations); stationList.setCellRenderer(renderer); stationList.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); stationList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()){ return; } ListSelectionModel selModel = stationList.getSelectionModel(); // assume only one selected network at at time... NetworkAccess[] nets = getSelectedNetworks(); NetworkAccess net = nets[0]; for (int i=e.getFirstIndex(); i<=e.getLastIndex(); i++) { if (stationList.isSelectedIndex(i)) { Station selectedStation = (Station)stations.getElementAt(i); Channel[] chans = net.retrieve_for_station(selectedStation.get_id()); for (int j=0; j<chans.length; j++) { String chanKey = ChannelIdUtil.toString(chans[j].get_id()); if ( ! channelMap.containsKey(chanKey)) { channelMap.put(chanKey, chans[j]); if ( ! sites.contains(chans[j].my_site.get_code())) { sites.addElement(chans[j].my_site.get_code()); } if ( ! channels.contains(chans[j].get_code())) { channels.addElement(chans[j].get_code()); } } } // end of for (int j=0; j<chans.length; j++) } else { Station selectedStation = (Station)stations.getElementAt(i); Channel[] chans = net.retrieve_for_station(selectedStation.get_id()); for (int j=0; j<chans.length; j++) { String chanKey = ChannelIdUtil.toString(chans[j].get_id()); if ( channelMap.containsKey(chanKey)) { channelMap.remove(chanKey); } } } } // end of for (int i=e.getFirstIndex(); i<e.getLastIndex(); i++) } } ); scroller = new JScrollPane(stationList); add(scroller, gbc); gbc.gridx++; siteList = new JList(sites); siteList.setCellRenderer(renderer); siteList.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); scroller = new JScrollPane(siteList); if (showSites) { add(scroller, gbc); gbc.gridx++; } final ListCellRenderer bundleRenderer = new BundleListCellRenderer(); String[] orientationTypes = new String[4]; orientationTypes[THREE_COMPONENT] = "THREE_COMPONENT"; orientationTypes[VERTICAL_ONLY] = "VERTICAL_ONLY"; orientationTypes[HORIZONTAL_ONLY] = "HORIZONTAL_ONLY"; orientationTypes[INDIVIDUAL_CHANNELS] = "INDIVIDUAL_CHANNELS"; orientationList = new JList(orientationTypes); orientationList.setCellRenderer(bundleRenderer); orientationList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); orientationList.getSelectionModel().setSelectionInterval(autoSelectedOrientation, autoSelectedOrientation); orientationList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()){ return; } String selected = (String)orientationList.getSelectedValue(); if ((selected.equals("THREE_COMPONENT") || selected.equals("VERTICAL_ONLY") || selected.equals("HORIZONTAL_ONLY")) && channelList.getModel() != bandListModel) { channelList.setModel(bandListModel); channelList.setCellRenderer(bundleRenderer); } else if (selected.equals("INDIVIDUAL_CHANNELS") && channelList.getModel() != channels) { channelList.setModel(channels); channelList.setCellRenderer(renderer); } } }); scroller = new JScrollPane(orientationList); add(scroller, gbc); gbc.gridx++; bandListModel.addElement("LONG_PERIOD"); bandListModel.addElement("BROAD_BAND"); bandListModel.addElement("SHORT_PERIOD"); bandListModel.addElement("VERY_LONG_PERIOD"); bandListModel.addElement("ULTRA_LONG_PERIOD"); bandListModel.addElement("EXTREMELY_LONG_PERIOD"); bandListModel.addElement("MID_PERIOD"); bandListModel.addElement("EXTREMELY_SHORT_PERIOD"); bandListModel.addElement("HIGH_BROAD_BAND"); bandListModel.addElement("ADMINISTRATIVE"); bandListModel.addElement("WEATHER_ENVIRONMENTAL"); bandListModel.addElement("EXPERIMENTAL"); if (autoSelectedOrientation == INDIVIDUAL_CHANNELS) { channelList = new JList(channels); channelList.setCellRenderer(renderer); } else { channelList = new JList(bandListModel); channelList.setCellRenderer(bundleRenderer); } // end of else channelList.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); ListModel chanListModel = channelList.getModel(); ListSelectionModel channelSelctionModel = channelList.getSelectionModel(); for (int j=0; j<autoSelectBandGain.length; j++) { for (int i=0; i<chanListModel.getSize(); i++) { String listElement = (String)chanListModel.getElementAt(i); System.out.println(bundle.getString("CODE_"+listElement)+" = "+autoSelectBandGain[j]); if (bundle.getString("CODE_"+listElement).equals(autoSelectBandGain[j])) { channelSelctionModel.addSelectionInterval(i,i); break; } } // end of for (int i=0; i<chanListModel; i++) } // end of for (int j=0; j<autoSelectBandGain.length; j++) scroller = new JScrollPane(channelList); add(scroller, gbc); gbc.gridx++; }
logger.debug("There are "+stations.getSize()+" items in the station list model");
public void initFrame(){ // setSize(new java.awt.Dimension (mywidth, myheight)); //setPreferredSize(new java.awt.Dimension (mywidth, myheight)); setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.fill = gbc.BOTH; gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.gridx = 0; gbc.gridy = 0; JLabel netLabel = new JLabel(bundle.getString("LABEL_NETWORKS")); JLabel staLabel = new JLabel(bundle.getString("LABEL_STATIONS")); JLabel siLabel = new JLabel(bundle.getString("LABEL_SITES")); JLabel orientationLabel = new JLabel(bundle.getString("LABEL_ORIENTATIONS")); JLabel chLabel = new JLabel(bundle.getString("LABEL_CHANNELS")); netLabel.setToolTipText(lnettip); staLabel.setToolTipText(lstatip); siLabel.setToolTipText(lsittip); chLabel.setToolTipText(lchatip); add(netLabel, gbc); gbc.gridx++; add(staLabel, gbc); gbc.gridx++; if (showSites) { add(siLabel, gbc); gbc.gridx++; } // end of if (showSites) add(orientationLabel, gbc); gbc.gridx++; add(chLabel, gbc); gbc.gridx++; gbc.gridy++; gbc.gridx = 0; gbc.weighty = 1.0; final ListCellRenderer renderer = new NameListCellRenderer(true); networkList = new JList(networks); networkList.setCellRenderer(renderer); networkList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); networkList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()){ return; } final NetworkAccess[] nets = getSelectedNetworks(); stations.clear(); Thread stationLoader = new Thread() { public void run() { try { for (int i=0; i<nets.length; i++) { Station[] newStations = nets[i].retrieve_stations(); logger.debug("got "+newStations.length+" stations"); for (int j=0; j<newStations.length; j++) { stations.addElement(newStations[j]); } logger.debug("finished adding stations"); } // end of for ((int i=0; i<nets.length; i++) } catch (Exception e) { edu.sc.seis.fissuresUtil.exceptionHandlerGUI.ExceptionHandlerGUI.handleException(e); } // end of try-catch } }; stationLoader.start(); } } ); JScrollPane scroller = new JScrollPane(networkList); add(scroller, gbc); gbc.gridx++; stationList = new JList(stations); stationList.setCellRenderer(renderer); stationList.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); stationList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()){ return; } ListSelectionModel selModel = stationList.getSelectionModel(); // assume only one selected network at at time... NetworkAccess[] nets = getSelectedNetworks(); NetworkAccess net = nets[0]; for (int i=e.getFirstIndex(); i<=e.getLastIndex(); i++) { if (stationList.isSelectedIndex(i)) { Station selectedStation = (Station)stations.getElementAt(i); Channel[] chans = net.retrieve_for_station(selectedStation.get_id()); for (int j=0; j<chans.length; j++) { String chanKey = ChannelIdUtil.toString(chans[j].get_id()); if ( ! channelMap.containsKey(chanKey)) { channelMap.put(chanKey, chans[j]); if ( ! sites.contains(chans[j].my_site.get_code())) { sites.addElement(chans[j].my_site.get_code()); } if ( ! channels.contains(chans[j].get_code())) { channels.addElement(chans[j].get_code()); } } } // end of for (int j=0; j<chans.length; j++) } else { Station selectedStation = (Station)stations.getElementAt(i); Channel[] chans = net.retrieve_for_station(selectedStation.get_id()); for (int j=0; j<chans.length; j++) { String chanKey = ChannelIdUtil.toString(chans[j].get_id()); if ( channelMap.containsKey(chanKey)) { channelMap.remove(chanKey); } } } } // end of for (int i=e.getFirstIndex(); i<e.getLastIndex(); i++) } } ); scroller = new JScrollPane(stationList); add(scroller, gbc); gbc.gridx++; siteList = new JList(sites); siteList.setCellRenderer(renderer); siteList.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); scroller = new JScrollPane(siteList); if (showSites) { add(scroller, gbc); gbc.gridx++; } final ListCellRenderer bundleRenderer = new BundleListCellRenderer(); String[] orientationTypes = new String[4]; orientationTypes[THREE_COMPONENT] = "THREE_COMPONENT"; orientationTypes[VERTICAL_ONLY] = "VERTICAL_ONLY"; orientationTypes[HORIZONTAL_ONLY] = "HORIZONTAL_ONLY"; orientationTypes[INDIVIDUAL_CHANNELS] = "INDIVIDUAL_CHANNELS"; orientationList = new JList(orientationTypes); orientationList.setCellRenderer(bundleRenderer); orientationList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); orientationList.getSelectionModel().setSelectionInterval(autoSelectedOrientation, autoSelectedOrientation); orientationList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()){ return; } String selected = (String)orientationList.getSelectedValue(); if ((selected.equals("THREE_COMPONENT") || selected.equals("VERTICAL_ONLY") || selected.equals("HORIZONTAL_ONLY")) && channelList.getModel() != bandListModel) { channelList.setModel(bandListModel); channelList.setCellRenderer(bundleRenderer); } else if (selected.equals("INDIVIDUAL_CHANNELS") && channelList.getModel() != channels) { channelList.setModel(channels); channelList.setCellRenderer(renderer); } } }); scroller = new JScrollPane(orientationList); add(scroller, gbc); gbc.gridx++; bandListModel.addElement("LONG_PERIOD"); bandListModel.addElement("BROAD_BAND"); bandListModel.addElement("SHORT_PERIOD"); bandListModel.addElement("VERY_LONG_PERIOD"); bandListModel.addElement("ULTRA_LONG_PERIOD"); bandListModel.addElement("EXTREMELY_LONG_PERIOD"); bandListModel.addElement("MID_PERIOD"); bandListModel.addElement("EXTREMELY_SHORT_PERIOD"); bandListModel.addElement("HIGH_BROAD_BAND"); bandListModel.addElement("ADMINISTRATIVE"); bandListModel.addElement("WEATHER_ENVIRONMENTAL"); bandListModel.addElement("EXPERIMENTAL"); if (autoSelectedOrientation == INDIVIDUAL_CHANNELS) { channelList = new JList(channels); channelList.setCellRenderer(renderer); } else { channelList = new JList(bandListModel); channelList.setCellRenderer(bundleRenderer); } // end of else channelList.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); ListModel chanListModel = channelList.getModel(); ListSelectionModel channelSelctionModel = channelList.getSelectionModel(); for (int j=0; j<autoSelectBandGain.length; j++) { for (int i=0; i<chanListModel.getSize(); i++) { String listElement = (String)chanListModel.getElementAt(i); System.out.println(bundle.getString("CODE_"+listElement)+" = "+autoSelectBandGain[j]); if (bundle.getString("CODE_"+listElement).equals(autoSelectBandGain[j])) { channelSelctionModel.addSelectionInterval(i,i); break; } } // end of for (int i=0; i<chanListModel; i++) } // end of for (int j=0; j<autoSelectBandGain.length; j++) scroller = new JScrollPane(channelList); add(scroller, gbc); gbc.gridx++; }
stations.clear();
public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()){ return; } final NetworkAccess[] nets = getSelectedNetworks(); stations.clear(); Thread stationLoader = new Thread() { public void run() { try { for (int i=0; i<nets.length; i++) { Station[] newStations = nets[i].retrieve_stations(); logger.debug("got "+newStations.length+" stations"); for (int j=0; j<newStations.length; j++) { stations.addElement(newStations[j]); } logger.debug("finished adding stations"); } // end of for ((int i=0; i<nets.length; i++) } catch (Exception e) { edu.sc.seis.fissuresUtil.exceptionHandlerGUI.ExceptionHandlerGUI.handleException(e); } // end of try-catch } }; stationLoader.start(); }
logger.debug("There are "+stations.getSize()+" items in the station list model");
public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()){ return; } final NetworkAccess[] nets = getSelectedNetworks(); stations.clear(); Thread stationLoader = new Thread() { public void run() { try { for (int i=0; i<nets.length; i++) { Station[] newStations = nets[i].retrieve_stations(); logger.debug("got "+newStations.length+" stations"); for (int j=0; j<newStations.length; j++) { stations.addElement(newStations[j]); } logger.debug("finished adding stations"); } // end of for ((int i=0; i<nets.length; i++) } catch (Exception e) { edu.sc.seis.fissuresUtil.exceptionHandlerGUI.ExceptionHandlerGUI.handleException(e); } // end of try-catch } }; stationLoader.start(); }
logger.debug("There are "+stations.getSize()+" items in the station list model");
public void run() { try { for (int i=0; i<nets.length; i++) { Station[] newStations = nets[i].retrieve_stations(); logger.debug("got "+newStations.length+" stations"); for (int j=0; j<newStations.length; j++) { stations.addElement(newStations[j]); } logger.debug("finished adding stations"); } // end of for ((int i=0; i<nets.length; i++) } catch (Exception e) { edu.sc.seis.fissuresUtil.exceptionHandlerGUI.ExceptionHandlerGUI.handleException(e); } // end of try-catch }
myParent = parent;
public MenuController(MenuView aView, MainController parent) { super(aView); myContents = aView; }