⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preferencepage.java

📁 jfa2ce 源码帮助开发人员更好的理解运用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * Computes the size needed by this page's UI control.     * <p>     * All pages should override this method and set the appropriate sizes     * of their widgets, and then call <code>super.doComputeSize</code>.     * </p>     *     * @return the size of the preference page encoded as     *   <code>new Point(width,height)</code>     */    protected Point doComputeSize() {        if (descriptionLabel != null && body != null) {            Point bodySize = body.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);            GridData gd = (GridData) descriptionLabel.getLayoutData();            gd.widthHint = bodySize.x;        }        return getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);    }    /**     * Returns the preference store of this preference page.     * <p>     * This is a framework hook method for subclasses to return a     * page-specific preference store. The default implementation     * returns <code>null</code>.     * </p>     *     * @return the preference store, or <code>null</code> if none     */    protected IPreferenceStore doGetPreferenceStore() {        return null;    }    /**     * Returns the container of this page.     *     * @return the preference page container, or <code>null</code> if this     *   page has yet to be added to a container     */    public IPreferencePageContainer getContainer() {        return container;    }    /**     * Returns the preference store of this preference page.     *     * @return the preference store , or <code>null</code> if none     */    public IPreferenceStore getPreferenceStore() {        if (preferenceStore == null) {			preferenceStore = doGetPreferenceStore();		}        if (preferenceStore != null) {			return preferenceStore;		} else if (container != null) {			return container.getPreferenceStore();		}        return null;    }    /**	     * The preference page implementation of an <code>IPreferencePage</code>     * method returns whether this preference page is valid. Preference     * pages are considered valid by default; call <code>setValid(false)</code>     * to make a page invalid.     */    public boolean isValid() {        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() != null) {			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() != null) {				getContainer().updateButtons();			}            // update page state            updateApplyButton();        }    }    /**     * Returns a string suitable for debugging purpose only.     */    public String toString() {        return getTitle();    }    /**     * 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) {			}		/* (non-Javadoc)	 * @see org.eclipse.jface.dialogs.DialogPage#setErrorMessage(java.lang.String)	 */	public void setErrorMessage(String newMessage) {		super.setErrorMessage(newMessage);		if (getContainer() != null) {			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() != null) {			getContainer().updateMessage();		}	}	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -