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