Initial commit from SVN.
This commit is contained in:
159
Foundation SWT/src/com/foundation/view/swt/Wizard.java
Normal file
159
Foundation SWT/src/com/foundation/view/swt/Wizard.java
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.swt;
|
||||
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.custom.StackLayout;
|
||||
|
||||
import com.common.util.*;
|
||||
import com.foundation.view.*;
|
||||
|
||||
/*
|
||||
* TODO: Is this used any more??
|
||||
*/
|
||||
public class Wizard extends Container {
|
||||
/** The attribute that tracks which page number is being displayed. */
|
||||
private IAttributeAssociation pageAttribute = null;
|
||||
/** The index of the currently visible 'page' component. */
|
||||
private int currentPageNumber = -1;
|
||||
/**
|
||||
* Wizard constructor.
|
||||
* @param parent A composite control which will be the parent of the new instance (cannot be null).
|
||||
* @param name The unique component name.
|
||||
* @param style The style of control to construct.
|
||||
* @see #STYLE_NO_BACKGROUND
|
||||
* @see #STYLE_NO_FOCUS
|
||||
* @see #STYLE_NO_MERGE_PAINTS
|
||||
* @see #STYLE_NO_REDRAW_RESIZE
|
||||
* @see #STYLE_NO_RADIO_GROUP
|
||||
* @see #STYLE_H_SCROLL
|
||||
* @see #STYLE_V_SCROLL
|
||||
* @see #STYLE_BORDER
|
||||
* @see #STYLE_LEFT_TO_RIGHT
|
||||
* @see #STYLE_RIGHT_TO_LEFT
|
||||
*/
|
||||
public Wizard(Container parent, String name, int style) {
|
||||
super(parent, name, style);
|
||||
}//Wizard()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.swt.AbstractComponent#initializeControl(int)
|
||||
*/
|
||||
protected void initializeControl(int style, Object data) {
|
||||
setSwtWidget(new org.eclipse.swt.widgets.Composite(((Container) getContainer()).getSwtParent(), style));
|
||||
getSwtWidget().setData(this);
|
||||
//getSwtComposite().setLayout(new com.foundation.view.swt.layout.WizardLayout());
|
||||
getSwtComposite().setLayout(new StackLayout());
|
||||
}//initializeControl()//
|
||||
/**
|
||||
* Gets the stack layout used with the wizard.
|
||||
* @return The wizard's stack layout.
|
||||
*/
|
||||
protected StackLayout getLayout() {
|
||||
return (StackLayout) getSwtComposite().getLayout();
|
||||
}//getLayout()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.swt.Container#setLayout(org.eclipse.swt.widgets.Layout)
|
||||
*/
|
||||
public void setLayout(Layout layout) {
|
||||
//Does nothing. Layouts are not allowed here.//
|
||||
}//setLayout()//
|
||||
/**
|
||||
* Gets the SWT composite that represents this panel.
|
||||
* @return The SWT composite providing visualization for this panel.
|
||||
*/
|
||||
public org.eclipse.swt.widgets.Composite getSwtComposite() {
|
||||
return (org.eclipse.swt.widgets.Composite) getSwtControl();
|
||||
}//getSwtComposite()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.swt.AbstractComponent#internalOnEventFired(com.foundation.view.swt.IEventAssociation, java.lang.Object[])
|
||||
*/
|
||||
protected void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
|
||||
}//internalOnEventFired()//
|
||||
/**
|
||||
* Sets the currently displayed page number attribute.
|
||||
* @param pageAttribute The attribute referencing the currently displayed page's number.
|
||||
*/
|
||||
public void setPageAttribute(IAttributeAssociation pageAttribute) {
|
||||
if((isInitialized()) && (this.pageAttribute != null)) {
|
||||
this.pageAttribute.unregister();
|
||||
}//if//
|
||||
|
||||
this.pageAttribute = pageAttribute;
|
||||
|
||||
if(isInitialized()) {
|
||||
pageAttribute.register();
|
||||
internalRefreshPage();
|
||||
}//if//
|
||||
}//setPageAttribute()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.swt.AbstractComponent#internalViewInitialize()
|
||||
*/
|
||||
protected void internalViewInitialize() {
|
||||
if(pageAttribute != null) {
|
||||
pageAttribute.register();
|
||||
}//if//
|
||||
|
||||
super.internalViewInitialize();
|
||||
}//internalViewInitialize()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.swt.AbstractComponent#internalViewRelease()
|
||||
*/
|
||||
protected void internalViewRelease() {
|
||||
super.internalViewRelease();
|
||||
|
||||
if(pageAttribute != null) {
|
||||
pageAttribute.unregister();
|
||||
}//if//
|
||||
}//internalViewRelease()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.swt.AbstractComponent#internalViewRefresh()
|
||||
*/
|
||||
protected void internalViewRefresh() {
|
||||
super.internalViewRefresh();
|
||||
|
||||
internalRefreshPage();
|
||||
}//internalViewRefresh()//
|
||||
/**
|
||||
* Refreshes the currently visible wizard page.
|
||||
*/
|
||||
protected void internalRefreshPage() {
|
||||
if(pageAttribute != null) {
|
||||
Number pageNumber = (Number) pageAttribute.getAttributeValue();
|
||||
|
||||
if(pageNumber == null) {
|
||||
pageNumber = new Integer(0);
|
||||
pageAttribute.setAttributeValue(pageNumber);
|
||||
}//if//
|
||||
|
||||
if(currentPageNumber != pageNumber.intValue()) {
|
||||
currentPageNumber = pageNumber.intValue();
|
||||
getLayout().topControl = ((Component) ((IList) getComponents()).get(currentPageNumber)).getSwtControl();
|
||||
getSwtComposite().layout();
|
||||
((Component) ((IList) getComponents()).get(currentPageNumber)).getSwtControl().setFocus();
|
||||
}//if//
|
||||
}//if//
|
||||
}//internalRefreshPage()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.swt.AbstractComponent#internalViewSynchronize()
|
||||
*/
|
||||
protected void internalViewSynchronize() {
|
||||
//Since the page can only be set manually, this method should do nothing.//
|
||||
super.internalViewSynchronize();
|
||||
}//internalViewSynchronize()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.swt.Component#onValueChanged(com.foundation.view.swt.IAttributeAssociation)
|
||||
*/
|
||||
protected void internalOnValueChanged(IAttributeAssociation attributeAssociation) {
|
||||
if(attributeAssociation == pageAttribute) {
|
||||
internalRefreshPage();
|
||||
}//if//
|
||||
else {
|
||||
super.internalOnValueChanged(attributeAssociation);
|
||||
}//else//
|
||||
}//internalOnValueChanged()//
|
||||
}//Wizard//
|
||||
Reference in New Issue
Block a user