[Ds-java-dev] svn commit r16527 - in trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice: . ide/dialog ide/wizard

svn at wso2.org svn at wso2.org
Mon May 5 04:07:36 PDT 2008


Author: sandakith
Date: Mon May  5 04:07:23 2008
New Revision: 16527

Log:

Move the common behaviour of the Wizard pages to an Abstract Class 
Added page navigation couple with page validation
Make the dataservices two words
Added Missing functionality of the RDBS CSV and EXCEL and JNDI Configurations 
Move all the Constants to a file
 


Added:
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/DBConstants.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/AbstractWSO2DataserviceWizardPage.java
Modified:
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOperationDialog.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/CSVConfigurationDialog.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/ExelConfigurationDialog.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/JNDIConfigurationDialog.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/RDBMSConfigurationDialog.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizard.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepOnePage.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepThree.java
   trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java

Added: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/DBConstants.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/DBConstants.java	Mon May  5 04:07:23 2008
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.ws.dataservice;
+
+public class DBConstants {
+	public static final String DRIVER = "org.wso2.ws.dataservice.driver";
+	public static final String PROTOCOL = "org.wso2.ws.dataservice.protocol";
+	public static final String USER = "org.wso2.ws.dataservice.user";
+	public static final String PASSWORD = "org.wso2.ws.dataservice.password";
+	public static final String MIN_POOL_SIZE = "org.wso2.ws.dataservice.minpoolsize";
+	public static final String MAX_POOL_SIZE = "org.wso2.ws.dataservice.maxpoolsize";
+	
+	//Keys for parameters in AxisService
+	public static final String CONNECTION_CONFIG = "org.wso2.ws.dataservice.config";
+	
+	public static final String CSV_DATASOURCE = "csv_datasource";
+	public static final String EXCEL_DATASOURCE = "excel_datasource";
+	public static final String JNDI_DATASOURCE = "jndi_datasource";
+	public static final String DB_OPERATION_ELEMENT = "org.wso2.ws.dataservice.db_operation_element";
+	public static final String CALL_QUERY_ELEMENT = "CallQuery";
+	public static final String DB_CONFIG_ELEMENT =  "org.wso2.ws.dataservice.db_config_element";
+	public static final String DB_QUERY_ELEMENTS =  "org.wso2.ws.dataservice.db_query_elements";
+	public static final String AXIS2_HOME = "/work/axis2/target/dist/axis2-SNAPSHOT";
+	public static final String DB_SERVICE_TYPE = "data_service";
+	public static final String DB_SERVICE_CONFIG_FILE = "org.wso2.ws.dataservice.db_service_config_file";
+	public static final String DB_SERVICE_REPO = "local_org.wso2.ws.dataservice.db_service_repo";
+	public static final String DB_SERVICE_EXTENSION = "local_org.wso2.ws.dataservice.db_service_extension";
+	public static final String DB_CONNECTION = "org.wso2.ws.dataservice.dbconnection";
+	public static final String NAMESPACE_PREFIX_MAP = "org.wso2.ws.dataservice.namespaceprefixmap";
+	public static final String QUERYLEVEL_PREFIX_MAP = "org.wso2.ws.dataservice.querylevelprefixmap";
+	public static final String QUERYLEVEL_NAMESPACE_MAP = "org.wso2.ws.dataservice.querylevelnamespacemap";
+	public static final String RESULT_PREFIX = "data"; 
+	
+    
+	public interface DataTypes{
+	    public static final String CHAR = "CHAR";
+	    public static final String STRING = "STRING";
+	    public static final String VARCHAR = "VARCHAR";
+	    public static final String TEXT = "TEXT";
+	    public static final String NUMERIC = "NUMERIC";
+	    public static final String DECIMAL = "DECIMAL";
+	    public static final String MONEY = "MONEY";
+	    public static final String SMALLMONEY = "SMALLMONEY";
+	    public static final String BIT = "BIT";
+	    public static final String TINYINT = "TINYINT";
+	    public static final String SMALLINT = "SMALLINT";
+	    public static final String INTEGER = "INTEGER";
+	    public static final String BIGINT = "BIGINT";
+	    public static final String REAL = "REAL";
+	    public static final String FLOAT = "FLOAT";
+	    public static final String DOUBLE = "DOUBLE";
+	    public static final String BINARY = "BINARY";
+	    public static final String VARBINARY = "VARBINARY";
+	    public static final String LONG_VARBINARY = "LONG VARBINARY";
+	    public static final String IMAGE = "IMAGE";
+	    public static final String DATE = "DATE";
+	    public static final String TIME = "TIME";
+	    public static final String TIMESTAMP = "TIMESTAMP";		
+	}
+    public static final String WSO2_NAMESPACE = "http://ws.wso2.org/dataservice";
+    
+    //Datasource Type
+    public static final String DATASOURCE_TYPE = "DATASOURCE_TYPE";
+    public static final String DATASOURCE_TYPE_RDBMS= "RDBMS";
+    public static final String DATASOURCE_TYPE_CSV= "CSV";
+    public static final String DATASOURCE_TYPE_EXCEL= "EXCEL";
+    public static final String DATASOURCE_TYPE_JNDI= "JNDI";
+    
+
+    //same values are present in data_service.js & data_service.xsl.If you change any value here, 
+    //make sure you change those files as well.
+    public interface Query{
+        //CSV query parameters
+    	String CSV = "csv";
+        String EXCEL = "excel";    	
+    	String HAS_HEADER = "hasheader";
+    	String STARTING_ROW = "startingrow";
+    	String MAX_ROW_COUNT = "maxrowcount";
+    	String COLUMNS = "columns";
+    	String COLUMN = "column";
+
+    	//CSV query parameters
+    	String CSV_COLUMN_SEPERATOR = "columnseperator";
+    	String CSV_COLUMN_ORDER = "columnordinal";
+    	//excel query parameters
+    	String EXCEL_WORKBOOK_NAME = "workbookname";
+    }
+    
+    public interface JNDI{
+        String INITIAL_CONTEXT_FACTORY = "jndi_context_class";   	
+        String PROVIDER_URL = "jndi_provider_url";
+    	String RESOURCE_NAME = "jndi_resource_name";
+    	String USERNAME = "jndi_username";
+    	String PASSWORD = "jndi_password";
+    }
+}
+

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOperationDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOperationDialog.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddOperationDialog.java	Mon May  5 04:07:23 2008
@@ -15,6 +15,15 @@
  */
 package org.wso2.ws.dataservice.ide.dialog;
 
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -27,19 +36,33 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
+import org.wso2.ws.dataservice.ide.WSO2DataservicePlugin;
+import org.wso2.ws.dataservice.ide.context.PersistentDSContext;
+import org.wso2.ws.dataservice.ide.util.DataServiceXMLUtil;
 import org.wso2.ws.dataservice.ide.util.FontUtil;
