/** * Creates a tree information control with the given shell as parent. The given styles are applied * to the shell and the tree widget. * * @param parent the parent shell * @param shellStyle the additional styles for the shell * @param treeStyle the additional styles for the tree widget * @param invokingCommandId the id of the command that invoked this control or <code>null</code> * @param showStatusField <code>true</code> iff the control has a status field at the bottom */ public AbstractQuickViewTop( Shell parent, int shellStyle, int treeStyle, String invokingCommandId, boolean showStatusField) { super(parent, shellStyle, true, true, false, true, true, null, null); if (invokingCommandId != null) { ICommandManager commandManager = PlatformUI.getWorkbench().getCommandSupport().getCommandManager(); fInvokingCommand = commandManager.getCommand(invokingCommandId); if (fInvokingCommand != null && !fInvokingCommand.isDefined()) fInvokingCommand = null; else // Pre-fetch key sequence - do not change because scope will change later. getInvokingCommandKeySequences(); } fTreeStyle = treeStyle; // Title and status text must be set to get the title label created, so force empty values here. if (hasHeader()) setTitleText(""); // $NON-NLS-1$ setInfoText(""); // //$NON-NLS-1$ // Create all controls early to preserve the life cycle of the original implementation. create(); // Status field text can only be computed after widgets are created. setInfoText(getStatusFieldText()); }
/** * Tests that the <code>SelectAllHandler</code> triggers a selection event. Creates a dialog with * a text widget, gives the text widget focus, and then calls the select all command. This should * then call the <code>SelectAllHandler</code> and trigger a selection event. * * @throws ExecutionException If the <code>SelectAllHandler</code> is broken in some way. * @throws NotHandledException If the dialog does not have focus, or if the <code> * WorkbenchCommandSupport</code> class is broken in some way. */ public final void testSelectAllHandlerSendsSelectionEvent() throws ExecutionException, NotHandledException { // Create a dialog with a text widget. final Shell dialog = new Shell(fWorkbench.getActiveWorkbenchWindow().getShell()); dialog.setLayout(new GridLayout()); final Text text = new Text(dialog, SWT.SINGLE); text.setText("Mooooooooooooooooooooooooooooo"); text.setLayoutData(new GridData()); text.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { selectionEventFired = true; } }); // Open the dialog and give the text widget focus. dialog.pack(); dialog.open(); text.setFocus(); // Spin the event loop to make sure focus is set-up properly. final Display display = fWorkbench.getDisplay(); while (display.readAndDispatch()) { ((Workbench) fWorkbench).getContext().processWaiting(); } // Get the select all command and execute it. final IWorkbenchCommandSupport commandSupport = fWorkbench.getCommandSupport(); final ICommand selectAllCommand = commandSupport.getCommandManager().getCommand("org.eclipse.ui.edit.selectAll"); selectAllCommand.execute(null); // Check to see if the selection event has been fired. assertTrue( "The selection event was not fired when the SelectAllHandler was used.", selectionEventFired); }