package net.sourceforge.phpdt.sql.view;
+import net.sourceforge.phpdt.sql.Messages;
import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
import net.sourceforge.phpdt.sql.actions.CloseTableAction;
import net.sourceforge.phpdt.sql.actions.RefreshTableAction;
import net.sourceforge.phpdt.sql.sql.SQLResults;
import net.sourceforge.phpdt.sql.sql.TableRow;
+import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
import net.sourceforge.phpdt.sql.view.tableview.TableAdapter;
import net.sourceforge.phpdt.sql.wizards.DeleteRowPage;
import net.sourceforge.phpdt.sql.wizards.InsertRowPage;
import org.eclipse.ui.part.ViewPart;
public class TableView extends ViewPart implements ISelectionListener {
- public static String TABLEVIEW_ID =
- "net.sourceforge.phpdt.sql.view.tableview";
private Clipboard clip;
private RefreshTableAction refreshTableAction;
private CloseTableAction closeTableAction;
public void refreshCurrent() {
TabItem item = tabs.getItem(tabs.getSelectionIndex());
TableAdapter adapter = (TableAdapter) item.getData();
+ BookmarkView bookmarkView = BookmarkView.getInstance();
+ BookmarkNode bookmark = bookmarkView.getCurrentBookmark();
String table = adapter.getTable();
if (table == null) {
- loadTable(item, null, null, true, true);
+ loadTable(bookmark, item, null, null, true, true);
} else {
- loadTable(item, null, null, true, true);
+ loadTable(bookmark, item, null, null, true, true);
}
}
- public void loadQuery(SQLResults results) {
- loadTable(null, null, results, true, false);
+ public void loadQuery(BookmarkNode bookmark, SQLResults results) {
+ loadTable(bookmark, null, null, results, true, false);
}
- public void loadTable(String table) {
- loadTable(null, table, null, false, true);
+ public void loadTable(BookmarkNode bookmark, String table) {
+ loadTable(bookmark, null, table, null, false, true);
}
- public void loadTable(
- TabItem tabItem,
- String entity,
- SQLResults results,
- boolean query,
- boolean reload) {
+ public void loadTable(BookmarkNode bookmark, TabItem tabItem, String entity, SQLResults results, boolean query, boolean reload) {
TableAdapter adapter;
if (tabItem == null) {
tabItem = new TabItem(tabs, SWT.NONE);
if (query) {
- adapter = TableAdapter.createFromQuery(results);
+ adapter = TableAdapter.createFromQuery(bookmark, results);
} else {
- adapter = TableAdapter.createFromTable(entity);
+ adapter = TableAdapter.createFromTable(bookmark, entity);
}
tabItem.setData(adapter);
} else {
}
text.append('\n');
}
- clip.setContents(
- new Object[] { text.toString()},
- new Transfer[] { TextTransfer.getInstance()});
+ clip.setContents(new Object[] { text.toString()}, new Transfer[] { TextTransfer.getInstance()});
}
};
final Action selectAllAction = new Action() {
final ToolItem previous = new ToolItem(toolbar, SWT.PUSH);
final ToolItem next = new ToolItem(toolbar, SWT.PUSH);
- fullMode.setImage(PHPEclipseSQLPlugin.getImage("fulldata.gif"));
+ fullMode.setImage(PHPEclipseSQLPlugin.getImage("fulldata.gif")); //$NON-NLS-1$
fullMode.setToolTipText(Messages.getString("tableview.showAll")); //$NON-NLS-1$
fullMode.setSelection(false);
fullMode.addSelectionListener(new SelectionListener() {
next.setEnabled(ta.hasNextPage());
}
});
- previous.setImage(PHPEclipseSQLPlugin.getImage("previous.gif"));
- previous.setToolTipText("Previous");
+ previous.setImage(PHPEclipseSQLPlugin.getImage("previous.gif")); //$NON-NLS-1$
+ previous.setToolTipText("Previous"); //$NON-NLS-1$
previous.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
next.setEnabled(ta.hasNextPage());
}
});
- next.setImage(PHPEclipseSQLPlugin.getImage("next.gif"));
- next.setToolTipText("Next");
+ next.setImage(PHPEclipseSQLPlugin.getImage("next.gif")); //$NON-NLS-1$
+ next.setToolTipText("Next"); //$NON-NLS-1$
next.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
}
String data[] = new String[columnNames.length];
for (int i = 0; i < columns.length; i++) {
- data[i] = "";
+ data[i] = ""; //$NON-NLS-1$
}
- final TableRow emptyRow = new TableRow(ta.getTable(), columnNames, data);
+
+ final TableRow emptyRow = new TableRow(ta.getBookmark(), ta.getTable(), columnNames, data);
filter.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
- SortFilterPage page = new SortFilterPage("");
+ SortFilterPage page = new SortFilterPage(""); //$NON-NLS-1$
SQLRowWizard wizard = new SQLRowWizard();
- wizard.init("Filter and Sort", page, emptyRow, ta);
+ wizard.init(Messages.getString("TableView.FilterAndSort"), page, emptyRow, ta); //$NON-NLS-1$
WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
}
}
} else {
for (int i = 0; i < columns.length; i++) {
- data[i] = "";
+ data[i] = ""; //$NON-NLS-1$
}
}
- final TableRow row = new TableRow(ta.getTable(), columnNames, data);
- Action updateAction = new Action() {
+ final TableRow row = new TableRow(ta.getBookmark(), ta.getTable(), columnNames, data);
+ Action phpSelectAction = new Action() {
public void run() {
- UpdateRowPage page = new UpdateRowPage("");
+ PHPSelectRowPage page = new PHPSelectRowPage(""); //$NON-NLS-1$
SQLRowWizard wizard = new SQLRowWizard();
- wizard.init("Update Row", page, row, ta);
- WizardDialog dialog =
- new WizardDialog(getSite().getShell(), wizard);
+ wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
}
};
- updateAction.setText(Messages.getString("tableview.update")); //$NON-NLS-1$
- Action insertAction = new Action() {
+ phpSelectAction.setText(Messages.getString("tableview.phpselect")); //$NON-NLS-1$
+
+ Action phpUpdateAction = new Action() {
public void run() {
- InsertRowPage page = new InsertRowPage("");
+ PHPUpdateRowPage page = new PHPUpdateRowPage(""); //$NON-NLS-1$
SQLRowWizard wizard = new SQLRowWizard();
- wizard.init("Insert Row", page, row, ta);
- WizardDialog dialog =
- new WizardDialog(getSite().getShell(), wizard);
+ wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
}
};
- insertAction.setText(Messages.getString("tableview.insert")); //$NON-NLS-1$
- Action deleteAction = new Action() {
+ phpUpdateAction.setText(Messages.getString("tableview.phpupdate")); //$NON-NLS-1$
+ Action phpInsertAction = new Action() {
public void run() {
- DeleteRowPage page = new DeleteRowPage("");
+ PHPInsertRowPage page = new PHPInsertRowPage(""); //$NON-NLS-1$
SQLRowWizard wizard = new SQLRowWizard();
- wizard.init("Delete Row", page, row, ta);
- WizardDialog dialog =
- new WizardDialog(getSite().getShell(), wizard);
+ wizard.init(Messages.getString("TableView.InsertRow"), page, row, ta); //$NON-NLS-1$
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
}
};
- deleteAction.setText(Messages.getString("tableview.delete")); //$NON-NLS-1$
-
- Action phpSelectAction = new Action() {
+ phpInsertAction.setText(Messages.getString("tableview.phpinsert")); //$NON-NLS-1$
+ Action phpDeleteAction = new Action() {
public void run() {
- PHPSelectRowPage page = new PHPSelectRowPage("");
+ PHPDeleteRowPage page = new PHPDeleteRowPage(""); //$NON-NLS-1$
SQLRowWizard wizard = new SQLRowWizard();
- wizard.init("PHP Select Generator", page, row, ta);
- WizardDialog dialog =
- new WizardDialog(getSite().getShell(), wizard);
+ wizard.init(Messages.getString("TableView.DeleteRow"), page, row, ta); //$NON-NLS-1$
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
}
};
- phpSelectAction.setText(Messages.getString("tableview.phpselect")); //$NON-NLS-1$
+ phpDeleteAction.setText(Messages.getString("tableview.phpdelete")); //$NON-NLS-1$
- Action phpUpdateAction = new Action() {
+ Action updateAction = new Action() {
public void run() {
- PHPUpdateRowPage page = new PHPUpdateRowPage("");
+ UpdateRowPage page = new UpdateRowPage(""); //$NON-NLS-1$
SQLRowWizard wizard = new SQLRowWizard();
- wizard.init("PHP Update Generator", page, row, ta);
- WizardDialog dialog =
- new WizardDialog(getSite().getShell(), wizard);
+ wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
}
};
- phpUpdateAction.setText(Messages.getString("tableview.phpupdate")); //$NON-NLS-1$
-
- Action phpInsertAction = new Action() {
+ updateAction.setText(Messages.getString("tableview.update")); //$NON-NLS-1$
+ Action insertAction = new Action() {
public void run() {
- PHPInsertRowPage page = new PHPInsertRowPage("");
+ InsertRowPage page = new InsertRowPage(""); //$NON-NLS-1$
SQLRowWizard wizard = new SQLRowWizard();
- wizard.init("PHP Insert Generator", page, row, ta);
- WizardDialog dialog =
- new WizardDialog(getSite().getShell(), wizard);
+ wizard.init(Messages.getString("TableView.InsertRow"), page, row, ta); //$NON-NLS-1$
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
}
};
- phpInsertAction.setText(Messages.getString("tableview.phpinsert")); //$NON-NLS-1$
-
- Action phpDeleteAction = new Action() {
+ insertAction.setText(Messages.getString("tableview.insert")); //$NON-NLS-1$
+ Action deleteAction = new Action() {
public void run() {
- PHPDeleteRowPage page = new PHPDeleteRowPage("");
+ DeleteRowPage page = new DeleteRowPage(""); //$NON-NLS-1$
SQLRowWizard wizard = new SQLRowWizard();
- wizard.init("PHP Delete Generator", page, row, ta);
- WizardDialog dialog =
- new WizardDialog(getSite().getShell(), wizard);
+ wizard.init(Messages.getString("TableView.DeleteRow"), page, row, ta); //$NON-NLS-1$
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), wizard);
dialog.open();
}
};
- phpDeleteAction.setText(Messages.getString("tableview.phpdelete")); //$NON-NLS-1$
-
+ deleteAction.setText(Messages.getString("tableview.delete")); //$NON-NLS-1$
mgr.add(phpSelectAction);
- mgr.add(phpUpdateAction);
mgr.add(phpInsertAction);
+ mgr.add(phpUpdateAction);
mgr.add(phpDeleteAction);
mgr.add(insertAction);
mgr.add(updateAction);
mgr.add(deleteAction);
-
}
mgr.add(defaultEncodingAction);
mgr.add(UTF8EncodingAction);
}
public void initActions() {
refreshTableAction = new RefreshTableAction();
- refreshTableAction.setText(Messages.getString("tableview.refresh"));
- refreshTableAction.setImageDescriptor(
- PHPEclipseSQLPlugin.getImageDescriptor("refresh.gif"));
+ refreshTableAction.setText(Messages.getString("tableview.refresh")); //$NON-NLS-1$
+ refreshTableAction.setImageDescriptor(PHPEclipseSQLPlugin.getImageDescriptor("refresh.gif")); //$NON-NLS-1$
refreshTableAction.init(this);
closeTableAction = new CloseTableAction();
- closeTableAction.setText(Messages.getString("tableview.close"));
- closeTableAction.setImageDescriptor(
- PHPEclipseSQLPlugin.getImageDescriptor("close.gif"));
+ closeTableAction.setText(Messages.getString("tableview.close")); //$NON-NLS-1$
+ closeTableAction.setImageDescriptor(PHPEclipseSQLPlugin.getImageDescriptor("close.gif")); //$NON-NLS-1$
closeTableAction.init(this);
}