1 package com.quantum.properties;
3 import java.sql.SQLException;
5 import com.quantum.ImageStore;
6 import com.quantum.Messages;
7 import com.quantum.model.Bookmark;
8 import com.quantum.model.NotConnectedException;
9 import com.quantum.view.bookmark.TreeNode;
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.layout.GridData;
13 import org.eclipse.swt.layout.GridLayout;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.swt.widgets.Label;
17 import org.eclipse.ui.dialogs.PropertyPage;
19 public class DatabaseInformationPropertyPage extends PropertyPage {
21 public DatabaseInformationPropertyPage() {
25 protected Control createContents(Composite parent) {
27 Composite composite = new Composite(parent, SWT.NONE);
28 GridLayout layout = new GridLayout();
29 layout.numColumns = 2;
30 composite.setLayout(layout);
31 GridData data = new GridData(GridData.FILL_BOTH);
32 composite.setLayoutData(data);
34 ((TreeNode) getElement()).getBookmark();
36 createDatabaseNameArea(composite, bookmark);
44 private void createErrorMessage(Composite composite, Exception e) {
45 Label icon = new Label(composite, SWT.NONE);
46 icon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
47 icon.setImage(ImageStore.getImage(ImageStore.WARNING));
49 Label error = new Label(composite, SWT.NONE);
50 error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
51 error.setText(Messages.getString(getClass(), "error")
52 + (e.getMessage() == null ? "" : "\n" + e.getMessage()));
59 private void createDatabaseNameArea(Composite composite, Bookmark bookmark) {
60 Label productLabel = new Label(composite, SWT.NONE);
61 productLabel.setText(Messages.getString(getClass(), "product"));
63 Label productDescriptionLabel = new Label(composite, SWT.NONE);
65 String description = null;
66 if (bookmark.isConnected()) {
68 description = bookmark.getDatabase().getInformation();
69 } catch (NotConnectedException e) {
70 createErrorMessage(composite, e);
71 } catch (SQLException e) {
72 createErrorMessage(composite, e);
73 } catch (RuntimeException e) {
74 createErrorMessage(composite, e);
77 if (description == null) {
78 description = Messages.getString(getClass(), "unknown");
80 productDescriptionLabel.setText(description);
83 protected void performDefaults() {
86 public boolean performOk() {