package com.quantum.properties;
-import com.quantum.IQuantumConstants;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DriverInfo;
-import com.quantum.model.Bookmark;
-import com.quantum.model.BookmarkCollection;
-import com.quantum.model.JDBCDriver;
-import com.quantum.view.bookmark.TreeNode;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.PropertyPage;
+import com.quantum.IQuantumConstants;
+import com.quantum.adapters.AdapterFactory;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.Bookmark;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.model.BookmarkHolder;
+import com.quantum.model.JDBCDriver;
+
public class BookmarkPropertyPage extends PropertyPage {
private Text password;
private Combo type;
private Combo autoCommit;
- private DriverInfo[] adapters = AdapterFactory.getInstance().getDriverList();
+ private DatabaseAdapter[] adapters = AdapterFactory.getInstance().getDriverList();
protected Control createContents(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
- GridData data = new GridData(GridData.FILL);
- data.grabExcessHorizontalSpace = true;
- composite.setLayoutData(data);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Label nameLabel = new Label(composite, SWT.NONE);
nameLabel.setText("Name:");
Bookmark bookmark = getBookmark();
String description = bookmark.getName();
name.setText(description);
+ name.setLayoutData(
+ new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING
+ | GridData.VERTICAL_ALIGN_BEGINNING));
- TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
+ TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
layout = new GridLayout();
tabFolder.setLayout(layout);
- data = new GridData(GridData.FILL_BOTH);
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- data.verticalAlignment = GridData.FILL;
+ GridData data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 2;
- data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
tabFolder.setLayoutData(data);
createUserTab(tabFolder);
private Bookmark getBookmark() {
Bookmark bookmark =
- ((TreeNode) getElement()).getBookmark();
+ ((BookmarkHolder) getElement()).getBookmark();
return bookmark;
}
composite.setLayoutData(data);
Label label = new Label(composite, SWT.NONE);
- label.setText("Connection URL:");
-
- this.jdbcURL = new Text(composite, SWT.BORDER);
- data = new GridData(GridData.FILL);
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessHorizontalSpace = true;
- this.jdbcURL.setLayoutData(data);
-
- label = new Label(composite, SWT.NONE);
label.setText("Driver Name:");
this.driverName = new Text(composite, SWT.BORDER);
private void createUserTab(TabFolder tabFolder) {
TabItem userTab = new TabItem(tabFolder, SWT.NONE);
- userTab.setText("User");
+ userTab.setText("Connection");
Composite composite = new Composite(tabFolder, SWT.NONE);
GridLayout layout = new GridLayout();
}
});
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Connection URL:");
+
+ this.jdbcURL = new Text(composite, SWT.BORDER);
+ data = new GridData(GridData.FILL);
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ data.grabExcessHorizontalSpace = true;
+ this.jdbcURL.setLayoutData(data);
+
userTab.setControl(composite);
}
}
int index = this.type.getSelectionIndex();
- bookmark.setType(this.adapters[index].getDriverType());
bookmark.setConnect(this.jdbcURL.getText());
JDBCDriver jdbcDriver = BookmarkCollection.getInstance().findDriver(
- this.driverName.getText(), this.driverPath.getText());
+ this.driverName.getText(), this.driverPath.getText(), this.adapters[index].getType());
bookmark.setJDBCDriver(jdbcDriver);
if (this.autoCommit.getSelectionIndex() >= 0)
bookmark.setAutoCommitPreference(this.autoCommit.getItem(this.autoCommit.getSelectionIndex()));
this.prompt.setSelection(bookmark.getPromptForPassword());
this.password.setEditable(!bookmark.getPromptForPassword());
- this.password.setText(bookmark.getPassword());
+ String password = bookmark.getPassword();
+ this.password.setText(password == null ? "" : password);
this.userid.setText(bookmark.getUsername());
this.type.select(0);
length = (adapters == null) ? 0 : adapters.length;
!done && i < length;
i++) {
- if (bookmark.getType() != null &&
- bookmark.getType().equals(adapters[i].getDriverType())) {
+ if (bookmark.getJDBCDriver().getType() != null &&
+ bookmark.getJDBCDriver().getType().equals(adapters[i].getType())) {
this.type.select(i);
done = true;
}