Added error log to the debug perspective
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / properties / DatabaseInformationPropertyPage.java
index 322ba0e..d60dcf9 100644 (file)
@@ -2,27 +2,18 @@ package com.quantum.properties;
 
 import java.sql.SQLException;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
-import com.quantum.model.DataType;
 import com.quantum.model.NotConnectedException;
 import com.quantum.view.bookmark.TreeNode;
 
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
 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.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.ui.dialogs.PropertyPage;
 
 public class DatabaseInformationPropertyPage extends PropertyPage {
@@ -43,104 +34,17 @@ public class DatabaseInformationPropertyPage extends PropertyPage {
             ((TreeNode) getElement()).getBookmark();
 
                createDatabaseNameArea(composite, bookmark);
-        createTypesArea(composite, bookmark);
         
         return composite;
        }
 
        /**
         * @param composite
-        * @param bookmark
-        */
-       private void createTypesArea(Composite composite, Bookmark bookmark) {
-               if (bookmark.isConnected()) {
-               try {
-                       DataType[] dataTypes = bookmark.getDatabase().getTypes();
-                       Label label = new Label(composite, SWT.NONE);
-                       label.setText(Messages.getString(getClass(), "dataTypes"));
-                       GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
-                       data.horizontalSpan = 2;
-                       label.setLayoutData(data);
-               
-                       Table table = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
-                table.setHeaderVisible(true);
-                GridData gridData = new GridData(GridData.FILL_BOTH);
-                gridData.horizontalSpan = 2;
-                gridData.heightHint = 200;
-                table.setLayoutData(gridData);
-                for (int i = 0, length = 2; i < length; i++) {
-                    TableColumn column = new TableColumn(table, SWT.NONE);
-                    column.setText(Messages.getString(getClass(), "column" + i));
-                }
-                       TableViewer viewer = new TableViewer(table);
-                       viewer.setContentProvider(new IStructuredContentProvider() {
-                                       public Object[] getElements(Object inputElement) {
-                                               if (inputElement instanceof DataType[]) {
-                                                       return (DataType[]) inputElement;
-                                               } else {
-                                                       return null;
-                                               }
-                                       }
-                                       public void dispose() {
-                                       }
-                                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                                       }
-                               });
-                       viewer.setLabelProvider(new ITableLabelProvider() {
-                                       public Image getColumnImage(Object element, int columnIndex) {
-                                               return null;
-                                       }
-                                       public String getColumnText(Object element, int columnIndex) {
-                                               String result = null;
-                                               if (element != null && element instanceof DataType) {
-                                                       DataType dataType = (DataType) element;
-                                                       switch (columnIndex) {
-                                                       case 0:
-                                                               result = dataType.getDatabaseTypeName();
-                                                               break;
-                                                       case 1:
-                                                               result = dataType.getJavaNameType();
-                                                               break;
-                                                       default:
-                                                               result = null;
-                                                       }
-                                               }
-                                               return result == null ? "" : result;
-                                       }
-                                       public void addListener(ILabelProviderListener listener) {
-                                       }
-                                       public void dispose() {
-                                       }
-                                       public boolean isLabelProperty(Object element, String property) {
-                                               return false;
-                                       }
-                                       public void removeListener(ILabelProviderListener listener) {
-                                       }
-                       });
-                       
-                       viewer.setInput(dataTypes);
-                       
-                for (int i = 0, length = table.getColumnCount(); i < length; i++) {
-                    table.getColumn(i).pack();
-                }
-               
-               } catch (SQLException e) {
-                       createErrorMessage(composite, e);
-               } catch (NotConnectedException e) {
-                       createErrorMessage(composite, e);
-               } catch (RuntimeException e) {
-                       createErrorMessage(composite, e);
-                       }
-        }
-       }
-
-       /**
-        * @param composite
         */
        private void createErrorMessage(Composite composite, Exception e) {
                Label icon = new Label(composite, SWT.NONE);
                icon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
-               icon.setImage(QuantumPlugin.getImage("warning.gif"));
+               icon.setImage(ImageStore.getImage(ImageStore.WARNING));
                
                Label error = new Label(composite, SWT.NONE);
                error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));