|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.internal.pi.model; |
|
19 |
|
20 import javax.swing.JProgressBar; |
|
21 |
|
22 public class ProgressBar extends JProgressBar { |
|
23 |
|
24 private static final long serialVersionUID = 4862691591715531894L; |
|
25 |
|
26 public ProgressBar() { |
|
27 super(); |
|
28 this.setValue(0); |
|
29 this.setStringPainted(true); |
|
30 this.setIndeterminate(true); |
|
31 this.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
|
32 this.setFont(new java.awt.Font(Messages.getString("ProgressBar.defaultFont"), java.awt.Font.PLAIN, 10)); //$NON-NLS-1$ |
|
33 } |
|
34 |
|
35 public void addValue(int value) |
|
36 { |
|
37 this.setValue(this.getValue() + value); |
|
38 this.validate(); |
|
39 } |
|
40 |
|
41 public int getMaxValue() |
|
42 { |
|
43 return this.getMaximum(); |
|
44 } |
|
45 |
|
46 public void advanceTo(int value) |
|
47 { |
|
48 try |
|
49 { |
|
50 for (int i = this.getValue(); i < value; i++) |
|
51 { |
|
52 addValue(1); |
|
53 Thread.sleep(10); |
|
54 } |
|
55 } |
|
56 catch (Exception e) {} |
|
57 } |
|
58 |
|
59 public void runToEnd() |
|
60 { |
|
61 try |
|
62 { |
|
63 for (int i = getValue(); i < getMaxValue(); i++) |
|
64 { |
|
65 addValue(1); |
|
66 Thread.sleep(10); |
|
67 } |
|
68 } |
|
69 catch (Exception e) {} |
|
70 } |
|
71 } |