Example usage for org.eclipse.jface.preference IPreferencePage setContainer

List of usage examples for org.eclipse.jface.preference IPreferencePage setContainer

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferencePage setContainer.

Prototype

public void setContainer(IPreferencePageContainer preferencePageContainer);

Source Link

Document

Sets or clears the container of this page.

Usage

From source file:com.mentor.nucleus.bp.ui.preference.TabbedPreferenceContainer.java

License:Open Source License

protected void addPage(IPreferencePage page) {
    if (workbench == null)
        throw new IllegalStateException(
                "local variable workbench has not been initialized; init(IWorkbench aWorkbench) has been overridden");

    if (page instanceof IWorkbenchPreferencePage) {
        ((IWorkbenchPreferencePage) page).init(workbench);
    }//from w ww . j ava  2 s  .c om

    PreferencePageTabItem tabItem = new PreferencePageTabItem(tabFolder, SWT.NULL, page);

    Composite tabFolderPage = new Composite(tabFolder, SWT.NULL);
    tabFolderPage.setLayout(new FillLayout());

    page.createControl(tabFolderPage);
    page.setContainer(this);
    tabItem.setControl(tabFolderPage);
}

From source file:net.sourceforge.eclipsetrader.core.ui.WizardPageAdapter.java

License:Open Source License

public WizardPageAdapter(IPreferencePage preferencePage) {
    super(""); //$NON-NLS-1$
    setTitle(preferencePage.getTitle());
    setDescription(preferencePage.getDescription());
    preferencePage.setContainer(preferencePageContainer);
    setPageComplete(preferencePage.isValid());
    this.preferencePage = preferencePage;
}

From source file:org.mailster.gui.prefs.ConfigurationDialog.java

License:Open Source License

/**
 * Shows the preference page corresponding to the given preference node.
 * Does nothing if that page is already current. This implementation
 * prevents auto resizing./*w  ww .ja va2 s.  c  om*/
 * 
 * @param node the preference node, or <code>null</code> if none
 * @return <code>true</code> if the page flip was successful;
 *         <code>false</code> if unsuccessful
 */
protected boolean showPage(IPreferenceNode node) {
    IPreferencePage currentPage = this.getCurrentPage();
    final Composite pageContainer = this.getPageContainer();

    if (node == null)
        return false;

    // Create the page if nessessary
    if (node.getPage() == null)
        this.createPage(node);

    if (node.getPage() == null)
        return false;

    IPreferencePage newPage = this.getPage(node);
    if (newPage == currentPage)
        return true;

    if (currentPage != null && !currentPage.okToLeave())
        return (false);

    IPreferencePage oldPage = currentPage;
    this.setCurrentPage(newPage);
    currentPage = this.getCurrentPage();
    // Set the new page's container
    currentPage.setContainer(this);

    // Ensure that the page control has been created
    // (this allows lazy page control creation)
    final IPreferencePage curPage = currentPage;
    if (currentPage.getControl() == null) {
        final boolean[] failed = { false };
        SafeRunnable.run(new ISafeRunnable() {
            public void handleException(Throwable e) {
                failed[0] = true;
            }

            public void run() {
                createPageControl(curPage, pageContainer);
            }
        });
        if (failed[0])
            return false;
        // the page is responsible for ensuring the created control is
        // accessable via getControl.
        Assert.isNotNull(currentPage.getControl());
    }

    // Force calculation of the page's description label because
    // label can be wrapped.
    final Point[] size = new Point[1];
    final Point failed = new Point(-1, -1);
    SafeRunnable.run(new ISafeRunnable() {
        public void handleException(Throwable e) {
            size[0] = failed;
        }

        public void run() {
            size[0] = curPage.computeSize();
        }
    });
    if (size[0].equals(failed))
        return false;

    // Do we need resizing. Computation not needed if the
    // first page is inserted since computing the dialog's
    // size is done by calling dialog.open().
    // Also prevent auto resize if the user has manually resized
    if (oldPage != null) {
        Rectangle rect = pageContainer.getClientArea();
        Point containerSize = new Point(rect.width, rect.height);
        // Set the size to be sure we use the result of computeSize
        currentPage.setSize(containerSize);
    }
    // Ensure that all other pages are invisible
    // (including ones that triggered an exception during
    // their creation).
    Control[] children = pageContainer.getChildren();
    Control currentControl = currentPage.getControl();
    for (int i = 0; i < children.length; i++) {
        if (children[i] != currentControl)
            children[i].setVisible(false);
    }
    // Make the new page visible
    currentPage.setVisible(true);
    if (oldPage != null)
        oldPage.setVisible(false);

    // update the dialog controls
    this.update();
    return true;
}

From source file:org.netxms.ui.eclipse.tools.ExtendedPropertyDialog.java

License:Open Source License

/**
 * Create controls for all pages//ww  w.  j ava  2 s .  c  om
 */
public void createAllPages() {
    List<?> nodes = getPreferenceManager().getElements(PreferenceManager.POST_ORDER);
    Iterator<?> i = nodes.iterator();
    while (i.hasNext()) {
        IPreferenceNode node = (IPreferenceNode) i.next();
        if (node.getPage() == null)
            createPage(node);
        IPreferencePage page = getPage(node);
        page.setContainer(this);
        if (page.getControl() == null)
            page.createControl(getPageContainer());
    }
}