reduce warnings due to core.runtime deprecations
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / AddSchemaDialog.java
1 /*
2  * Created on 12-jul-2003
3  *
4  */
5 package com.quantum.view.bookmark;
6 import java.util.ArrayList;
7 import java.util.Collection;
8 import java.util.Iterator;
9 import java.util.Vector;
10
11 import com.quantum.IQuantumConstants;
12
13 import org.eclipse.jface.dialogs.Dialog;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.layout.GridData;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18 import org.eclipse.swt.widgets.List;
19 import org.eclipse.swt.widgets.Shell;
20 import org.eclipse.ui.help.WorkbenchHelp;
21
22 /**
23  * @author panic
24  *
25  */
26 public class AddSchemaDialog extends Dialog {
27
28     protected Vector input;
29     protected List list;
30     private Vector selection;
31     /**
32      * Creates a new AddSchemaDialog.
33      */
34     public AddSchemaDialog(Shell parentShell, Vector input) {
35         super(parentShell);
36         this.input = input;
37         this.list = null;
38         selection = null;
39     }
40     /* (non-Javadoc)
41      * Method declared on Window.
42      */
43     protected void configureShell(Shell newShell) {
44         super.configureShell(newShell);
45         newShell.setText("Set Schemas");
46         WorkbenchHelp.setHelp(
47             newShell,
48             IQuantumConstants.ADD_SCHEMA_DIALOG_CONTEXT);
49     }
50     /* (non-Javadoc)
51      * Method declared on Dialog
52      */
53     protected Control createDialogArea(Composite parent) {
54         Composite composite = (Composite) super.createDialogArea(parent);
55
56         list = new List(composite, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
57         GridData data = new GridData(GridData.FILL_BOTH);
58         list.setLayoutData(data);
59         for (Iterator iter = input.iterator(); iter.hasNext();) {
60             String element = (String) iter.next();
61             list.add(element);
62         }
63         return composite;
64     }
65
66     /* (non-Javadoc)
67      * @see org.eclipse.jface.dialogs.Dialog#okPressed()
68      */
69     protected void okPressed() {
70         // If it's OK, then the selection is not null. Null is used to signal a canceled dialog.
71         selection = new Vector();
72         if (list != null) {
73             String selecStr[] = list.getSelection();
74             for (int i = 0; i < selecStr.length; i++) {
75                 String string = selecStr[i];
76                 selection.add(string);
77             }
78         }
79         super.okPressed();
80     }
81
82     public Collection getSelectedSchemas() {
83         return this.selection == null ? null : new ArrayList(this.selection);
84     }
85
86 }