Revision 454 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTaskStatus.java

View differences:

DefaultJTaskStatus.java
28 28
	 */
29 29
	private static final long serialVersionUID = -1908456747637477552L;
30 30

  
31
	private JLabel tittlelabel = null;
31
	private JLabel titlelabel = null;
32 32
	private JLabel messagelabel = null;
33 33
	private JProgressBar progressBar = null;
34 34
	private JButton cancelRequestButton = null;
35 35
	private boolean showCancelButton;
36 36

  
37
	private TaskStatus taskStatus; 
37
	private TaskStatus taskStatus;
38

  
39
	private JButton removeTaskButton; 
38 40
	
39 41
	public DefaultJTaskStatus() {
40 42
		this.taskStatus = null;
......
73 75
	}
74 76

  
75 77
	private void createComponents() {
76
		this.tittlelabel = new JLabel();
77
		this.tittlelabel.setPreferredSize( new Dimension( 200, 16));
78
		this.titlelabel = new JLabel();
79
		this.titlelabel.setPreferredSize( new Dimension( 200, 16));
78 80
		
79 81
		this.progressBar = new JProgressBar(1,100);
80 82
		this.progressBar.setPreferredSize(new Dimension( 200, 10));
......
85 87
		this.cancelRequestButton.setPreferredSize( new Dimension(16, 16));
86 88
		this.cancelRequestButton.setBorderPainted(false);
87 89
    	this.cancelRequestButton.setIcon( getIcon("cancelRequestButton.png"));
90
    	this.cancelRequestButton.setDisabledIcon( getIcon("disabledCancelRequestButton.png") );
88 91
    	if( !this.showCancelButton ) {
89 92
    		this.cancelRequestButton.setVisible(this.showCancelButton);
90 93
    	}
......
94 97
				taskStatus.cancelRequest();
95 98
			}
96 99
		});
97
    	this.cancelRequestButton.setDisabledIcon( getIcon("disabledCancelRequestButton.png") );
100
		this.removeTaskButton = new JButton();
101
		this.removeTaskButton.setPreferredSize( new Dimension(16, 16));
102
		this.removeTaskButton.setBorderPainted(false);
103
    	this.removeTaskButton.setIcon( getIcon("removeTaskButton.png"));
104
    	this.removeTaskButton.setDisabledIcon( getIcon("disabledRemoveTaskButton.png") );
105
    	this.removeTaskButton.setEnabled(false);
106
    	this.removeTaskButton.addActionListener(new ActionListener() {
107
			public void actionPerformed(ActionEvent arg0) {
108
				if( !taskStatus.isRunning() ) {
109
					taskStatus.getManager().remove(taskStatus);
110
				}
111
			}
112
		});
98 113
    	
99 114
		this.messagelabel = new JLabel();
100 115
		this.messagelabel.setPreferredSize( new Dimension( 200, 16));
101 116

  
102 117
		this.setLayout(new GridBagLayout());
103 118
		
104
		this.add(this.tittlelabel, 0, 0, GridBagConstraints.HORIZONTAL, 0.9, 0);
105
		this.add(this.progressBar, 0, 1, GridBagConstraints.HORIZONTAL, 0.9, 0);
106
		this.add(this.messagelabel, 0, 2, GridBagConstraints.HORIZONTAL, 0.9, 0);
107
		this.add(this.cancelRequestButton, 1, 1, GridBagConstraints.NONE, 0.1, 0);
119
		this.add(this.titlelabel, 0, 0, GridBagConstraints.HORIZONTAL, 0.98, 0);
120
		this.add(this.progressBar, 0, 1, GridBagConstraints.HORIZONTAL, 0.98, 0);
121
		this.add(this.messagelabel, 0, 2, GridBagConstraints.HORIZONTAL, 0.98, 0);
122
		this.add(this.cancelRequestButton, 1, 1, GridBagConstraints.NONE, 0.01, 0);
123
		this.add(this.removeTaskButton, 2, 1, GridBagConstraints.NONE, 0.01, 0);
108 124
	}
109 125

  
110 126
	private ImageIcon getIcon(String name) {
......
141 157
		}
142 158
		TaskStatus taskStatus = (TaskStatus) observable;
143 159
		if( taskStatus == null || !taskStatus.isRunning() ) {
144
			//this.tittlelabel.setText("");
145 160
			this.messagelabel.setText("");
146 161
			this.progressBar.setValue(100);
147 162
			this.cancelRequestButton.setEnabled(false);
163
			this.removeTaskButton.setEnabled(true);
148 164
			return;
149 165
		}
150
		this.tittlelabel.setText(taskStatus.getTitle());
166
		this.titlelabel.setText(taskStatus.getTitle());
151 167
		this.messagelabel.setText(taskStatus.getLabel());
152 168
		this.progressBar.setIndeterminate( taskStatus.isIndeterminate() );
153 169
		this.progressBar.setValue( taskStatus.getCompleted() );
154 170
		if( !this.cancelRequestButton.isEnabled() ) {
155 171
			this.cancelRequestButton.setEnabled(true);
156 172
		}
173
		
157 174
	}
158 175

  
159 176
	public TaskStatus getTaskStatus() {

Also available in: Unified diff