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

at.spardat.xma.appshell.TabAppShell Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*
 * @(#) $Id: TabAppShell.java 8695 2011-11-21 18:25:16Z laslovd $
 *
 * Copyright 2009/2010 by sIT Solutions,
 * A-1110 Wien, Geiselbergstr.21-25.
 * All rights reserved.
 *
 */
package at.spardat.xma.appshell;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Widget;

import at.spardat.xma.component.ComponentClient;
import at.spardat.xma.page.EventAdapter;
import at.spardat.xma.page.PageClient;

/**
 * An AppShell implementing the menu tree with SWT's CTabs and the
 * visualization of the context strings with a SWT-List.
 * This class is to be thought to be subclassed by an application specific implementation.
 * @author s4709
 * @since 4.1.0
 */
public abstract class TabAppShell extends CompositeMenuAppShell implements ITabItemCreator {

    /**
     * Initializes an AppShell.
     *
     * @param component the Component containing the DialogPage.
     * @param stateless indicating if this page is stateless on the server.
     * @param style The SWT-Style for the Shell of the DialogPage.
     * @param alignment SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT for aligning the tabs
     * @throws IllegalArgumentException if component is null.
     */
    public TabAppShell ( ComponentClient component, boolean stateless, int style, int alignment ) {
        super(component, stateless, style);
        addDelegate(new TabAppShellDelegate(alignment));
    }

    /**
     * Initializes an AppShell inside a given Component.
     *
     * @param component the Component containing the DialogPage.
     * @param parentShell the Shell which shall be the parent of the Shell of the DialogPage.
     * @param style The SWT-Style for the Shell of the DialogPage.
     * @param stateless indicating if this page is stateless on the server.
     * @param tabAlignment defines the alignment of the tab menu (SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT)
     * @throws IllegalArgumentException if component is null.
     */
    public TabAppShell(ComponentClient component, Shell parentShell, boolean stateless, int style, final int alignment ) {
        super(component,parentShell,stateless,style);
        addDelegate(new TabAppShellDelegate(alignment));
    }

    /**
     * Initializes an AppShell inside the same Component as the parent PageClient.
     *
     * @param parent the PageClient calling this DialogPage.
     * @param stateless indicating if this page is stateless on the server.
     * @param style The SWT-Style for the Shell of the DialogPage.
     * @param tabAlignment defines the alignment of the tab menu (SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT)
     */
    public TabAppShell(PageClient parent, boolean stateless, int style, final int alignment ) {
        super(parent,stateless,style);
        addDelegate(new TabAppShellDelegate(alignment));
    }
    
    /**
     * Initializes an AppShell.
     *
     * @param component the Component containing the DialogPage.
     * @param stateless indicating if this page is stateless on the server.
     * @param style The SWT-Style for the Shell of the DialogPage.
     * @throws IllegalArgumentException if component is null.
     */
    public TabAppShell ( ComponentClient component, boolean stateless, int style ) {
        this(component, stateless, style, SWT.LEFT_TO_RIGHT);
    }

    /**
     * Initializes an AppShell inside a given Component.
     *
     * @param component the Component containing the DialogPage.
     * @param parentShell the Shell which shall be the parent of the Shell of the DialogPage.
     * @param style The SWT-Style for the Shell of the DialogPage.
     * @param stateless indicating if this page is stateless on the server.
     * @throws IllegalArgumentException if component is null.
     */
    public TabAppShell(ComponentClient component, Shell parentShell, boolean stateless, int style ) {
        this(component,parentShell,stateless,style,SWT.LEFT_TO_RIGHT);
    }

    /**
     * Initializes an AppShell inside the same Component as the parent PageClient.
     *
     * @param parent the PageClient calling this DialogPage.
     * @param stateless indicating if this page is stateless on the server.
     * @param style The SWT-Style for the Shell of the DialogPage.
     */
    public TabAppShell(PageClient parent, boolean stateless, int style ) {
        this(parent,stateless,style,SWT.LEFT_TO_RIGHT);
    }
    
    /**
     * Factory method for creating all the CTabFolders used for the menu.
     * This method can be overwritten to change or enhance the folder creation, 
     * e.g. to customize graphical design. 
     * @param parent The parent Composite (or CTabFolder what is a specialized Composite) 
     * @param menuItem The menu item related to the CTab related to the folder that has to be created here, 
     *                 or null for the root tab folder
     * @param globalAlignment the instance-wide defined alignment setting, see {@link #TabAppShell(ComponentClient, boolean, int, int)} 
     * @return the created CTabFolder instance
     */
    public CTabFolder createTabFolder ( Composite parent, IMenuItem menuItem, int globalAlignment ) {
        // customization hook, no default implementation
        return null; 
    }
    
    /**
     * Factory method for creating all the CTabItems used for the menu.
     * This method can be overwritten to change or enhance the folder creation, 
     * e.g. to customize graphical design. 
     * @param parent The parent CTabFolder
     * @param item related IMenuItem instance
     * @return the created CTabItem instance
     */
    public CTabItem createTabItem ( CTabFolder parent, IMenuItem item ) {
        // customization hook, no default implementation
        return null; 
    }

    /**
     * Event-method called, when an item in the given tab folder is selected. Calls the
     * Task of the corresponding MenuItem, witch could possible be a child leave under 
     * the selected one.  
     *
     * @param folder which got the selection event
     */
    public void tabFolderSelected ( CTabFolder folder ) {
        // customization hook, no default implementation
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy