aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRené Brandstetter2014-04-01 11:42:47 (EDT)
committerRené Brandstetter2014-04-02 12:16:44 (EDT)
commit557835799a4f2038a9a5a91d8cde7822384842ea (patch)
treeb62935461eaf94bddfdabec36e80ae7027a180d8
parent5bce3c23abc377df17fa805da69e234a64277a61 (diff)
downloadeclipse.platform.ui-557835799a4f2038a9a5a91d8cde7822384842ea.zip
eclipse.platform.ui-557835799a4f2038a9a5a91d8cde7822384842ea.tar.gz
eclipse.platform.ui-557835799a4f2038a9a5a91d8cde7822384842ea.tar.bz2
Bug 431707 - [QuickAccess] Quick Access should open a dialog if hiddenrefs/changes/72/24272/3
Use the original/legacy QuickAccess-Dialog if either the Toolbars aren't visible or no QuickAccess-SearchField exists. Change-Id: Ia68953ce462c285cb4e340ed05c60e85bb420274 Signed-off-by: René Brandstetter <Rene.Brandstetter@gmx.net>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java58
1 files changed, 33 insertions, 25 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java
index 6c6a2c1..6d4cd6d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java
@@ -7,14 +7,17 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * René Brandstetter - Bug 431707 - [QuickAccess] Quick Access should open a dialog if hidden
*******************************************************************************/
package org.eclipse.ui.internal.quickaccess;
import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -27,18 +30,9 @@ import org.eclipse.ui.internal.WorkbenchWindow;
*/
public class QuickAccessHandler extends AbstractHandler {
- private IWorkbenchWindow window;
-
- /**
- * The constructor.
- */
- public QuickAccessHandler() {
- }
-
@Override
public Object execute(ExecutionEvent executionEvent) {
-
- window = HandlerUtil.getActiveWorkbenchWindow(executionEvent);
+ final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(executionEvent);
if (window == null) {
return null;
}
@@ -46,23 +40,37 @@ public class QuickAccessHandler extends AbstractHandler {
MWindow mWindow = ((WorkbenchWindow) window).getModel();
EModelService modelService = mWindow.getContext().get(EModelService.class);
MToolControl searchField = (MToolControl) modelService.find("SearchField", mWindow); //$NON-NLS-1$
- if (searchField == null) {
- return null;
- }
- Control control = (Control) searchField.getWidget();
- if (!((WorkbenchWindow) window).isToolbarVisible()) {
- ((WorkbenchWindow) window).toggleToolbarVisibility();
- control = (Control) searchField.getWidget();
- }
- // the workbench configurer may override visibility; if so, focus should
- // not change
- if (((WorkbenchWindow) window).isToolbarVisible() && control != null) {
- Control previousFocusControl = control.getDisplay().getFocusControl();
- control.setFocus();
- SearchField field = (SearchField) searchField.getObject();
- field.activate(previousFocusControl);
+ if (searchField != null && searchField.isVisible()) {
+ Control control = (Control) searchField.getWidget();
+ // the workbench configurer may override visibility; if so,
+ // focus should not change
+ if (control != null && control.isVisible()) {
+ Control previousFocusControl = control.getDisplay().getFocusControl();
+ control.setFocus();
+ SearchField field = (SearchField) searchField.getObject();
+ field.activate(previousFocusControl);
+ return null;
+ }
}
+
+ // open the original/legacy QuickAccess Dialog if the toolbars are
+ // hidden or if the search field isn't available (maybe because the
+ // dialog is explicitly wanted)
+ displayQuickAccessDialog(window, executionEvent.getCommand());
return null;
}
+ /**
+ * Utility method to displays the original/legacy QuickAccess dialog.
+ *
+ * @param window
+ * the active workbench window
+ * @param command
+ * the command which invokes the open of the dialog
+ */
+ private static void displayQuickAccessDialog(IWorkbenchWindow window, Command command) {
+ PopupDialog popupDialog = new QuickAccessDialog(window, command);
+ popupDialog.open();
+ }
+
} \ No newline at end of file