improved syntax highlighting (php tag/return keyword/brackets and operators)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / tableview / TableAdapter.java
index 17d7b29..e65c9d0 100644 (file)
@@ -3,16 +3,6 @@ package com.quantum.view.tableview;
 import java.sql.SQLException;
 import java.util.Vector;
 
-import com.quantum.Messages;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DatabaseAdapter;
-import com.quantum.model.Bookmark;
-import com.quantum.model.Entity;
-import com.quantum.model.NotConnectedException;
-import com.quantum.sql.FilterSort;
-import com.quantum.sql.SQLHelper;
-import com.quantum.sql.SQLResults;
-
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TextCellEditor;
@@ -22,10 +12,17 @@ import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
 
+import com.quantum.Messages;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.Bookmark;
+import com.quantum.model.Entity;
+import com.quantum.model.NotConnectedException;
+import com.quantum.sql.FilterSort;
+import com.quantum.sql.SQLHelper;
+import com.quantum.sql.SQLResults;
+
 public class TableAdapter {
        
-       private Table table = null;
-       
        public static final String DEFAULT = ""; //$NON-NLS-1$
        public static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
        public static final String UTF_16 = "UTF-16"; //$NON-NLS-1$
@@ -74,8 +71,8 @@ public class TableAdapter {
         try {
                if (entity != null) {
                 totalSize = SQLHelper.getSize(
-                    bookmark.getConnection(), entity.getCondQualifiedName(), 
-                        AdapterFactory.getInstance().getAdapter(bookmark.getType()));
+                    bookmark.getConnection(), entity.getQualifiedName(), 
+                        bookmark.getAdapter());
                }
         } catch (SQLException e) {
             e.printStackTrace();
@@ -126,9 +123,9 @@ public class TableAdapter {
 
        public String getQuery() {
                if (entity != null) {
-                       DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+                       DatabaseAdapter adapter = bookmark.getAdapter();
                        if (adapter == null) throw new RuntimeException();
-                       else return adapter.getTableQuery((entity).getCondQualifiedName()) + extra.toString();
+                       else return adapter.getTableQuery((entity).getQualifiedName()) + extra.toString();
                }
                return query;
        }
@@ -172,7 +169,6 @@ public class TableAdapter {
                }
        }
        public void loadTable(Table table) {
-               this.table = table;
                table.setHeaderVisible(true);
                for (int i = 0; i < columnNames.size(); i++) {
                        TableColumn column = new TableColumn(table, SWT.NONE);
@@ -191,31 +187,31 @@ public class TableAdapter {
                }
        }
        
-       public TableViewer addTableViewer(Table table) {
-               TableViewer tableViewer = new TableViewer(table);
-               tableViewer.setUseHashlookup(true);
-               String[] colNams = new String[columnNames.size()];
-               for (int i = 0; i < columnNames.size(); i++) {
-                       colNams[i] = (String) columnNames.get(i);
-               }
-               tableViewer.setColumnProperties(colNams);
-
-               // Create the cell editors
-               CellEditor[] editors = new CellEditor[columnNames.size()];
-               for (int i = 0; i < columnNames.size(); i++) {
-                       TextCellEditor textEditor = new TextCellEditor(table);
-                       ((Text) textEditor.getControl()).setTextLimit(60);
-                       editors[i] = textEditor;
-               }
-               // Assign the cell editors to the viewer 
-               tableViewer.setCellEditors(editors);
-               // Set the cell modifier for the viewer
-               //tableViewer.setCellModifier(new MetaDataModifier(this));
-               // Set the default sorter for the viewer 
-               //tableViewer.setSorter(new ExampleTaskSorter(ExampleTaskSorter.DESCRIPTION));
-               
-               return tableViewer;
-       }
+//     public TableViewer addTableViewer(Table table) {
+//             TableViewer tableViewer = new TableViewer(table);
+//             tableViewer.setUseHashlookup(true);
+//             String[] colNams = new String[columnNames.size()];
+//             for (int i = 0; i < columnNames.size(); i++) {
+//                     colNams[i] = (String) columnNames.get(i);
+//             }
+//             tableViewer.setColumnProperties(colNams);
+//
+//             // Create the cell editors
+//             CellEditor[] editors = new CellEditor[columnNames.size()];
+//             for (int i = 0; i < columnNames.size(); i++) {
+//                     TextCellEditor textEditor = new TextCellEditor(table);
+//                     ((Text) textEditor.getControl()).setTextLimit(60);
+//                     editors[i] = textEditor;
+//             }
+//             // Assign the cell editors to the viewer 
+//             tableViewer.setCellEditors(editors);
+//             // Set the cell modifier for the viewer
+//             //tableViewer.setCellModifier(new MetaDataModifier(this));
+//             // Set the default sorter for the viewer 
+//             //tableViewer.setSorter(new ExampleTaskSorter(ExampleTaskSorter.DESCRIPTION));
+//             
+//             return tableViewer;
+//     }
        
        public int getPageSize() {
                return pageSize;
@@ -225,7 +221,7 @@ public class TableAdapter {
                this.extra = extra;
        }
        public String getTable() {
-               return (entity != null) ? entity.getCondQualifiedName() : null;
+               return (entity != null) ? entity.getQualifiedName() : null;
        }
 
        public void setQuery(String query) {