Revision 11273

View differences:

trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/incrementabletask/IncrementableTask.java
50 50
	private boolean bDoCallListeners = true;
51 51
	static private int eventId = Integer.MIN_VALUE;
52 52

  
53
	/**
54
	 * Constructor del IncrementableTask.
55
	 * @param incrementable
56
	 */
53 57
	public IncrementableTask(IIncrementable incrementable) {
54 58
		progressPanel = getProgressPanel();
55 59
		iIncrementable = incrementable;
56 60
	}
57 61

  
62
	/**
63
	 * Inicio del thread para que la ventana vaya consultando por si sola al
64
	 * iIncrementable
65
	 */
58 66
	public void start() {
59 67
		blinker = new Thread(this);
60 68
		blinker.start();
61 69
	}
62
	
70

  
71
	/**
72
	 * Poder parar el proceso de consulta de la ventana
73
	 */
63 74
	public synchronized void stop() {
64 75
		ended = true;
65 76
		blinker = null;
......
77 88
				getProgressPanel().setTitle(iIncrementable.getTitle());
78 89
				getProgressPanel().setLog(iIncrementable.getLog());
79 90
				Thread.sleep(100);
80
				synchronized(this) {
91
				synchronized (this) {
81 92
					while (threadSuspended && !ended)
82 93
						wait(500);
83 94
				}
......
85 96
			}
86 97
		}
87 98
	}
88
	
99

  
100
	/**
101
	 * Ocultar la ventana y parar el proceso
102
	 */
89 103
	public void Hide() {
90 104
		getProgressPanel().setVisible(false);
91 105
		getProgressPanel().hide();
......
93 107
		this.stop();
94 108
	}
95 109
	
110
	/**
111
	 * Devuelve un booleano indicando si esta activa la ventana.
112
	 * @return boolean
113
	 */
96 114
	public boolean isAlive() {
97 115
		return blinker.isAlive();
98 116
	}
......
101 119
	 * Muestra la ventana de incremento con el porcentaje de la construcci?n del
102 120
	 * histograma.
103 121
	 */
104
	public void showWindow(){
122
	public void showWindow() {
105 123
		getProgressPanel().setTitle(iIncrementable.getTitle());
106 124
		getProgressPanel().showLog(false);
107 125
		getProgressPanel().show();
108 126
	}
109
	
127

  
128
	/**
129
	 * Devuelve el componente ProgressPanel de la ventana incrementable.
130
	 * @return ProgressPanel
131
	 */
110 132
	private ProgressPanel getProgressPanel() {
111 133
		if (progressPanel == null) {
112 134
			progressPanel = new ProgressPanel(false);
113 135
			progressPanel.addButtonPressedListener(this);
114
			progressPanel.addWindowListener( new WindowAdapter() {
115
        public void windowClosing(WindowEvent e)
116
        {
117
        	ended = true;
118
  				callActionCommandListeners(IncrementableEvent.CANCELED);
119
        }
120
      });
136
			progressPanel.addWindowListener(new WindowAdapter() {
137
				public void windowClosing(WindowEvent e) {
138
					ended = true;
139
					callActionCommandListeners(IncrementableEvent.CANCELED);
140
				}
141
			});
121 142
		}
122 143
		return progressPanel;
123 144
	}
......
143 164
		eventId++;
144 165
	}
145 166

  
167
	/**
168
	 * A?adir el manejador de eventos para atender las peticiones de start,
169
	 * stop...
170
	 * 
171
	 * @param listener
172
	 */
146 173
	public void addIncrementableListener(IncrementableListener listener) {
147 174
		if (!actionCommandListeners.contains(listener))
148 175
			actionCommandListeners.add(listener);
149 176
	}
150 177

  
178
	/**
179
	 * Borrar un manejador de eventos.
180
	 * @param listener
181
	 */
151 182
	public void removeIncrementableListener(IncrementableListener listener) {
152 183
		actionCommandListeners.remove(listener);
153 184
	}
154 185

  
155 186
	/**
187
	 * Definir si queremos que confirme al usuario si realmente desea cancelar el
188
	 * proceso
156 189
	 * 
157 190
	 * @param value
158 191
	 */
......
160 193
		askOnCancel = value;
161 194
	}
162 195
	
196
	/**
197
	 * Metodo para gestionar todos los eventos del objeto.
198
	 */
