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

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

The newest version!
/*
 * @(#) $Id: CompositeMenuAppShellDelegate.java 8541 2011-09-23 15:12:18Z 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.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

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

/**
 * Base class for AppSehells that uses non-drop-down menus in a composite (like an SWT Tree).  
 * @author s4709  
 * @since 4.1.0
 */
public abstract class CompositeMenuAppShellDelegate extends ContextAppShellDelegate {

    protected Composite menuCompW;
    
    /**
     * Get the swt-composite for holding the menu items.
     * It will be filled completely with a tree containing the menu items.
     * @return the composite for the menu.
     */
    protected Composite getMenuComp () {
        if ( appShell instanceof CompositeMenuAppShell )
            return ((CompositeMenuAppShell) appShell).getMenuComp();
        return null;
    }

    /**
     * Creates the root menu control (whatever that is) into the given composite   
     * @param adapter The event adapter to catch all the menu selection events
     * @param menuCompositeW Composite to be used as parent for the root menu
     * @return The created root menu
     */
    abstract protected Control createRootMenu ( EventAdapter adapter, Composite menuCompositeW );
    
    // TODO: change docu
    /**
     * Creates the Widgets of the PageClient and all Subpages by calling
     * {@link #createWidgets()} on the PageClient and all Subpages. Overloaded here
     * to add its own widgets: the composite menu for the menu and the SWT-List for 
     * the context stack.
     */
    void prepare () {
        super.prepare();
        EventAdapter adapter = new EventAdapter(appShell);
        menuCompW = getMenuComp();
        if ( menuCompW != null ) {
            FormData data = new FormData();
            data.left = new FormAttachment(0,100,0);
            data.right = new FormAttachment(100,100,0);
            data.top = new FormAttachment(0,100,0);
            data.bottom = new FormAttachment(100,100,0);
            Control ctrl = createRootMenu(adapter,menuCompW);
            ctrl.setLayoutData(data);
            menuCompW.setTabList(new Control[] { ctrl });
            menuCompW.layout();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy