private Object aboutToStart(boolean cancelable) { Map savedState = null; Shell shell = getShell(); if (shell != null) { // Save focus control Control focusControl = getShell().getDisplay().getFocusControl(); if (focusControl != null && focusControl.getShell() != getShell()) focusControl = null; Button cancelButton = getButton(IDialogConstants.CANCEL_ID); // Set the busy cursor to all shells. Display d = getShell().getDisplay(); setDisplayCursor(d, d.getSystemCursor(SWT.CURSOR_WAIT)); // Set the arrow cursor to the cancel component. cancelButton.setCursor(d.getSystemCursor(SWT.CURSOR_ARROW)); boolean hasProgressMonitor = fProgressMonitorPart != null; // Deactivate shell savedState = saveUIState(false); if (focusControl != null) savedState.put("focus", focusControl); // $NON-NLS-1$ if (hasProgressMonitor) { if (cancelable) fProgressMonitorPart.attachToCancelComponent(cancelButton); fStatusContainer.showPage(fProgressMonitorPart); } // Update the status container since we are blocking the event loop right now. fStatusContainer.update(); } return savedState; }
private void makeVisible(IWizardPage page) { if (fVisiblePage == page) return; if (fVisiblePage != null) fVisiblePage.setVisible(false); fVisiblePage = page; fPageContainer.showPage(page.getControl()); fVisiblePage.setVisible(true); }
private void saveSize() { if (fCurrentPage instanceof PreviewWizardPage) { Control control = fPageContainer.getTopPage(); Point size = control.getSize(); fSettings.put(WIDTH, size.x); fSettings.put(HEIGHT, size.y); } }
protected Control createContents(Composite parent) { Composite result = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; result.setLayout(layout); result.setLayoutData(new GridData(GridData.FILL_BOTH)); // initialize the dialog units initializeDialogUnits(result); fPageContainer = new PageBook(result, SWT.NONE); GridData gd = new GridData(GridData.FILL_BOTH); fPageContainer.setLayoutData(gd); fCurrentPage = fWizard.getStartingPage(); dialogArea = fPageContainer; if (fCurrentPage instanceof PreviewWizardPage) { gd.widthHint = fPreviewWidth; gd.heightHint = fPreviewHeight; } fStatusContainer = new PageBook(result, SWT.NONE); gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = convertWidthInCharsToPixels(fWizard.getMessageLineWidthInChars()); fStatusContainer.setLayoutData(gd); if (fWizard.needsProgressMonitor()) createProgressMonitorPart(); createMessageBox(); fStatusContainer.showPage(fMessageBox); buttonBar = createButtonBar(result); if (fCurrentPage != null) { fCurrentPage.createControl(fPageContainer); makeVisible(fCurrentPage); updateMessage(); updateButtons(); } applyDialogFont(result); return result; }
private void stopped(Object savedState) { Shell shell = getShell(); if (shell != null) { Button cancelButton = getButton(IDialogConstants.CANCEL_ID); if (fProgressMonitorPart != null) fProgressMonitorPart.removeFromCancelComponent(cancelButton); fStatusContainer.showPage(fMessageBox); Map state = (Map) savedState; restoreUIState(state); setDisplayCursor(shell.getDisplay(), null); cancelButton.setCursor(null); Control focusControl = (Control) state.get("focus"); // $NON-NLS-1$ if (focusControl != null) focusControl.setFocus(); } }
private void resize() { if (isFirstPage()) { getShell().setBounds(fInitialSize); return; } Control control = fPageContainer.getTopPage(); Point size = control.getSize(); int dw = Math.max(0, fPreviewWidth - size.x); int dh = Math.max(0, fPreviewHeight - size.y); int dx = dw / 2; int dy = dh / 2; Shell shell = getShell(); Rectangle rect = shell.getBounds(); Rectangle clientRect = shell.getMonitor().getClientArea(); rect.x = Math.max(clientRect.x, rect.x - dx); rect.y = Math.max(clientRect.y, rect.y - dy); // limit with and height to monitor rect.width = Math.min(rect.width + dw, clientRect.width); rect.height = Math.min(rect.height + dh, clientRect.height); // Reposition the dialog so that it will be fully visible. // Normalize x and y relative to the client area. int xe = (rect.x - clientRect.x) + rect.width; if (xe > clientRect.width) { rect.x -= xe - clientRect.width; } int ye = (rect.y - clientRect.y) + rect.height; if (ye > clientRect.height) { rect.y -= ye - clientRect.height; } shell.setBounds(rect); }
/* (non-Javadoc) * Method declared on IWizardContainer. */ public void updateMessage() { if (fStatusContainer == null || fStatusContainer.isDisposed()) return; fStatusContainer.showPage(fMessageBox); fMessageBox.setMessage(fCurrentPage); }