Changeset 2138
- Timestamp:
- Mar 31, 2006, 2:15:40 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/Base.java
r2033 r2138 382 382 } 383 383 384 // Property filters and selected items 385 // Filter parameters have names like: filter:STRING:propertyName 386 // where propertyName can start with an optional operator: <>, >=, <=, >, <, = 387 Enumeration<String> names = (Enumeration<String>)request.getParameterNames(); 388 cc.getSelected().clear(); 389 while (names.hasMoreElements()) 390 { 391 String name = names.nextElement(); 392 if (name.startsWith("filter:")) 384 if (Values.getBoolean(request.getParameter("filter:clearAll"))) 385 { 386 cc.removeAllPropertyFilters(); 387 } 388 else 389 { 390 // Property filters and selected items 391 // Filter parameters have names like: filter:STRING:propertyName 392 // where propertyName can start with an optional operator: <>, >=, <=, >, <, = 393 Enumeration<String> names = (Enumeration<String>)request.getParameterNames(); 394 cc.getSelected().clear(); 395 while (names.hasMoreElements()) 393 396 { 394 String value = Values.getStringOrNull(request.getParameter(name)); 395 int colonIndex = name.indexOf(":", 7); // Second colon 396 String property = name.substring(colonIndex+1); 397 if (value != null) 397 String name = names.nextElement(); 398 if (name.startsWith("filter:")) 398 399 { 399 Type valueType = Type.valueOf(name.substring(7, colonIndex)); 400 401 PropertyFilter filter = cc.getPropertyFilter(property); 402 if (filter == null) filter = new PropertyFilter(property); 403 filter.setValueType(valueType); 404 405 Operator op = Operator.EQ; 406 if (value.startsWith("<>") || value.startsWith("!=")) 400 String value = Values.getStringOrNull(request.getParameter(name)); 401 int colonIndex = name.indexOf(":", 7); // Second colon 402 String property = name.substring(colonIndex+1); 403 if (value != null) 407 404 { 408 op = Operator.NEQ; 409 value = value.substring(2); 405 Type valueType = Type.valueOf(name.substring(7, colonIndex)); 406 407 PropertyFilter filter = cc.getPropertyFilter(property); 408 if (filter == null) filter = new PropertyFilter(property); 409 filter.setValueType(valueType); 410 411 Operator op = Operator.EQ; 412 if (value.startsWith("<>") || value.startsWith("!=")) 413 { 414 op = Operator.NEQ; 415 value = value.substring(2); 416 } 417 else if (value.startsWith(">=")) 418 { 419 op = Operator.GTEQ; 420 value = value.substring(2); 421 } 422 else if (value.startsWith("<=")) 423 { 424 op = Operator.LTEQ; 425 value = value.substring(2); 426 } 427 else if (value.startsWith(">")) 428 { 429 op = Operator.GT; 430 value = value.substring(1); 431 } 432 else if (value.startsWith("<")) 433 { 434 op = Operator.LT; 435 value = value.substring(1); 436 } 437 else if (value.startsWith("=")) 438 { 439 op = Operator.EQ; 440 value = value.substring(1); 441 if ("".equals(value)) value = null; 442 } 443 else if (value.indexOf('%') >= 0) 444 { 445 op = Operator.LIKE; 446 } 447 /* 448 TODO - null operator is a signal to use JEP for parsing as an adavanced formula 449 for example: ? = 'Nicklas' OR ? = 'Johan' 450 or: 10 <= ? AND ? <= 20 451 else if (value.startsWith(":")) 452 { 453 op = null; 454 value = value.substring(1); 455 } 456 */ 457 filter.setOperator(op); 458 filter.setValue(value); 459 cc.setPropertyFilter(filter); 410 460 } 411 else if (value.startsWith(">="))461 else 412 462 { 413 op = Operator.GTEQ; 414 value = value.substring(2); 463 cc.removePropertyFilter(property); 415 464 } 416 else if (value.startsWith("<=")) 417 { 418 op = Operator.LTEQ; 419 value = value.substring(2); 420 } 421 else if (value.startsWith(">")) 422 { 423 op = Operator.GT; 424 value = value.substring(1); 425 } 426 else if (value.startsWith("<")) 427 { 428 op = Operator.LT; 429 value = value.substring(1); 430 } 431 else if (value.startsWith("=")) 432 { 433 op = Operator.EQ; 434 value = value.substring(1); 435 if ("".equals(value)) value = null; 436 } 437 else if (value.indexOf('%') >= 0) 438 { 439 op = Operator.LIKE; 440 } 441 /* 442 TODO - null operator is a signal to use JEP for parsing as an adavanced formula 443 for example: ? = 'Nicklas' OR ? = 'Johan' 444 or: 10 <= ? AND ? <= 20 445 else if (value.startsWith(":")) 446 { 447 op = null; 448 value = value.substring(1); 449 } 450 */ 451 filter.setOperator(op); 452 filter.setValue(value); 453 cc.setPropertyFilter(filter); 465 } 466 else if (name.startsWith("D:")) 467 { 468 // Special case for file manager which lists both files and directories in the 469 // same list 470 if (dirContext == null) dirContext = sc.getCurrentContext(Item.DIRECTORY, subContext); 471 int id = Values.getInt(name.substring(2), -1); 472 if (id != -1) dirContext.getSelected().add(id); 454 473 } 455 474 else 456 475 { 457 cc.removePropertyFilter(property); 476 int id = Values.getInt(name, -1); 477 if (id != -1) cc.getSelected().add(id); 458 478 } 459 }460 else if (name.startsWith("D:"))461 {462 // Special case for file manager which lists both files and directories in the463 // same list464 if (dirContext == null) dirContext = sc.getCurrentContext(Item.DIRECTORY, subContext);465 int id = Values.getInt(name.substring(2), -1);466 if (id != -1) dirContext.getSelected().add(id);467 }468 else469 {470 int id = Values.getInt(name, -1);471 if (id != -1) cc.getSelected().add(id);472 479 } 473 480 } -
trunk/src/core/net/sf/basedb/core/ItemContext.java
r2031 r2138 40 40 import net.sf.basedb.core.data.ClientData; 41 41 42 import java.util.Collection; 42 43 import java.util.Map; 43 44 import java.util.HashMap; … … 413 414 414 415 /** 416 Get a collection of all property filters stored in this context. 417 @return A Collection containsing PropertyFilter objects or null 418 */ 419 public Collection<PropertyFilter> getPropertyFilters() 420 { 421 return propertyFilters == null ? null : propertyFilters.values(); 422 } 423 424 /** 415 425 Get the value of a property filter. It is a shortcut 416 426 for <code>getPropertyFilter(property).getValue()</code> … … 440 450 { 441 451 propertyFilters.remove(property); 452 } 453 } 454 455 /** 456 Remove all property filter from this context. 457 */ 458 public void removeAllPropertyFilters() 459 { 460 if (propertyFilters != null) 461 { 462 propertyFilters.clear(); 442 463 } 443 464 } -
trunk/www/include/scripts/table.js
r2017 r2138 3 3 BioArray Software Environment (BASE) - http://base.thep.lu.se/ 4 4 Copyright (C) 2002-2004 Lao Saal, Carl Troein, 5 Johan Vallon-Christersson, Jari H äkkinen, Nicklas Nordborg5 Johan Vallon-Christersson, Jari H??kkinen, Nicklas Nordborg 6 6 7 7 This file is part of BASE. … … 223 223 { 224 224 var frm = document.forms[formId]; 225 for (var i=0; i < frm.elements.length; i++) // > 226 { 227 var element = frm.elements[i]; 228 if (element.name.substr(0, 7) == 'filter:') 229 { 230 var type = element.type; 231 if (type == 'text') 232 { 233 element.value = ''; 234 } 235 else if (type == 'select-one') 236 { 237 element.selectedIndex = 0; 238 } 239 else if (type == 'radio') 240 { 241 element.checked = element.value == ''; 242 } 243 else 244 { 245 alert(element.type); 246 } 247 } 248 } 225 Forms.createHidden(frm, 'filter:clearAll', '1'); 249 226 frm.submit(); 250 227 }
Note: See TracChangeset
for help on using the changeset viewer.