View Javadoc
1   package fr.ifremer.quadrige3.ui.swing.model;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: Quadrige3 UI Common
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  
27  import fr.ifremer.quadrige3.core.ProgressionCoreModel;
28  import org.nuiton.updater.DownloadMonitor;
29  
30  /**
31   * Simple model for a progression long task.
32   */
33  public class ProgressionUIModel extends ProgressionCoreModel implements DownloadMonitor {
34  
35      private static final long serialVersionUID = 1L;
36  
37      /** Constant <code>PROPERTY_INDETERMINATE="indeterminate"</code> */
38      public static final String PROPERTY_INDETERMINATE = "indeterminate";
39  
40      private boolean indeterminate;
41  
42      /** {@inheritDoc} */
43      @Override
44      public void setSize(long size) {
45          setTotal(size);
46      }
47  
48      /** {@inheritDoc} */
49      @Override
50      public void setCurrent(long current) {
51          super.setCurrent(current);
52      }
53  
54  
55      /**
56       * <p>isIndeterminate.</p>
57       *
58       * @return a boolean.
59       */
60      public boolean isIndeterminate() {
61          return indeterminate;
62      }
63  
64      /**
65       * <p>Setter for the field <code>indeterminate</code>.</p>
66       *
67       * @param indeterminate a boolean.
68       */
69      public void setIndeterminate(boolean indeterminate) {
70          boolean oldValue = isIndeterminate();
71          this.indeterminate = indeterminate;
72          firePropertyChange(PROPERTY_INDETERMINATE, oldValue, indeterminate);
73      }
74  
75      /**
76       * <p>clear.</p>
77       */
78      public void clear() {
79          setIndeterminate(false);
80          setCurrent(0);
81          setMessage("");
82      }
83  }