Improved template handling in HTML partition
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / wizards / html / FormElementWizardPage.java
1 /*
2  * $Id: FormElementWizardPage.java,v 1.2 2005-05-06 00:57:33 stefanbjarni 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         Button postRadio, getRadio, multipartCheck;
21         Combo charsetCombo;
22
23         public FormElementWizardPage() {
24                 super("FormElementWizardPage");
25         }
26
27         protected void createChildControl(Composite parent) throws CoreException {
28                 postRadio = new Button(parent, SWT.RADIO);
29                 
30         }
31
32         public String getPreviewText() {
33                 boolean controlCreated = actionText != null;
34                 
35                 StringBuffer buff = new StringBuffer("<form action=\"");
36                 if(controlCreated){
37                         buff.append(actionText.getText());
38                 }
39                 buff.append("\" method=\"");
40                 if( controlCreated && postRadio.getSelection() ){
41                         buff.append("POST\"");
42                         if(multipartCheck.getSelection()){
43                                 buff.append(" enctype=\"multipart/form-data\"");
44                         }
45                         
46                 }else{
47                         buff.append("GET\"");
48                 }
49                 
50                 if(controlCreated){
51                         String charset = charsetCombo.getText();
52                         if(charset != null){
53                                 buff.append(" accept-charset=\"" + charset + "\"");
54                         }
55                 }
56                 
57                 buff.append(">\n");
58                 buff.append( getSelectionText() );
59                 buff.append("\n</form>\n");
60                 
61                 return buff.toString();
62         }
63
64 }