+import org.wso2.ws.dataservice.ide.wizard.WSO2DataserviceWizardStepThree;
+import org.wso2.ws.dataservice.ide.wizard.WSO2DataserviceWizardStepTwo;
 
 public class AddOperationDialog extends Dialog{
 
 	private Combo queryTypeCombo;
 	private String dialogHeadingPrefix;
+	private Text operationNameText;
+	private Text paramText;
+	private PersistentDSContext dsContext;
+	private WSO2DataserviceWizardStepThree parentPage;
+	private List configList;
+
 	
 	/**
 	 * Dialog represent the Add Operations configuration UI
 	 */
-	public AddOperationDialog(Shell parentShell, String headingPrefix) {
+	public AddOperationDialog(Shell parentShell, String headingPrefix, WSO2DataserviceWizardStepThree page) {
 		super(parentShell);
 		dialogHeadingPrefix = headingPrefix;
+		//Obtain the current context from eclipse preferences.
+		dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
+		parentPage = page;
 	}
 
 	/**
@@ -72,13 +95,13 @@
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
 		
-		Text operationNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		operationNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 2;
 		operationNameText.setLayoutData(gd);
 		operationNameText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				operationNameChanged();
+				createListFromQuerySConfig();
 			}
 		});
 		
@@ -96,7 +119,7 @@
 		queryTypeCombo.setLayoutData(gd);
 		queryTypeCombo.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				comboChanged();
+				createListFromQuerySConfig();
 			}
 		});
 		
@@ -118,13 +141,13 @@
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
 		
-		Text paramText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		paramText = new Text(container, SWT.BORDER | SWT.SINGLE);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 2;
 		paramText.setLayoutData(gd);
 		paramText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				paramNameChanged();
+				createListFromQuerySConfig();
 			}
 		});
 
@@ -159,7 +182,80 @@
 	private void comboChanged() {
 		//handle query change
 	}
+	
+	/**
+	 * Handle the Cancel button event 
+	 */
+	protected void cancelPressed() {
+		super.cancelPressed();
+		//Remove the DS Config from the 
+	}
+
+	/**
+	 * Handle the OK button pressed
+	 */
+	protected void okPressed() {
+		super.okPressed();
+		//Update the DS Configuration
+		configChanged();
+	}
+	
+	/**
+	 * Handle the configuration changes
+	 */
+	private void configChanged(){
+		//update config with the change
+		try {
+			OMElement root = DataServiceXMLUtil.getOMDocFromString(dsContext.getDSConfig());
+			OMElement element = createQueryElement();
+			//Remove the existing data service config
+			Iterator children = root.getChildElements();
+			while(children.hasNext()){
+				OMElement node = (OMElement)children.next();
+			        if (node.getLocalName().equals("operation")) {
+						node.detach();
+					}
+			}
+			root.addChild(element);
+			OutputStream xmlOutputStream = new ByteArrayOutputStream();
+			root.serialize(xmlOutputStream);
+			//call refresh configuration
+			OutputStream stream = DataServiceXMLUtil.prettyPrintDSConfig(xmlOutputStream.toString());
+			parentPage.refreshConfig(stream.toString());
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	
+	/**
+	 * Build the Query Element
+	 * @param propertyList : List of properties of Data Service Connection Configuration.
+	 * @return Query Element
+	 */
+	public OMElement createQueryElement(){
+		//create a factory
+		OMFactory factory = OMAbstractFactory.getOMFactory();
+		//use the factory to create three elements
+		OMElement root = factory.createOMElement("operation",null);
+		root.addAttribute("name",configList.get(0).toString(), null);
+
+		OMElement currentElement = factory.createOMElement("call-query",null);
+		currentElement.addAttribute("href",configList.get(0).toString(), null);
+		root.addChild(currentElement);
+		return root;
+	}
+	
+	/**
+	 * This method updates the List form current RDBMS Configuration.
+	 * @return RDBMS COnfiguration 
+	 */
+	private void createListFromQuerySConfig(){
+		configList = new ArrayList();
+		configList.add(operationNameText.getText());
+		configList.add(paramText.getText());
+	}
 
-}
 
 
+}
\ No newline at end of file

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/AddQueryDialog.java	Mon May  5 04:07:23 2008
@@ -15,6 +15,15 @@
  */
 package org.wso2.ws.dataservice.ide.dialog;
 
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StyledText;
@@ -22,7 +31,6 @@
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -31,7 +39,11 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
+import org.wso2.ws.dataservice.ide.WSO2DataservicePlugin;
+import org.wso2.ws.dataservice.ide.context.PersistentDSContext;
+import org.wso2.ws.dataservice.ide.util.DataServiceXMLUtil;
 import org.wso2.ws.dataservice.ide.util.FontUtil;
+import org.wso2.ws.dataservice.ide.wizard.WSO2DataserviceWizardStepTwo;
 
 /**
  * Dialog represent the Add Query configuration UI
@@ -41,10 +53,19 @@
 	private Button inputMappingButton;
 	private Button outMappingButton;
 	private String dialogHeadingPrefix;
+	private Text queryIDText;
+	private StyledText sqlStatementText;
+	private PersistentDSContext dsContext;
+	private WSO2DataserviceWizardStepTwo parentPage;
+	private List configList;
 
-	public AddQueryDialog(Shell parentShell, String headingPrefix) {
+	public AddQueryDialog(Shell parentShell, String headingPrefix,
+			WSO2DataserviceWizardStepTwo page) {
 		super(parentShell);
 		dialogHeadingPrefix = headingPrefix;
+		//Obtain the current context from eclipse preferences.
+		dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
+		parentPage = page;
 	}
 
 	/**
@@ -77,13 +98,13 @@
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
 
-		Text queryIDText = new Text(container, SWT.BORDER | SWT.SINGLE);
+		queryIDText = new Text(container, SWT.BORDER | SWT.SINGLE);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 2;
 		queryIDText.setLayoutData(gd);
 		queryIDText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				textChanged();
+				createListFromQuerySConfig();
 			}
 		});
 		
@@ -116,7 +137,7 @@
 		gd.horizontalSpan = 3;
 		label.setLayoutData(gd);
 
-		StyledText sqlStatementText = new StyledText(container, 
+		sqlStatementText = new StyledText(container, 
 				SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
 		gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
 		gd.horizontalSpan = 3;
@@ -124,7 +145,7 @@
 		sqlStatementText.setLayoutData(gd);
 		sqlStatementText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				textChanged();
+				createListFromQuerySConfig();
 			}
 		});
 
@@ -174,7 +195,7 @@
 		groupByElementText.setLayoutData(gd);
 		groupByElementText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				textChanged();
+				createListFromQuerySConfig();
 			}
 		});
 
@@ -190,7 +211,7 @@
 		rowNameText.setLayoutData(gd);
 		rowNameText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				textChanged();
+				createListFromQuerySConfig();
 			}
 		});
 
@@ -206,7 +227,7 @@
 		rowNamespaceText.setLayoutData(gd);
 		rowNamespaceText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
-				textChanged();
+				createListFromQuerySConfig();
 			}
 		});
 
@@ -257,8 +278,81 @@
 		addInputParamDialog.open();
 	}
 
-	private void textChanged() {
-		//update the data model
+	/**
+	 * Handle the Cancel button event 
+	 */
+	protected void cancelPressed() {
+		super.cancelPressed();
+		//Remove the DS Config from the 
+	}
+
+	/**
+	 * Handle the OK button pressed
+	 */
+	protected void okPressed() {
+		super.okPressed();
+		//Update the DS Configuration
+		configChanged();
+	}
+	
+	/**
+	 * Handle the configuration changes
+	 */
+	private void configChanged(){
+		//update config with the change
+		try {
+			OMElement root = DataServiceXMLUtil.getOMDocFromString(dsContext.getDSConfig());
+			OMElement element = createQueryElement();
+			//Remove the existing data service config
+			Iterator children = root.getChildElements();
+			while(children.hasNext()){
+				OMElement node = (OMElement)children.next();
+			        if (node.getLocalName().equals("query")) {
+						node.detach();
+					}
+			}
+			root.addChild(element);
+			OutputStream xmlOutputStream = new ByteArrayOutputStream();
+			root.serialize(xmlOutputStream);
+			//call refresh configuration
+			OutputStream stream = DataServiceXMLUtil.prettyPrintDSConfig(xmlOutputStream.toString());
+			parentPage.refreshConfig(stream.toString());
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	
+	/**
+	 * Build the Query Element
+	 * @param propertyList : List of properties of Data Service Connection Configuration.
+	 * @return Query Element
+	 */
+	public OMElement createQueryElement(){
+		//create a factory
+		OMFactory factory = OMAbstractFactory.getOMFactory();
+		//use the factory to create three elements
+		OMElement root = factory.createOMElement("query",null);
+		root.addAttribute("id",configList.get(0).toString(), null);
+
+		OMElement currentElement = factory.createOMElement("sql",null);
+		currentElement.setText(configList.get(1).toString());
+		root.addChild(currentElement);
+		return root;
+	}
+	
+	/**
+	 * This method updates the List form current RDBMS Configuration.
+	 * @return RDBMS COnfiguration 
+	 */
+	private void createListFromQuerySConfig(){
+		configList = new ArrayList();
+		configList.add(queryIDText.getText());
+		configList.add(sqlStatementText.getText());
+	}
+	
+	public List getQueryList(){
+		return configList;
 	}
 
 }
\ No newline at end of file

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/CSVConfigurationDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/CSVConfigurationDialog.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/CSVConfigurationDialog.java	Mon May  5 04:07:23 2008
@@ -83,7 +83,7 @@
 		label.setLayoutData(gd);
 
 		label = new Label(container, SWT.NULL);
-		label.setText("CSV File Location");
+		label.setText("CSV File Location *");
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
@@ -92,6 +92,7 @@
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 2;
 		csvFileLocationText.setLayoutData(gd);
+		csvFileLocationText.setText("path-to-your-csv-file");
 		csvFileLocationText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
 				createListFromRDBMSConfig();
@@ -108,6 +109,7 @@
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 2;
 		columnSeperationText.setLayoutData(gd);
+		columnSeperationText.setText(",");
 		columnSeperationText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
 				createListFromRDBMSConfig();
@@ -140,6 +142,7 @@
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 2;
 		maxToReadText.setLayoutData(gd);
+		maxToReadText.setText("-1");
 		maxToReadText.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
 				createListFromRDBMSConfig();
@@ -147,7 +150,7 @@
 		});
 		
 		label = new Label(container, SWT.NULL);
-		label.setText("Header Available");
+		label.setText("Header Available *");
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/ExelConfigurationDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/ExelConfigurationDialog.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/ExelConfigurationDialog.java	Mon May  5 04:07:23 2008
@@ -75,6 +75,7 @@
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 6;
 		exelFilePath.setLayoutData(gd);
+		exelFilePath.setText("path-to-your-excel-file");
 		exelFilePath.addModifyListener(new ModifyListener() {
 			public void modifyText(ModifyEvent e) {
 				createListFromRDBMSConfig();

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/JNDIConfigurationDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/JNDIConfigurationDialog.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/JNDIConfigurationDialog.java	Mon May  5 04:07:23 2008
@@ -82,7 +82,7 @@
 		label.setLayoutData(gd);
 
 		label = new Label(container, SWT.NULL);
-		label.setText("JNDI Context Class");
+		label.setText("JNDI Context Class *");
 		gd = new GridData();
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
@@ -98,7 +98,7 @@
 		});
 		
 		label = new Label(container, SWT.NULL);
-		label.setText("Provider URL");
+		label.setText("Provider URL *");
 		gd = new GridData();
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);
@@ -114,7 +114,7 @@
 		});
 		
 		label = new Label(container, SWT.NULL);
