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

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

/*******************************************************************************
 * 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
 *******************************************************************************/

/*******************************************************************************
 * 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
 *******************************************************************************/

/*
 * @(#) $Id: ContextAppShell.java 2089 2007-11-28 13:56:13Z s3460 $
 *
 *
 *
 *
 *
 */
package at.spardat.xma.appshell;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.List;

import at.spardat.xma.boot.component.IXMAControl;
import at.spardat.xma.component.ComponentClient;
import at.spardat.xma.page.IEmbeddable;

/**
 * An AppShell implementing the visualisation of the context strings with a SWT-List.
 * This class is to be thought to be subclassed by other abstract AppShells implementing
 * some kind of menu like TreeMenu, SWT menu.
 * @author s3460
 * @since version_number
 */
public abstract class ContextAppShell extends AppShell {

    /**
     * swt-list containing the context strings of all tasks on the task stack.
     */
    protected List contextW=null;


    public ContextAppShell(ComponentClient component, boolean stateless, int style) {
        super(component, stateless, style);
    }

    /**
     * Gets the swt-composite for holding the context strings of the call stack.
     * It will be filled completely with a list containing the context stack.
     * @return the composite for the context strings.
     */
    abstract protected Composite getContextComp();

    public void initGUI() {
        super.initGUI();
        Composite contextCompW = getContextComp();
        if(contextCompW!=null) {
            contextW = new List(contextCompW,SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL);

            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);
            contextW.setLayoutData(data);
            contextCompW.layout();
        }
    }

    /**
     * Notify the PageClient and all Subpages, that the Widgets are disposed
     * by calling {@link #removeWidgets()} on all Subpages and the PageClient.
     */
    public void removeWidgetsBase() {
        super.removeWidgetsBase();
        contextW=null;
    }

    /**
     * Show the contextStrings of all Tasks, Components and Pages on
     * the call stack.
     */
    public void showContextStack() {
        if(contextW==null) return;

        contextW.removeAll();
        boolean even = true;
        String line = "";
        for (ITask task = rootTask; task != null; task = task.getSubTask()) {
            String text = task.getContextString();
            if (text != null) {
                contextW.add(text);
            }
            IEmbeddable page = task.getPage();
            if(page!=null) {
                text = page.getContextString();
                if(text!=null) {
                    contextW.add(text);
                }
            }
        }
    }

    /**
     * Notifies the AppShell of a change in the context-string of a component or page.
     * Propagates the change to the GUI.
     * @param source the component or page which changed its context string.
     * @param newText the new context string of the source.
     */
    public void contextStringChanged(IXMAControl source, String newText) {
        showContextStack();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy