1 11 package org.eclipse.ui.application; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.core.runtime.Status; 16 import org.eclipse.swt.widgets.Composite; 17 import org.eclipse.swt.widgets.Control; 18 import org.eclipse.swt.widgets.Shell; 19 import org.eclipse.ui.IMemento; 20 import org.eclipse.ui.IWorkbenchPreferenceConstants; 21 import org.eclipse.ui.PlatformUI; 22 import org.eclipse.ui.WorkbenchException; 23 import org.eclipse.ui.actions.ActionFactory; 24 import org.eclipse.ui.internal.WorkbenchWindowConfigurer; 25 import org.eclipse.ui.internal.util.PrefUtil; 26 import org.eclipse.ui.intro.IIntroManager; 27 28 64 public class WorkbenchWindowAdvisor { 65 66 private IWorkbenchWindowConfigurer windowConfigurer; 67 68 74 public WorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { 75 Assert.isNotNull(configurer); 76 this.windowConfigurer = configurer; 77 } 78 79 84 protected IWorkbenchWindowConfigurer getWindowConfigurer() { 85 return windowConfigurer; 86 } 87 88 101 public void preWindowOpen() { 102 } 104 105 113 public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { 114 return new ActionBarAdvisor(configurer); 115 } 116 117 133 public void postWindowRestore() throws WorkbenchException { 134 } 136 137 150 public void openIntro() { 151 153 IWorkbenchConfigurer wbConfig = getWindowConfigurer().getWorkbenchConfigurer(); 155 final String key = "introOpened"; Boolean introOpened = (Boolean ) wbConfig.getData(key); 157 if (introOpened != null && introOpened.booleanValue()) { 158 return; 159 } 160 161 wbConfig.setData(key, Boolean.TRUE); 162 163 boolean showIntro = PrefUtil.getAPIPreferenceStore().getBoolean( 164 IWorkbenchPreferenceConstants.SHOW_INTRO); 165 166 IIntroManager introManager = wbConfig.getWorkbench().getIntroManager(); 167 168 boolean hasIntro = introManager.hasIntro(); 169 boolean isNewIntroContentAvailable = introManager.isNewContentAvailable(); 170 171 if (hasIntro && (showIntro || isNewIntroContentAvailable)) { 172 introManager 173 .showIntro(getWindowConfigurer().getWindow(), false); 174 175 PrefUtil.getAPIPreferenceStore().setValue( 176 IWorkbenchPreferenceConstants.SHOW_INTRO, false); 177 PrefUtil.saveAPIPrefs(); 178 } 179 } 180 181 192 public void postWindowCreate() { 193 } 195 196 207 public void postWindowOpen() { 208 } 210 211 231 public boolean preWindowShellClose() { 232 return true; 234 } 235 236 244 public void postWindowClose() { 245 } 247 248 267 public void createWindowContents(Shell shell) { 268 ((WorkbenchWindowConfigurer) getWindowConfigurer()).createDefaultContents(shell); 269 } 270 271 282 public Control createEmptyWindowContents(Composite parent) { 283 return null; 284 } 285 286 292 public void dispose() { 293 } 295 296 303 public IStatus saveState(IMemento memento) { 304 return Status.OK_STATUS; 306 } 307 308 315 public IStatus restoreState(IMemento memento) { 316 return Status.OK_STATUS; 318 } 319 } 320 | Popular Tags |