1 package com.quantum.view.bookmark;
3 import java.io.IOException;
4 import java.util.ArrayList;
7 import com.quantum.Messages;
8 import com.quantum.actions.BaseExecuteAction;
9 import com.quantum.model.Bookmark;
10 import com.quantum.model.Entity;
11 import com.quantum.model.EntityHolder;
12 import com.quantum.sql.parser.DropEntityStatement;
13 import com.quantum.wizards.sql.DropEntityWizardPage;
14 import com.quantum.wizards.sql.SQLStatementWizard;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.jface.action.IStatusLineManager;
18 import org.eclipse.jface.viewers.IStructuredSelection;
19 import org.eclipse.jface.wizard.WizardDialog;
20 import org.eclipse.jface.wizard.WizardPage;
21 import org.eclipse.swt.widgets.Shell;
22 import org.eclipse.ui.IViewPart;
30 public class DropEntityAction extends BaseExecuteAction {
32 private final IViewPart view;
33 private DropEntityStatement statement = new DropEntityStatement();
35 public DropEntityAction(IViewPart view) {
37 setText(Messages.getString(getClass(), "text"));
41 Entity entity = getEntity();
43 this.statement.setTableName(entity.getQuotedTableName());
44 this.statement.setType(entity.getType());
47 DropEntityWizardPage page = new DropEntityWizardPage("page1", this.statement);
48 SQLStatementWizard wizard = new SQLStatementWizard(new WizardPage[] { page }, this.statement);
50 WizardDialog dialog = new WizardDialog(this.view.getViewSite().getShell(), wizard);
51 if (WizardDialog.OK == dialog.open()) {
55 protected Shell getShell() {
56 return this.view.getViewSite().getShell();
59 protected Bookmark getBookmark() {
60 Entity entity = getEntity();
61 return entity != null ? entity.getBookmark() : super.getBookmark();
63 protected List getQueries() throws IOException, CoreException {
64 List list = new ArrayList();
65 list.add(this.statement.toString());
69 protected Entity getEntity() {
70 List list = getSelectedNonResources();
71 return list == null || list.isEmpty() ? null : ((EntityHolder) list.get(0)).getEntity();
74 protected IStatusLineManager getStatusLineManager() {
75 return this.view.getViewSite().getActionBars().getStatusLineManager();
78 protected boolean updateSelection(IStructuredSelection selection) {
79 return !selection.isEmpty();