package ch.sahits;
import java.util.Iterator;
import java.util.Vector;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
public class Taz {
private Display display = new Display();
private Shell shell = new Shell(display);
private String date="20080809";
private String date="20080809";
private String date="20080809";
private String date="20080809";
private String date="20080809";
private String date="20080809";
private String date="20080809";
private String date="20080809";
private String date="20080809";
private Label lbl;
private Text txtUsername;
private Label lbl1;
private Text txtPassword;
private Label lbl2;
private Text txtDescription;
private Label lbl3;
private Composite checkCreditComp;
private Button checkCredit;
private Button checkCredit1;
private Button checkCredit2;
private Label lbl4;
private List listTop5;
private Label lbl5;
private Combo comboTop3;
private Label lbl6;
private Composite fupFileComp;
private Text fupFile;
private Button btnBrowseFile;
private Label lbl7;
private Composite checkZutatComp;
private Button checkZutat;
private Button checkZutat1;
private Button checkZutat2;
private Button btnInput3;
private Button btnInput31;
/**
* Default constructor initializes this GUI element
*/
public Taz(){
createControl(getShell());
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
// If no more entries in event queue
display.sleep();
}
}
display.dispose();
}
/**
* Create all the field instances
* @param parent container
*/
private void init(Composite parent){
lbl = new Label(parent,SWT.NULL);
txtUsername = new Text(parent,SWT.BORDER | SWT.SINGLE);
lbl1 = new Label(parent,SWT.NULL);
txtPassword = new Text(parent,SWT.BORDER | SWT.PASSWORD);
lbl2 = new Label(parent,SWT.NULL);
txtDescription = new Text(parent,SWT.BORDER | SWT.WRAP| SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
lbl3 = new Label(parent,SWT.NULL);
checkCreditComp = new Composite(parent,SWT.NULL);
checkCredit = new Button(parent,SWT.CHECK);
checkCredit1 = new Button(parent,SWT.CHECK);
checkCredit2 = new Button(parent,SWT.CHECK);
lbl4 = new Label(parent,SWT.NULL);
listTop5 = new org.eclipse.swt.widgets.List(parent,SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
lbl5 = new Label(parent,SWT.NULL);
comboTop3 = new Combo(parent,SWT.DROP_DOWN);
lbl6 = new Label(parent,SWT.NULL);
fupFileComp = new Composite(parent,SWT.NULL);
fupFile = new Text(parent,SWT.BORDER | SWT.SINGLE);
btnBrowseFile = new Button(parent,SWT.PUSH);
lbl7 = new Label(parent,SWT.NULL);
checkZutatComp = new Composite(parent,SWT.NULL);
checkZutat = new Button(parent,SWT.CHECK);
checkZutat1 = new Button(parent,SWT.CHECK);
checkZutat2 = new Button(parent,SWT.CHECK);
btnInput3 = new Button(parent,SWT.PUSH);
btnInput31 = new Button(parent,SWT.PUSH);
}
/**
* Retrive the shell of this GUI element
* @return shell
*/
private Shell getShell(){
return shell;
}
/**
* Set the control up with the layout and the input fields
*/
private void createControl(Composite composite) {
Composite container = shell;//new Composite(composite, SWT.NULL);
init(container);
container.setFont(composite.getFont());
GridLayout layout = new GridLayout();
container.setLayout(layout);
int nColumns = 4;
layout.numColumns = nColumns;
layout.verticalSpacing = 9;
// Create the different elements
createInput(container, lbl, txtUsername, "User name:", true, true,
true, "", "");
createPassword(container, lbl1, txtPassword, "Password:", true, true,
true, "", "");
createTextArea(container, lbl2, txtDescription, "Description:", true,
true, true, "", "Some text");
{
Button[] btns = {checkCredit, checkCredit1, checkCredit2};
String[] text = {"Mastercard", "Visa", "AmericanExpress"};
String[] tooltip = {"", "", ""};
boolean[] visible={true, true, true};
boolean[] editable={true, true, true};
boolean[] selected ={true, false, false};
createRadioButtons(container,checkCreditComp, lbl3, btns, "Credit card:", text,
tooltip, visible, editable,selected);
}
{
Vector<String> l = new Vector<String>();l.add("Heino");l.add("Michael Jackson");l.add("Tom Waits");l.add("Nina Hagen");l.add("Marianne Rosenberg");
createList(container, lbl4, listTop5, "Artists:", true, true,
true, "", l, true);
}
{
Vector<String> l = new Vector<String>();l.add("Prince");l.add("Wired Al");l.add("R.E.M.");l.add("Red Hot chilli Peppers");l.add("Wham");
createCombo(container, lbl5, comboTop3, "More Artists", true,
true, true, "",
-1, l);
}
Vector<String> l = new Vector<String>();l.add("text/*");
{
String[] accType = {"text/*"};
createFileBrowse(container, fupFileComp, lbl6, fupFile, btnBrowseFile, "File upload:", true,
true, true, "", "Search",
"Search", accType);
}
{
Button[] btns = {checkZutat, checkZutat1, checkZutat2};
String[] text = {"salami", "funghi", "anchovi"};
String[] tooltip = {"", "", ""};
boolean[] visible={true, true, true};
boolean[] editable={true, true, true};
boolean[] selected ={false, false, false};
createCheckBoxes(container,checkZutatComp, lbl7, btns, "Topping:",text,
tooltip , visible, editable, selected);
}
createButton(container, btnInput3, " Save ", "",
true, true);createResetButton(container, btnInput31, " Cancel", "",
true, true);
}
/**
* Create a button
* @param parent container
* @param btn Button
* @param btnText button text
* @param tooltip button tooltip
* @param visible is the button visible
* @param editable is the button cklickable
*/
private void createButton(Composite parent,Button btn,String btnText,String tooltip,boolean visible,boolean editable) {
btn.setText(btnText);
btn.setToolTipText(tooltip);
btn.setEnabled(editable);
btn.setVisible(visible);
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// set the default data
}
});
}
/**
* Create a reset buttonbutton
* @param parent container
* @param btn Button
* @param btnText button text
* @param tooltip button tooltip
* @param visible is the button visible
* @param editable is the button cklickable
*/
private void createResetButton(Composite parent,Button btn,String btnText,String tooltip,boolean visible,boolean editable) {
btn.setText(btnText);
btn.setToolTipText(tooltip);
btn.setEnabled(editable);
btn.setVisible(visible);
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// set the default data
}
});
}
}