Commit before delete.
authorp.ciardelli <p.ciardelli@localhost>
Mon, 15 Dec 2008 12:57:48 +0000 (12:57 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Mon, 15 Dec 2008 12:57:48 +0000 (12:57 +0000)
.gitattributes
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/datasource/CdmDataSourceDialog_.java [new file with mode: 0644]

index d96a1faa0dfc825acff55d8d87e00832c6ea4f27..4439283dfc1d1e581ea6c187968324159efad600 100644 (file)
@@ -449,6 +449,7 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/des
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/description/DeleteElementCompositeAction.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/messages.properties -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/datasource/CdmDataSourceDialog.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/datasource/CdmDataSourceDialog_.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/datasource/CopyOfCdmDataSourceDialog.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/datasource/RegisterDatabaseDialog.java -text
 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/AbstractTaxonEditorView.java -text
diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/datasource/CdmDataSourceDialog_.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/datasource/CdmDataSourceDialog_.java
new file mode 100644 (file)
index 0000000..5697eb8
--- /dev/null
@@ -0,0 +1,232 @@
+package eu.etaxonomy.taxeditor.datasource;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.dialogs.Dialog;\r
+import org.eclipse.jface.dialogs.IDialogConstants;\r
+import org.eclipse.jface.viewers.ArrayContentProvider;\r
+import org.eclipse.jface.viewers.DoubleClickEvent;\r
+import org.eclipse.jface.viewers.IDoubleClickListener;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.jface.viewers.LabelProvider;\r
+import org.eclipse.jface.viewers.ListViewer;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.CCombo;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.List;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Text;\r
+\r
+import eu.etaxonomy.cdm.database.CdmDataSource;\r
+import eu.etaxonomy.cdm.database.DatabaseTypeEnum;\r
+import eu.etaxonomy.cdm.database.ICdmDataSource;\r
+import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
+\r
+public class CdmDataSourceDialog_ extends Dialog {\r
+       private List list;\r
+       private List list_1;\r
+       private Text text_6;\r
+       private Text text_5;\r
+       private Text text_4;\r
+       private Text text_2;\r
+       private Text text_3;\r
+       private Text text;\r
+       private static final Logger logger = Logger\r
+                       .getLogger(CdmDataSourceDialog_.class);\r
+       private CCombo datasourceTypesCombo;\r
+       private Composite composite;\r
+       private Composite container;\r
+\r
+       /**\r
+        * Create the dialog\r
+        * @param parentShell\r
+        */\r
+       public CdmDataSourceDialog_(Shell parentShell) {\r
+               super(parentShell);\r
+       }\r
+\r
+       /**\r
+        * Create contents of the dialog\r
+        * @param parent\r
+        */\r
+       @Override\r
+       protected Control createDialogArea(Composite parent) {\r
+               container = (Composite) super.createDialogArea(parent);\r
+               final GridLayout gridLayout = new GridLayout();\r
+               gridLayout.numColumns = 2;\r
+               container.setLayout(gridLayout);\r
+\r
+               final ListViewer listViewer = new ListViewer(container, SWT.BORDER);\r
+               list = listViewer.getList();\r
+               final GridData gd_list = new GridData(SWT.LEFT, SWT.FILL, false, true);\r
+               gd_list.widthHint = 162;\r
+               list.setLayoutData(gd_list);\r
+               \r
+               listViewer.setContentProvider(new ArrayContentProvider());\r
+               listViewer.setLabelProvider(new LabelProvider() {\r
+                       /* (non-Javadoc)\r
+                        * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)\r
+                        */\r
+                       public String getText(Object element) {\r
+                               if (element instanceof ICdmDataSource) {\r
+                                       return ((ICdmDataSource) element).getName();\r
+                               } \r
+                               return super.getText(element);\r
+                       }\r
+               });\r
+//             list.addListener(SWT. .PaintItem, new Listener() {\r
+//                     @Override\r
+//                     public void handleEvent(Event event) {\r
+//                             Object data = event.item.getData();\r
+//                             if (!(data instanceof ICdmDataSource)) {\r
+//                                     Font italics = TaxEditorPlugin.getDefault().getFont\r
+//                                                     (ITaxEditorConstants.MENU_ITEM_ITALICS_FONT);\r
+//                                     ((Control) event.item).setFont(italics);\r
+//                             }\r
+//                     }\r
+//             });\r
+               \r
+               java.util.List<ICdmDataSource> dataSources = \r
+                       TaxEditorPlugin.getDefault().getDataSources();\r
+               \r
+               listViewer.setInput(dataSources);\r
+               listViewer.add("<< Add data source >>");\r
+               \r
+               listViewer.addDoubleClickListener(new IDoubleClickListener() {\r
+                       public void doubleClick(DoubleClickEvent event) {\r
+                               Object selection = \r
+                                               ((IStructuredSelection) event.getSelection()).\r
+                                               getFirstElement();\r
+                               if (selection instanceof ICdmDataSource) {\r
+                                       createExistingDatasource((ICdmDataSource) selection);\r
+                               } else {\r
+//                                     newDataSource(CdmDataSource.);\r
+                               }\r
+                       }\r
+               });\r
+\r
+\r
+               //\r
+               return container;\r
+       }\r
+\r
+       private void populateComboBoxItems() {\r
+               // TODO: replace w cdmApp.getDatabaseService().getDatabaseEnum();\r
+               for (DatabaseTypeEnum type : DatabaseTypeEnum.getAllTypes()) {\r
+                       datasourceTypesCombo.add(type.getName());\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Create contents of the button bar\r
+        * @param parent\r
+        */\r
+       @Override\r
+       protected void createButtonsForButtonBar(Composite parent) {\r
+               createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,\r
+                               true);\r
+               createButton(parent, IDialogConstants.CANCEL_ID,\r
+                               IDialogConstants.CANCEL_LABEL, false);\r
+       }\r
+\r
+       /**\r
+        * Return the initial size of the dialog\r
+        */\r
+       @Override\r
+       protected Point getInitialSize() {\r
+               return new Point(500, 375);\r
+       }\r
+       \r
+       private void createExistingDatasource(ICdmDataSource dataSource) {\r
+               composite = new Composite(container, SWT.NONE);\r
+               final GridData gd_composite = new GridData(SWT.FILL, SWT.TOP, true, true);\r
+               composite.setLayoutData(gd_composite);\r
+               final GridLayout gridLayout_1 = new GridLayout();\r
+               gridLayout_1.numColumns = 2;\r
+               composite.setLayout(gridLayout_1);\r
+               \r
+               final Label datasourceNameLabel = new Label(composite, SWT.NONE);\r
+               datasourceNameLabel.setText("Datasource Name:");\r
+\r
+               text = new Text(composite, SWT.BORDER);\r
+               text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+\r
+               final Label databaseTypeLabel = new Label(composite, SWT.NONE);\r
+               databaseTypeLabel.setText("Database Type:");\r
+\r
+               datasourceTypesCombo = new CCombo(composite, SWT.BORDER);\r
+               final GridData gd_list_1 = new GridData(SWT.FILL, SWT.CENTER, false, false);\r
+               datasourceTypesCombo.setLayoutData(gd_list_1);\r
+               populateComboBoxItems();\r
+               \r
+//             BeanDefinition bean = dataSource.getDatasourceBean();\r
+               \r
+               // Redraw dialog container\r
+               container.layout();\r
+       }\r
+       \r
+       private void createMySqlForm(ICdmDataSource dataSource) {\r
+               final Group authenticationGroup = new Group(composite, SWT.NONE);\r
+               authenticationGroup.setText("Authentication");\r
+               authenticationGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));\r
+               final GridLayout gridLayout_2 = new GridLayout();\r
+               gridLayout_2.numColumns = 2;\r
+               authenticationGroup.setLayout(gridLayout_2);\r
+\r
+               final Label loginNameLabel = new Label(authenticationGroup, SWT.NONE);\r
+               loginNameLabel.setText("Login Name:");\r
+\r
+               text_3 = new Text(authenticationGroup, SWT.BORDER);\r
+               text_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+\r
+               final Label passwordLabel = new Label(authenticationGroup, SWT.NONE);\r
+               passwordLabel.setText("Password:");\r
+\r
+               text_2 = new Text(authenticationGroup, SWT.BORDER);\r
+               text_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+\r
+               final Label savePasswordLabel = new Label(authenticationGroup, SWT.NONE);\r
+               savePasswordLabel.setText("Save password:");\r
+\r
+               final Button button = new Button(authenticationGroup, SWT.CHECK);\r
+\r
+               final Group locationGroup = new Group(composite, SWT.NONE);\r
+               locationGroup.setText("Location");\r
+               final GridData gd_locationGroup = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);\r
+               locationGroup.setLayoutData(gd_locationGroup);\r
+               final GridLayout gridLayout_3 = new GridLayout();\r
+               gridLayout_3.numColumns = 2;\r
+               locationGroup.setLayout(gridLayout_3);\r
+\r
+               final Label hostLabel = new Label(locationGroup, SWT.NONE);\r
+               hostLabel.setText("Host:");\r
+\r
+               text_4 = new Text(locationGroup, SWT.BORDER);\r
+               text_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+\r
+               final Label portLabel = new Label(locationGroup, SWT.NONE);\r
+               portLabel.setText("Port <3306>:");\r
+\r
+               text_5 = new Text(locationGroup, SWT.BORDER);\r
+               text_5.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+\r
+               final Label databaseLabel = new Label(locationGroup, SWT.NONE);\r
+               databaseLabel.setText("Database:");\r
+\r
+               text_6 = new Text(locationGroup, SWT.BORDER);\r
+               text_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
+               new Label(composite, SWT.NONE);\r
+\r
+               final Button saveButton = new Button(composite, SWT.NONE);\r
+               final GridData gd_saveButton = new GridData(SWT.RIGHT, SWT.CENTER, false, false);\r
+               gd_saveButton.widthHint = 76;\r
+               saveButton.setLayoutData(gd_saveButton);\r
+               saveButton.setText("Save");\r
+       }\r
+}\r