1 package com.quantum.wizards;
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.events.ModifyEvent;
5 import org.eclipse.swt.events.ModifyListener;
6 import org.eclipse.swt.layout.GridData;
7 import org.eclipse.swt.layout.GridLayout;
8 import org.eclipse.swt.widgets.Composite;
9 import org.eclipse.swt.widgets.Label;
10 import org.eclipse.swt.widgets.Text;
12 import com.quantum.Messages;
13 import com.quantum.model.BookmarkCollection;
19 public class BookmarkNameWizardPage extends PropertyChangeWizardPage {
22 private final String originalName;
24 public BookmarkNameWizardPage(String pageName) {
31 public BookmarkNameWizardPage(String pageName, String originalName) {
33 this.originalName = originalName;
34 setTitle(Messages.getString(getClass(), "title"));
35 setDescription(Messages.getString(getClass(), "description"));
38 public void createControl(Composite parent) {
39 setPageComplete(false);
41 Composite composite = new Composite(parent, SWT.NONE);
42 GridLayout layout = new GridLayout();
43 layout.numColumns = 2;
44 composite.setLayout(layout);
46 Label label = new Label(composite, SWT.NONE);
47 label.setText(Messages.getString(getClass(), "name"));
49 Text name = new Text(composite, SWT.BORDER | SWT.SINGLE);
50 GridData data = new GridData(GridData.FILL_HORIZONTAL);
51 name.setLayoutData(data);
52 if (this.originalName != null) {
53 name.setText(this.originalName);
55 name.addModifyListener(new ModifyListener() {
56 public void modifyText(ModifyEvent event) {
57 String name = ((Text) event.getSource()).getText();
61 setControl(composite);
67 private void setName(String bookmarkName) {
68 String errorMessage = null;
70 if (bookmarkName == null || bookmarkName.trim().length() == 0) {
71 errorMessage = Messages.getString(getClass(), "mustProvide");
73 } else if (this.originalName != null && this.originalName.equals(bookmarkName)) {
75 } else if (BookmarkCollection.getInstance().find(bookmarkName) != null) {
76 errorMessage = Messages.getString(getClass(), "alreadyExists");
80 setErrorMessage(errorMessage);
81 setPageComplete(done);
83 if (errorMessage == null && !bookmarkName.equals(this.name)) {
84 String original = this.name;
85 this.name = bookmarkName;
86 firePropertyChange("name", original, bookmarkName);
91 * @return Returns the name.
93 public String getName() {