Added plog4u.de plog4u.org
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / wizards / html / FormElementWizardPage.java
1 /*
2  * $Id: FormElementWizardPage.java,v 1.1 2004-10-05 20:51:57 jsurfer 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.*;
10
11 /**
12  * 
13  */
14 public class FormElementWizardPage extends EditElementWizardPage {
15
16         Text actionText;
17         Button postRadio, getRadio, multipartCheck;
18         Combo charsetCombo;
19
20         public FormElementWizardPage() {
21                 super("FormElementWizardPage");
22         }
23
24         protected void createChildControl(Composite parent) throws CoreException {
25                 postRadio = new Button(parent, SWT.RADIO);
26                 
27         }
28
29         public String getPreviewText() {
30                 boolean controlCreated = actionText != null;
31                 
32                 StringBuffer buff = new StringBuffer("<form action=\"");
33                 if(controlCreated){
34                         buff.append(actionText.getText());
35                 }
36                 buff.append("\" method=\"");
37                 if( controlCreated && postRadio.getSelection() ){
38                         buff.append("POST\"");
39                         if(multipartCheck.getSelection()){
40                                 buff.append(" enctype=\"multipart/form-data\"");
41                         }
42                         
43                 }else{
44                         buff.append("GET\"");
45                 }
46                 
47                 if(controlCreated){
48                         String charset = charsetCombo.getText();
49                         if(charset != null){
50                                 buff.append(" accept-charset=\"" + charset + "\"");
51                         }
52                 }
53                 
54                 buff.append(">\n");
55                 buff.append( getSelectionText() );
56                 buff.append("\n</form>\n");
57                 
58                 return buff.toString();
59         }
60
61 }