1) Added missing strings for italic, underline and strike through.
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / properties / DatabaseInformationPropertyPage.java
index e1a0606..d60dcf9 100644 (file)
@@ -2,6 +2,8 @@ package com.quantum.properties;
 
 import java.sql.SQLException;
 
+import com.quantum.ImageStore;
+import com.quantum.Messages;
 import com.quantum.model.Bookmark;
 import com.quantum.model.NotConnectedException;
 import com.quantum.view.bookmark.TreeNode;
@@ -26,28 +28,56 @@ public class DatabaseInformationPropertyPage extends PropertyPage {
         GridLayout layout = new GridLayout();
         layout.numColumns = 2;
         composite.setLayout(layout);
-        GridData data = new GridData(GridData.FILL);
-        data.grabExcessHorizontalSpace = true;
+        GridData data = new GridData(GridData.FILL_BOTH);
         composite.setLayoutData(data);
+        Bookmark bookmark =
+            ((TreeNode) getElement()).getBookmark();
+
+               createDatabaseNameArea(composite, bookmark);
+        
+        return composite;
+       }
 
+       /**
+        * @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(ImageStore.getImage(ImageStore.WARNING));
+               
+               Label error = new Label(composite, SWT.NONE);
+               error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               error.setText(Messages.getString(getClass(), "error") 
+                               + (e.getMessage() == null ? "" : "\n" + e.getMessage()));
+       }
+
+       /**
+        * @param composite
+        * @param bookmark
+        */
+       private void createDatabaseNameArea(Composite composite, Bookmark bookmark) {
                Label productLabel = new Label(composite, SWT.NONE);
-               productLabel.setText("Product:");
+               productLabel.setText(Messages.getString(getClass(), "product"));
 
         Label productDescriptionLabel = new Label(composite, SWT.NONE);
 
-        Bookmark bookmark =
-            ((TreeNode) getElement()).getBookmark();
         String description = null;
-        try {
-            description = bookmark.getDatabase().getInformation();
-        } catch (NotConnectedException e) {
-        } catch (SQLException e) {
+        if (bookmark.isConnected()) {
+               try {
+                   description = bookmark.getDatabase().getInformation();
+               } catch (NotConnectedException e) {
+                       createErrorMessage(composite, e);
+               } catch (SQLException e) {
+                       createErrorMessage(composite, e);
+               } catch (RuntimeException e) {
+                       createErrorMessage(composite, e);
+               }
         }
         if (description == null) {
-            description = "<unknown>";
+            description = Messages.getString(getClass(), "unknown");
         }
         productDescriptionLabel.setText(description);
-        return composite;
        }
 
        protected void performDefaults() {