2 * $Id: ListElementWizardPage.java,v 1.1 2004-10-05 20:51:57 jsurfer Exp $
3 * Copyright Narushima Hironori. All rights reserved.
5 package net.sourceforge.phpeclipse.wizards.html;
7 import org.eclipse.swt.SWT;
8 import org.eclipse.swt.events.*;
9 import org.eclipse.swt.layout.*;
10 import org.eclipse.swt.widgets.*;
15 public class ListElementWizardPage extends EditElementWizardPage {
17 final static String[] LIST_TYPES = {"ul", "ol", "dl"};
21 public ListElementWizardPage() {
22 super("ListElementWizardPage");
24 setDescription("Editing list element.");
27 protected void createChildControl(Composite parent) {
28 parent.setLayout(new GridLayout(2, false));
29 Label labe = new Label(parent, SWT.NONE);
30 labe.setText("List &Type:");
32 types = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
34 for (int i = 0; i < LIST_TYPES.length; i++) {
35 String type = LIST_TYPES[i];
37 if( getElementName().equals(type) ){
42 types.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
43 types.addSelectionListener(new SelectionListener() {
44 public void widgetSelected(SelectionEvent e) {
45 setElementName( types.getText() );
48 public void widgetDefaultSelected(SelectionEvent e) {}
52 public String getPreviewText() {
53 String content = ((EditElementWizard) getWizard() ).getSelection().getText().trim();
55 String elemName = getElementName();
56 switch (getEditType()) {
58 content = chooseContent(content).trim();
62 String[] lines = content.split("\n+");
63 StringBuffer result = new StringBuffer();
64 for (int i = 0; i < lines.length; i++) {
66 if(elemName.equals("dl")){
67 itemElemName = (i % 2 == 0) ? "dt" : "dd";
71 result.append( "<" + itemElemName + ">" + lines[i].trim() + "</" + itemElemName + ">\n");
73 content = result.toString();
77 return "<" + elemName + ">\n" + content + "</" + elemName + ">\n";