Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/Application.java93
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationActionBarAdvisor.java1109
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationWorkbenchAdvisor.java167
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationWorkbenchWindowAdvisor.java394
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/activator/UIPlugin.java64
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/nls/Messages.java47
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/nls/Messages.properties16
7 files changed, 1890 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/Application.java b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/Application.java
new file mode 100644
index 000000000..951ad9abc
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/Application.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.rcp.application;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.osgi.service.datalocation.Location;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Target Explorer, RCP: Application implementation.
+ *
+ * @author uwe.stieber@windriver.com
+ */
+public class Application implements IApplication {
+
+ private static final String PROP_EXIT_CODE = "eclipse.exitcode"; //$NON-NLS-1$
+
+ /**
+ * A special return code that will be recognized by the launcher and used to
+ * restart the application.
+ */
+ private static final Integer EXIT_RELAUNCH = new Integer(24);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
+ */
+ public Object start(IApplicationContext context) throws Exception {
+ Display display = createDisplay();
+
+ try {
+ // create the workbench with this advisor and run it until it exits
+ // N.B. createWorkbench remembers the advisor, and also registers
+ // the workbench globally so that all UI plug-ins can find it using
+ // PlatformUI.getWorkbench() or AbstractUIPlugin.getWorkbench()
+ int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
+
+ // the workbench doesn't support relaunch yet (bug 61809) so
+ // for now restart is used, and exit data properties are checked
+ // here to substitute in the relaunch return code if needed
+ if (returnCode != PlatformUI.RETURN_RESTART) {
+ return EXIT_OK;
+ }
+
+ // if the exit code property has been set to the relaunch code, then
+ // return that code now, otherwise this is a normal restart
+ return EXIT_RELAUNCH.equals(Integer.getInteger(PROP_EXIT_CODE)) ? EXIT_RELAUNCH : EXIT_RESTART;
+ } finally {
+ if (display != null) {
+ display.dispose();
+ }
+ Location instanceLoc = Platform.getInstanceLocation();
+ if (instanceLoc != null)
+ instanceLoc.release();
+ }
+ }
+
+ /**
+ * Creates the display used by the application.
+ *
+ * @return the display used by the application
+ */
+ protected Display createDisplay() {
+ return PlatformUI.createDisplay();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.app.IApplication#stop()
+ */
+ public void stop() {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench == null) return;
+
+ final Display display = workbench.getDisplay();
+ display.syncExec(new Runnable() {
+ public void run() {
+ if (!display.isDisposed())
+ workbench.close();
+ }
+ });
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationActionBarAdvisor.java b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationActionBarAdvisor.java
new file mode 100644
index 000000000..dbe00bf17
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationActionBarAdvisor.java
@@ -0,0 +1,1109 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.rcp.application;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.ICoolBarManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.StatusLineContributionItem;
+import org.eclipse.jface.internal.provisional.action.IToolBarContributionItem;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.util.Util;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.actions.ContributionItemFactory;
+import org.eclipse.ui.actions.NewWizardMenu;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.ide.IIDEActionConstants;
+import org.eclipse.ui.internal.IPreferenceConstants;
+import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
+import org.eclipse.ui.internal.WorkbenchMessages;
+import org.eclipse.ui.internal.WorkbenchPlugin;
+import org.eclipse.ui.internal.handlers.IActionCommandMappingService;
+import org.eclipse.ui.internal.ide.AboutInfo;
+import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.ide.actions.QuickMenuAction;
+import org.eclipse.ui.internal.provisional.application.IActionBarConfigurer2;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.ui.menus.IMenuService;
+
+/**
+ * Target Explorer, RCP: Adds actions to the application window.
+ */
+@SuppressWarnings("restriction")
+public final class ApplicationActionBarAdvisor extends ActionBarAdvisor {
+ private final IWorkbenchWindow window;
+
+ // generic actions
+ private IWorkbenchAction closeAction;
+
+ private IWorkbenchAction closeAllAction;
+
+ private IWorkbenchAction closeOthersAction;
+
+ private IWorkbenchAction closeAllSavedAction;
+
+ private IWorkbenchAction saveAction;
+
+ private IWorkbenchAction saveAllAction;
+
+ private IWorkbenchAction newWindowAction;
+
+ private IWorkbenchAction newEditorAction;
+
+ private IWorkbenchAction helpContentsAction;
+
+ private IWorkbenchAction helpSearchAction;
+
+ private IWorkbenchAction dynamicHelpAction;
+
+ private IWorkbenchAction aboutAction;
+
+ private IWorkbenchAction openPreferencesAction;
+
+ private IWorkbenchAction saveAsAction;
+
+ private IWorkbenchAction hideShowEditorAction;
+
+ private IWorkbenchAction savePerspectiveAction;
+
+ private IWorkbenchAction resetPerspectiveAction;
+
+ private IWorkbenchAction editActionSetAction;
+
+ private IWorkbenchAction closePerspAction;
+
+ private IWorkbenchAction lockToolBarAction;
+
+ private IWorkbenchAction closeAllPerspsAction;
+
+ private IWorkbenchAction showViewMenuAction;
+
+ private IWorkbenchAction showPartPaneMenuAction;
+
+ private IWorkbenchAction nextPartAction;
+
+ private IWorkbenchAction prevPartAction;
+
+ private IWorkbenchAction nextEditorAction;
+
+ private IWorkbenchAction prevEditorAction;
+
+ private IWorkbenchAction nextPerspectiveAction;
+
+ private IWorkbenchAction prevPerspectiveAction;
+
+ private IWorkbenchAction activateEditorAction;
+
+ private IWorkbenchAction maximizePartAction;
+
+ private IWorkbenchAction minimizePartAction;
+
+ private IWorkbenchAction switchToEditorAction;
+
+ private IWorkbenchAction workbookEditorsAction;
+
+ private IWorkbenchAction quickAccessAction;
+
+ private IWorkbenchAction backwardHistoryAction;
+
+ private IWorkbenchAction forwardHistoryAction;
+
+ // generic retarget actions
+ private IWorkbenchAction undoAction;
+
+ private IWorkbenchAction redoAction;
+
+ private IWorkbenchAction quitAction;
+
+ private IWorkbenchAction goIntoAction;
+
+ private IWorkbenchAction backAction;
+
+ private IWorkbenchAction forwardAction;
+
+ private IWorkbenchAction upAction;
+
+ private IWorkbenchAction nextAction;
+
+ private IWorkbenchAction previousAction;
+
+ private IWorkbenchAction newWizardAction;
+
+ private IWorkbenchAction newWizardDropDownAction;
+
+ private IWorkbenchAction importResourcesAction;
+
+ private IWorkbenchAction exportResourcesAction;
+
+ private IWorkbenchAction quickStartAction;
+
+ private IWorkbenchAction tipsAndTricksAction;
+
+ private QuickMenuAction showInQuickMenu;
+
+ private QuickMenuAction newQuickMenu;
+
+ private IWorkbenchAction introAction;
+
+ // contribution items
+ // @issue should obtain from ContributionItemFactory
+ private NewWizardMenu newWizardMenu;
+
+ // @issue class is workbench internal
+ private StatusLineContributionItem statusLineItem;
+
+ // listener for the "close editors automatically"
+ // preference change
+ private IPropertyChangeListener propPrefListener;
+
+ /**
+ * Indicates if the action builder has been disposed
+ */
+ private boolean isDisposed = false;
+
+ /**
+ * The coolbar context menu manager.
+ */
+ private MenuManager coolbarPopupMenuManager;
+
+ /**
+ * Constructs a new action builder which contributes actions to the given window.
+ *
+ * @param configurer the action bar configurer for the window
+ */
+ public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
+ super(configurer);
+ window = configurer.getWindowConfigurer().getWindow();
+ }
+
+ /**
+ * Returns the window to which this action builder is contributing.
+ */
+ private IWorkbenchWindow getWindow() {
+ return window;
+ }
+
+ /**
+ * Hooks listeners on the preference store and the window's page, perspective and selection services.
+ */
+ private void hookListeners() {
+
+ // listener for the "close editors automatically"
+ // preference change
+ propPrefListener = new IPropertyChangeListener() {
+ @SuppressWarnings("synthetic-access")
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)) {
+ if (window.getShell() != null && !window.getShell().isDisposed()) {
+ // this property change notification could be from a non-UI thread
+ window.getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ updatePinActionToolbar();
+ }
+ });
+ }
+ }
+ }
+ };
+ /*
+ * In order to ensure that the pin action toolbar sets its size
+ * correctly, the pin action should set its visiblity before we call updatePinActionToolbar().
+ *
+ * In other words we always want the PinActionContributionItem to be notified before the
+ * WorkbenchActionBuilder.
+ */
+ WorkbenchPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propPrefListener);
+ }
+
+ @Override
+ public void fillActionBars(int flags) {
+ super.fillActionBars(flags);
+ if ((flags & FILL_PROXY) == 0) {
+ hookListeners();
+ }
+ }
+
+ /**
+ * Fills the coolbar with the workbench actions.
+ */
+ @Override
+ protected void fillCoolBar(ICoolBarManager coolBar) {
+
+ IActionBarConfigurer2 actionBarConfigurer = (IActionBarConfigurer2)getActionBarConfigurer();
+ { // Set up the context Menu
+ coolbarPopupMenuManager = new MenuManager();
+ coolbarPopupMenuManager.add(new ActionContributionItem(lockToolBarAction));
+ coolbarPopupMenuManager.add(new ActionContributionItem(editActionSetAction));
+ coolBar.setContextMenuManager(coolbarPopupMenuManager);
+ IMenuService menuService = (IMenuService)window.getService(IMenuService.class);
+ menuService.populateContributionManager(coolbarPopupMenuManager, "popup:windowCoolbarContextMenu"); //$NON-NLS-1$
+ }
+ coolBar.add(new GroupMarker(IIDEActionConstants.GROUP_FILE));
+ { // File Group
+ IToolBarManager fileToolBar = actionBarConfigurer.createToolBarManager();
+ fileToolBar.add(new Separator(IWorkbenchActionConstants.NEW_GROUP));
+ fileToolBar.add(newWizardDropDownAction);
+ fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
+ fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.SAVE_GROUP));
+ fileToolBar.add(saveAction);
+ fileToolBar.add(saveAllAction);
+ fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT));
+ fileToolBar.add(getPrintItem());
+ fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT));
+
+ fileToolBar.add(new Separator(IWorkbenchActionConstants.BUILD_GROUP));
+ fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.BUILD_EXT));
+ fileToolBar.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ // Add to the cool bar manager
+ coolBar.add(actionBarConfigurer.createToolBarContributionItem(fileToolBar, IWorkbenchActionConstants.TOOLBAR_FILE));
+ }
+
+ coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ coolBar.add(new GroupMarker(IIDEActionConstants.GROUP_NAV));
+ { // Navigate group
+ IToolBarManager navToolBar = actionBarConfigurer.createToolBarManager();
+ navToolBar.add(new Separator(IWorkbenchActionConstants.HISTORY_GROUP));
+ navToolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_APP));
+ navToolBar.add(backwardHistoryAction);
+ navToolBar.add(forwardHistoryAction);
+ navToolBar.add(new Separator(IWorkbenchActionConstants.PIN_GROUP));
+ navToolBar.add(getPinEditorItem());
+
+ // Add to the cool bar manager
+ coolBar.add(actionBarConfigurer.createToolBarContributionItem(navToolBar, IWorkbenchActionConstants.TOOLBAR_NAVIGATE));
+ }
+
+ coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR));
+
+ coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_HELP));
+
+ { // Help group
+ IToolBarManager helpToolBar = actionBarConfigurer.createToolBarManager();
+ helpToolBar.add(new Separator(IWorkbenchActionConstants.GROUP_HELP));
+ // helpToolBar.add(searchComboItem);
+ // Add the group for applications to contribute
+ helpToolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_APP));
+ // Add to the cool bar manager
+ coolBar.add(actionBarConfigurer.createToolBarContributionItem(helpToolBar, IWorkbenchActionConstants.TOOLBAR_HELP));
+ }
+
+ }
+
+ /**
+ * Fills the menu bar with the workbench actions.
+ */
+ @Override
+ protected void fillMenuBar(IMenuManager menuBar) {
+ menuBar.add(createFileMenu());
+ menuBar.add(createEditMenu());
+ menuBar.add(createNavigateMenu());
+ menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ menuBar.add(createWindowMenu());
+ menuBar.add(createHelpMenu());
+ }
+
+ /**
+ * Creates and returns the File menu.
+ */
+ private MenuManager createFileMenu() {
+ MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_file, IWorkbenchActionConstants.M_FILE);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
+ {
+ // create the New submenu, using the same id for it as the New action
+ String newText = IDEWorkbenchMessages.Workbench_new;
+ String newId = ActionFactory.NEW.getId();
+ MenuManager newMenu = new MenuManager(newText, newId);
+ newMenu.setActionDefinitionId("org.eclipse.ui.file.newQuickMenu"); //$NON-NLS-1$
+ newMenu.add(new Separator(newId));
+ this.newWizardMenu = new NewWizardMenu(getWindow());
+ newMenu.add(this.newWizardMenu);
+ newMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(newMenu);
+ }
+
+ menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
+ menu.add(new Separator());
+
+ menu.add(closeAction);
+ menu.add(closeAllAction);
+ // menu.add(closeAllSavedAction);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT));
+ menu.add(new Separator());
+ menu.add(saveAction);
+ menu.add(saveAsAction);
+ menu.add(saveAllAction);
+ menu.add(getRevertItem());
+ menu.add(new Separator());
+ menu.add(getMoveItem());
+ menu.add(getRenameItem());
+ menu.add(getRefreshItem());
+
+ menu.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT));
+ menu.add(new Separator());
+ menu.add(getPrintItem());
+ menu.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT));
+ menu.add(new Separator());
+ menu.add(new GroupMarker(IWorkbenchActionConstants.OPEN_EXT));
+ menu.add(new Separator());
+ menu.add(importResourcesAction);
+ menu.add(exportResourcesAction);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.IMPORT_EXT));
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ menu.add(new Separator());
+ menu.add(getPropertiesItem());
+
+ menu.add(ContributionItemFactory.REOPEN_EDITORS.create(getWindow()));
+ menu.add(new GroupMarker(IWorkbenchActionConstants.MRU));
+ menu.add(new Separator());
+
+ // If we're on OS X we shouldn't show this command in the File menu. It
+ // should be invisible to the user. However, we should not remove it -
+ // the carbon UI code will do a search through our menu structure
+ // looking for it when Cmd-Q is invoked (or Quit is chosen from the
+ // application menu.
+ ActionContributionItem quitItem = new ActionContributionItem(quitAction);
+ quitItem.setVisible(!Util.isMac());
+ menu.add(quitItem);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
+ return menu;
+ }
+
+ /**
+ * Creates and returns the Edit menu.
+ */
+ private MenuManager createEditMenu() {
+ MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_edit, IWorkbenchActionConstants.M_EDIT);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START));
+
+ menu.add(undoAction);
+ menu.add(redoAction);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));
+ menu.add(new Separator());
+
+ menu.add(getCutItem());
+ menu.add(getCopyItem());
+ menu.add(getPasteItem());
+ menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));
+ menu.add(new Separator());
+
+ menu.add(getDeleteItem());
+ menu.add(getSelectAllItem());
+ menu.add(new Separator());
+
+ menu.add(getFindItem());
+ menu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT));
+ menu.add(new Separator());
+
+ menu.add(getBookmarkItem());
+ menu.add(getTaskItem());
+ menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));
+
+ menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END));
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ return menu;
+ }
+
+ /**
+ * Creates and returns the Navigate menu.
+ */
+ private MenuManager createNavigateMenu() {
+ MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_navigate, IWorkbenchActionConstants.M_NAVIGATE);
+ menu.add(new GroupMarker(IWorkbenchActionConstants.NAV_START));
+ menu.add(goIntoAction);
+
+ MenuManager goToSubMenu = new MenuManager(IDEWorkbenchMessages.Workbench_goTo, IWorkbenchActionConstants.GO_TO);
+ menu.add(goToSubMenu);
+ goToSubMenu.add(backAction);
+ goToSubMenu.add(forwardAction);
+ goToSubMenu.add(upAction);
+ goToSubMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ menu.add(new Separator(IWorkbenchActionConstants.OPEN_EXT));
+ for (int i = 2; i < 5; ++i) {
+ menu.add(new Separator(IWorkbenchActionConstants.OPEN_EXT + i));
+ }
+ menu.add(new Separator(IWorkbenchActionConstants.SHOW_EXT));
+ {
+ MenuManager showInSubMenu = new MenuManager(IDEWorkbenchMessages.Workbench_showIn, "showIn"); //$NON-NLS-1$
+ showInSubMenu.setActionDefinitionId(showInQuickMenu.getActionDefinitionId());
+ showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getWindow()));
+ menu.add(showInSubMenu);
+ }
+ for (int i = 2; i < 5; ++i) {
+ menu.add(new Separator(IWorkbenchActionConstants.SHOW_EXT + i));
+ }
+ menu.add(new Separator());
+ menu.add(nextAction);
+ menu.add(previousAction);
+ menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(new GroupMarker(IWorkbenchActionConstants.NAV_END));
+
+ // TBD: Location of this actions
+ menu.add(new Separator());
+ menu.add(backwardHistoryAction);
+ menu.add(forwardHistoryAction);
+ return menu;
+ }
+
+ /**
+ * Creates and returns the Window menu.
+ */
+ private MenuManager createWindowMenu() {
+ MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_window, IWorkbenchActionConstants.M_WINDOW);
+
+ menu.add(newWindowAction);
+ menu.add(newEditorAction);
+
+ menu.add(new Separator());
+ addPerspectiveActions(menu);
+ menu.add(new Separator());
+ addKeyboardShortcuts(menu);
+ Separator sep = new Separator(IWorkbenchActionConstants.MB_ADDITIONS);
+ sep.setVisible(!Util.isMac());
+ menu.add(sep);
+
+ // See the comment for quit in createFileMenu
+ ActionContributionItem openPreferencesItem = new ActionContributionItem(openPreferencesAction);
+ openPreferencesItem.setVisible(!Util.isMac());
+ menu.add(openPreferencesItem);
+
+ menu.add(ContributionItemFactory.OPEN_WINDOWS.create(getWindow()));
+ return menu;
+ }
+
+ /**
+ * Adds the perspective actions to the specified menu.
+ */
+ private void addPerspectiveActions(MenuManager menu) {
+ {
+ String openText = IDEWorkbenchMessages.Workbench_openPerspective;
+ MenuManager changePerspMenuMgr = new MenuManager(openText, "openPerspective"); //$NON-NLS-1$
+ IContributionItem changePerspMenuItem = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(getWindow());
+ changePerspMenuMgr.add(changePerspMenuItem);
+ menu.add(changePerspMenuMgr);
+ }
+ {
+ MenuManager showViewMenuMgr = new MenuManager(IDEWorkbenchMessages.Workbench_showView, "showView"); //$NON-NLS-1$
+ IContributionItem showViewMenu = ContributionItemFactory.VIEWS_SHORTLIST.create(getWindow());
+ showViewMenuMgr.add(showViewMenu);
+ menu.add(showViewMenuMgr);
+ }
+ menu.add(new Separator());
+ menu.add(editActionSetAction);
+ menu.add(savePerspectiveAction);
+ menu.add(resetPerspectiveAction);
+ menu.add(closePerspAction);
+ menu.add(closeAllPerspsAction);
+ }
+
+ /**
+ * Adds the keyboard navigation submenu to the specified menu.
+ */
+ private void addKeyboardShortcuts(MenuManager menu) {
+ MenuManager subMenu = new MenuManager(IDEWorkbenchMessages.Workbench_shortcuts, "shortcuts"); //$NON-NLS-1$
+ menu.add(subMenu);
+ subMenu.add(showPartPaneMenuAction);
+ subMenu.add(showViewMenuAction);
+ subMenu.add(quickAccessAction);
+ subMenu.add(new Separator());
+ subMenu.add(maximizePartAction);
+ subMenu.add(minimizePartAction);
+ subMenu.add(new Separator());
+ subMenu.add(activateEditorAction);
+ subMenu.add(nextEditorAction);
+ subMenu.add(prevEditorAction);
+ subMenu.add(switchToEditorAction);
+ subMenu.add(new Separator());
+ subMenu.add(nextPartAction);
+ subMenu.add(prevPartAction);
+ subMenu.add(new Separator());
+ subMenu.add(nextPerspectiveAction);
+ subMenu.add(prevPerspectiveAction);
+ }
+
+ /**
+ * Creates and returns the Help menu.
+ */
+ private MenuManager createHelpMenu() {
+ MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_help, IWorkbenchActionConstants.M_HELP);
+ addSeparatorOrGroupMarker(menu, "group.intro"); //$NON-NLS-1$
+ // See if a welcome or intro page is specified
+ if (introAction != null) {
+ menu.add(introAction);
+ } else if (quickStartAction != null) {
+ menu.add(quickStartAction);
+ }
+ menu.add(new GroupMarker("group.intro.ext")); //$NON-NLS-1$
+ addSeparatorOrGroupMarker(menu, "group.main"); //$NON-NLS-1$
+ menu.add(helpContentsAction);
+ menu.add(helpSearchAction);
+ menu.add(dynamicHelpAction);
+ addSeparatorOrGroupMarker(menu, "group.assist"); //$NON-NLS-1$
+ // See if a tips and tricks page is specified
+ if (tipsAndTricksAction != null) {
+ menu.add(tipsAndTricksAction);
+ }
+ // HELP_START should really be the first item, but it was after
+ // quickStartAction and tipsAndTricksAction in 2.1.
+ menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START));
+ menu.add(new GroupMarker("group.main.ext")); //$NON-NLS-1$
+ addSeparatorOrGroupMarker(menu, "group.tutorials"); //$NON-NLS-1$
+ addSeparatorOrGroupMarker(menu, "group.tools"); //$NON-NLS-1$
+ addSeparatorOrGroupMarker(menu, "group.updates"); //$NON-NLS-1$
+ menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END));
+ addSeparatorOrGroupMarker(menu, IWorkbenchActionConstants.MB_ADDITIONS);
+ // about should always be at the bottom
+ menu.add(new Separator("group.about")); //$NON-NLS-1$
+
+ ActionContributionItem aboutItem = new ActionContributionItem(aboutAction);
+ aboutItem.setVisible(!Util.isMac());
+ menu.add(aboutItem);
+ menu.add(new GroupMarker("group.about.ext")); //$NON-NLS-1$
+ return menu;
+ }
+
+ /**
+ * Adds a <code>GroupMarker</code> or <code>Separator</code> to a menu. The test for whether a separator should be
+ * added is done by checking for the existence of a preference matching the string useSeparator.MENUID.GROUPID that
+ * is set to <code>true</code>.
+ *
+ * @param menu the menu to add to
+ * @param groupId the group id for the added separator or group marker
+ */
+ private void addSeparatorOrGroupMarker(MenuManager menu, String groupId) {
+ String prefId = "useSeparator." + menu.getId() + "." + groupId; //$NON-NLS-1$ //$NON-NLS-2$
+ boolean addExtraSeparators = IDEWorkbenchPlugin.getDefault().getPreferenceStore().getBoolean(prefId);
+ if (addExtraSeparators) {
+ menu.add(new Separator(groupId));
+ } else {
+ menu.add(new GroupMarker(groupId));
+ }
+ }
+
+ /**
+ * Disposes any resources and unhooks any listeners that are no longer needed. Called when the window is closed.
+ */
+ @Override
+ public void dispose() {
+ if (isDisposed) { return; }
+ isDisposed = true;
+ IMenuService menuService = (IMenuService)window.getService(IMenuService.class);
+ menuService.releaseContributions(coolbarPopupMenuManager);
+ coolbarPopupMenuManager.dispose();
+
+ getActionBarConfigurer().getStatusLineManager().remove(statusLineItem);
+ if (propPrefListener != null) {
+ WorkbenchPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(propPrefListener);
+ propPrefListener = null;
+ }
+
+ showInQuickMenu.dispose();
+ newQuickMenu.dispose();
+
+ // null out actions to make leak debugging easier
+ closeAction = null;
+ closeAllAction = null;
+ closeAllSavedAction = null;
+ closeOthersAction = null;
+ saveAction = null;
+ saveAllAction = null;
+ newWindowAction = null;
+ newEditorAction = null;
+ helpContentsAction = null;
+ helpSearchAction = null;
+ dynamicHelpAction = null;
+ aboutAction = null;
+ openPreferencesAction = null;
+ saveAsAction = null;
+ hideShowEditorAction = null;
+ savePerspectiveAction = null;
+ resetPerspectiveAction = null;
+ editActionSetAction = null;
+ closePerspAction = null;
+ lockToolBarAction = null;
+ closeAllPerspsAction = null;
+ showViewMenuAction = null;
+ showPartPaneMenuAction = null;
+ nextPartAction = null;
+ prevPartAction = null;
+ nextEditorAction = null;
+ prevEditorAction = null;
+ nextPerspectiveAction = null;
+ prevPerspectiveAction = null;
+ activateEditorAction = null;
+ maximizePartAction = null;
+ minimizePartAction = null;
+ switchToEditorAction = null;
+ quickAccessAction.dispose();
+ quickAccessAction = null;
+ backwardHistoryAction = null;
+ forwardHistoryAction = null;
+ undoAction = null;
+ redoAction = null;
+ quitAction = null;
+ goIntoAction = null;
+ backAction = null;
+ forwardAction = null;
+ upAction = null;
+ nextAction = null;
+ previousAction = null;
+ newWizardAction = null;
+ newWizardDropDownAction = null;
+ importResourcesAction = null;
+ exportResourcesAction = null;
+ quickStartAction = null;
+ tipsAndTricksAction = null;
+ showInQuickMenu = null;
+ newQuickMenu = null;
+ newWizardMenu = null;
+ statusLineItem = null;
+ propPrefListener = null;
+ introAction = null;
+
+ super.dispose();
+ }
+
+ void updateModeLine(final String text) {
+ statusLineItem.setText(text);
+ }
+
+ /**
+ * Returns true if the menu with the given ID should be considered as an OLE container menu. Container menus are
+ * preserved in OLE menu merging.
+ */
+ @Override
+ public boolean isApplicationMenu(String menuId) {
+ if (menuId.equals(IWorkbenchActionConstants.M_FILE)) { return true; }
+ if (menuId.equals(IWorkbenchActionConstants.M_WINDOW)) { return true; }
+ return false;
+ }
+
+ /**
+ * Return whether or not given id matches the id of the coolitems that the workbench creates.
+ */
+ public boolean isWorkbenchCoolItemId(String id) {
+ if (IWorkbenchActionConstants.TOOLBAR_FILE.equalsIgnoreCase(id)) { return true; }
+ if (IWorkbenchActionConstants.TOOLBAR_NAVIGATE.equalsIgnoreCase(id)) { return true; }
+ return false;
+ }
+
+ /**
+ * Fills the status line with the workbench contribution items.
+ */
+ @Override
+ protected void fillStatusLine(IStatusLineManager statusLine) {
+ statusLine.add(statusLineItem);
+ }
+
+ /**
+ * Creates actions (and contribution items) for the menu bar, toolbar and status line.
+ */
+ @Override
+ protected void makeActions(final IWorkbenchWindow window) {
+ // @issue should obtain from ConfigurationItemFactory
+ statusLineItem = new StatusLineContributionItem("ModeContributionItem"); //$NON-NLS-1$
+
+ newWizardAction = ActionFactory.NEW.create(window);
+ register(newWizardAction);
+
+ newWizardDropDownAction = IDEActionFactory.NEW_WIZARD_DROP_DOWN.create(window);
+ register(newWizardDropDownAction);
+
+ importResourcesAction = ActionFactory.IMPORT.create(window);
+ register(importResourcesAction);
+
+ exportResourcesAction = ActionFactory.EXPORT.create(window);
+ register(exportResourcesAction);
+
+ saveAction = ActionFactory.SAVE.create(window);
+ register(saveAction);
+
+ saveAsAction = ActionFactory.SAVE_AS.create(window);
+ register(saveAsAction);
+
+ saveAllAction = ActionFactory.SAVE_ALL.create(window);
+ register(saveAllAction);
+
+ newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(getWindow());
+ newWindowAction.setText(IDEWorkbenchMessages.Workbench_openNewWindow);
+ register(newWindowAction);
+
+ newEditorAction = ActionFactory.NEW_EDITOR.create(window);
+ register(newEditorAction);
+
+ undoAction = ActionFactory.UNDO.create(window);
+ register(undoAction);
+
+ redoAction = ActionFactory.REDO.create(window);
+ register(redoAction);
+
+ closeAction = ActionFactory.CLOSE.create(window);
+ register(closeAction);
+
+ closeAllAction = ActionFactory.CLOSE_ALL.create(window);
+ register(closeAllAction);
+
+ closeOthersAction = ActionFactory.CLOSE_OTHERS.create(window);
+ register(closeOthersAction);
+
+ closeAllSavedAction = ActionFactory.CLOSE_ALL_SAVED.create(window);
+ register(closeAllSavedAction);
+
+ helpContentsAction = ActionFactory.HELP_CONTENTS.create(window);
+ register(helpContentsAction);
+
+ helpSearchAction = ActionFactory.HELP_SEARCH.create(window);
+ register(helpSearchAction);
+
+ dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create(window);
+ register(dynamicHelpAction);
+
+ aboutAction = ActionFactory.ABOUT.create(window);
+ aboutAction.setImageDescriptor(IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_OBJS_DEFAULT_PROD));
+ register(aboutAction);
+
+ openPreferencesAction = ActionFactory.PREFERENCES.create(window);
+ register(openPreferencesAction);
+
+ makeFeatureDependentActions(window);
+
+ // Actions for invisible accelerators
+ showViewMenuAction = ActionFactory.SHOW_VIEW_MENU.create(window);
+ register(showViewMenuAction);
+
+ showPartPaneMenuAction = ActionFactory.SHOW_PART_PANE_MENU.create(window);
+ register(showPartPaneMenuAction);
+
+ nextEditorAction = ActionFactory.NEXT_EDITOR.create(window);
+ register(nextEditorAction);
+ prevEditorAction = ActionFactory.PREVIOUS_EDITOR.create(window);
+ register(prevEditorAction);
+ ActionFactory.linkCycleActionPair(nextEditorAction, prevEditorAction);
+
+ nextPartAction = ActionFactory.NEXT_PART.create(window);
+ register(nextPartAction);
+ prevPartAction = ActionFactory.PREVIOUS_PART.create(window);
+ register(prevPartAction);
+ ActionFactory.linkCycleActionPair(nextPartAction, prevPartAction);
+
+ nextPerspectiveAction = ActionFactory.NEXT_PERSPECTIVE.create(window);
+ register(nextPerspectiveAction);
+ prevPerspectiveAction = ActionFactory.PREVIOUS_PERSPECTIVE.create(window);
+ register(prevPerspectiveAction);
+ ActionFactory.linkCycleActionPair(nextPerspectiveAction, prevPerspectiveAction);
+
+ activateEditorAction = ActionFactory.ACTIVATE_EDITOR.create(window);
+ register(activateEditorAction);
+
+ maximizePartAction = ActionFactory.MAXIMIZE.create(window);
+ register(maximizePartAction);
+
+ minimizePartAction = ActionFactory.MINIMIZE.create(window);
+ register(minimizePartAction);
+
+ switchToEditorAction = ActionFactory.SHOW_OPEN_EDITORS.create(window);
+ register(switchToEditorAction);
+
+ workbookEditorsAction = ActionFactory.SHOW_WORKBOOK_EDITORS.create(window);
+ register(workbookEditorsAction);
+
+ quickAccessAction = ActionFactory.SHOW_QUICK_ACCESS.create(window);
+
+ hideShowEditorAction = ActionFactory.SHOW_EDITOR.create(window);
+ register(hideShowEditorAction);
+ savePerspectiveAction = ActionFactory.SAVE_PERSPECTIVE.create(window);
+ register(savePerspectiveAction);
+ editActionSetAction = ActionFactory.EDIT_ACTION_SETS.create(window);
+ register(editActionSetAction);
+ lockToolBarAction = ActionFactory.LOCK_TOOL_BAR.create(window);
+ register(lockToolBarAction);
+ resetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window);
+ register(resetPerspectiveAction);
+ closePerspAction = ActionFactory.CLOSE_PERSPECTIVE.create(window);
+ register(closePerspAction);
+ closeAllPerspsAction = ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window);
+ register(closeAllPerspsAction);
+
+ forwardHistoryAction = ActionFactory.FORWARD_HISTORY.create(window);
+ register(forwardHistoryAction);
+
+ backwardHistoryAction = ActionFactory.BACKWARD_HISTORY.create(window);
+ register(backwardHistoryAction);
+
+ quitAction = ActionFactory.QUIT.create(window);
+ register(quitAction);
+
+ goIntoAction = ActionFactory.GO_INTO.create(window);
+ register(goIntoAction);
+
+ backAction = ActionFactory.BACK.create(window);
+ register(backAction);
+
+ forwardAction = ActionFactory.FORWARD.create(window);
+ register(forwardAction);
+
+ upAction = ActionFactory.UP.create(window);
+ register(upAction);
+
+ nextAction = ActionFactory.NEXT.create(window);
+ nextAction.setImageDescriptor(IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV));
+ register(nextAction);
+
+ previousAction = ActionFactory.PREVIOUS.create(window);
+ previousAction.setImageDescriptor(IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV));
+ register(previousAction);
+
+ if (window.getWorkbench().getIntroManager().hasIntro()) {
+ introAction = ActionFactory.INTRO.create(window);
+ register(introAction);
+ }
+
+ String showInQuickMenuId = IWorkbenchCommandConstants.NAVIGATE_SHOW_IN_QUICK_MENU;
+ showInQuickMenu = new QuickMenuAction(showInQuickMenuId) {
+ @Override
+ protected void fillMenu(IMenuManager menu) {
+ menu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(window));
+ }
+ };
+ register(showInQuickMenu);
+
+ final String newQuickMenuId = "org.eclipse.ui.file.newQuickMenu"; //$NON-NLS-1$
+ newQuickMenu = new QuickMenuAction(newQuickMenuId) {
+ @Override
+ protected void fillMenu(IMenuManager menu) {
+ menu.add(new NewWizardMenu(window));
+ }
+ };
+ register(newQuickMenu);
+
+ }
+
+ /**
+ * Creates the feature-dependent actions for the menu bar.
+ */
+ @SuppressWarnings("deprecation")
+ private void makeFeatureDependentActions(IWorkbenchWindow window) {
+ AboutInfo[] infos = null;
+
+ IPreferenceStore prefs = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
+
+ // Optimization: avoid obtaining the about infos if the platform state is
+ // unchanged from last time. See bug 75130 for details.
+ String stateKey = "platformState"; //$NON-NLS-1$
+ String prevState = prefs.getString(stateKey);
+ String currentState = String.valueOf(Platform.getStateStamp());
+ boolean sameState = currentState.equals(prevState);
+ if (!sameState) {
+ prefs.putValue(stateKey, currentState);
+ }
+
+ // See if a welcome page is specified.
+ // Optimization: if welcome pages were found on a previous run, then just add the action.
+ String quickStartKey = IDEActionFactory.QUICK_START.getId();
+ String showQuickStart = prefs.getString(quickStartKey);
+ if (sameState && "true".equals(showQuickStart)) { //$NON-NLS-1$
+ quickStartAction = IDEActionFactory.QUICK_START.create(window);
+ register(quickStartAction);
+ } else if (sameState && "false".equals(showQuickStart)) { //$NON-NLS-1$
+ // do nothing
+ } else {
+ // do the work
+ infos = IDEWorkbenchPlugin.getDefault().getFeatureInfos();
+ boolean found = hasWelcomePage(infos);
+ prefs.setValue(quickStartKey, String.valueOf(found));
+ if (found) {
+ quickStartAction = IDEActionFactory.QUICK_START.create(window);
+ register(quickStartAction);
+ }
+ }
+
+ // See if a tips and tricks page is specified.
+ // Optimization: if tips and tricks were found on a previous run, then just add the action.
+ String tipsAndTricksKey = IDEActionFactory.TIPS_AND_TRICKS.getId();
+ String showTipsAndTricks = prefs.getString(tipsAndTricksKey);
+ if (sameState && "true".equals(showTipsAndTricks)) { //$NON-NLS-1$
+ tipsAndTricksAction = IDEActionFactory.TIPS_AND_TRICKS.create(window);
+ register(tipsAndTricksAction);
+ } else if (sameState && "false".equals(showTipsAndTricks)) { //$NON-NLS-1$
+ // do nothing
+ } else {
+ // do the work
+ if (infos == null) {
+ infos = IDEWorkbenchPlugin.getDefault().getFeatureInfos();
+ }
+ boolean found = hasTipsAndTricks(infos);
+ prefs.setValue(tipsAndTricksKey, String.valueOf(found));
+ if (found) {
+ tipsAndTricksAction = IDEActionFactory.TIPS_AND_TRICKS.create(window);
+ register(tipsAndTricksAction);
+ }
+ }
+ }
+
+ /**
+ * Returns whether any of the given infos have a welcome page.
+ *
+ * @param infos the infos
+ * @return <code>true</code> if a welcome page was found, <code>false</code> if not
+ */
+ private boolean hasWelcomePage(AboutInfo[] infos) {
+ for (int i = 0; i < infos.length; i++) {
+ if (infos[i].getWelcomePageURL() != null) { return true; }
+ }
+ return false;
+ }
+
+ /**
+ * Returns whether any of the given infos have tips and tricks.
+ *
+ * @param infos the infos
+ * @return <code>true</code> if tips and tricks were found, <code>false</code> if not
+ */
+ private boolean hasTipsAndTricks(AboutInfo[] infos) {
+ for (int i = 0; i < infos.length; i++) {
+ if (infos[i].getTipsAndTricksHref() != null) { return true; }
+ }
+ return false;
+ }
+
+ /**
+ * Update the pin action's tool bar
+ */
+ void updatePinActionToolbar() {
+
+ ICoolBarManager coolBarManager = getActionBarConfigurer().getCoolBarManager();
+ IContributionItem cbItem = coolBarManager.find(IWorkbenchActionConstants.TOOLBAR_NAVIGATE);
+ if (!(cbItem instanceof IToolBarContributionItem)) {
+ // This should not happen
+ IDEWorkbenchPlugin.log("Navigation toolbar contribution item is missing"); //$NON-NLS-1$
+ return;
+ }
+ IToolBarContributionItem toolBarItem = (IToolBarContributionItem)cbItem;
+ IToolBarManager toolBarManager = toolBarItem.getToolBarManager();
+ if (toolBarManager == null) {
+ // error if this happens, navigation toolbar assumed to always exist
+ IDEWorkbenchPlugin.log("Navigate toolbar is missing"); //$NON-NLS-1$
+ return;
+ }
+
+ toolBarManager.update(false);
+ toolBarItem.update(ICoolBarManager.SIZE);
+ }
+
+ private IContributionItem getPinEditorItem() {
+ return ContributionItemFactory.PIN_EDITOR.create(window);
+ }
+
+ private IContributionItem getCutItem() {
+ return getItem( ActionFactory.CUT.getId(), ActionFactory.CUT.getCommandId(), ISharedImages.IMG_TOOL_CUT, ISharedImages.IMG_TOOL_CUT_DISABLED,
+ WorkbenchMessages.Workbench_cut, WorkbenchMessages.Workbench_cutToolTip, null);
+ }
+
+ private IContributionItem getCopyItem() {
+ return getItem( ActionFactory.COPY.getId(), ActionFactory.COPY.getCommandId(), ISharedImages.IMG_TOOL_COPY, ISharedImages.IMG_TOOL_COPY_DISABLED,
+ WorkbenchMessages.Workbench_copy, WorkbenchMessages.Workbench_copyToolTip, null);
+ }
+
+ private IContributionItem getPasteItem() {
+ return getItem( ActionFactory.PASTE.getId(), ActionFactory.PASTE.getCommandId(), ISharedImages.IMG_TOOL_PASTE, ISharedImages.IMG_TOOL_PASTE_DISABLED,
+ WorkbenchMessages.Workbench_paste, WorkbenchMessages.Workbench_pasteToolTip, null);
+ }
+
+ private IContributionItem getPrintItem() {
+ return getItem( ActionFactory.PRINT.getId(), ActionFactory.PRINT.getCommandId(), ISharedImages.IMG_ETOOL_PRINT_EDIT,
+ ISharedImages.IMG_ETOOL_PRINT_EDIT_DISABLED, WorkbenchMessages.Workbench_print, WorkbenchMessages.Workbench_printToolTip, null);
+ }
+
+ private IContributionItem getSelectAllItem() {
+ return getItem( ActionFactory.SELECT_ALL.getId(), ActionFactory.SELECT_ALL.getCommandId(), null, null, WorkbenchMessages.Workbench_selectAll,
+ WorkbenchMessages.Workbench_selectAllToolTip, null);
+ }
+
+ private IContributionItem getFindItem() {
+ return getItem( ActionFactory.FIND.getId(), ActionFactory.FIND.getCommandId(), null, null, WorkbenchMessages.Workbench_findReplace,
+ WorkbenchMessages.Workbench_findReplaceToolTip, null);
+ }
+
+ private IContributionItem getBookmarkItem() {
+ return getItem( IDEActionFactory.BOOKMARK.getId(), IDEActionFactory.BOOKMARK.getCommandId(), null, null, IDEWorkbenchMessages.Workbench_addBookmark,
+ IDEWorkbenchMessages.Workbench_addBookmarkToolTip, null);
+ }
+
+ private IContributionItem getTaskItem() {
+ return getItem( IDEActionFactory.ADD_TASK.getId(), IDEActionFactory.ADD_TASK.getCommandId(), null, null, IDEWorkbenchMessages.Workbench_addTask,
+ IDEWorkbenchMessages.Workbench_addTaskToolTip, null);
+ }
+
+ private IContributionItem getDeleteItem() {
+ return getItem( ActionFactory.DELETE.getId(), ActionFactory.DELETE.getCommandId(), ISharedImages.IMG_TOOL_DELETE,
+ ISharedImages.IMG_TOOL_DELETE_DISABLED, WorkbenchMessages.Workbench_delete, WorkbenchMessages.Workbench_deleteToolTip,
+ IWorkbenchHelpContextIds.DELETE_RETARGET_ACTION);
+ }
+
+ private IContributionItem getRevertItem() {
+ return getItem( ActionFactory.REVERT.getId(), ActionFactory.REVERT.getCommandId(), null, null, WorkbenchMessages.Workbench_revert,
+ WorkbenchMessages.Workbench_revertToolTip, null);
+ }
+
+ private IContributionItem getRefreshItem() {
+ return getItem( ActionFactory.REFRESH.getId(), ActionFactory.REFRESH.getCommandId(), null, null, WorkbenchMessages.Workbench_refresh,
+ WorkbenchMessages.Workbench_refreshToolTip, null);
+ }
+
+ private IContributionItem getPropertiesItem() {
+ return getItem( ActionFactory.PROPERTIES.getId(), ActionFactory.PROPERTIES.getCommandId(), null, null, WorkbenchMessages.Workbench_properties,
+ WorkbenchMessages.Workbench_propertiesToolTip, null);
+ }
+
+ private IContributionItem getMoveItem() {
+ return getItem( ActionFactory.MOVE.getId(), ActionFactory.MOVE.getCommandId(), null, null, WorkbenchMessages.Workbench_move,
+ WorkbenchMessages.Workbench_moveToolTip, null);
+ }
+
+ private IContributionItem getRenameItem() {
+ return getItem( ActionFactory.RENAME.getId(), ActionFactory.RENAME.getCommandId(), null, null, WorkbenchMessages.Workbench_rename,
+ WorkbenchMessages.Workbench_renameToolTip, null);
+ }
+
+ private IContributionItem getItem(String actionId, String commandId, String image, String disabledImage, String label, String tooltip, String helpContextId) {
+ ISharedImages sharedImages = getWindow().getWorkbench().getSharedImages();
+
+ IActionCommandMappingService acms = (IActionCommandMappingService)getWindow().getService(IActionCommandMappingService.class);
+ acms.map(actionId, commandId);
+
+ CommandContributionItemParameter commandParm = new CommandContributionItemParameter(getWindow(), actionId, commandId, null,
+ sharedImages.getImageDescriptor(image),
+ sharedImages.getImageDescriptor(disabledImage), null, label, null,
+ tooltip, CommandContributionItem.STYLE_PUSH, null, false);
+ return new CommandContributionItem(commandParm);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationWorkbenchAdvisor.java b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationWorkbenchAdvisor.java
new file mode 100644
index 000000000..f16de5b36
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationWorkbenchAdvisor.java
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.rcp.application;
+
+import java.text.Collator;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.util.Policy;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.tcf.te.rcp.application.nls.Messages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.application.IWorkbenchConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+import org.eclipse.ui.internal.PluginActionBuilder;
+
+
+/**
+ * Target Explorer, RCP: Workbench advisor implementation.
+ */
+@SuppressWarnings("restriction")
+public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
+
+ private final static String PERSPECTIVE_ID = "org.eclipse.tcf.te.ui.perspective"; //$NON-NLS-1$
+
+ private static ApplicationWorkbenchAdvisor workbenchAdvisor = null;
+
+ private Listener settingsChangeListener;
+
+ /**
+ * Creates a new workbench advisor instance.
+ */
+ public ApplicationWorkbenchAdvisor() {
+ super();
+ if (workbenchAdvisor != null) { throw new IllegalStateException(); }
+ workbenchAdvisor = this;
+
+ Listener closeListener = new Listener() {
+ public void handleEvent(Event event) {
+ boolean doExit = ApplicationWorkbenchWindowAdvisor.promptOnExit(null);
+ event.doit = doExit;
+ if (!doExit) event.type = SWT.None;
+ }
+ };
+ Display.getDefault().addListener(SWT.Close, closeListener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize
+ */
+ @Override
+ public void initialize(IWorkbenchConfigurer configurer) {
+
+ PluginActionBuilder.setAllowIdeLogging(false);
+
+ // make sure we always save and restore workspace state
+ configurer.setSaveAndRestore(true);
+
+ // show Help button in JFace dialogs
+ TrayDialog.setDialogHelpAvailable(true);
+
+ Policy.setComparator(Collator.getInstance());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#preStartup()
+ */
+ @Override
+ public void preStartup() {
+
+ // Suspend background jobs while we startup
+ Job.getJobManager().suspend();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#postStartup()
+ */
+ @Override
+ public void postStartup() {
+ try {
+ initializeSettingsChangeListener();
+ Display.getCurrent().addListener(SWT.Settings, settingsChangeListener);
+ } finally {// Resume background jobs after we startup
+ Job.getJobManager().resume();
+ }
+ }
+
+ /**
+ * Initialize the listener for settings changes.
+ */
+ private void initializeSettingsChangeListener() {
+ settingsChangeListener = new Listener() {
+
+ boolean currentHighContrast = Display.getCurrent().getHighContrast();
+
+ public void handleEvent(org.eclipse.swt.widgets.Event event) {
+ if (Display.getCurrent().getHighContrast() == currentHighContrast) return;
+
+ currentHighContrast = !currentHighContrast;
+
+ // make sure they really want to do this
+ if (new MessageDialog(null, Messages.SystemSettingsChange_title, null, Messages.SystemSettingsChange_message,
+ MessageDialog.QUESTION, new String[] { Messages.SystemSettingsChange_yes,
+ Messages.SystemSettingsChange_no }, 1).open() == Window.OK) {
+ PlatformUI.getWorkbench().restart();
+ }
+ }
+ };
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#preShutdown()
+ */
+ @Override
+ public boolean preShutdown() {
+ Display.getCurrent().removeListener(SWT.Settings, settingsChangeListener);
+ return super.preShutdown();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
+ */
+ @Override
+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
+ return new ApplicationWorkbenchWindowAdvisor(this, configurer);
+ }
+
+ /**
+ * Return true if the intro plugin is present and false otherwise.
+ *
+ * @return boolean
+ */
+ public boolean hasIntro() {
+ return getWorkbenchConfigurer().getWorkbench().getIntroManager().hasIntro();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.application.WorkbenchAdvisor
+ */
+ @Override
+ public String getInitialWindowPerspectiveId() {
+ return PERSPECTIVE_ID;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationWorkbenchWindowAdvisor.java b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationWorkbenchWindowAdvisor.java
new file mode 100644
index 000000000..b55a4b5ed
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/ApplicationWorkbenchWindowAdvisor.java
@@ -0,0 +1,394 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.rcp.application;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProduct;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.tcf.te.rcp.application.activator.UIPlugin;
+import org.eclipse.tcf.te.rcp.application.nls.Messages;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IPageListener;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartConstants;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PerspectiveAdapter;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+import org.eclipse.ui.part.EditorInputTransfer;
+
+
+/**
+ * Target Explorer, RCP: Workbench window advisor implementation.
+ */
+public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
+ // (boolean) Prompt for exit confirmation when last window closed.
+ public static final String EXIT_PROMPT_ON_CLOSE_LAST_WINDOW = "EXIT_PROMPT_ON_CLOSE_LAST_WINDOW"; //$NON-NLS-1$
+
+ private ApplicationWorkbenchAdvisor wbAdvisor;
+ private IEditorPart lastActiveEditor = null;
+ private IPerspectiveDescriptor lastPerspective = null;
+
+ private IWorkbenchPage lastActivePage;
+ private String lastEditorTitle = ""; //$NON-NLS-1$
+
+ private IPropertyListener editorPropertyListener = new IPropertyListener() {
+ @SuppressWarnings("synthetic-access")
+ public void propertyChanged(Object source, int propId) {
+ if (propId == IWorkbenchPartConstants.PROP_TITLE) {
+ if (lastActiveEditor != null) {
+ String newTitle = lastActiveEditor.getTitle();
+ if (!lastEditorTitle.equals(newTitle)) {
+ recomputeTitle();
+ }
+ }
+ }
+ }
+ };
+
+ private IAdaptable lastInput;
+ private IWorkbenchAction openPerspectiveAction;
+
+ /**
+ * Crates a new IDE workbench window advisor.
+ *
+ * @param wbAdvisor the workbench advisor
+ * @param configurer the window configurer
+ */
+ public ApplicationWorkbenchWindowAdvisor(ApplicationWorkbenchAdvisor wbAdvisor, IWorkbenchWindowConfigurer configurer) {
+ super(configurer);
+ this.wbAdvisor = wbAdvisor;
+ }
+
+ /**
+ * Returns the workbench.
+ *
+ * @return the workbench
+ */
+ private IWorkbench getWorkbench() {
+ return getWindowConfigurer().getWorkbenchConfigurer().getWorkbench();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#createActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)
+ */
+ @Override
+ public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
+ return new ApplicationActionBarAdvisor(configurer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#preWindowShellClose
+ */
+ @Override
+ public boolean preWindowShellClose() {
+ if (getWorkbench().getWorkbenchWindowCount() > 1) { return true; }
+ // the user has asked to close the last window, while will cause the
+ // workbench to close in due course - prompt the user for confirmation
+ return promptOnExit(getWindowConfigurer().getWindow().getShell());
+ }
+
+ /**
+ * Asks the user whether the workbench should really be closed. Only asks if the preference is enabled.
+ *
+ * @param parentShell the parent shell to use for the confirmation dialog
+ * @return <code>true</code> if OK to exit, <code>false</code> if the user canceled
+ */
+ static boolean promptOnExit(Shell parentShell) {
+ boolean promptOnExit = Platform.getPreferencesService().getBoolean(UIPlugin.getUniqueIdentifier(),
+ EXIT_PROMPT_ON_CLOSE_LAST_WINDOW,
+ false,
+ null);
+
+ if (promptOnExit) {
+ String message;
+
+ String productName = null;
+ IProduct product = Platform.getProduct();
+ if (product != null) {
+ productName = product.getName();
+ }
+ if (productName == null) {
+ message = Messages.PromptOnExitDialog_message0;
+ } else {
+ message = NLS.bind(Messages.PromptOnExitDialog_message1, productName);
+ }
+
+ MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm( parentShell, Messages.PromptOnExitDialog_shellTitle,
+ message,
+ Messages.PromptOnExitDialog_choice, false, null, null);
+ if (dlg.getReturnCode() != IDialogConstants.OK_ID) { return false; }
+ if (dlg.getToggleState()) {
+ InstanceScope.INSTANCE.getNode(UIPlugin.getUniqueIdentifier()).putBoolean(EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, false);
+ }
+ }
+
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#preWindowOpen
+ */
+ @Override
+ public void preWindowOpen() {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+
+ // show the shortcut bar and progress indicator, which are hidden by
+ // default
+ configurer.setShowPerspectiveBar(true);
+ configurer.setShowFastViewBars(true);
+ configurer.setShowProgressIndicator(true);
+
+ // add the drag and drop support for the editor area
+ configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance());
+ configurer.addEditorAreaTransfer(FileTransfer.getInstance());
+
+ hookTitleUpdateListeners(configurer);
+ }
+
+ /**
+ * Hooks the listeners needed on the window
+ *
+ * @param configurer
+ */
+ @SuppressWarnings("synthetic-access")
+ private void hookTitleUpdateListeners(IWorkbenchWindowConfigurer configurer) {
+ // hook up the listeners to update the window title
+ configurer.getWindow().addPageListener(new IPageListener() {
+ public void pageActivated(IWorkbenchPage page) {
+ updateTitle(false);
+ }
+
+ public void pageClosed(IWorkbenchPage page) {
+ updateTitle(false);
+ }
+
+ public void pageOpened(IWorkbenchPage page) {
+ // do nothing
+ }
+ });
+ configurer.getWindow().addPerspectiveListener(new PerspectiveAdapter() {
+ @Override
+ public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
+ updateTitle(false);
+ }
+
+ @Override
+ public void perspectiveSavedAs(IWorkbenchPage page, IPerspectiveDescriptor oldPerspective, IPerspectiveDescriptor newPerspective) {
+ updateTitle(false);
+ }
+
+ @Override
+ public void perspectiveDeactivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
+ updateTitle(false);
+ }
+ });
+ configurer.getWindow().getPartService().addPartListener(new IPartListener2() {
+ public void partActivated(IWorkbenchPartReference ref) {
+ if (ref instanceof IEditorReference) {
+ updateTitle(false);
+ }
+ }
+
+ public void partBroughtToTop(IWorkbenchPartReference ref) {
+ if (ref instanceof IEditorReference) {
+ updateTitle(false);
+ }
+ }
+
+ public void partClosed(IWorkbenchPartReference ref) {
+ updateTitle(false);
+ }
+
+ public void partDeactivated(IWorkbenchPartReference ref) {
+ // do nothing
+ }
+
+ public void partOpened(IWorkbenchPartReference ref) {
+ // do nothing
+ }
+
+ public void partHidden(IWorkbenchPartReference ref) {
+ if (ref.getPart(false) == lastActiveEditor && lastActiveEditor != null) {
+ updateTitle(true);
+ }
+ }
+
+ public void partVisible(IWorkbenchPartReference ref) {
+ if (ref.getPart(false) == lastActiveEditor && lastActiveEditor != null) {
+ updateTitle(false);
+ }
+ }
+
+ public void partInputChanged(IWorkbenchPartReference ref) {
+ // do nothing
+ }
+ });
+ }
+
+ private String computeTitle() {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ IWorkbenchPage currentPage = configurer.getWindow().getActivePage();
+ IEditorPart activeEditor = null;
+ if (currentPage != null) {
+ activeEditor = lastActiveEditor;
+ }
+
+ String title = null;
+ IProduct product = Platform.getProduct();
+ if (product != null) {
+ title = product.getName();
+ }
+ if (title == null) {
+ title = ""; //$NON-NLS-1$
+ }
+
+ if (currentPage != null) {
+ if (activeEditor != null) {
+ lastEditorTitle = activeEditor.getTitleToolTip();
+ title = NLS.bind("{0} - {1}", lastEditorTitle, title); //$NON-NLS-1$
+ }
+ IPerspectiveDescriptor persp = currentPage.getPerspective();
+ String label = ""; //$NON-NLS-1$
+ if (persp != null) {
+ label = persp.getLabel();
+ }
+ IAdaptable input = currentPage.getInput();
+ if (input != null && !input.equals(wbAdvisor.getDefaultPageInput())) {
+ label = currentPage.getLabel();
+ }
+ if (label != null && !label.equals("")) { //$NON-NLS-1$
+ title = NLS.bind("{0} - {1}", label, title); //$NON-NLS-1$
+ }
+ }
+
+ return title;
+ }
+
+ private void recomputeTitle() {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ String oldTitle = configurer.getTitle();
+ String newTitle = computeTitle();
+ if (!newTitle.equals(oldTitle)) {
+ configurer.setTitle(newTitle);
+ }
+ }
+
+ /**
+ * Updates the window title. Format will be: [pageInput -] [currentPerspective -] [editorInput -] [workspaceLocation
+ * -] productName
+ *
+ * @param editorHidden TODO
+ */
+ private void updateTitle(boolean editorHidden) {
+ IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+ IWorkbenchWindow window = configurer.getWindow();
+ IEditorPart activeEditor = null;
+ IWorkbenchPage currentPage = window.getActivePage();
+ IPerspectiveDescriptor persp = null;
+ IAdaptable input = null;
+
+ if (currentPage != null) {
+ activeEditor = currentPage.getActiveEditor();
+ persp = currentPage.getPerspective();
+ input = currentPage.getInput();
+ }
+
+ if (editorHidden) {
+ activeEditor = null;
+ }
+
+ // Nothing to do if the editor hasn't changed
+ if (activeEditor == lastActiveEditor && currentPage == lastActivePage && persp == lastPerspective && input == lastInput) { return; }
+
+ if (lastActiveEditor != null) {
+ lastActiveEditor.removePropertyListener(editorPropertyListener);
+ }
+
+ lastActiveEditor = activeEditor;
+ lastActivePage = currentPage;
+ lastPerspective = persp;
+ lastInput = input;
+
+ if (activeEditor != null) {
+ activeEditor.addPropertyListener(editorPropertyListener);
+ }
+
+ recomputeTitle();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#createEmptyWindowContents(org.eclipse.ui.application.IWorkbenchWindowConfigurer,
+ * org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public Control createEmptyWindowContents(Composite parent) {
+ final IWorkbenchWindow window = getWindowConfigurer().getWindow();
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ Display display = composite.getDisplay();
+ Color bgCol = display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND);
+ composite.setBackground(bgCol);
+ Label label = new Label(composite, SWT.WRAP);
+ label.setForeground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
+ label.setBackground(bgCol);
+ label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
+ String msg = Messages.ApplicationWorkbenchAdvisor_noPerspective;
+ label.setText(msg);
+ ToolBarManager toolBarManager = new ToolBarManager();
+ // TODO: should obtain the open perspective action from ActionFactory
+ openPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window);
+ toolBarManager.add(openPerspectiveAction);
+ ToolBar toolBar = toolBarManager.createControl(composite);
+ toolBar.setBackground(bgCol);
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (openPerspectiveAction != null) {
+ openPerspectiveAction.dispose();
+ openPerspectiveAction = null;
+ }
+ super.dispose();
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/activator/UIPlugin.java
new file mode 100644
index 000000000..5cc503063
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/activator/UIPlugin.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.rcp.application.activator;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class UIPlugin extends AbstractUIPlugin {
+ // The shared instance
+ private static UIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public UIPlugin() {
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static UIPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Convenience method which returns the unique identifier of this plugin.
+ */
+ public static String getUniqueIdentifier() {
+ if (getDefault() != null && getDefault().getBundle() != null) {
+ return getDefault().getBundle().getSymbolicName();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/nls/Messages.java
new file mode 100644
index 000000000..0c30dad23
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/nls/Messages.java
@@ -0,0 +1,47 @@
+/**
+ * Messages.java
+ * Created on Dec 05, 2010
+ *
+ * Copyright (c) 2010 Wind River Systems Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.rcp.application.nls;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Target Management product bundle externalized strings management.
+ *
+ * @author uwe.stieber@windriver.com
+ */
+public class Messages extends NLS {
+
+ // The plug-in resource bundle name
+ private static final String BUNDLE_NAME = "org.eclipse.tcf.te.rcp.internal.nls.Messages"; //$NON-NLS-1$
+
+ /**
+ * Static constructor.
+ */
+ static {
+ // Load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ // **** Declare externalized string id's down here *****
+
+ public static String SystemSettingsChange_title;
+ public static String SystemSettingsChange_message;
+ public static String SystemSettingsChange_yes;
+ public static String SystemSettingsChange_no;
+
+ public static String PromptOnExitDialog_shellTitle;
+ public static String PromptOnExitDialog_message0;
+ public static String PromptOnExitDialog_message1;
+ public static String PromptOnExitDialog_choice;
+
+ public static String ApplicationWorkbenchAdvisor_noPerspective;
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/nls/Messages.properties
new file mode 100644
index 000000000..ca2af3f93
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.rcp.application/src/org/eclipse/tcf/te/rcp/application/nls/Messages.properties
@@ -0,0 +1,16 @@
+#
+# org.eclipse.tcf.te.rcp.application
+# Externalized Strings.
+#
+
+SystemSettingsChange_title = High Contrast Mode Change
+SystemSettingsChange_message = The high contrast mode has changed. You will need to restart the workbench to complete the change. Restart now?
+SystemSettingsChange_yes = Yes
+SystemSettingsChange_no = No
+
+PromptOnExitDialog_shellTitle = Confirm Exit
+PromptOnExitDialog_message0 = Exit application?
+PromptOnExitDialog_message1 = Exit {0}?
+PromptOnExitDialog_choice = &Always exit without prompt
+
+ApplicationWorkbenchAdvisor_noPerspective=No perspectives are open. To open a perspective, press this button:

Back to the top