All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.page.NotebookPage Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

package at.spardat.xma.page;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

/**
 * Base class of all Pages shown as a folder inside a Notebook.
 * 
 * @author s2877
 */
public abstract class NotebookPage extends PageClient {
    /** the Notebook containing this NotebookPage */
    private Notebook notebook;


    /**
     * Initializes the NotebookPage inside the given Notebook.
     *
     * @param notebook the Notebook containing this NotebookPage.
     */
    public NotebookPage(Notebook notebook,boolean stateless) {
        super(notebook.getParent(),stateless);
        this.notebook = notebook;
    }

    /**
     * Gets the Notebook containing this NotebookPage.
     * 
     * @return the Notebook containing this NotebookPage.
     */
    public Notebook getNotebook() {
        return notebook;
    }

    /** 
     * Get the SWT-Composite of the NotebookPage. All SWT-Widgets of this NotebookPage
     * are children of this Composite (directly or indirectly).
     * 
     * @return the SWT-Composite corresponding to this PageClient 
     */
    public Composite getComposite() {
        if(composite==null && notebook.getTabFolder()!=null) {
            createComposite(notebook.getTabFolder());
        }
        return composite;
    }

    /** 
     * Creates the SWT-Composite of the NotebookPage. All SWT-Widgets of this PageClient
     * will be children of this Composite (directly or indirectly).
     * 
     * @param parentComp the SWT-Composite to use as parent of the created SWT-Composite.
     * @return the newly created SWT-Composite corresponding to this NotebookPage 
     */
    public Composite createComposite(Composite parentComp) {
        composite = new Composite(parentComp, SWT.NONE);
        composite.setData(this);
        return composite;
    }
                
    /**
     * Creates the Composite and Widgets of the NotebookPage 
     * by calling {@link #createWidgets()}.
     */
    public void initGUI() {
        if(composite==null) createComposite(notebook.getTabFolder());
        if(getTabItem()==null&¬ebook.pages.contains(this)) {
            createTabItem(notebook.getTabFolder(),notebook.pages.indexOf(this));
        }
        super.initGUI();
    }
    
    /**
     * Creates the coresponding TabItem
     * @param tabfolderW the parent of the TabItem
     * @param index the position where to add the TabItem to its TabFolder
     */
    protected TabItem createTabItem(TabFolder tabfolderW,int index) {
        TabItem item = new TabItem (tabfolderW, SWT.NULL, index);
        item.setControl(getComposite());
        item.setData(this);
        return item;
    }
    
    /**
     * Get the TabItem corresponding to this NotebookPage
     * @return the TabItem corresponding to this NotebookPage
     */
    public TabItem getTabItem() {
        if(notebook.tabFolder!=null && notebook.pages.contains(this)) {
            int index = notebook.pages.indexOf(this);
            if(index




© 2015 - 2024 Weber Informatics LLC | Privacy Policy