-		label.setText("Resource Name");
+		label.setText("Resource Name *");
 		gd = new GridData();
 		gd.horizontalSpan = 1;
 		label.setLayoutData(gd);

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/RDBMSConfigurationDialog.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/RDBMSConfigurationDialog.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/dialog/RDBMSConfigurationDialog.java	Mon May  5 04:07:23 2008
@@ -17,6 +17,9 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -53,6 +56,7 @@
 	private Text passwordText;
 	private Text minPoolSizeText;
 	private Text maxPoolSizeText;
+	private Label connectionResultLabel;
 	private PersistentDSContext dsContext;
 	private WSO2DataserviceWizardStepOnePage parentPage;
 	private List configList;
@@ -193,7 +197,7 @@
 		gd.horizontalSpan = 3;
 		label.setLayoutData(gd);
 		
-		testConButton = new Button(container, SWT.BORDER);
+		testConButton = new Button(container, SWT.NULL);
 		testConButton.setText("Test Connection");
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 1;
@@ -203,6 +207,19 @@
 				handleTestCon(parent.getShell());
 			}
 		});
+		
+		label = new Label(container, SWT.NULL);
+		label.setText("");
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = 3;
+		label.setLayoutData(gd);
+		
+		connectionResultLabel = new Label(container, SWT.NULL);
+		connectionResultLabel.setText("");
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = 3;
+		connectionResultLabel.setLayoutData(gd);
+		
 		// Load the Default Database parameters for the user.
 		loadDefaultDatabaseParams(databaseTypeCombo.getText());
 		createListFromRDBMSConfig();