163 199
	public void actionButtonPressed(ButtonsPanelEvent e) {
164 200
		switch (e.getButton()) {
165 201
			case ButtonsPanel.BUTTON_CANCEL:
......
170 206
					String string2 = Messages.getText("no");
171 207
					Object[] options = { string1, string2 };
172 208
					int answer = JOptionPane.showOptionDialog(progressPanel, Messages
173
							.getText("msg_cancel_incrementable"), Messages.getText("title_cancel_incrementable"),
209
							.getText("msg_cancel_incrementable"), Messages
210
							.getText("title_cancel_incrementable"),
174 211
							JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
175 212
							options, string1);
176 213
					if (answer == JOptionPane.YES_OPTION)
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/buttonspanel/ButtonsPanel.java
53 53
	public static final int BUTTON_HIDEDETAILS = 9;
54 54
	public static final int BUTTON_PAUSE = 10;
55 55
	public static final int BUTTON_RESTART = 11;
56
	public static final int BUTTON_SAVE = 12;
57
	/**
58
	 * Sirve para cuando se crean botones nuevos, saber el ?ltimo n?mero usado
59
	 * internamente, as? '<code>new_id = BUTTON_LAST + 1;</code>' podr?a ser
60
	 * el ?ndice del nuevo bot?n.
61
	 */
62
	public static final int BUTTON_LAST = 12;
56 63
	
57 64
	public static final int BUTTONS_ACCEPT = 1;
58 65
	public static final int BUTTONS_ACCEPTCANCEL = 2;
......
72 79

  
73 80
	/**
74 81
	 * Crea un ButtonsPanel con un Layout por defecto.
75
	 * 
76 82
	 * @param items Que botones vamos a usar en la creaci?n.
77 83
	 */
78 84
	public ButtonsPanel(int items) {
......
108 114
		}
109 115
	}
110 116

  
117
	/**
118
	 * A?adir el disparador de cuando se pulsa un bot?n.
119
	 * @param listener
120
	 */
111 121
	public void addButtonPressedListener(ButtonsPanelListener listener) {
112
	  if (!actionCommandListeners.contains(listener))
113
	    actionCommandListeners.add(listener);
122
		if (!actionCommandListeners.contains(listener))
123
			actionCommandListeners.add(listener);
114 124
	}
115 125

  
126
	/**
127
	 * Borrar el disparador de eventos de los botones.
128
	 * @param listener
129
	 */
116 130
	public void removeButtonPressedListener(ButtonsPanelListener listener) {
117 131
	  actionCommandListeners.remove(listener);
118 132
	}
119 133

  
120 134
	private void callActionCommandListeners(int buttonID) {
121
	  Iterator acIterator = actionCommandListeners.iterator();
122
	  while (acIterator.hasNext()) {
123
	  	ButtonsPanelListener listener = (ButtonsPanelListener) acIterator.next();
124
	    listener.actionButtonPressed(new ButtonsPanelEvent(this, buttonID));
125
	  }
126
	  eventId++;
135
		Iterator acIterator = actionCommandListeners.iterator();
136
		while (acIterator.hasNext()) {
137
			ButtonsPanelListener listener = (ButtonsPanelListener) acIterator.next();
138
			listener.actionButtonPressed(new ButtonsPanelEvent(this, buttonID));
139
		}
140
		eventId++;
127 141
	}
128 142

  
129 143
	/**
......
134 148
	}
135 149
	
136 150
	/**
151
	 * A?adir el boton Guardar.
152
	 */
153
	public void addSave() {
154
		addButton(Messages.getText("guardar"), BUTTON_SAVE);
155
	}
156
	
157
	/**
137 158
	 * A?adir el boton Cancelar.
138 159
	 */
139 160
	public void addCancel() {
......
215 236
		button.setText(text);
216 237
		button.setActionCommand(id + "");
217 238
		button.addActionListener(new ActionListener() {
218
      public void actionPerformed(ActionEvent e) {
219
      	callActionCommandListeners(Integer.parseInt(e.getActionCommand()));
220
      }
239
			public void actionPerformed(ActionEvent e) {
240
				callActionCommandListeners(Integer.parseInt(e.getActionCommand()));
241
			}
221 242
		});
222
	
243

  
223 244
		add(button);
224 245
	}
225 246

  
......
230 251
	 */
231 252
	public JButton getButton(int id) {
232 253
		Iterator acIterator = buttonsList.iterator();
233
	  while (acIterator.hasNext()) {
234
	  	JButton button = (JButton) acIterator.next();
235
	  	if (Integer.parseInt(button.getActionCommand()) == id)
236
	  		return button;
237
	 	}
238
	  return null;
254
		while (acIterator.hasNext()) {
255
			JButton button = (JButton) acIterator.next();
256
			if (Integer.parseInt(button.getActionCommand()) == id)
257
				return button;
258
		}
259
		return null;
239 260
	}
240 261
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/translations/text.properties
33 33
ocultardetalles=Ocultar detalles
34 34
pausar=Pausar
35 35
reanudar=Reanudar
36
guardar=Guardar
36 37
tiempo_transcurrido=Tiempo transcurrido
37 38
msg_cancel_incrementable=?Esta seguro de que desea cancelar este proceso?
38 39
title_cancel_incrementable=Confirmaci?n

Also available in: Unified diff