Salut,

Je souhaiterais créer mon propre InputBlocker, tout comme l'a fait Hans Muller, le créateur de l'appframework, dans cet exemple : BusyIndicatorInputBlocker extends InputBlocker

J'ai donc écrit ce code (@Action) qui appelle une ma classe Task nommée StartPanelCommandButtonsActionTask :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	/**
         * Start inventory.
         * @return Task for task monitor
         */
	@Action
	protected Task startPanelCommandButtonsAction()
	{
		// code...
 
		// Set components blocker
		StartPanelCommandButtonsActionTask startPanelCommandButtonsActionTask = new StartPanelCommandButtonsActionTask();
		startPanelCommandButtonsActionTask.setInputBlocker(new ComponentsBlocker(startPanelCommandButtonsActionTask, 
																			new JComponent[]{btnStartPanelCommandButtons, 
																							btnResumePanelCommandButtons}));
		return startPanelCommandButtonsActionTask;
 
	}
Mon InputBlocker nommé ComponentsBlocker :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
	class ComponentsBlocker extends InputBlocker
	{
		List<JComponent> listComponents;
		/**
                 * Constructor.
                 * @param task
                 * @param components
                 */
		public ComponentsBlocker(Task task, JComponent[] components)
		{
			super(task, Task.BlockingScope.NONE, null);
			listComponents = Arrays.asList(components);
			LOGGER.debug("ComponentsBlocker set with : " + listComponents);
		}
 
		/**
                 * @see org.jdesktop.application.Task.InputBlocker#block()
                 */
		@Override
		protected void block()
		{
			LOGGER.debug("block");
			for(JComponent component : listComponents)
			{
				component.setEnabled(false);
			}
		}
		/**
                 * @see org.jdesktop.application.Task.InputBlocker#unblock()
                 */
		@Override
		protected void unblock()
		{
			LOGGER.debug("unblock");
			for(JComponent component : listComponents)
			{
				component.setEnabled(true);
			}
		}
	}

Seul problème, les méthodes block et unblock ne sont jamais appelées par le TaskService lors de l'exécution de ma Task.

Avez-vous des idées ou déjà essayé qqchose du genre ?


Thx,
Bapt.ice.