+++ /dev/null
-package com.quantum.ui.dialog;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
-import com.quantum.Messages;
-import com.quantum.model.Bookmark;
-import com.quantum.model.BookmarkCollection;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @author BC
- */
-public class BookmarkSelectionDialog extends Dialog {
-
- private List list;
- private String selection = null;
- private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
-
- /**
- * @param parentShell
- */
- public BookmarkSelectionDialog(Shell parentShell) {
- super(parentShell);
- int style = getShellStyle() | SWT.TITLE;
- setShellStyle(style);
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(Messages.getString("BookmarkSelectionDialog.title"));
- }
-
- /**
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
-
- Composite composite = new Composite(parent, 0);
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
- layout.numColumns = 1;
- layout.verticalSpacing = 1;
-
- Label label = new Label(composite, SWT.NULL);
- label.setText(Messages.getString("BookmarkSelectionDialog.text"));
-
- this.list = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
- Bookmark[] bookmarks = BookmarkCollection.getInstance().getBookmarks();
-
- for (int i = 0, length = (bookmarks == null) ? 0 : bookmarks.length; i < length; i++) {
- this.list.add(bookmarks[i].getName());
- if (i == 0) {
- this.list.select(i);
- setSelection(bookmarks[i].getName());
- }
- }
-
- final List list = this.list;
- list.addListener(SWT.Selection, new Listener() {
- public void handleEvent (Event event) {
- String[] selections = list.getSelection();
- if (selections != null && selections.length > 0) {
- BookmarkSelectionDialog.this.setSelection(selections[0]);
- }
- }
- });
-
- GridData full = new GridData();
- full.horizontalAlignment = GridData.FILL;
- full.verticalAlignment = GridData.FILL;
- full.heightHint = convertHeightInCharsToPixels(3);
- this.list.setLayoutData(full);
-
- return composite;
- }
-
- /**
- * @param listener
- */
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- this.propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
- /**
- * @param listener
- */
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- this.propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
- private void setSelection(String selection) {
- String original = this.selection;
- if (this.selection == null || !this.selection.equals(selection)) {
- this.selection = selection;
- this.propertyChangeSupport.firePropertyChange("selection", original, this.selection);
- }
- }
-}
+++ /dev/null
-/*
- * Created on 28-jul-2003
- *
- */
-package com.quantum.view;
-
-import com.quantum.QuantumPlugin;
-import com.quantum.view.tableview.TableView;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-
-public final class CopyAction extends Action {
- private final Table table;
- public CopyAction(TableView view, Table table) {
- super();
- this.table = table;
- }
- public void run() {
- TableItem items[] = table.getSelection();
- StringBuffer text = new StringBuffer();
- for (int i = 0; i < items.length; i++) {
- int columns = table.getColumnCount();
- for (int col = 0; col < columns; col++) {
- text.append(items[i].getText(col));
- text.append('\t');
- }
- text.append('\n');
- }
- QuantumPlugin.getDefault().getSysClip().setContents(
- new Object[] { text.toString()},
- new Transfer[] { TextTransfer.getInstance()});
- }
-}
\ No newline at end of file
+++ /dev/null
-package com.quantum.view;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-import com.quantum.model.BookmarkCollection;
-
-
-/**
- * @author BC
- */
-public class JDBCDriverContentProvider implements IStructuredContentProvider {
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public Object[] getElements(Object inputElement) {
- if (inputElement == BookmarkCollection.getInstance()) {
- return BookmarkCollection.getInstance().getJDBCDrivers();
- } else {
- return null;
- }
- }
-
-}
+++ /dev/null
-package com.quantum.view;
-
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-
-
-/**
- * @author BC
- */
-public class JDBCDriverView extends ViewPart {
-
- private JDBCDriverTableViewer viewer;
-
- public void createPartControl(Composite parent) {
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- parent.setLayout(layout);
- this.viewer = new JDBCDriverTableViewer(parent);
- this.viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- public void setFocus() {
- }
- public void dispose() {
- this.viewer.dispose();
- super.dispose();
- }
-}
+++ /dev/null
-package com.quantum.view.tableview;
-
-public class DefaultSizes {
- public static int PAGE_SIZE = 200;
- public static int MAX_COLUMN_SIZE = 1024 * 2;
-}
+++ /dev/null
-/*
- * Created on 28-jul-2003
- *
- */
-package com.quantum.view.tableview;
-import java.util.Vector;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import com.quantum.Messages;
-import com.quantum.extensions.ExtensionAction;
-import com.quantum.sql.TableRow;
-import com.quantum.util.StringMatrix;
-import com.quantum.wizards.DeleteRowPage;
-import com.quantum.wizards.InsertRowPage;
-import com.quantum.wizards.PHPDeleteRowPage;
-import com.quantum.wizards.PHPInsertRowPage;
-import com.quantum.wizards.PHPSelectRowPage;
-import com.quantum.wizards.PHPUpdateRowPage;
-import com.quantum.wizards.SQLRowWizard;
-import com.quantum.wizards.UpdateRowPage;
-public final class TableViewMenuListener implements IMenuListener {
- private final TableView tableView;
- private final Table table;
- private final Action UTF16EncodingAction;
- private final TableAdapter ta;
- private final Action defaultEncodingAction;
- private final Action UTF8EncodingAction;
- private final Vector extensionVector;
- public TableViewMenuListener(TableView view, Table table,
- Action UTF16EncodingAction, TableAdapter ta,
- Action defaultEncodingAction, Action UTF8EncodingAction,
- Vector extensionVector) {
- super();
- this.tableView = view;
- this.table = table;
- this.UTF16EncodingAction = UTF16EncodingAction;
- this.ta = ta;
- this.defaultEncodingAction = defaultEncodingAction;
- this.UTF8EncodingAction = UTF8EncodingAction;
- this.extensionVector = extensionVector;
- }
- public void menuAboutToShow(IMenuManager mgr) {
- if (ta.getTable() != null) {
- TableItem[] selection = table.getSelection();
- TableColumn[] columns = table.getColumns();
- // Copy in columnNames the names of the columns of the selected rows
- String columnNames[] = new String[columns.length];
- for (int i = 0; i < columns.length; i++) {
- columnNames[i] = columns[i].getText();
- }
- // Copy in data the values of the data columns of the selected rows
- StringMatrix data = new StringMatrix();
- data.addMatrixHeader(columnNames);
- if (selection != null && selection.length > 0) {
- for (int iRow = 0; iRow < selection.length; iRow++) {
- TableItem sel = selection[iRow];
- for (int i = 0; i < columns.length; i++) {
- data.addAt(columnNames[i], sel.getText(i), iRow);
- }
- }
- } else {
- // Create dummy values in case nothing selected
- for (int i = 0; i < columns.length; i++) {
- data.addAt(columnNames[i], "", 0); //$NON-NLS-1$
- }
- }
- final TableRow row = new TableRow(ta.getEntity(), ta.getBookmark(), ta
- .getTable(), data);
- Action phpSelectAction = new Action() {
- public void run() {
- PHPSelectRowPage page = new PHPSelectRowPage(""); //$NON-NLS-1$
- SQLRowWizard wizard = new SQLRowWizard();
- wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
- WizardDialog dialog = new WizardDialog(tableView.getSite().getShell()
- .getShell(), wizard);
- dialog.open();
- }
- };
- phpSelectAction.setText(Messages.getString("tableview.phpselect")); //$NON-NLS-1$
- Action phpUpdateAction = new Action() {
- public void run() {
- PHPUpdateRowPage page = new PHPUpdateRowPage(""); //$NON-NLS-1$
- SQLRowWizard wizard = new SQLRowWizard();
- wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
- WizardDialog dialog = new WizardDialog(
- tableView.getSite().getShell(), wizard);
- dialog.open();
- }
- };
- phpUpdateAction.setText(Messages.getString("tableview.phpupdate")); //$NON-NLS-1$
- Action phpInsertAction = new Action() {
- public void run() {
- PHPInsertRowPage page = new PHPInsertRowPage(""); //$NON-NLS-1$
- SQLRowWizard wizard = new SQLRowWizard();
- wizard.init(Messages.getString("TableView.InsertRow"), page, row, ta); //$NON-NLS-1$
- WizardDialog dialog = new WizardDialog(
- tableView.getSite().getShell(), wizard);
- dialog.open();
- }
- };
- phpInsertAction.setText(Messages.getString("tableview.phpinsert")); //$NON-NLS-1$
- Action phpDeleteAction = new Action() {
- public void run() {
- PHPDeleteRowPage page = new PHPDeleteRowPage(""); //$NON-NLS-1$
- SQLRowWizard wizard = new SQLRowWizard();
- wizard.init(Messages.getString("TableView.DeleteRow"), page, row, ta); //$NON-NLS-1$
- WizardDialog dialog = new WizardDialog(
- tableView.getSite().getShell(), wizard);
- dialog.open();
- }
- };
- phpDeleteAction.setText(Messages.getString("tableview.phpdelete")); //$NON-NLS-1$
- Action updateAction = new Action() {
- public void run() {
- UpdateRowPage page = new UpdateRowPage(""); //$NON-NLS-1$
- SQLRowWizard wizard = new SQLRowWizard();
- wizard.init(Messages.getString("TableView.UpdateRow"), page, row, ta); //$NON-NLS-1$
- WizardDialog dialog = new WizardDialog(
- tableView.getSite().getShell(), wizard);
- dialog.open();
- }
- };
- updateAction.setText(Messages.getString("tableview.update")); //$NON-NLS-1$
- Action insertAction = new Action() {
- public void run() {
- InsertRowPage page = new InsertRowPage(""); //$NON-NLS-1$
- SQLRowWizard wizard = new SQLRowWizard();
- wizard.init(Messages.getString("TableView.InsertRow"), page, row, ta); //$NON-NLS-1$
- WizardDialog dialog = new WizardDialog(
- tableView.getSite().getShell(), wizard);
- dialog.open();
- }
- };
- insertAction.setText(Messages.getString("tableview.insert")); //$NON-NLS-1$
- Action deleteAction = new Action() {
- public void run() {
- DeleteRowPage page = new DeleteRowPage(""); //$NON-NLS-1$
- SQLRowWizard wizard = new SQLRowWizard();
- wizard.init(Messages.getString("TableView.DeleteRow"), page, row, ta); //$NON-NLS-1$
- WizardDialog dialog = new WizardDialog(
- tableView.getSite().getShell(), wizard);
- dialog.open();
- }
- };
- deleteAction.setText(Messages.getString("tableview.delete")); //$NON-NLS-1$
- mgr.add(phpSelectAction);
- mgr.add(phpInsertAction);
- mgr.add(phpUpdateAction);
- mgr.add(phpDeleteAction);
- mgr.add(insertAction);
- mgr.add(updateAction);
- mgr.add(deleteAction);
- MenuManager subMenuExtension = new MenuManager("Extensions");
- for (int i = 0; i < extensionVector.size(); i++) {
- ExtensionAction extensionAction = (ExtensionAction) extensionVector
- .get(i);
- extensionAction.addRowData(row);
- subMenuExtension.add(extensionAction);
- }
- if (extensionVector.size() > 0)
- mgr.add(subMenuExtension);
- }
- mgr.add(defaultEncodingAction);
- mgr.add(UTF8EncodingAction);
- mgr.add(UTF16EncodingAction);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Created on 28-jul-2003
- *
- */
-package com.quantum.view.tableview;
-
-import com.quantum.ImageStore;
-import com.quantum.Messages;
-import com.quantum.actions.CloseTableAction;
-import com.quantum.actions.RefreshTableAction;
-import com.quantum.model.NotConnectedException;
-import com.quantum.sql.TableRow;
-import com.quantum.util.StringMatrix;
-import com.quantum.view.CopyAction;
-import com.quantum.wizards.SQLRowWizard;
-import com.quantum.wizards.SortFilterPage;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-
-/**
- * @author panic
- *
- */
-public class TableViewToolBar {
-
- private ToolBar toolBar;
- private ToolItem previous;
- private ToolItem next;
-
- ToolItem filter;
-
- public TableViewToolBar(
- final TableView view,
- final ToolBar toolBar,
- final Table table,
- final TableAdapter ta,
- final Label label) {
-
- this.toolBar = toolBar;
-
- final Action copyAction = new CopyAction(view, table);
- final Action selectAllAction = new Action() {
- public void run() {
- table.selectAll();
- }
- };
- ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
- toolItem.setImage(ImageStore.getImage(ImageStore.COPY));
- toolItem.setToolTipText(Messages.getString("tableview.copy")); //$NON-NLS-1$
- toolItem.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- copyAction.run();
- }
- });
- toolItem = new ToolItem(toolBar, SWT.PUSH);
- toolItem.setImage(ImageStore.getImage(ImageStore.OPEN_TABLE)); //$NON-NLS-1$
- toolItem.setToolTipText(Messages.getString("tableview.selectAll")); //$NON-NLS-1$
- toolItem.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- selectAllAction.run();
- }
- });
-
- filter = new ToolItem(toolBar, SWT.PUSH);
- filter.setImage(ImageStore.getImage(ImageStore.FILTER));
- filter.setToolTipText(Messages.getString("tableview.filterSort")); //$NON-NLS-1$
-
- toolItem = new ToolItem(toolBar, SWT.SEPARATOR);
-
- final ToolItem fullMode = new ToolItem(toolBar, SWT.PUSH | SWT.CHECK);
-
- previous = new ToolItem(toolBar, SWT.PUSH);
- next = new ToolItem(toolBar, SWT.PUSH);
-
- fullMode.setImage(ImageStore.getImage(ImageStore.FULLDATA));
- fullMode.setToolTipText(Messages.getString("tableview.showAll")); //$NON-NLS-1$
- fullMode.setSelection(false);
- fullMode.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent event) {
- try {
- if (ta.getPageSize() == Integer.MAX_VALUE) {
- ta.resetMode();
- } else {
- ta.fullMode();
- }
- ta.loadData();
- table.removeAll();
- for (int i = table.getColumnCount() - 1; i >= 0; i--) {
- table.getColumn(i).dispose();
- }
- ta.loadTable(table);
- label.setText(ta.getStatusString());
- previous.setEnabled(ta.hasPreviousPage());
- next.setEnabled(ta.hasNextPage());
- } catch (NotConnectedException e) {
- view.handleException(e);
- }
- }
- });
- previous.setImage(ImageStore.getImage(ImageStore.PREVIOUS));
- previous.setToolTipText("Previous"); //$NON-NLS-1$
- previous.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent event) {
- try {
- ta.previousPage();
- ta.loadData();
- table.removeAll();
- for (int i = table.getColumnCount() - 1; i >= 0; i--) {
- table.getColumn(i).dispose();
- }
- ta.loadTable(table);
- label.setText(ta.getStatusString());
- previous.setEnabled(ta.hasPreviousPage());
- next.setEnabled(ta.hasNextPage());
- } catch (NotConnectedException e) {
- view.handleException(e);
- }
- }
- });
- next.setImage(ImageStore.getImage(ImageStore.NEXT));
- next.setToolTipText("Next"); //$NON-NLS-1$
- next.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent event) {
- try {
- ta.nextPage();
- ta.loadData();
- table.removeAll();
- for (int i = table.getColumnCount() - 1; i >= 0; i--) {
- table.getColumn(i).dispose();
- }
- ta.loadTable(table);
- label.setText(ta.getStatusString());
- previous.setEnabled(ta.hasPreviousPage());
- next.setEnabled(ta.hasNextPage());
- } catch (NotConnectedException e) {
- view.handleException(e);
- }
- }
- });
-
- }
-
- public void setColumns( final TableView view, final TableAdapter ta, Table table) {
-
- // We create a matrix of TableColumn (columns in the Table widget) with
- // the columns in the table object
- TableColumn[] columns = table.getColumns();
- String columnNames[] = new String[columns.length];
- for (int i = 0; i < columns.length; i++) {
- columnNames[i] = columns[i].getText();
- }
- // Copy in data the values of the data columns of the selected rows
- StringMatrix data = new StringMatrix();
- data.addMatrixHeader(columnNames);
- // Create dummy values in case nothing selected
- for (int i = 0; i < columns.length; i++) {
- data.addAt(columnNames[i], "", 0); //$NON-NLS-1$
- }
- final TableRow emptyRow = new TableRow(ta.getEntity(), ta.getBookmark(), ta.getTable(), data);
-
- filter.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- SortFilterPage page = new SortFilterPage(""); //$NON-NLS-1$
- SQLRowWizard wizard = new SQLRowWizard();
- wizard.init(Messages.getString("TableView.FilterAndSort"), page, emptyRow, ta); //$NON-NLS-1$
- WizardDialog dialog = new WizardDialog(view.getSite().getShell(), wizard);
- dialog.open();
- }
- });
- }
-
-
-
- /**
- * @return
- */
- public ToolItem getNext() {
- return next;
- }
-
- /**
- * @return
- */
- public ToolItem getPrevious() {
- return previous;
- }
-
-}