package com.quantum.view.bookmark;
-import com.quantum.Messages;
-import com.quantum.model.Bookmark;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
-import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.SelectionListenerAction;
+import com.quantum.Messages;
+import com.quantum.model.Bookmark;
+import com.quantum.wizards.BookmarkNameWizardPage;
+
/**
* @author BC
*/
public class RenameAction extends SelectionListenerAction {
+
+ public class RenameWizard extends Wizard implements PropertyChangeListener {
+
+ private BookmarkNameWizardPage page;
+ private String name;
+
+ public RenameWizard(String name) {
+ this.name = name;
+ }
+
+ public void addPages() {
+ super.addPages();
+ this.page = new BookmarkNameWizardPage("pageName", this.name);
+ this.page.addPropertyChangeListener(this);
+ addPage(this.page);
+ }
+
+ public void dispose() {
+ this.page.removePropertyChangeListener(this);
+ super.dispose();
+ }
+ public boolean performFinish() {
+ return true;
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if ("name".equals(event.getPropertyName())) {
+ setName((String) event.getNewValue());
+ }
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
private IViewPart viewPart;
super(Messages.getString(RenameAction.class.getName() + ".text"));
this.viewPart = viewPart;
}
-
-
/**
* @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
- InputDialog dialog = new InputDialog(this.viewPart.getSite().getShell(), "Select a new name",
- "Name: ", getBookmark().getName(), null);
+ RenameWizard wizard = new RenameWizard(getBookmark().getName());
+ WizardDialog dialog = new WizardDialog(this.viewPart.getSite().getShell(), wizard);
int result = dialog.open();
- if (result == InputDialog.OK) {
- getBookmark().setName(dialog.getValue());
+ if (result == WizardDialog.OK) {
+ getBookmark().setName(wizard.getName());
}
}
}