📄 wizarddialog.java
字号:
* Method declared on IWizardContainer. */ public void showPage(IWizardPage page) { if (page == null || page == currentPage) { return; } if (!isMovingToPreviousPage) { // remember my previous page. page.setPreviousPage(currentPage); } else { isMovingToPreviousPage = false; } //Update for the new page ina busy cursor if possible if (getContents() == null) { updateForPage(page); } else { final IWizardPage finalPage = page; BusyIndicator.showWhile(getContents().getDisplay(), new Runnable() { public void run() { updateForPage(finalPage); } }); } } /** * Update the receiver for the new page. * @param page */ private void updateForPage(IWizardPage page) { // ensure this page belongs to the current wizard if (wizard != page.getWizard()) { setWizard(page.getWizard()); } // ensure that page control has been created // (this allows lazy page control creation) if (page.getControl() == null) { page.createControl(pageContainer); // the page is responsible for ensuring the created control is accessable // via getControl. Assert.isNotNull(page.getControl()); // ensure the dialog is large enough for this page updateSize(page); } // make the new page visible IWizardPage oldPage = currentPage; currentPage = page; currentPage.setVisible(true); if (oldPage != null) { oldPage.setVisible(false); } // update the dialog controls update(); } /** * Shows the starting page of the wizard. */ private void showStartingPage() { currentPage = wizard.getStartingPage(); if (currentPage == null) { // something must have happend getting the page return; } // ensure the page control has been created if (currentPage.getControl() == null) { currentPage.createControl(pageContainer); // the page is responsible for ensuring the created control is accessable // via getControl. Assert.isNotNull(currentPage.getControl()); // we do not need to update the size since the call // to initialize bounds has not been made yet. } // make the new page visible currentPage.setVisible(true); // update the dialog controls update(); } /** * A long running operation triggered through the wizard * was stopped either by user input or by normal end. * Hides the progress monitor and restores the enable state * wizard's buttons and controls. * * @param savedState the saved UI state as returned by <code>aboutToStart</code> * @see #aboutToStart */ private void stopped(Object savedState) { if (getShell() != null) { if (wizard.needsProgressMonitor()) { progressMonitorPart.setVisible(false); progressMonitorPart.removeFromCancelComponent(cancelButton); } Map state = (Map) savedState; restoreUIState(state); cancelButton.addSelectionListener(cancelListener); setDisplayCursor(null); cancelButton.setCursor(null); waitCursor.dispose(); waitCursor = null; arrowCursor.dispose(); arrowCursor = null; Control focusControl = (Control) state.get(FOCUS_CONTROL); if (focusControl != null) { focusControl.setFocus(); } } } /** * Updates this dialog's controls to reflect the current page. */ protected void update() { // Update the window title updateWindowTitle(); // Update the title bar updateTitleBar(); // Update the buttons updateButtons(); // Fires the page change event firePageChanged(new PageChangedEvent(this, getCurrentPage())); } /* (non-Javadoc) * Method declared on IWizardContainer. */ public void updateButtons() { boolean canFlipToNextPage = false; boolean canFinish = wizard.canFinish(); if (backButton != null) { backButton.setEnabled(currentPage.getPreviousPage() != null); } if (nextButton != null) { canFlipToNextPage = currentPage.canFlipToNextPage(); nextButton.setEnabled(canFlipToNextPage); } finishButton.setEnabled(canFinish); // finish is default unless it is diabled and next is enabled if (canFlipToNextPage && !canFinish) { getShell().setDefaultButton(nextButton); } else { getShell().setDefaultButton(finishButton); } } /** * Update the message line with the page's description. * <p> * A discription is shown only if there is no message or error message. * </p> */ private void updateDescriptionMessage() { pageDescription = currentPage.getDescription(); setMessage(currentPage.getDescription()); } /* (non-Javadoc) * Method declared on IWizardContainer. */ public void updateMessage() { if (currentPage == null) { return; } pageMessage = currentPage.getMessage(); if (pageMessage != null && currentPage instanceof IMessageProvider) { pageMessageType = ((IMessageProvider) currentPage).getMessageType(); } else { pageMessageType = IMessageProvider.NONE; } if (pageMessage == null) { setMessage(pageDescription); } else { setMessage(pageMessage, pageMessageType); } setErrorMessage(currentPage.getErrorMessage()); } /** * Changes the shell size to the given size, ensuring that * it is no larger than the display bounds. * * @param width the shell width * @param height the shell height */ private void setShellSize(int width, int height) { Rectangle size = getShell().getBounds(); size.height = height; size.width = width; getShell().setBounds(getConstrainedShellBounds(size)); } /** * Computes the correct dialog size for the current page and resizes * its shell if nessessary. Also causes the container to refresh its * layout. * * @param page the wizard page to use to resize the dialog * @since 2.0 */ protected void updateSize(IWizardPage page) { if (page == null || page.getControl() == null) { return; } updateSizeForPage(page); pageContainerLayout.layoutPage(page.getControl()); } /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizardContainer2#updateSize() */ public void updateSize() { updateSize(currentPage); } /** * Computes the correct dialog size for the given page and resizes * its shell if nessessary. * * @param page the wizard page */ private void updateSizeForPage(IWizardPage page) { // ensure the page container is large enough Point delta = calculatePageSizeDelta(page); if (delta.x > 0 || delta.y > 0) { // increase the size of the shell Shell shell = getShell(); Point shellSize = shell.getSize(); setShellSize(shellSize.x + delta.x, shellSize.y + delta.y); constrainShellSize(); } } /** * Computes the correct dialog size for the given wizard and resizes * its shell if nessessary. * * @param sizingWizard the wizard */ private void updateSizeForWizard(IWizard sizingWizard) { Point delta = new Point(0, 0); IWizardPage[] pages = sizingWizard.getPages(); for (int i = 0; i < pages.length; i++) { // ensure the page container is large enough Point pageDelta = calculatePageSizeDelta(pages[i]); delta.x = Math.max(delta.x, pageDelta.x); delta.y = Math.max(delta.y, pageDelta.y); } if (delta.x > 0 || delta.y > 0) { // increase the size of the shell Shell shell = getShell(); Point shellSize = shell.getSize(); setShellSize(shellSize.x + delta.x, shellSize.y + delta.y); } } /* (non-Javadoc) * Method declared on IWizardContainer. */ public void updateTitleBar() { String s = null; if (currentPage != null) { s = currentPage.getTitle(); } if (s == null) { s = ""; //$NON-NLS-1$ } setTitle(s); if (currentPage != null) { setTitleImage(currentPage.getImage()); updateDescriptionMessage(); } updateMessage(); } /* (non-Javadoc) * Method declared on IWizardContainer. */ public void updateWindowTitle() { if (getShell() == null) { // Not created yet return; } String title = wizard.getWindowTitle(); if (title == null) { title = ""; //$NON-NLS-1$ } getShell().setText(title); } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IPageChangeProvider#getSelectedPage() */ public Object getSelectedPage() { return getCurrentPage(); } /* (non-Javadoc) * @see org.eclipse.jface.dialog.IPageChangeProvider#addPageChangedListener() */ public void addPageChangedListener(IPageChangedListener listener) { pageChangedListeners.add(listener); } /* (non-Javadoc) * @see org.eclipse.jface.dialog.IPageChangeProvider#removePageChangedListener() */ public void removePageChangedListener(IPageChangedListener listener) { pageChangedListeners.remove(listener); } /** * Notifies any selection changed listeners that the selected page * has changed. * Only listeners registered at the time this method is called are notified. * * @param event a selection changed event * * @see IPageChangedListener#pageChanged * * @since 3.1 */ protected void firePageChanged(final PageChangedEvent event) { Object[] listeners = pageChangedListeners.getListeners(); for (int i = 0; i < listeners.length; ++i) { final IPageChangedListener l = (IPageChangedListener) listeners[i]; SafeRunnable.run(new SafeRunnable() { public void run() { l.pageChanged(event); } }); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -