*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / wizards / html / NewElementWizardPage.java
1 /*
2  * $Id: NewElementWizardPage.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.jface.wizard.IWizardPage;
8 import org.eclipse.swt.SWT;
9 import org.eclipse.swt.events.ModifyEvent;
10 import org.eclipse.swt.events.ModifyListener;
11 import org.eclipse.swt.layout.GridData;
12 import org.eclipse.swt.layout.GridLayout;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Label;
15 import org.eclipse.swt.widgets.Text;
16
17
18 /**
19  * 
20  */
21 public class NewElementWizardPage extends EditElementWizardPage {
22
23         Text elementName;
24         EditElementWizardPage nextPage = null;
25
26         public NewElementWizardPage() {
27                 super("NewElementPage");
28                 setTitle("Create HTML Element");
29                 setDescription("Specify new HTML tag (dl,ul,ol or table) and configure that tag.");
30         }
31         
32         protected void createChildControl(Composite base) {
33                 // create foundation component
34                 base.setLayout(new GridLayout(1, false));
35                 
36                 // element input components
37                 new Label(base, SWT.NONE).setText("&Element Name:");
38                 
39                 elementName = new Text(base, SWT.BORDER | SWT.SINGLE);
40                 elementName.setLayoutData( new GridData(GridData.FILL_HORIZONTAL));
41                 elementName.addModifyListener( new ModifyListener() {
42                         public void modifyText(ModifyEvent e) {
43                                 String eName = elementName.getText();
44                                 if( eName.indexOf(' ') != -1 ){
45                                         setErrorMessage("Don't contain blink in speicfied element name.");
46                                 } else if (eName.length() == 0){
47                                         setErrorMessage("Need to specify element name.");
48                                 } else {
49                                         setErrorMessage(null);
50                                         nextPage = ((EditElementWizard)getWizard()).createElementEditPage(eName);
51                                         nextPage.setElementName(eName);
52                                         if( nextPage instanceof UnknownElementWizardPage){
53                                                 setMessage("This editor does not known element name.", WARNING);
54                                         }else{
55                                                 setMessage(null, NONE);
56                                         }
57                                 }
58                                 refreshPreview();
59                                 getWizard().getContainer().updateButtons();
60                         }
61                 });
62         }
63         
64         public String getPreviewText(){
65                 if(nextPage instanceof EditElementWizardPage){
66                         return ((EditElementWizardPage)nextPage).getPreviewText();
67                 }
68                 return null;
69         }
70         
71         public void setErrorMessage(String newMessage) {
72                 super.setErrorMessage(newMessage);
73                 if( newMessage != null){
74                         nextPage = null;
75                 }
76         }
77
78         public IWizardPage getNextPage() {
79                 return nextPage;
80         }
81
82 }