Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* 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
*******************************************************************************/
package at.spardat.xma.page;
import org.eclipse.swt.widgets.*;
import java.util.*;
import at.spardat.xma.component.*;
/**
* This class is the base class of all assistents (wizards) in XMA.
* This class is not fully implemented yet.
*
* @author s2877
* @deprecated use XMAWzardPage in GUI designer instead
*/
public abstract class Assistent extends DialogPage {
/**
* Collection of all AssistentPages of the Assistent.
*/
private ArrayList assistentPages;
/** currently visible AssistentPage */
AssistentPage activePage;
/**
* Buttons of the Assistent. They must be instantiated and positioned by the
* generated Class for each Assistent.
*/
protected Button butPrevious;
protected Button butNext;
protected Button butOK;
protected Button butCancel;
/**
* Initializes an Assistent inside a given Component.
* Creates the Shell for the Assistent.
*
* @param component the Component containing the Assistent.
* @param style The SWT-Style for the Shell of the Assistent.
* @throws IllegalArgumentException if comonent is null.
*/
public Assistent(ComponentClient component, boolean stateless, int style) {
super(component,stateless,style);
assistentPages = new ArrayList();
}
/**
* Initializes an Assistent inside the same Component as the parent PageClient.
* Creates the Shell for the Assistent.
*
* @param parent the PageClient calling this Assistent.
* @param style The SWT-Style for the Shell of the Assistent.
*/
public Assistent(PageClient parent, boolean stateless, int style) {
super(parent,stateless,style);
assistentPages = new ArrayList();
}
/**
* Gets the AssistentPage with the given index
*
* @param index the index of the desired AssistentPage.
* @return the AssistentPage with the given index.
* @throws IndexOutOfBoundsException if the index is out of range.
*/
public AssistentPage getPage(int index) {
return (AssistentPage) assistentPages.get(index);
}
/**
* Adds an AssistentPage to the existing AssistentPages of this Assistent.
* The new AssistentPage is appended at the end of the list.
*
* @param page the AssistentPage to add.
*/
public void addPage(AssistentPage page) {
assistentPages.add(page);
}
/**
* Adds an AssistentPage to the existing AssistentPages at the given index.
* The new AssistentPage is insertet at the given index position.
*
* @param index the index at which the new AssistentPage is to be inserted.
* @param page the AssistentPage to add.
*/
public void addPage(int index, AssistentPage page) {
assistentPages.add(index, page);
}
/**
* Activates the AssistentPage with the given index. The new active
* PageClient will become visible inside the Assistend.
*
* @param index the index of the AssistentPage to activate.
* @throws IndexOutOfBoundsException if the index is out of range.
*/
// todo: wenn der Assistent bereits sichtbar ist -> wechsel der aktiven AssistentPage
public void setActivePage(int index) {
activePage = (AssistentPage) assistentPages.get(index);
}
/**
* Gets the active AssistentPage. The active AssistenPage is the AssistentPage
* that is visible inside the Assistent.
*
* @return the currently active AssistentPage.
*/
public AssistentPage getActivePage() {
if (activePage == null) activePage = (AssistentPage) assistentPages.get(0);
return activePage;
}
public Button getPrevButton() {
return butPrevious;
}
public Button getNextButton() {
return butNext;
}
public Button getOKButton() {
return butOK;
}
public Button getCancelButton() {
return butCancel;
}
/**
* Creates the Widgets of the Assistent and the active AssistentPage by calling
* {@link AssistentPage#createWidgets()} on the Assistent and the active AssistentPage.
*/
public void initGUI() {
// createButtons();
super.initGUI();
getActivePage().initGUI();
}
/**
* Notify the Assistent and the active AssistentPage, that the Page is becoming visible
* by calling {@link AssistentPage#enter()} on the Assistent and the active AssistentPage.
*/
public void enterBase() {
super.enterBase();
activePage.enterBase();
}
/**
* Notify the Assistent and the active AssistentPage of a possible Change in the PageModels
* by calling {@link AssistentPage#stateChanged()} on the Assistent and the active AssistentPage.
*/
public void stateChangedBase() {
super.stateChangedBase();
activePage.stateChangedBase();
}
/**
* Notify the Assistent and the active AssistentPage, that the Page no longer is visible
* by calling {@link AssistentPage#leave()}on the active AssistentPage and the Assistent.
*/
public void leaveBase() {
activePage.leaveBase();
super.leaveBase();
}
/**
* Removes the WidgetModels of all AssistentPage by calling
* {@link AssistentPage#removeWidgetModels()} on all AssistentPages.
*/
public void removeModel() {
for (Iterator it = assistentPages.iterator(); it.hasNext();) {
((AssistentPage) it.next()).removeModel();
}
}
/* todo: move to generated class
protected void createButtons() {
Composite comp = getComposite();
FormLayout layout = new FormLayout();
layout.marginHeight = 3;
layout.marginWidth = 3;
comp.setLayout(layout);
butCancel = new Button(comp, SWT.PUSH);
butOK = new Button(comp, SWT.PUSH);
butNext = new Button(comp, SWT.PUSH);
butPrevious = new Button(comp, SWT.PUSH);
FormData data = new FormData();
butCancel.setText("Abbrechen");
data.right = new FormAttachment(100, 0);
data.bottom = new FormAttachment(100, 0);
butCancel.setLayoutData(data);
butCancel.addSelectionListener(this);
butOK.setText("&Fertig stellen");
data = new FormData();
data.right = new FormAttachment(butCancel, -5, SWT.LEFT);
data.bottom = new FormAttachment(100, 0);
butOK.setLayoutData(data);
butOK.addSelectionListener(this);
butNext.setText("&Weiter >");
data = new FormData();
data.right = new FormAttachment(butOK, -5, SWT.LEFT);
data.bottom = new FormAttachment(100, 0);
butNext.setLayoutData(data);
butNext.addSelectionListener(this);
butPrevious.setText("< &Zur?ck");
data = new FormData();
data.right = new FormAttachment(butNext, -5, SWT.LEFT);
data.bottom = new FormAttachment(100, 0);
butPrevious.setLayoutData(data);
butPrevious.addSelectionListener(this);
Control[] order = new Control[5];
order[0] = getActivePage().getComposite();
order[1] = butPrevious;
order[2] = butNext;
order[3] = butOK;
order[4] = butCancel;
getComposite().setTabList(order);
}
public void widgetSelected(SelectionEvent event) {
if (event.widget == butCancel) {
buttonCancelEvent();
} else if (event.widget == butOK) {
buttonSaveEvent();
} else if (event.widget == butNext) {
buttonNextEvent();
} else if (event.widget == butPrevious) {
buttonPrevEvent();
}
if (!getShell().isDisposed())
stateChanged();
}
*/
/**
* Eventhandler called every time the Cancel-Button is pressed.
* This Method is intendet to by implemented by the application
* programmer. This default implementation simply closes the Shell.
*/
protected void buttonCancelEvent() {
closeCancel();
}
/**
* Eventhandler called every time the Save-Button is pressed.
* This Method is intendet to by implemented by the application
* programmer. This default implementation simply closes the Shell.
*/
protected void buttonSaveEvent() {
closeOK();
}
/**
* Eventhandler called every time the Next-Button is pressed.
* Deactivates the currently active AssistentPage and
* activates the next AssistentPage. The next AssistentPage can be
* coosen by the currently active AssistentPage by implementing
* {@link AssistentPage#getNextPage()}.
* If this Method is not implentet the next AssistentPage in the
* internal List of the Assistent is coosen.
*/
public void buttonNextEvent() {
AssistentPage next = activePage.getNextPage();
if (next == null) {
int index = assistentPages.indexOf(activePage);
if (index < assistentPages.size()) {
next = (AssistentPage) assistentPages.get(index + 1);
}
}
if (next != null) {
activePage.leaveBase();
activePage.getComposite().dispose();
activePage = next;
activePage.initGUI();
activePage.enterBase();
getShell().layout(true);
}
}
/**
* Eventhandler called every time the Prev-Button is pressed.
* Deactivates the currently active AssistentPage and
* activates the previous AssistentPage. The previous AssistentPage can be
* coosen by the currently active AssistentPage by implementing
* {@link AssistentPage#getPrevPage()}.
* If this Method is not implented the preceding AssistentPage in the
* internal List of the Assistent is coosen.
*/
public void buttonPrevEvent() {
AssistentPage next = activePage.getPrevPage();
if (next == null) {
int index = assistentPages.indexOf(activePage);
if (index > 0) {
next = (AssistentPage) assistentPages.get(index - 1);
}
}
if (next != null) {
activePage.leaveBase();
activePage.getComposite().dispose();
activePage = next;
activePage.initGUI();
activePage.enterBase();
getShell().layout(true);
}
}
}