001: package com.salmonllc.ideTools.eclipse;
002:
003: import org.eclipse.jface.wizard.WizardPage;
004: import org.eclipse.swt.SWT;
005: import org.eclipse.swt.events.MouseEvent;
006: import org.eclipse.swt.events.MouseListener;
007: import org.eclipse.swt.layout.GridData;
008: import org.eclipse.swt.layout.GridLayout;
009: import org.eclipse.swt.widgets.Button;
010: import org.eclipse.swt.widgets.Composite;
011: import org.eclipse.swt.widgets.FileDialog;
012: import org.eclipse.swt.widgets.Label;
013: import org.eclipse.swt.widgets.Text;
014:
015: /**
016: * @author Administrator
017: *
018: * To change this generated comment edit the template variable "typecomment":
019: * Window>Preferences>Java>Templates.
020: * To enable and disable the creation of type comments go to
021: * Window>Preferences>Java>Code Generation.
022: */
023: public class SalmonProjectCreationWizardPage extends WizardPage
024: implements MouseListener {
025:
026: SalmonProjectCreationWizard _wizard;
027: Text _driver, _dbURL, _dbUser, _dbPass, _dbJar;
028: Button _makeDefault;
029:
030: public SalmonProjectCreationWizardPage(
031: SalmonProjectCreationWizard wizard, String pageName) {
032: super (pageName);
033: setPageComplete(true);
034: _wizard = wizard;
035: }
036:
037: public void createControl(Composite parent) {
038: Composite composite = new Composite(parent, SWT.NULL);
039:
040: GridLayout l = new GridLayout();
041: composite.setLayout(l);
042: composite.setLayoutData(new GridData(GridData.FILL_BOTH));
043: l.numColumns = 2;
044:
045: _dbJar = createFileChooser(composite, "Driver Jar File");
046: _driver = createText(composite, "JDBC Driver");
047: _dbURL = createText(composite, "Database URL");
048: _dbUser = createText(composite, "Database User ID");
049: _dbPass = createText(composite, "Database Password");
050: _dbPass.setEchoChar('*');
051:
052: if (SalmonPlugin.isWindows())
053: _makeDefault = createCheckBox(composite,
054: "Make Project Default for Dreamweaver");
055:
056: setErrorMessage(null);
057: setMessage(null);
058: setControl(composite);
059: }
060:
061: public Text createText(Composite parent, String labelText) {
062:
063: Label label = new Label(parent, SWT.NONE);
064: label.setText(labelText);
065: label.setEnabled(true);
066:
067: Text t = new Text(parent, SWT.BORDER);
068: GridData data = new GridData(GridData.FILL_HORIZONTAL);
069: t.setLayoutData(data);
070: t.setEnabled(true);
071: return t;
072: }
073:
074: public Text createFileChooser(Composite parent, String labelText) {
075:
076: Label label = new Label(parent, SWT.NONE);
077: label.setText(labelText);
078: label.setEnabled(true);
079:
080: Composite c = new Composite(parent, SWT.NONE);
081: GridLayout l = new GridLayout();
082: c.setLayout(l);
083: c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
084: l.numColumns = 2;
085:
086: Text t = new Text(c, SWT.BORDER);
087: GridData data = new GridData(GridData.FILL_HORIZONTAL);
088: t.setLayoutData(data);
089: t.setEnabled(true);
090:
091: Button b = new Button(c, SWT.NONE);
092: b.setText("Browse...");
093: b.addMouseListener(this );
094: b.setData(t);
095: return t;
096: }
097:
098: public Button createCheckBox(Composite parent, String labelText) {
099:
100: Label label = new Label(parent, SWT.NONE);
101: label.setText(labelText);
102: label.setEnabled(true);
103:
104: Button b = new Button(parent, SWT.CHECK | SWT.LEFT);
105: b.setSelection(true);
106: b.setEnabled(true);
107: return b;
108: }
109:
110: /**
111: * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(MouseEvent)
112: */
113: public void mouseDoubleClick(MouseEvent e) {
114: }
115:
116: /**
117: * @see org.eclipse.swt.events.MouseListener#mouseDown(MouseEvent)
118: */
119: public void mouseDown(MouseEvent e) {
120: }
121:
122: /**
123: * @see org.eclipse.swt.events.MouseListener#mouseUp(MouseEvent)
124: */
125: public void mouseUp(MouseEvent e) {
126: Button b = (Button) e.getSource();
127: Text t = (Text) b.getData();
128: FileDialog f = new FileDialog(b.getShell());
129: String fileName = f.open();
130: if (fileName != null && fileName.trim().length() > 0)
131: t.setText(fileName);
132:
133: }
134:
135: public String getDriver() {
136: return _driver.getText();
137: }
138:
139: public String getDBURL() {
140: return _dbURL.getText();
141: }
142:
143: public String getDBUser() {
144: return _dbUser.getText();
145: }
146:
147: public String getDBPassword() {
148: return _dbPass.getText();
149: }
150:
151: public String getJDBCJar() {
152: return _dbJar.getText();
153: }
154:
155: public boolean getMakeDefault() {
156: if (_makeDefault == null)
157: return false;
158: else
159: return _makeDefault.getSelection();
160: }
161:
162: }
|