@@ -211,12 +228,29 @@
 	
 	private void handleTestCon(Shell parent) {
 		//Test Connection Logic
-	}
-
-	private void pathChanged() {
-		//update the data model
+		try { 
+			//First Try to load the driver class
+			Class.forName(driverClassText.getText());
+			//Try to connect
+			Connection dbConnection = DriverManager.getConnection(jdbcURLText.getText(),
+					userNameText.getText(), passwordText.getText());
+			if (dbConnection != null) {;
+				// Update the result label
+				updateConnectionResults("Test Connection Successful !!",null);
+			}
+		} catch(ClassNotFoundException e){ 
+			updateConnectionResults("Unable to load the driver class!!",e);
+		} 
+		catch( SQLException e ){
+			updateConnectionResults("Couldn't get connection!!", e);
+		}
 	}
 	
+	private void updateConnectionResults(String message, Exception e){
+		connectionResultLabel.setText("Ping Result :" +
+				message + "\n" + ((e==null)?"":e.getMessage()));
+	}
+
 	/**
 	 * Add the content to the data source combo.
 	 */

Added: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/AbstractWSO2DataserviceWizardPage.java
==============================================================================
--- (empty file)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/AbstractWSO2DataserviceWizardPage.java	Mon May  5 04:07:23 2008
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.ws.dataservice.ide.wizard;
+
+import org.eclipse.jface.wizard.WizardPage;
+
+/**
+ * The Abstract Wizard Page that defines the Wizard Page
+ */
+public abstract class AbstractWSO2DataserviceWizardPage extends WizardPage {
+	
+	/**
+	 * Default Constructor 
+	 * @param pageName
+	 */
+	protected AbstractWSO2DataserviceWizardPage(String pageName) {
+		super(pageName);
+	}
+
+	public abstract String loadPreviousConfig();
+	
+	public abstract void refreshConfig(String config);
+
+}
\ No newline at end of file

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizard.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizard.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizard.java	Mon May  5 04:07:23 2008
@@ -23,7 +23,9 @@
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchWizard;
@@ -104,4 +106,30 @@
 		this.selection = selection;
 	}
 	
