1 11 package org.eclipse.debug.internal.ui.commands.actions; 12 13 import org.eclipse.jface.action.IAction; 14 15 21 public class ActionsUpdater { 22 23 private IAction[] fActions; 24 private int fNumVoters; 25 private int fNumOfVotes = 0; 26 private boolean fDone = false; 27 private boolean fEnabled = true; 28 29 public ActionsUpdater(IAction[] actions, int numVoters) { 30 fActions = actions; 31 fNumVoters = numVoters; 32 } 33 34 public synchronized void setEnabled(boolean result) { 35 fNumOfVotes++; 36 if (fEnabled) { 37 fEnabled = result; 38 } 39 done(); 40 } 41 42 private synchronized void done() { 43 if (!fDone) { 44 if (!fEnabled || fNumOfVotes == fNumVoters) { 45 fDone = true; 46 for (int i = 0; i < fActions.length; i++) { 47 fActions[i].setEnabled(fEnabled); 48 } 49 } 50 } 51 } 52 53 } 54 | Popular Tags |