d9ab7e7ca3dc3e39fb703305d77455e808f36ec8
[phpeclipse.git] /
1 /*
2  * $Id: FormElementWizardPage.java,v 1.3 2006-10-21 23:18:43 pombredanne Exp $
3  * Copyright Narushima Hironori. All rights reserved.
4  */
5 package net.sourceforge.phpeclipse.wizards.html;
6
7 import org.eclipse.core.runtime.CoreException;
8 import org.eclipse.swt.SWT;
9 import org.eclipse.swt.widgets.Button;
10 import org.eclipse.swt.widgets.Combo;
11 import org.eclipse.swt.widgets.Composite;
12 import org.eclipse.swt.widgets.Text;
13
14 /**
15  * 
16  */
17 public class FormElementWizardPage extends EditElementWizardPage {
18
19         Text actionText;
20
21         Button postRadio, getRadio, multipartCheck;
22
23         Combo charsetCombo;
24
25         public FormElementWizardPage() {
26                 super("FormElementWizardPage");
27         }
28
29         protected void createChildControl(Composite parent) throws CoreException {
30                 postRadio = new Button(parent, SWT.RADIO);
31
32         }
33
34         public String getPreviewText() {
35                 boolean controlCreated = actionText != null;
36
37                 StringBuffer buff = new StringBuffer("<form action=\"");
38                 if (controlCreated) {
39                         buff.append(actionText.getText());
40                 }
41                 buff.append("\" method=\"");
42                 if (controlCreated && postRadio.getSelection()) {
43                         buff.append("POST\"");
44                         if (multipartCheck.getSelection()) {
45                                 buff.append(" enctype=\"multipart/form-data\"");
46                         }
47
48                 } else {
49                         buff.append("GET\"");
50                 }
51
52                 if (controlCreated) {
53                         String charset = charsetCombo.getText();
54                         if (charset != null) {
55                                 buff.append(" accept-charset=\"" + charset + "\"");
56                         }
57                 }
58
59                 buff.append(">\n");
60                 buff.append(getSelectionText());
61                 buff.append("\n</form>\n");
62
63                 return buff.toString();
64         }
65
66 }