+	/**
+	 * Page calculates enableness of the Finish button on each wizard page
+	 * @see org.eclipse.jface.wizard.IWizard#canFinish()
+	 */
+	public boolean canFinish() {
+		IWizardPage[] pages = getPages();
+		WizardPage wizardPage = null;
+		for (int i = 0; i < pages.length; i++) {
+			wizardPage = (WizardPage) pages[i];
+			if (!(wizardPage.isPageComplete()))
+				return false;
+		}
+		return true;
+	}
+	
+	/**
+	 * Checks the availability of the next page
+	 */
+	public IWizardPage getNextPage(IWizardPage page) {
+		AbstractWSO2DataserviceWizardPage pageout = 
+			(AbstractWSO2DataserviceWizardPage) super.getNextPage(page);
+		pageout.loadPreviousConfig();
+		return pageout;
+	}
+
+	
 }
\ No newline at end of file

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepOnePage.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepOnePage.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepOnePage.java	Mon May  5 04:07:23 2008
@@ -19,7 +19,6 @@
 
 import org.eclipse.jface.dialogs.IDialogPage;
 import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.ModifyEvent;
@@ -47,7 +46,7 @@
 /**
  * The Wizard page that involves the configuration of the data service
  */
-public class WSO2DataserviceWizardStepOnePage extends WizardPage {
+public class WSO2DataserviceWizardStepOnePage extends AbstractWSO2DataserviceWizardPage {
 	
 	private Text serviceNameText;
 	private Combo dataSource;
@@ -59,8 +58,8 @@
 	 * @param pageName
 	 */
 	public WSO2DataserviceWizardStepOnePage(ISelection selection) {
-		super("WSO2 Dataservice Wizard Step One : Data Service Configuration");
-		setTitle("WSO2 Dataservice Wizard Step One : Data Service Configuration");
+		super("WSO2 Data service Wizard Step One : Data Service Configuration");
+		setTitle("WSO2 Data service Wizard Step One : Data Service Configuration");
 		setDescription(WSO2DataserviceWizardConstant.pageDiscription);
 	}
 
@@ -69,9 +68,6 @@
 	 */
 	public void createControl(Composite parent) {
 		
-		//Obtain the current context from eclipse preferences.
-		dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
-
 		Composite container = new Composite(parent, SWT.NULL);
 		GridLayout layout = new GridLayout();
 		container.setLayout(layout);
@@ -128,7 +124,7 @@
 		label.setLayoutData(gd);
 		
 		previewConfig = new StyledText(container,SWT.V_SCROLL | SWT.H_SCROLL);
-		previewConfig.setText(loadDefaultConfig());
+		previewConfig.setText(loadPreviousConfig());
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		gd.horizontalSpan = 3;
 		gd.heightHint = 300;
@@ -138,6 +134,7 @@
 		initialize();
 		comboChanged();
 		setControl(container);
+		setPageComplete(false);
 	}
 	
 	/**
@@ -207,6 +204,7 @@
 			//call refresh configuration
 			OutputStream stream = DataServiceXMLUtil.prettyPrintDSConfig(dsConfig);
 			refreshConfig(stream.toString());
+			updateStatus(null);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -222,16 +220,28 @@
 		updateStatus(null);
 	}
 
+	/**
+	 * Update the status of the Page depending on the values on items.
+	 * @param message : message to display
+	 */
 	private void updateStatus(String message) {
-		setErrorMessage(message);
-		setPageComplete(message == null);
+		if ((message == null) && !(serviceNameText.getText().equals("")) 
+				&& (dataSource.getSelectionIndex() != 0) ) {
+			setErrorMessage(message);
+			setPageComplete(message == null);
+		}else {
+			setErrorMessage("Please select a Data Service Name and Configure the Data Source");
+		}
 	}
 
-	private String loadDefaultConfig(){
+	public String loadPreviousConfig(){
 		String defaultConfig = null;
 		try {
+			//Obtain the current context from eclipse preferences.
+			dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
 			defaultConfig = DataServiceXMLUtil.prettyPrintDSConfig(
 					WSO2DataserviceWizardConstant.defaultDataServiceConfig).toString();
+			refreshConfig(defaultConfig);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepThree.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepThree.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepThree.java	Mon May  5 04:07:23 2008
@@ -20,7 +20,6 @@
 
 import org.eclipse.jface.dialogs.IDialogPage;
 import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -42,7 +41,7 @@
 /**
  * The Wizard page that involves the configuration of Operations for DS
  */
-public class WSO2DataserviceWizardStepThree extends WizardPage {
+public class WSO2DataserviceWizardStepThree extends AbstractWSO2DataserviceWizardPage {
 
 	private int noOfLoadedOperations;
 	private Button newButton;
@@ -61,8 +60,8 @@
 	 * @param pageName
 	 */
 	public WSO2DataserviceWizardStepThree(ISelection selection) {
-		super("WSO2 Dataservice Wizard Step Three : Add Operation");
-		setTitle("WSO2 Dataservice Wizard Step Three : Add Operation");
+		super("WSO2 Data service Wizard Step Three : Add Operation");
+		setTitle("WSO2 Data service Wizard Step Three : Add Operation");
 		setDescription(WSO2DataserviceWizardConstant.pageDiscription);
 	}
 
@@ -71,10 +70,6 @@
 	 */
 	public void createControl(Composite parent) {
 		
-		//Obtain the current context from eclipse preferences.
-		dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
-
-
 		final Composite container = new Composite(parent, SWT.NULL);
 		GridLayout layout = new GridLayout();
 		container.setLayout(layout);
@@ -169,6 +164,7 @@
 		updateTable(operationToUIMapping);
 		initialize();
 		setControl(container);
+		setPageComplete(true);
 	}
 
 	/**
@@ -213,7 +209,7 @@
 	private void handleAddOperation() {
 		//Add Operation Selection
 		AddOperationDialog addOperationDialog = new AddOperationDialog(getShell(), 
-				WSO2DataserviceWizardConstant.addTag);
+				WSO2DataserviceWizardConstant.addTag, this);
 		addOperationDialog.create();
 		addOperationDialog.getShell().setSize(500, 300);
 		addOperationDialog.open();
@@ -229,7 +225,7 @@
 	private void handleEditOperation() {
 		//Add Operation Selection
 		AddOperationDialog addOperationDialog = new AddOperationDialog(getShell(), 
-				WSO2DataserviceWizardConstant.editTag);
+				WSO2DataserviceWizardConstant.editTag, this);
 		addOperationDialog.create();
 		addOperationDialog.getShell().setSize(500, 300);
 		addOperationDialog.open();
@@ -251,14 +247,24 @@
 		setPageComplete(message == null);
 	}
 	
-	private String loadPreviousConfig(){
+	public String loadPreviousConfig(){
 		String defaultConfig = null;
 		try {
+			//Obtain the current context from eclipse preferences.
+			dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
 			defaultConfig = DataServiceXMLUtil.prettyPrintDSConfig(dsContext.getDSConfig()).toString();
+			refreshConfig(defaultConfig);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
 		return defaultConfig;
 	}
 
+	public void refreshConfig(String config) {
+		//refresh the default configuration
+		previewConfig.setText(config);
+		//set the configuration on the eclipse preferences again
+		dsContext.setDSConfig(config);
+	}
+
 }
\ No newline at end of file

Modified: trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java
==============================================================================
--- trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java	(original)
+++ trunk/solutions/data-services/java/modules/ide/src/org/wso2/ws/dataservice/ide/wizard/WSO2DataserviceWizardStepTwo.java	Mon May  5 04:07:23 2008
@@ -20,7 +20,6 @@
 
 import org.eclipse.jface.dialogs.IDialogPage;
 import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -42,7 +41,7 @@
 /**
  * The Wizard page that involves the configuration of Queries for DS.
  */
-public class WSO2DataserviceWizardStepTwo extends WizardPage {
+public class WSO2DataserviceWizardStepTwo extends AbstractWSO2DataserviceWizardPage {
 
 	private int noOfLoadedQuery;
 	private Button newButton;
@@ -58,8 +57,8 @@
 	 * @param pageName
 	 */
 	public WSO2DataserviceWizardStepTwo(ISelection selection) {
-		super("WSO2 Dataservice Wizard Step Two : Add Query");
-		setTitle("WSO2 Dataservice Wizard Step Two : Add Query");
+		super("WSO2 Data service Wizard Step Two : Add Query");
+		setTitle("WSO2 Data service Wizard Step Two : Add Query");
 		setDescription(WSO2DataserviceWizardConstant.pageDiscription);
 	}
 
@@ -68,10 +67,6 @@
 	 */
 	public void createControl(Composite parent) {
 		
-		//Obtain the current context from eclipse preferences.
-		dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
-
-
 		final Composite container = new Composite(parent, SWT.NULL);
 		GridLayout layout = new GridLayout();
 		container.setLayout(layout);
@@ -167,6 +162,7 @@
 		updateTable(queryToUIMapping);
 		initialize();
 		setControl(container);
+		setPageComplete(false);
 	}
 
 
@@ -212,7 +208,7 @@
 	private void handleAddQuery() {
 		//Add Query Selection
 		AddQueryDialog addQueryDialog = new AddQueryDialog(getShell(), 
-				WSO2DataserviceWizardConstant.addTag);
+				WSO2DataserviceWizardConstant.addTag, this);
 		addQueryDialog.create();
 		addQueryDialog.getShell().setSize(500, 700);
 		addQueryDialog.open();
@@ -228,7 +224,7 @@
 	private void handleEditQuery() {
 		//Add Query Selection
 		AddQueryDialog addQueryDialog = new AddQueryDialog(getShell(), 
-				WSO2DataserviceWizardConstant.editTag);
+				WSO2DataserviceWizardConstant.editTag, this);
 		addQueryDialog.create();
 		addQueryDialog.getShell().setSize(500, 700);
 		addQueryDialog.open();
@@ -248,14 +244,24 @@
 		setPageComplete(message == null);
 	}
 	
-	private String loadPreviousConfig(){
+	public String loadPreviousConfig(){
 		String defaultConfig = null;
 		try {
+			//Obtain the current context from eclipse preferences.
+			dsContext = WSO2DataservicePlugin.getDefault().getPersistentDSContext();
 			defaultConfig = DataServiceXMLUtil.prettyPrintDSConfig(dsContext.getDSConfig()).toString();
+			refreshConfig(defaultConfig);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
 		return defaultConfig;
 	}
 
+	public void refreshConfig(String config) {
+		//refresh the default configuration
+		previewConfig.setText(config);
+		//set the configuration on the eclipse preferences again
+		dsContext.setDSConfig(config);
+	}
+
 }
\ No newline at end of file



More information about the Ds-java-dev mailing list