001 // SECTION-START[License Header] 002 // <editor-fold defaultstate="collapsed" desc=" Generated License "> 003 /* 004 * Copyright (c) 2010 The JOMC Project 005 * Copyright (c) 2005 Christian Schulte <schulte2005@users.sourceforge.net> 006 * All rights reserved. 007 * 008 * Redistribution and use in source and binary forms, with or without 009 * modification, are permitted provided that the following conditions 010 * are met: 011 * 012 * o Redistributions of source code must retain the above copyright 013 * notice, this list of conditions and the following disclaimer. 014 * 015 * o Redistributions in binary form must reproduce the above copyright 016 * notice, this list of conditions and the following disclaimer in 017 * the documentation and/or other materials provided with the 018 * distribution. 019 * 020 * THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS" 021 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 022 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 023 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR 024 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 026 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 027 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 029 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 030 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 031 * 032 * $Id: SequencesTableModel.java 2249 2010-06-29 08:04:28Z schulte2005 $ 033 * 034 */ 035 // </editor-fold> 036 // SECTION-END 037 package org.jomc.sequences.util; 038 039 import java.beans.Beans; 040 import java.beans.ExceptionListener; 041 import java.beans.PropertyChangeListener; 042 import java.beans.PropertyChangeSupport; 043 import java.io.Serializable; 044 import java.math.BigInteger; 045 import java.util.LinkedList; 046 import java.util.List; 047 import javax.swing.event.SwingPropertyChangeSupport; 048 import javax.swing.table.AbstractTableModel; 049 import org.jomc.sequences.Sequence; 050 import org.jomc.sequences.SequencesException; 051 import org.jomc.sequences.SequencesSystemException; 052 053 // SECTION-START[Documentation] 054 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> 055 /** 056 * Swing TableModel Java Bean for displaying and editing a system's SequenceDirectory. 057 * <p><b>Specifications</b><ul> 058 * <li>{@code 'javax.swing.table.TableModel'} {@code (javax.swing.table.TableModel)} {@code Multiton}</li> 059 * </ul></p> 060 * <p><b>Properties</b><ul> 061 * <li>"{@link #isIncrementColumnEditableByDefault incrementColumnEditableByDefault}" 062 * <blockquote>Property of type {@code java.lang.Boolean}. 063 * <p>Flag indicating that the "increment" column is editable by default.</p> 064 * </blockquote></li> 065 * <li>"{@link #isMaximumColumnEditableByDefault maximumColumnEditableByDefault}" 066 * <blockquote>Property of type {@code java.lang.Boolean}. 067 * <p>Flag indicating that the "maximum" column is editable by default.</p> 068 * </blockquote></li> 069 * <li>"{@link #isMinimumColumnEditableByDefault minimumColumnEditableByDefault}" 070 * <blockquote>Property of type {@code java.lang.Boolean}. 071 * <p>Flag indicating that the "minimum" column is editable by default.</p> 072 * </blockquote></li> 073 * <li>"{@link #isNameColumnEditableByDefault nameColumnEditableByDefault}" 074 * <blockquote>Property of type {@code java.lang.Boolean}. 075 * <p>Flag indicating that the "name" column is editable by default.</p> 076 * </blockquote></li> 077 * <li>"{@link #isValueColumnEditableByDefault valueColumnEditableByDefault}" 078 * <blockquote>Property of type {@code java.lang.Boolean}. 079 * <p>Flag indicating that the "value" column is editable by default.</p> 080 * </blockquote></li> 081 * </ul></p> 082 * <p><b>Dependencies</b><ul> 083 * <li>"{@link #getExceptionListener ExceptionListener}"<blockquote> 084 * Dependency on {@code 'java.beans.ExceptionListener'} {@code (java.beans.ExceptionListener)} at specification level 1.4 bound to an instance.</blockquote></li> 085 * <li>"{@link #getLocale Locale}"<blockquote> 086 * Dependency on {@code 'java.util.Locale'} {@code (java.util.Locale)} at specification level 1.1 bound to an instance.</blockquote></li> 087 * <li>"{@link #getLogger Logger}"<blockquote> 088 * Dependency on {@code 'org.jomc.logging.Logger'} {@code (org.jomc.logging.Logger)} at specification level 1.0 bound to an instance.</blockquote></li> 089 * <li>"{@link #getSequenceDirectory SequenceDirectory}"<blockquote> 090 * Dependency on {@code 'org.jomc.sequences.SequenceDirectory'} {@code (org.jomc.sequences.SequenceDirectory)} at specification level 1.0 bound to an instance.</blockquote></li> 091 * </ul></p> 092 * <p><b>Messages</b><ul> 093 * <li>"{@link #getIllegalColumnIndexMessage illegalColumnIndexMessage}"<table> 094 * <tr><td valign="top">English:</td><td valign="top"><pre>Illegal column index {0}. {1}</pre></td></tr> 095 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Ungültiger Spalten-Index {0}. {1}</pre></td></tr> 096 * </table> 097 * <li>"{@link #getIncrementColumnTitle incrementColumnTitle}"<table> 098 * <tr><td valign="top">English:</td><td valign="top"><pre>Increment</pre></td></tr> 099 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Inkrement</pre></td></tr> 100 * </table> 101 * <li>"{@link #getMaximumColumnTitle maximumColumnTitle}"<table> 102 * <tr><td valign="top">English:</td><td valign="top"><pre>Maximum</pre></td></tr> 103 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Maximum</pre></td></tr> 104 * </table> 105 * <li>"{@link #getMinimumColumnTitle minimumColumnTitle}"<table> 106 * <tr><td valign="top">English:</td><td valign="top"><pre>Minimum</pre></td></tr> 107 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Minimum</pre></td></tr> 108 * </table> 109 * <li>"{@link #getNameColumnTitle nameColumnTitle}"<table> 110 * <tr><td valign="top">English:</td><td valign="top"><pre>Name</pre></td></tr> 111 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Name</pre></td></tr> 112 * </table> 113 * <li>"{@link #getValueColumnTitle valueColumnTitle}"<table> 114 * <tr><td valign="top">English:</td><td valign="top"><pre>Value</pre></td></tr> 115 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Wert</pre></td></tr> 116 * </table> 117 * </ul></p> 118 * 119 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0 120 * @version $Id: SequencesTableModel.java 2249 2010-06-29 08:04:28Z schulte2005 $ 121 */ 122 // </editor-fold> 123 // SECTION-END 124 // SECTION-START[Annotations] 125 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> 126 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 127 // </editor-fold> 128 // SECTION-END 129 public class SequencesTableModel extends AbstractTableModel implements Serializable 130 { 131 // SECTION-START[TableModel] 132 133 public int getRowCount() 134 { 135 try 136 { 137 return this.getSequences().size(); 138 } 139 catch ( final SequencesSystemException e ) 140 { 141 this.fireExceptionThrown( e ); 142 } 143 144 return 0; 145 } 146 147 public int getColumnCount() 148 { 149 return COLUMN_COUNT; 150 } 151 152 @Override 153 public String getColumnName( final int columnIndex ) 154 { 155 final String columnName; 156 157 switch ( columnIndex ) 158 { 159 case NAME_COLUMN_INDEX: 160 columnName = this.getNameColumnTitle( this.getLocale() ); 161 break; 162 163 case MINIMUM_COLUMN_INDEX: 164 columnName = this.getMinimumColumnTitle( this.getLocale() ); 165 break; 166 167 case MAXIMUM_COLUMN_INDEX: 168 columnName = this.getMaximumColumnTitle( this.getLocale() ); 169 break; 170 171 case INCREMENT_COLUMN_INDEX: 172 columnName = this.getIncrementColumnTitle( this.getLocale() ); 173 break; 174 175 case VALUE_COLUMN_INDEX: 176 columnName = this.getValueColumnTitle( this.getLocale() ); 177 break; 178 179 default: 180 columnName = super.getColumnName( columnIndex ); 181 this.getLogger().warn( this.getIllegalColumnIndexMessage( this.getLocale(), columnIndex ) ); 182 break; 183 184 } 185 186 return columnName; 187 } 188 189 @Override 190 public Class<?> getColumnClass( final int columnIndex ) 191 { 192 final Class columnClass; 193 194 switch ( columnIndex ) 195 { 196 case NAME_COLUMN_INDEX: 197 columnClass = String.class; 198 break; 199 200 case MINIMUM_COLUMN_INDEX: 201 case MAXIMUM_COLUMN_INDEX: 202 case INCREMENT_COLUMN_INDEX: 203 case VALUE_COLUMN_INDEX: 204 columnClass = BigInteger.class; 205 break; 206 207 default: 208 columnClass = super.getColumnClass( columnIndex ); 209 this.getLogger().warn( this.getIllegalColumnIndexMessage( this.getLocale(), columnIndex ) ); 210 break; 211 212 } 213 214 return columnClass; 215 } 216 217 @Override 218 public boolean isCellEditable( final int rowIndex, final int columnIndex ) 219 { 220 final boolean cellEditable; 221 222 switch ( columnIndex ) 223 { 224 case NAME_COLUMN_INDEX: 225 cellEditable = this.getNameColumnEditable(); 226 break; 227 228 case MINIMUM_COLUMN_INDEX: 229 cellEditable = this.getMinimumColumnEditable(); 230 break; 231 232 case MAXIMUM_COLUMN_INDEX: 233 cellEditable = this.getMaximumColumnEditable(); 234 break; 235 236 case INCREMENT_COLUMN_INDEX: 237 cellEditable = this.getIncrementColumnEditable(); 238 break; 239 240 case VALUE_COLUMN_INDEX: 241 cellEditable = this.getValueColumnEditable(); 242 break; 243 244 default: 245 cellEditable = super.isCellEditable( rowIndex, columnIndex ); 246 this.getLogger().warn( this.getIllegalColumnIndexMessage( this.getLocale(), columnIndex ) ); 247 break; 248 249 } 250 251 return cellEditable; 252 } 253 254 public Object getValueAt( final int rowIndex, final int columnIndex ) 255 { 256 try 257 { 258 final Object value; 259 final Sequence sequence = this.getSequences().get( rowIndex ); 260 261 switch ( columnIndex ) 262 { 263 case NAME_COLUMN_INDEX: 264 value = sequence.getName(); 265 break; 266 267 case MINIMUM_COLUMN_INDEX: 268 value = sequence.getMinimum(); 269 break; 270 271 case MAXIMUM_COLUMN_INDEX: 272 value = sequence.getMaximum(); 273 break; 274 275 case INCREMENT_COLUMN_INDEX: 276 value = sequence.getIncrement(); 277 break; 278 279 case VALUE_COLUMN_INDEX: 280 value = sequence.getValue(); 281 break; 282 283 default: 284 value = null; 285 this.getLogger().warn( this.getIllegalColumnIndexMessage( this.getLocale(), columnIndex ) ); 286 break; 287 288 } 289 290 return value; 291 } 292 catch ( final SequencesSystemException e ) 293 { 294 this.fireExceptionThrown( e ); 295 } 296 catch ( final IndexOutOfBoundsException e ) 297 { 298 this.fireExceptionThrown( e ); 299 } 300 301 return null; 302 } 303 304 @Override 305 public void setValueAt( final Object aValue, final int rowIndex, final int columnIndex ) 306 { 307 try 308 { 309 final Sequence sequence = this.getSequences().get( rowIndex ); 310 final String name = sequence.getName(); 311 final long revision = sequence.getRevision(); 312 313 switch ( columnIndex ) 314 { 315 case NAME_COLUMN_INDEX: 316 sequence.setName( aValue.toString() ); 317 break; 318 319 case MINIMUM_COLUMN_INDEX: 320 sequence.setMinimum( (Long) aValue ); 321 break; 322 323 case MAXIMUM_COLUMN_INDEX: 324 sequence.setMaximum( (Long) aValue ); 325 break; 326 327 case INCREMENT_COLUMN_INDEX: 328 sequence.setIncrement( (Long) aValue ); 329 break; 330 331 case VALUE_COLUMN_INDEX: 332 sequence.setValue( (Long) aValue ); 333 break; 334 335 default: 336 this.getLogger().warn( this.getIllegalColumnIndexMessage( this.getLocale(), columnIndex ) ); 337 break; 338 339 } 340 341 if ( !Beans.isDesignTime() ) 342 { 343 this.getSequenceDirectory().editSequence( name, revision, sequence ); 344 } 345 346 this.fireTableRowsUpdated( rowIndex, rowIndex ); 347 } 348 catch ( final SequencesException e ) 349 { 350 this.fireExceptionThrown( e ); 351 this.sequences = null; 352 this.fireTableDataChanged(); 353 } 354 catch ( final SequencesSystemException e ) 355 { 356 this.fireExceptionThrown( e ); 357 this.sequences = null; 358 this.fireTableDataChanged(); 359 } 360 catch ( final IndexOutOfBoundsException e ) 361 { 362 this.fireExceptionThrown( e ); 363 this.sequences = null; 364 this.fireTableDataChanged(); 365 } 366 } 367 368 // SECTION-END 369 // SECTION-START[SequencesTableModel] 370 /** Number of table columns. */ 371 public static final int COLUMN_COUNT = 5; 372 373 /** Index of the column displaying a sequence's name. */ 374 public static final int NAME_COLUMN_INDEX = 0; 375 376 /** Index of the column displaying a sequence's minimum value. */ 377 public static final int MINIMUM_COLUMN_INDEX = 1; 378 379 /** Index of the column displaying a sequence's maximum value. */ 380 public static final int MAXIMUM_COLUMN_INDEX = 2; 381 382 /** Index of the column displaying a sequence's increment value. */ 383 public static final int INCREMENT_COLUMN_INDEX = 3; 384 385 /** Index of the column displaying a sequence's value. */ 386 public static final int VALUE_COLUMN_INDEX = 4; 387 388 /** Name of property {@code nameColumnEditable}. */ 389 public static final String NAME_COLUMN_EDITABLE = 390 "org.jomc.sequences.util.SequencesTableModel.NAME_COLUMN_EDITABLE"; 391 392 /** Name of property {@code minimumColumnEditable}. */ 393 public static final String MINIMUM_COLUMN_EDITABLE = 394 "org.jomc.sequences.util.SequencesTableModel.MINIMUM_COLUMN_EDITABLE"; 395 396 /** Name of property {@code maximumColumnEditable}. */ 397 public static final String MAXIMUM_COLUMN_EDITABLE = 398 "org.jomc.sequences.util.SequencesTableModel.MAXIMUM_COLUMN_EDITABLE"; 399 400 /** Name of property {@code incrementColumnEditable}. */ 401 public static final String INCREMENT_COLUMN_EDITABLE = 402 "org.jomc.sequences.util.SequencesTableModel.INCREMENT_COLUMN_EDITABLE"; 403 404 /** Name of property {@code valueColumnEditable}. */ 405 public static final String VALUE_COLUMN_EDITABLE = 406 "org.jomc.sequences.util.SequencesTableModel.VALUE_COLUMN_EDITABLE"; 407 408 /** Name of property {@code sequenceFilter}. */ 409 public static final String SEQUENCE_FILTER = 410 "org.jomc.sequences.util.SequencesTableModel.SEQUENCE_FILTER"; 411 412 /** 413 * Flag indicating that the {@code name} column is editable. 414 * @serial 415 */ 416 private Boolean nameColumnEditable; 417 418 /** 419 * Flag indicating that the {@code minimum} column is editable. 420 * @serial 421 */ 422 private Boolean minimumColumnEditable; 423 424 /** 425 * Flag indicating that the {@code maximum} column is editable. 426 * @serial 427 */ 428 private Boolean maximumColumnEditable; 429 430 /** 431 * Flag indicating that the {@code increment} column is editable. 432 * @serial 433 */ 434 private Boolean incrementColumnEditable; 435 436 /** 437 * Flag indicating that the {@code value} column is editable. 438 * @serial 439 */ 440 private Boolean valueColumnEditable; 441 442 /** 443 * Entity filter. 444 * @serial 445 */ 446 private Sequence sequenceFilter; 447 448 /** Sequences of the model. */ 449 private transient List<Sequence> sequences; 450 451 /** 452 * Change support. 453 * @serial 454 */ 455 private PropertyChangeSupport changeSupport = new SwingPropertyChangeSupport( this ); 456 457 /** 458 * Gets the flag indicating that the {@code name} column is editable. 459 * 460 * @return {@code true} if the {@code name} column is editable; {@code false} if not. 461 */ 462 public Boolean getNameColumnEditable() 463 { 464 if ( this.nameColumnEditable == null ) 465 { 466 this.nameColumnEditable = this.isNameColumnEditableByDefault(); 467 this.changeSupport.firePropertyChange( NAME_COLUMN_EDITABLE, null, this.nameColumnEditable ); 468 } 469 470 return this.nameColumnEditable; 471 } 472 473 /** 474 * Sets the flag indicating that the {@code name} column is editable. 475 * 476 * @param value {@code true} if the {@code name} column should be editable; {@code false} if not. 477 */ 478 public void setNameColumnEditable( final Boolean value ) 479 { 480 final Boolean oldValue = this.nameColumnEditable; 481 this.nameColumnEditable = value; 482 this.changeSupport.firePropertyChange( NAME_COLUMN_EDITABLE, oldValue, this.nameColumnEditable ); 483 } 484 485 /** 486 * Gets the flag indicating that the {@code minimum} column is editable. 487 * 488 * @return {@code true} if the {@code minimum} column is editable;{@code false} if not. 489 */ 490 public Boolean getMinimumColumnEditable() 491 { 492 if ( this.minimumColumnEditable == null ) 493 { 494 this.minimumColumnEditable = this.isMinimumColumnEditableByDefault(); 495 this.changeSupport.firePropertyChange( MINIMUM_COLUMN_EDITABLE, null, this.minimumColumnEditable ); 496 } 497 498 return this.minimumColumnEditable; 499 } 500 501 /** 502 * Set the flag indicating that the {@code minimum} column is editable. 503 * 504 * @param value {@code true} if the {@code minimum} column should be editable; {@code false} if not. 505 */ 506 public void setMinimumColumnEditable( final Boolean value ) 507 { 508 final Boolean oldValue = this.minimumColumnEditable; 509 this.minimumColumnEditable = value; 510 this.changeSupport.firePropertyChange( MINIMUM_COLUMN_EDITABLE, oldValue, this.minimumColumnEditable ); 511 } 512 513 /** 514 * Gets the flag indicating that the {@code maximum} column is editable. 515 * 516 * @return {@code true} if the {@code maximum} column is editable; {@code false} if not. 517 */ 518 public Boolean getMaximumColumnEditable() 519 { 520 if ( this.maximumColumnEditable == null ) 521 { 522 this.maximumColumnEditable = this.isMaximumColumnEditableByDefault(); 523 this.changeSupport.firePropertyChange( MAXIMUM_COLUMN_EDITABLE, null, this.maximumColumnEditable ); 524 } 525 526 return this.maximumColumnEditable; 527 } 528 529 /** 530 * Sets the flag indicating that the {@code maximum} column is editable. 531 * 532 * @param value {@code true} if the {@code maximum} column should be editable; {@code false} if not. 533 */ 534 public void setMaximumColumnEditable( final Boolean value ) 535 { 536 final Boolean oldValue = this.maximumColumnEditable; 537 this.maximumColumnEditable = value; 538 this.changeSupport.firePropertyChange( MAXIMUM_COLUMN_EDITABLE, oldValue, this.maximumColumnEditable ); 539 } 540 541 /** 542 * Gets the flag indicating that the {@code increment} column is editable. 543 * 544 * @return {@code true} if the {@code increment} column is editable; {@code false} if not. 545 */ 546 public Boolean getIncrementColumnEditable() 547 { 548 if ( this.incrementColumnEditable == null ) 549 { 550 this.incrementColumnEditable = this.isIncrementColumnEditableByDefault(); 551 this.changeSupport.firePropertyChange( INCREMENT_COLUMN_EDITABLE, null, this.incrementColumnEditable ); 552 } 553 554 return this.incrementColumnEditable; 555 } 556 557 /** 558 * Sets the flag indicating that the {@code increment} column is editable. 559 * 560 * @param value {@code true} if the {@code increment} column should be editable; {@code false} if not. 561 */ 562 public void setIncrementColumnEditable( final Boolean value ) 563 { 564 final Boolean oldValue = this.incrementColumnEditable; 565 this.incrementColumnEditable = value; 566 this.changeSupport.firePropertyChange( INCREMENT_COLUMN_EDITABLE, oldValue, this.incrementColumnEditable ); 567 } 568 569 /** 570 * Gets the flag indicating that the {@code value} column is editable. 571 * 572 * @return {@code true} if the {@code value} column is editable; {@code false} if not. 573 */ 574 public Boolean getValueColumnEditable() 575 { 576 if ( this.valueColumnEditable == null ) 577 { 578 this.valueColumnEditable = this.isValueColumnEditableByDefault(); 579 this.changeSupport.firePropertyChange( VALUE_COLUMN_EDITABLE, null, this.valueColumnEditable ); 580 } 581 582 return this.valueColumnEditable; 583 } 584 585 /** 586 * Sets the flag indicating that the {@code value} column is editable. 587 * 588 * @param value {@code true} if the {@code value} column should be editable; {@code false} if not. 589 */ 590 public void setValueColumnEditable( final Boolean value ) 591 { 592 final Boolean oldValue = this.valueColumnEditable; 593 this.valueColumnEditable = value; 594 this.changeSupport.firePropertyChange( VALUE_COLUMN_EDITABLE, oldValue, this.valueColumnEditable ); 595 } 596 597 /** 598 * Gets the entity used for filtering sequences. 599 * 600 * @return Entity used for filtering sequences or {@code null}. 601 */ 602 public Sequence getSequenceFilter() 603 { 604 return this.sequenceFilter; 605 } 606 607 /** 608 * Sets the entity used for filtering sequences. 609 * 610 * @param value Entity to use for filtering sequences or {@code null}. 611 */ 612 public void setSequenceFilter( final Sequence value ) 613 { 614 final Sequence oldValue = this.sequenceFilter; 615 this.sequenceFilter = value; 616 this.sequences = null; 617 this.fireTableDataChanged(); 618 this.changeSupport.firePropertyChange( SEQUENCE_FILTER, oldValue, this.sequenceFilter ); 619 } 620 621 /** 622 * Add a {@code PropertyChangeListener} to the listener list. 623 * <p>The listener is registered for all properties. The same listener object may be added more than once, and will 624 * be called as many times as it is added. If {@code listener} is {@code null}, no exception is thrown and no action 625 * is taken.</p> 626 * 627 * @param listener The listener to be added. 628 */ 629 public void addPropertyChangeListener( final PropertyChangeListener listener ) 630 { 631 this.changeSupport.addPropertyChangeListener( listener ); 632 } 633 634 /** 635 * Removes a {@code PropertyChangeListener} from the listener list. 636 * <p>This removes a {@code PropertyChangeListener} that was registered for all properties. If {@code listener} was 637 * added more than once, it will be notified one less time after being removed. If {@code listener} is {@code null}, 638 * or was never added, no exception is thrown and no action is taken.</p> 639 * 640 * @param listener The listener to be removed. 641 */ 642 public void removePropertyChangeListener( final PropertyChangeListener listener ) 643 { 644 this.changeSupport.removePropertyChangeListener( listener ); 645 } 646 647 /** 648 * Gets an array of all the listeners that were added to the instance. 649 * <p>If some listeners have been added with a named property, then the returned array will be a mixture of 650 * {@code PropertyChangeListeners} and {@code PropertyChangeListenerProxy}s. If the calling method is interested in 651 * distinguishing the listeners then it must test each element to see if it's a {@code PropertyChangeListenerProxy}, 652 * perform the cast, and examine the parameter.</p> 653 * 654 * @return All of the {@code PropertyChangeListeners} added or an empty array if no listeners have been added. 655 * 656 * @see PropertyChangeSupport#getPropertyChangeListeners() 657 */ 658 public PropertyChangeListener[] getPropertyChangeListeners() 659 { 660 return this.changeSupport.getPropertyChangeListeners(); 661 } 662 663 /** 664 * Add a {@code PropertyChangeListener} for a specific property. 665 * <p>The listener will be invoked only when an event for that specific property occurs. The same listener object 666 * may be added more than once. For each property, the listener will be invoked the number of times it was added for 667 * that property. If {@code propertyName} or {@code listener} is {@code null}, no exception is thrown and no action 668 * is taken.</p> 669 * 670 * @param propertyName The name of the property to listen on. 671 * @param listener The listener to be added. 672 */ 673 public void addPropertyChangeListener( final String propertyName, final PropertyChangeListener listener ) 674 { 675 this.changeSupport.addPropertyChangeListener( propertyName, listener ); 676 } 677 678 /** 679 * Removes a {@code PropertyChangeListener} for a specific property. 680 * <p>If {@code listener} was added more than once to the instance for the specified property, it will be notified 681 * one less time after being removed. If {@code propertyName} is {@code null}, no exception is thrown and no action 682 * is taken. If {@code listener} is {@code null}, or was never added for the specified property, no exception is 683 * thrown and no action is taken.</p> 684 * 685 * @param propertyName The name of the property that was listened on. 686 * @param listener The listener to be removed. 687 */ 688 public void removePropertyChangeListener( final String propertyName, final PropertyChangeListener listener ) 689 { 690 this.changeSupport.removePropertyChangeListener( propertyName, listener ); 691 } 692 693 /** 694 * Gets an array of all the listeners which have been associated with the named property. 695 * 696 * @param propertyName The name of the property being listened to. 697 * 698 * @return All of the {@code PropertyChangeListeners} associated with the named property. If no such listeners have 699 * been added, or if {@code propertyName} is {@code null}, an empty array is returned. 700 */ 701 public PropertyChangeListener[] getPropertyChangeListeners( final String propertyName ) 702 { 703 return this.changeSupport.getPropertyChangeListeners( propertyName ); 704 } 705 706 /** 707 * Gets the entities of the model. 708 * 709 * @return The entities of the model. 710 * 711 * @throws SequencesSystemException if searching entities fails. 712 */ 713 public List<Sequence> getSequences() 714 { 715 if ( this.sequences == null ) 716 { 717 this.sequences = new LinkedList<Sequence>(); 718 719 if ( !Beans.isDesignTime() ) 720 { 721 this.sequences.addAll( this.getSequenceDirectory().searchSequences( 722 this.getSequenceFilter() != null ? this.getSequenceFilter().getName() : null ) ); 723 724 } 725 } 726 727 return this.sequences; 728 } 729 730 /** 731 * Notifies any available {@code ExceptionListener} whenever a recoverable exception has been caught. 732 * 733 * @param e The exception that was caught. 734 */ 735 protected void fireExceptionThrown( final Exception e ) 736 { 737 this.getLogger().error( e ); 738 739 if ( this.getExceptionListener() != null ) 740 { 741 for ( ExceptionListener l : this.getExceptionListener() ) 742 { 743 l.exceptionThrown( e ); 744 } 745 } 746 } 747 748 // SECTION-END 749 // SECTION-START[Constructors] 750 // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> 751 752 /** Creates a new {@code SequencesTableModel} instance. */ 753 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 754 public SequencesTableModel() 755 { 756 // SECTION-START[Default Constructor] 757 super(); 758 // SECTION-END 759 } 760 // </editor-fold> 761 // SECTION-END 762 // SECTION-START[Dependencies] 763 // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies "> 764 765 /** 766 * Gets the {@code ExceptionListener} dependency. 767 * <p>This method returns any available object of the {@code 'java.beans.ExceptionListener'} {@code (java.beans.ExceptionListener)} specification at specification level 1.4.</p> 768 * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> 769 * @return The {@code ExceptionListener} dependency. 770 * {@code null} if no object is available. 771 * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. 772 */ 773 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 774 private java.beans.ExceptionListener[] getExceptionListener() 775 { 776 return (java.beans.ExceptionListener[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "ExceptionListener" ); 777 } 778 779 /** 780 * Gets the {@code Locale} dependency. 781 * <p>This method returns the {@code 'default'} object of the {@code 'java.util.Locale'} {@code (java.util.Locale)} specification at specification level 1.1.</p> 782 * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> 783 * @return The {@code Locale} dependency. 784 * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. 785 */ 786 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 787 private java.util.Locale getLocale() 788 { 789 final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" ); 790 assert _d != null : "'Locale' dependency not found."; 791 return _d; 792 } 793 794 /** 795 * Gets the {@code Logger} dependency. 796 * <p>This method returns any available object of the {@code 'org.jomc.logging.Logger'} {@code (org.jomc.logging.Logger)} specification at specification level 1.0.</p> 797 * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> 798 * <p><b>Properties</b><dl> 799 * <dt>"{@code name}"</dt> 800 * <dd>Property of type {@code java.lang.String}. 801 * </dd> 802 * </dl> 803 * @return The {@code Logger} dependency. 804 * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. 805 */ 806 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 807 private org.jomc.logging.Logger getLogger() 808 { 809 final org.jomc.logging.Logger _d = (org.jomc.logging.Logger) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Logger" ); 810 assert _d != null : "'Logger' dependency not found."; 811 return _d; 812 } 813 814 /** 815 * Gets the {@code SequenceDirectory} dependency. 816 * <p>This method returns any available object of the {@code 'org.jomc.sequences.SequenceDirectory'} {@code (org.jomc.sequences.SequenceDirectory)} specification at specification level 1.0.</p> 817 * <p>That specification applies to {@code Singleton} scope. The singleton object is returned whenever requested and bound to this instance.</p> 818 * @return The {@code SequenceDirectory} dependency. 819 * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. 820 */ 821 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 822 private org.jomc.sequences.SequenceDirectory getSequenceDirectory() 823 { 824 final org.jomc.sequences.SequenceDirectory _d = (org.jomc.sequences.SequenceDirectory) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SequenceDirectory" ); 825 assert _d != null : "'SequenceDirectory' dependency not found."; 826 return _d; 827 } 828 // </editor-fold> 829 // SECTION-END 830 // SECTION-START[Properties] 831 // <editor-fold defaultstate="collapsed" desc=" Generated Properties "> 832 833 /** 834 * Gets the value of the {@code incrementColumnEditableByDefault} property. 835 * @return Flag indicating that the "increment" column is editable by default. 836 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 837 */ 838 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 839 private java.lang.Boolean isIncrementColumnEditableByDefault() 840 { 841 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "incrementColumnEditableByDefault" ); 842 assert _p != null : "'incrementColumnEditableByDefault' property not found."; 843 return _p; 844 } 845 846 /** 847 * Gets the value of the {@code maximumColumnEditableByDefault} property. 848 * @return Flag indicating that the "maximum" column is editable by default. 849 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 850 */ 851 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 852 private java.lang.Boolean isMaximumColumnEditableByDefault() 853 { 854 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "maximumColumnEditableByDefault" ); 855 assert _p != null : "'maximumColumnEditableByDefault' property not found."; 856 return _p; 857 } 858 859 /** 860 * Gets the value of the {@code minimumColumnEditableByDefault} property. 861 * @return Flag indicating that the "minimum" column is editable by default. 862 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 863 */ 864 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 865 private java.lang.Boolean isMinimumColumnEditableByDefault() 866 { 867 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "minimumColumnEditableByDefault" ); 868 assert _p != null : "'minimumColumnEditableByDefault' property not found."; 869 return _p; 870 } 871 872 /** 873 * Gets the value of the {@code nameColumnEditableByDefault} property. 874 * @return Flag indicating that the "name" column is editable by default. 875 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 876 */ 877 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 878 private java.lang.Boolean isNameColumnEditableByDefault() 879 { 880 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "nameColumnEditableByDefault" ); 881 assert _p != null : "'nameColumnEditableByDefault' property not found."; 882 return _p; 883 } 884 885 /** 886 * Gets the value of the {@code valueColumnEditableByDefault} property. 887 * @return Flag indicating that the "value" column is editable by default. 888 * @throws org.jomc.ObjectManagementException if getting the property instance fails. 889 */ 890 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 891 private java.lang.Boolean isValueColumnEditableByDefault() 892 { 893 final java.lang.Boolean _p = (java.lang.Boolean) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "valueColumnEditableByDefault" ); 894 assert _p != null : "'valueColumnEditableByDefault' property not found."; 895 return _p; 896 } 897 // </editor-fold> 898 // SECTION-END 899 // SECTION-START[Messages] 900 // <editor-fold defaultstate="collapsed" desc=" Generated Messages "> 901 902 /** 903 * Gets the text of the {@code illegalColumnIndexMessage} message. 904 * <p><b>Templates</b><br/><table> 905 * <tr><td valign="top">English:</td><td valign="top"><pre>Illegal column index {0}. {1}</pre></td></tr> 906 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Ungültiger Spalten-Index {0}. {1}</pre></td></tr> 907 * </table></p> 908 * @param locale The locale of the message to return. 909 * @param columnIndex Format argument. 910 * @return The text of the {@code illegalColumnIndexMessage} message. 911 * 912 * @throws org.jomc.ObjectManagementException if getting the message instance fails. 913 */ 914 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 915 private String getIllegalColumnIndexMessage( final java.util.Locale locale, final java.lang.Number columnIndex ) 916 { 917 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "illegalColumnIndexMessage", locale, columnIndex ); 918 assert _m != null : "'illegalColumnIndexMessage' message not found."; 919 return _m; 920 } 921 922 /** 923 * Gets the text of the {@code incrementColumnTitle} message. 924 * <p><b>Templates</b><br/><table> 925 * <tr><td valign="top">English:</td><td valign="top"><pre>Increment</pre></td></tr> 926 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Inkrement</pre></td></tr> 927 * </table></p> 928 * @param locale The locale of the message to return. 929 * @return The text of the {@code incrementColumnTitle} message. 930 * 931 * @throws org.jomc.ObjectManagementException if getting the message instance fails. 932 */ 933 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 934 private String getIncrementColumnTitle( final java.util.Locale locale ) 935 { 936 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "incrementColumnTitle", locale ); 937 assert _m != null : "'incrementColumnTitle' message not found."; 938 return _m; 939 } 940 941 /** 942 * Gets the text of the {@code maximumColumnTitle} message. 943 * <p><b>Templates</b><br/><table> 944 * <tr><td valign="top">English:</td><td valign="top"><pre>Maximum</pre></td></tr> 945 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Maximum</pre></td></tr> 946 * </table></p> 947 * @param locale The locale of the message to return. 948 * @return The text of the {@code maximumColumnTitle} message. 949 * 950 * @throws org.jomc.ObjectManagementException if getting the message instance fails. 951 */ 952 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 953 private String getMaximumColumnTitle( final java.util.Locale locale ) 954 { 955 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "maximumColumnTitle", locale ); 956 assert _m != null : "'maximumColumnTitle' message not found."; 957 return _m; 958 } 959 960 /** 961 * Gets the text of the {@code minimumColumnTitle} message. 962 * <p><b>Templates</b><br/><table> 963 * <tr><td valign="top">English:</td><td valign="top"><pre>Minimum</pre></td></tr> 964 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Minimum</pre></td></tr> 965 * </table></p> 966 * @param locale The locale of the message to return. 967 * @return The text of the {@code minimumColumnTitle} message. 968 * 969 * @throws org.jomc.ObjectManagementException if getting the message instance fails. 970 */ 971 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 972 private String getMinimumColumnTitle( final java.util.Locale locale ) 973 { 974 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "minimumColumnTitle", locale ); 975 assert _m != null : "'minimumColumnTitle' message not found."; 976 return _m; 977 } 978 979 /** 980 * Gets the text of the {@code nameColumnTitle} message. 981 * <p><b>Templates</b><br/><table> 982 * <tr><td valign="top">English:</td><td valign="top"><pre>Name</pre></td></tr> 983 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Name</pre></td></tr> 984 * </table></p> 985 * @param locale The locale of the message to return. 986 * @return The text of the {@code nameColumnTitle} message. 987 * 988 * @throws org.jomc.ObjectManagementException if getting the message instance fails. 989 */ 990 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 991 private String getNameColumnTitle( final java.util.Locale locale ) 992 { 993 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "nameColumnTitle", locale ); 994 assert _m != null : "'nameColumnTitle' message not found."; 995 return _m; 996 } 997 998 /** 999 * Gets the text of the {@code valueColumnTitle} message. 1000 * <p><b>Templates</b><br/><table> 1001 * <tr><td valign="top">English:</td><td valign="top"><pre>Value</pre></td></tr> 1002 * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Wert</pre></td></tr> 1003 * </table></p> 1004 * @param locale The locale of the message to return. 1005 * @return The text of the {@code valueColumnTitle} message. 1006 * 1007 * @throws org.jomc.ObjectManagementException if getting the message instance fails. 1008 */ 1009 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" ) 1010 private String getValueColumnTitle( final java.util.Locale locale ) 1011 { 1012 final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "valueColumnTitle", locale ); 1013 assert _m != null : "'valueColumnTitle' message not found."; 1014 return _m; 1015 } 1016 // </editor-fold> 1017 // SECTION-END 1018 }