📄 pluginpreferencepage.java
字号:
{ return isValid; } /** * Suppresses creation of the standard Default and Apply buttons * for this page. * <p> * Subclasses wishing a preference page wihthout these buttons * should call this framework method before the page's control * has been created. * </p> */ protected void noDefaultAndApplyButton() { createDefaultAndApplyButton = false; } /** * The <code>PreferencePage</code> implementation of this * <code>IPreferencePage</code> method returns <code>true</code> * if the page is valid. */ public boolean okToLeave() { return isValid(); } /** * Performs special processing when this page's Apply button has been pressed. * <p> * This is a framework hook method for sublcasses to do special things when * the Apply button has been pressed. * The default implementation of this framework method simply calls * <code>performOk</code> to simulate the pressing of the page's OK button. * </p> * * @see #performOk */ protected void performApply() { performOk(); } /** * The preference page implementation of an <code>IPreferencePage</code> * method performs special processing when this page's Cancel button has * been pressed. * <p> * This is a framework hook method for sublcasses to do special things when * the Cancel button has been pressed. The default implementation of this * framework method does nothing and returns <code>true</code>. */ public boolean performCancel() { return true; } /** * Performs special processing when this page's Defaults button has been pressed. * <p> * This is a framework hook method for subclasses to do special things when * the Defaults button has been pressed. * Subclasses may override, but should call <code>super.performDefaults</code>. * </p> */ protected void performDefaults() { updateApplyButton(); } /** * Method declared on IPreferencePage. * Subclasses should override */ public boolean performOk() { return true; } /** (non-Javadoc) * Method declared on IPreferencePage. */ public void setContainer(IPreferencePageContainer container) { this.container = container; } /** * Sets the preference store for this preference page. * <p> * If preferenceStore is set to null, getPreferenceStore * will invoke doGetPreferenceStore the next time it is called. * </p> * * @param store the preference store, or <code>null</code> * @see #getPreferenceStore */ public void setPreferenceStore(IPreferenceStore store) { preferenceStore = store; } /* (non-Javadoc) * Method declared on IPreferencePage. */ public void setSize(Point uiSize) { Control control = getControl(); if (control != null) { control.setSize(uiSize); size = uiSize; } } /** * The <code>PreferencePage</code> implementation of this <code>IDialogPage</code> * method extends the <code>DialogPage</code> implementation to update * the preference page container title. Subclasses may extend. */ public void setTitle(String title) { super.setTitle(title); if (getContainer() instanceof IPreferencePageContainer) ((IPreferencePageContainer) getContainer()).updateTitle(); } /** * Sets whether this page is valid. * The enable state of the container buttons and the * apply button is updated when a page's valid state * changes. * <p> * * @param b the new valid state */ public void setValid(boolean b) { boolean oldValue = isValid; isValid = b; if (oldValue != isValid) { // update container state if (getContainer() instanceof IPreferencePageContainer) { ((IPreferencePageContainer) getContainer()).updateButtons(); // update page state updateApplyButton(); } if (getContainer() instanceof IWizardContainer && isCurrentPage()) ((IWizardContainer) getContainer()).updateButtons(); } } /** * Updates the enabled state of the Apply button to reflect whether * this page is valid. */ protected void updateApplyButton() { if (applyButton != null) applyButton.setEnabled(isValid()); } /** * Creates a composite with a highlighted Note entry and a message text. * This is designed to take up the full width of the page. * * @param font the font to use * @param composite the parent composite * @param title the title of the note * @param message the message for the note * @return the composite for the note */ protected Composite createNoteComposite(Font font, Composite composite, String title, String message) { Composite messageComposite = new Composite(composite, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; messageLayout.marginWidth = 0; messageLayout.marginHeight = 0; messageComposite.setLayout(messageLayout); messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); messageComposite.setFont(font); final Label noteLabel = new Label(messageComposite, SWT.BOLD); noteLabel.setText(title); noteLabel.setFont(JFaceResources.getBannerFont()); noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); final IPropertyChangeListener fontListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (JFaceResources.BANNER_FONT.equals(event.getProperty())) { noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT)); } } }; JFaceResources.getFontRegistry().addListener(fontListener); noteLabel.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { JFaceResources.getFontRegistry().removeListener(fontListener); } }); Label messageLabel = new Label(messageComposite, SWT.WRAP); messageLabel.setText(message); messageLabel.setFont(font); return messageComposite; } /** * Returns the Apply button. * * @return the Apply button */ protected Button getApplyButton() { return applyButton; } /** * Returns the Restore Defaults button. * * @return the Restore Defaults button */ protected Button getDefaultsButton() { return defaultsButton; } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#performHelp() */ public void performHelp() { getControl().notifyListeners(SWT.Help, new Event()); } /** * Apply the data to the receiver. By default do nothing. * @param data * @since 3.1 */ public void applyData(Object data) { } /** * Returns whether this page is the current one in the wizard's container. * * @return <code>true</code> if the page is active, * and <code>false</code> otherwise */ protected boolean isCurrentPage() { return (getContainer() instanceof IWizardContainer && this == ((IWizardContainer) getContainer()).getCurrentPage()); } /** * The <code>WizardPage</code> implementation of this method * declared on <code>DialogPage</code> updates the container * if this is the current page. */ public void setErrorMessage(String newMessage) { super.setErrorMessage(newMessage); if (getContainer() instanceof IPreferencePageContainer) ((IPreferencePageContainer) getContainer()).updateMessage(); else if (getContainer() instanceof IWizardContainer && isCurrentPage()) { ((IWizardContainer) getContainer()).updateMessage(); } } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.DialogPage#setMessage(java.lang.String, int) */ public void setMessage(String newMessage, int newType) { super.setMessage(newMessage, newType); if (getContainer() instanceof IPreferencePageContainer) ((IPreferencePageContainer) getContainer()).updateMessage(); else if (getContainer() instanceof IWizardContainer) ((IWizardContainer) getContainer()).updateMessage(); } /** * The <code>WizardPage</code> implementation of this <code>IWizardPage</code> * method returns <code>true</code> if this page is complete (<code>isPageComplete</code>) * and there is a next page to flip to. Subclasses may override (extend or reimplement). * * @see #getNextPage * @see #isPageComplete */ public boolean canFlipToNextPage() { return isPageComplete() && getNextPage() != null; } /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizardPage#getName() */ public String getName() { return null; } /* (non-Javadoc) * Method declared on IWizardPage. * The default behavior is to ask the wizard for the next page. */ public IWizardPage getNextPage() { if (wizard == null) return null; return wizard.getNextPage(this); } /* (non-Javadoc) * Method declared on IWizardPage. * The default behavior is return the cached previous back or, * lacking that, to ask the wizard for the previous page. */ public IWizardPage getPreviousPage() { if (previousPage != null) return previousPage; if (wizard == null) return null; return wizard.getPreviousPage(this); } /** * The <code>WizardPage</code> implementation of this method declared on * <code>DialogPage</code> returns the shell of the container. * The advantage of this implementation is that the shell is accessable * once the container is created even though this page's control may not * yet be created. */ public Shell getShell() { if (getContainer() instanceof IWizardContainer) return ((IWizardContainer) getContainer()).getShell(); if (body != null) return body.getShell(); return null; } /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizardPage#getWizard() */ public IWizard getWizard() { return wizard; } /* (non-Javadoc) * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete() */ public boolean isPageComplete() { return isValid; } /* (non-Javadoc) * Method declared on IWizardPage. */ public void setPreviousPage(IWizardPage page) { previousPage = page; } /* (non-Javadoc) * Method declared on IWizardPage. */ public void setWizard(IWizard newWizard) { wizard = newWizard; } /** * Returns a string suitable for debugging purpose only. */ public String toString() { return getTitle(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -