at.spardat.xma.appshell.ContextAppShellDelegate 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: ContextAppShellDelegate.java 8541 2011-09-23 15:12:18Z laslovd $
*
*
*
*
*
*/
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 ContextAppShellDelegate extends AppShellDelegate {
/**
* swt-list containing the context strings of all tasks on the task stack.
*/
protected List contextW=null;
void prepare() {
super.prepare();
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();
}
}
/**
* Show the contextStrings of all Tasks, Components and Pages on
* the call stack.
*/
public void showContextStack() {
if(contextW==null) return;
contextW.removeAll();
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();
}
// TODO: comment me
public void removeWidgets() {
super.removeWidgets();
contextW=null;
}
/**
* 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.
*/
protected Composite getContextComp () {
if ( appShell instanceof ContextAppShell )
return ((ContextAppShell) appShell).getContextComp();
return null;
}
}