Lines 95-100
Link Here
|
95 |
import org.eclipse.swt.widgets.Display; |
95 |
import org.eclipse.swt.widgets.Display; |
96 |
import org.eclipse.swt.widgets.Event; |
96 |
import org.eclipse.swt.widgets.Event; |
97 |
import org.eclipse.swt.widgets.Listener; |
97 |
import org.eclipse.swt.widgets.Listener; |
|
|
98 |
import org.eclipse.swt.widgets.Menu; |
98 |
import org.eclipse.swt.widgets.Shell; |
99 |
import org.eclipse.swt.widgets.Shell; |
99 |
import org.eclipse.swt.widgets.TaskBar; |
100 |
import org.eclipse.swt.widgets.TaskBar; |
100 |
import org.eclipse.swt.widgets.TaskItem; |
101 |
import org.eclipse.swt.widgets.TaskItem; |
Lines 131-136
Link Here
|
131 |
import org.eclipse.ui.commands.ICommandImageService; |
132 |
import org.eclipse.ui.commands.ICommandImageService; |
132 |
import org.eclipse.ui.commands.ICommandService; |
133 |
import org.eclipse.ui.commands.ICommandService; |
133 |
import org.eclipse.ui.commands.IWorkbenchCommandSupport; |
134 |
import org.eclipse.ui.commands.IWorkbenchCommandSupport; |
|
|
135 |
import org.eclipse.ui.contexts.IContextActivation; |
134 |
import org.eclipse.ui.contexts.IContextService; |
136 |
import org.eclipse.ui.contexts.IContextService; |
135 |
import org.eclipse.ui.contexts.IWorkbenchContextSupport; |
137 |
import org.eclipse.ui.contexts.IWorkbenchContextSupport; |
136 |
import org.eclipse.ui.handlers.IHandlerService; |
138 |
import org.eclipse.ui.handlers.IHandlerService; |
Lines 189-194
Link Here
|
189 |
import org.eclipse.ui.intro.IIntroManager; |
191 |
import org.eclipse.ui.intro.IIntroManager; |
190 |
import org.eclipse.ui.keys.IBindingService; |
192 |
import org.eclipse.ui.keys.IBindingService; |
191 |
import org.eclipse.ui.menus.IMenuService; |
193 |
import org.eclipse.ui.menus.IMenuService; |
|
|
194 |
import org.eclipse.ui.menus.MenuUtil; |
192 |
import org.eclipse.ui.model.IContributionService; |
195 |
import org.eclipse.ui.model.IContributionService; |
193 |
import org.eclipse.ui.operations.IWorkbenchOperationSupport; |
196 |
import org.eclipse.ui.operations.IWorkbenchOperationSupport; |
194 |
import org.eclipse.ui.progress.IProgressService; |
197 |
import org.eclipse.ui.progress.IProgressService; |
Lines 1554-1559
Link Here
|
1554 |
} |
1557 |
} |
1555 |
}); |
1558 |
}); |
1556 |
|
1559 |
|
|
|
1560 |
StartupThreading.runWithoutExceptions(new StartupRunnable() { |
1561 |
|
1562 |
public void runWithException() { |
1563 |
|
1564 |
activateWorkbenchContext(); |
1565 |
|
1566 |
} |
1567 |
}); |
1568 |
|
1569 |
StartupThreading.runWithoutExceptions(new StartupRunnable() { |
1570 |
|
1571 |
public void runWithException() { |
1572 |
|
1573 |
Menu appMenu = getAppMenu(); |
1574 |
if (appMenu == null) |
1575 |
return; |
1576 |
|
1577 |
createApplicationMenu(appMenu); |
1578 |
} |
1579 |
}); |
1580 |
|
1581 |
|
1582 |
|
1557 |
// attempt to restore a previous workbench state |
1583 |
// attempt to restore a previous workbench state |
1558 |
try { |
1584 |
try { |
1559 |
UIStats.start(UIStats.RESTORE_WORKBENCH, "Workbench"); //$NON-NLS-1$ |
1585 |
UIStats.start(UIStats.RESTORE_WORKBENCH, "Workbench"); //$NON-NLS-1$ |
Lines 1751-1756
Link Here
|
1751 |
new SaveablesList()); |
1777 |
new SaveablesList()); |
1752 |
}}); |
1778 |
}}); |
1753 |
|
1779 |
|
|
|
1780 |
StartupThreading.runWithoutExceptions(new StartupRunnable() { |
1781 |
|
1782 |
public void runWithException() { |
1783 |
// side effect of getter is initializing |
1784 |
getProgressService(); |
1785 |
} |
1786 |
}); |
1787 |
|
1754 |
/* |
1788 |
/* |
1755 |
* Phase 1 of the initialization of commands. When this phase completes, |
1789 |
* Phase 1 of the initialization of commands. When this phase completes, |
1756 |
* all the services and managers will exist, and be accessible via the |
1790 |
* all the services and managers will exist, and be accessible via the |
Lines 2128-2135
Link Here
|
2128 |
super.handleException(e); |
2162 |
super.handleException(e); |
2129 |
} |
2163 |
} |
2130 |
}); |
2164 |
}); |
2131 |
// ensure at least one window was opened |
2165 |
// ensure at least one window was opened, only when appMenu isn't there |
2132 |
if (result[0].isOK() && windowManager.getWindows().length == 0) { |
2166 |
if (shouldReturnNoWindowError(result[0])) { |
2133 |
String msg = WorkbenchMessages.Workbench_noWindowsRestored; |
2167 |
String msg = WorkbenchMessages.Workbench_noWindowsRestored; |
2134 |
result[0] = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, |
2168 |
result[0] = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, |
2135 |
IWorkbenchConfigurer.RESTORE_CODE_RESET, msg, null); |
2169 |
IWorkbenchConfigurer.RESTORE_CODE_RESET, msg, null); |
Lines 2137-2142
Link Here
|
2137 |
return result[0]; |
2171 |
return result[0]; |
2138 |
} |
2172 |
} |
2139 |
|
2173 |
|
|
|
2174 |
private boolean shouldReturnNoWindowError(final IStatus result) { |
2175 |
|
2176 |
final boolean[] shouldReturn = new boolean[1]; |
2177 |
// first check for the result & no of windows |
2178 |
shouldReturn[0] = result.isOK() && windowManager.getWindows().length == 0; |
2179 |
if (shouldReturn[0]) { |
2180 |
// if result is ok and there is no window, check for appMenu |
2181 |
display.syncExec(new Runnable() { |
2182 |
public void run() { |
2183 |
// return error if there is no appMenu |
2184 |
shouldReturn[0] = display.getAppMenuBar() == null; |
2185 |
} |
2186 |
}); |
2187 |
} |
2188 |
return shouldReturn[0]; |
2189 |
} |
2190 |
|
2140 |
/* |
2191 |
/* |
2141 |
* (non-Javadoc) Method declared on IWorkbench. |
2192 |
* (non-Javadoc) Method declared on IWorkbench. |
2142 |
*/ |
2193 |
*/ |
Lines 2988-2993
Link Here
|
2988 |
|
3039 |
|
2989 |
((GrabFocus) Tweaklets.get(GrabFocus.KEY)).dispose(); |
3040 |
((GrabFocus) Tweaklets.get(GrabFocus.KEY)).dispose(); |
2990 |
|
3041 |
|
|
|
3042 |
deactivateWorkbenchContext(); |
3043 |
|
3044 |
disposeApplicationMenu(); |
3045 |
|
2991 |
// Bring down all of the services. |
3046 |
// Bring down all of the services. |
2992 |
serviceLocator.dispose(); |
3047 |
serviceLocator.dispose(); |
2993 |
|
3048 |
|
Lines 3009-3014
Link Here
|
3009 |
} |
3064 |
} |
3010 |
} |
3065 |
} |
3011 |
|
3066 |
|
|
|
3067 |
|
3012 |
/** |
3068 |
/** |
3013 |
* Cancels the early startup job, if it's still running. |
3069 |
* Cancels the early startup job, if it's still running. |
3014 |
*/ |
3070 |
*/ |
Lines 3709-3714
Link Here
|
3709 |
*/ |
3765 |
*/ |
3710 |
private MenuSourceProvider menuSourceProvider; |
3766 |
private MenuSourceProvider menuSourceProvider; |
3711 |
|
3767 |
|
|
|
3768 |
private IContextActivation workbenchContext; |
3769 |
|
3770 |
private ApplicationMenuManager applicationMenuMgr; |
3712 |
|
3771 |
|
3713 |
|
3772 |
|
3714 |
/** |
3773 |
/** |
Lines 3816-3819
Link Here
|
3816 |
}; |
3875 |
}; |
3817 |
} |
3876 |
} |
3818 |
|
3877 |
|
|
|
3878 |
private void createApplicationMenu(Menu appMenu) { |
3879 |
|
3880 |
applicationMenuMgr = new ApplicationMenuManager(appMenu); |
3881 |
IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class); |
3882 |
menuService.populateContributionManager(applicationMenuMgr, MenuUtil.APPLICATION_MENU); |
3883 |
applicationMenuMgr.update(true); |
3884 |
} |
3885 |
|
3886 |
private void disposeApplicationMenu() { |
3887 |
|
3888 |
if (applicationMenuMgr == null) |
3889 |
return; |
3890 |
IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class); |
3891 |
menuService.releaseContributions(applicationMenuMgr); |
3892 |
applicationMenuMgr.dispose(); |
3893 |
} |
3894 |
|
3895 |
private void activateWorkbenchContext() { |
3896 |
IContextService contextService = (IContextService) serviceLocator |
3897 |
.getService(IContextService.class); |
3898 |
workbenchContext = contextService.activateContext(IContextService.CONTEXT_ID_WORKBENCH); |
3899 |
} |
3900 |
|
3901 |
private void deactivateWorkbenchContext() { |
3902 |
if(workbenchContext == null) |
3903 |
return; |
3904 |
workbenchContext.getContextService().deactivateContext(workbenchContext); |
3905 |
} |
3906 |
|
3907 |
|
3908 |
private Menu getAppMenu() { |
3909 |
IWorkbench workbench = getWorkbenchConfigurer().getWorkbench(); |
3910 |
return workbench.getDisplay().getAppMenuBar(); |
3911 |
} |
3912 |
|
3819 |
} |
3913 |
} |