Fixed: 1736622 - "php marker occurrences" color - did`t have an effect
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / wizards / html / NewElementWizardPage.java
1 /*
2  * $Id: NewElementWizardPage.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.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 public class NewElementWizardPage extends EditElementWizardPage {
21
22         Text elementName;
23
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())
51                                                         .createElementEditPage(eName);
52                                         nextPage.setElementName(eName);
53                                         if (nextPage instanceof UnknownElementWizardPage) {
54                                                 setMessage("This editor does not known element name.",
55                                                                 WARNING);
56                                         } else {
57                                                 setMessage(null, NONE);
58                                         }
59                                 }
60                                 refreshPreview();
61                                 getWizard().getContainer().updateButtons();
62                         }
63                 });
64         }
65
66         public String getPreviewText() {
67                 if (nextPage instanceof EditElementWizardPage) {
68                         return ((EditElementWizardPage) nextPage).getPreviewText();
69                 }
70                 return null;
71         }
72
73         public void setErrorMessage(String newMessage) {
74                 super.setErrorMessage(newMessage);
75                 if (newMessage != null) {
76                         nextPage = null;
77                 }
78         }
79
80         public IWizardPage getNextPage() {
81                 return nextPage;
82         }
83
84 }