📄 choosetheroutines.java
字号:
package GUI;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.*;
import PizzaProduct.Pizza;
public class ChooseTheRoutines extends Dialog {
protected Object result;
protected Shell shell;
protected Pizza[] pizzas;
protected int routinestime;
/**
* Create the dialog
* @param parent
* @param style
*/
public ChooseTheRoutines(Shell parent, int style) {
super(parent, style);
}
/**
* Create the dialog
* @param parent
*/
public ChooseTheRoutines(Shell parent) {
this(parent, SWT.NONE);
}
public ChooseTheRoutines(Shell parent , Pizza[] pizzas) {
this(parent, SWT.NONE);
this.pizzas = pizzas;
}
/**
* Open the dialog
* @return the result
*/
public Object open() {
createContents();
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return result;
}
/**
* Create contents of the dialog
*/
protected void createContents() {
shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setSize(363, 173);
shell.setText("请选择");
final Label label = new Label(shell, SWT.NONE);
label.setText("请选择PIZZA的烘烤速度");
label.setBounds(26, 23, 151, 35);
final Button fastButton = new Button(shell, SWT.RADIO);
fastButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
routinestime=3;
}
});
fastButton.setText("Fast");
fastButton.setBounds(26, 64, 93, 16);
final Button normalButton = new Button(shell, SWT.RADIO);
normalButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
routinestime=5;
}
});
normalButton.setText("Normal");
normalButton.setBounds(141, 64, 93, 16);
final Button slowButton = new Button(shell, SWT.RADIO);
slowButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
routinestime=10;
}
});
slowButton.setText("Slow");
slowButton.setBounds(256, 64, 93, 16);
/**
* We need to check if user has choosed a routines
* and Set the routines of all the pizza in the order
* after do that, we need to go to next.
* Create a dialog to get the information that if the customer eatting in the store.
*/
final Button button = new Button(shell, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int i;
if(fastButton.getSelection()||normalButton.getSelection()||slowButton.getSelection()){
for(i=0;i<pizzas.length;i++){
pizzas[i].setRoutines(routinestime);
}
final Shell fornext;
fornext=shell.getShell();
final IfInStore ifinstore= new IfInStore(fornext,pizzas);
ifinstore.open();
shell.close();
}
else
MessageDialog.openWarning(shell, "警告","请选择烘烤的速度");
}
});
button.setText("确定");
button.setBounds(96, 102, 48, 22);
final Button cancelbutton = new Button(shell, SWT.NONE);
cancelbutton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
shell.close();
}
});
cancelbutton.setText("返回");
cancelbutton.setBounds(205, 102, 48, 22);
//
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -