1 11 package org.eclipse.ui.activities; 12 13 import java.util.Hashtable ; 14 import java.util.Properties ; 15 import java.util.Set ; 16 17 import org.eclipse.core.runtime.IConfigurationElement; 18 import org.eclipse.core.runtime.IExecutableExtension; 19 import org.eclipse.jface.window.Window; 20 import org.eclipse.ui.internal.IPreferenceConstants; 21 import org.eclipse.ui.internal.WorkbenchPlugin; 22 import org.eclipse.ui.internal.activities.ws.EnablementDialog; 23 import org.eclipse.ui.internal.util.PrefUtil; 24 import org.eclipse.ui.internal.util.Util; 25 26 41 public class WorkbenchTriggerPointAdvisor implements ITriggerPointAdvisor, 42 IExecutableExtension { 43 44 48 public static String PROCEED_MULTI = "proceedMulti"; 50 54 public static String PROCEED_SINGLE = "proceedSingle"; 56 60 public static String DONT_ASK = "dontAsk"; 62 66 public static String NO_DETAILS = "noDetails"; 68 69 private Properties strings = new Properties (); 70 71 74 public WorkbenchTriggerPointAdvisor() { 75 super(); 76 } 77 78 81 public Set allow(ITriggerPoint triggerPoint, IIdentifier identifier) { 82 if (!PrefUtil.getInternalPreferenceStore().getBoolean( 83 IPreferenceConstants.SHOULD_PROMPT_FOR_ENABLEMENT)) { 84 return identifier.getActivityIds(); 85 } 86 87 if (!triggerPoint.getBooleanHint(ITriggerPoint.HINT_INTERACTIVE)) { 89 return identifier.getActivityIds(); 90 } 91 92 EnablementDialog dialog = new EnablementDialog(Util.getShellToParentOn(), identifier 93 .getActivityIds(), strings); 94 if (dialog.open() == Window.OK) { 95 Set activities = dialog.getActivitiesToEnable(); 96 if (dialog.getDontAsk()) { 97 PrefUtil.getInternalPreferenceStore().setValue( 98 IPreferenceConstants.SHOULD_PROMPT_FOR_ENABLEMENT, 99 false); 100 WorkbenchPlugin.getDefault().savePluginPreferences(); 101 } 102 103 return activities; 104 } 105 106 return null; 107 } 108 109 112 public void setInitializationData(IConfigurationElement config, String propertyName, Object data) { 113 if (data instanceof Hashtable ) { 114 strings.putAll((Hashtable )data); 115 } 116 } 117 } 118 | Popular Tags |