1 11 12 package org.eclipse.ui.internal.services; 13 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 import org.eclipse.ui.AbstractSourceProvider; 18 import org.eclipse.ui.ISources; 19 import org.eclipse.ui.internal.ActionSetsEvent; 20 import org.eclipse.ui.internal.menus.IActionSetsListener; 21 import org.eclipse.ui.internal.registry.IActionSetDescriptor; 22 import org.eclipse.ui.internal.util.Util; 23 24 35 public final class ActionSetSourceProvider extends AbstractSourceProvider 36 implements IActionSetsListener { 37 38 41 private static final String [] PROVIDED_SOURCE_NAMES = new String [] { ISources.ACTIVE_ACTION_SETS_NAME }; 42 43 47 private IActionSetDescriptor[] activeActionSets; 48 49 public ActionSetSourceProvider() { 50 super(); 51 } 52 53 public final void actionSetsChanged(final ActionSetsEvent event) { 54 final IActionSetDescriptor[] newActionSets = event.getNewActionSets(); 55 if (!Util.equals(newActionSets, activeActionSets)) { 56 if (DEBUG) { 57 final StringBuffer message = new StringBuffer (); 58 message.append("Action sets changed to ["); if (newActionSets != null) { 60 for (int i = 0; i < newActionSets.length; i++) { 61 message.append(newActionSets[i].getLabel()); 62 if (i < newActionSets.length - 1) { 63 message.append(", "); } 65 } 66 } 67 message.append(']'); 68 logDebuggingInfo(message.toString()); 69 } 70 71 activeActionSets = newActionSets; 72 fireSourceChanged(ISources.ACTIVE_ACTION_SETS, 73 ISources.ACTIVE_ACTION_SETS_NAME, activeActionSets); 74 75 } 76 } 77 78 public final void dispose() { 79 activeActionSets = null; 80 } 81 82 public final Map getCurrentState() { 83 final Map currentState = new HashMap (); 84 currentState.put(ISources.ACTIVE_ACTION_SETS_NAME, activeActionSets); 85 return currentState; 86 } 87 88 public final String [] getProvidedSourceNames() { 89 return PROVIDED_SOURCE_NAMES; 90 } 91 } | Popular Tags |